documentation.d.ts 3.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823
  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. private _wheelEventName;
  38754. private _onPointerMove;
  38755. private _onPointerDown;
  38756. private _onPointerUp;
  38757. private _initClickEvent;
  38758. private _initActionManager;
  38759. private _delayedSimpleClick;
  38760. private _delayedSimpleClickTimeout;
  38761. private _previousDelayedSimpleClickTimeout;
  38762. private _meshPickProceed;
  38763. private _previousButtonPressed;
  38764. private _currentPickResult;
  38765. private _previousPickResult;
  38766. private _totalPointersPressed;
  38767. private _doubleClickOccured;
  38768. private _pointerOverMesh;
  38769. private _pickedDownMesh;
  38770. private _pickedUpMesh;
  38771. private _pointerX;
  38772. private _pointerY;
  38773. private _unTranslatedPointerX;
  38774. private _unTranslatedPointerY;
  38775. private _startingPointerPosition;
  38776. private _previousStartingPointerPosition;
  38777. private _startingPointerTime;
  38778. private _previousStartingPointerTime;
  38779. private _pointerCaptures;
  38780. private _onKeyDown;
  38781. private _onKeyUp;
  38782. private _onCanvasFocusObserver;
  38783. private _onCanvasBlurObserver;
  38784. private _scene;
  38785. /**
  38786. * Creates a new InputManager
  38787. * @param scene defines the hosting scene
  38788. */
  38789. constructor(scene: Scene);
  38790. /**
  38791. * Gets the mesh that is currently under the pointer
  38792. */
  38793. get meshUnderPointer(): Nullable<AbstractMesh>;
  38794. /**
  38795. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38796. */
  38797. get unTranslatedPointer(): Vector2;
  38798. /**
  38799. * Gets or sets the current on-screen X position of the pointer
  38800. */
  38801. get pointerX(): number;
  38802. set pointerX(value: number);
  38803. /**
  38804. * Gets or sets the current on-screen Y position of the pointer
  38805. */
  38806. get pointerY(): number;
  38807. set pointerY(value: number);
  38808. private _updatePointerPosition;
  38809. private _processPointerMove;
  38810. private _setRayOnPointerInfo;
  38811. private _checkPrePointerObservable;
  38812. /**
  38813. * Use this method to simulate a pointer move on a mesh
  38814. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38815. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38816. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38817. */
  38818. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38819. /**
  38820. * Use this method to simulate a pointer down on a mesh
  38821. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38822. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38823. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38824. */
  38825. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38826. private _processPointerDown;
  38827. /** @hidden */
  38828. _isPointerSwiping(): boolean;
  38829. /**
  38830. * Use this method to simulate a pointer up on a mesh
  38831. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38832. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38833. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38834. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38835. */
  38836. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38837. private _processPointerUp;
  38838. /**
  38839. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38840. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38841. * @returns true if the pointer was captured
  38842. */
  38843. isPointerCaptured(pointerId?: number): boolean;
  38844. /**
  38845. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38846. * @param attachUp defines if you want to attach events to pointerup
  38847. * @param attachDown defines if you want to attach events to pointerdown
  38848. * @param attachMove defines if you want to attach events to pointermove
  38849. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38850. */
  38851. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38852. /**
  38853. * Detaches all event handlers
  38854. */
  38855. detachControl(): void;
  38856. /**
  38857. * Force the value of meshUnderPointer
  38858. * @param mesh defines the mesh to use
  38859. */
  38860. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38861. /**
  38862. * Gets the mesh under the pointer
  38863. * @returns a Mesh or null if no mesh is under the pointer
  38864. */
  38865. getPointerOverMesh(): Nullable<AbstractMesh>;
  38866. }
  38867. }
  38868. declare module BABYLON {
  38869. /**
  38870. * This class defines the direct association between an animation and a target
  38871. */
  38872. export class TargetedAnimation {
  38873. /**
  38874. * Animation to perform
  38875. */
  38876. animation: Animation;
  38877. /**
  38878. * Target to animate
  38879. */
  38880. target: any;
  38881. /**
  38882. * Returns the string "TargetedAnimation"
  38883. * @returns "TargetedAnimation"
  38884. */
  38885. getClassName(): string;
  38886. /**
  38887. * Serialize the object
  38888. * @returns the JSON object representing the current entity
  38889. */
  38890. serialize(): any;
  38891. }
  38892. /**
  38893. * Use this class to create coordinated animations on multiple targets
  38894. */
  38895. export class AnimationGroup implements IDisposable {
  38896. /** The name of the animation group */
  38897. name: string;
  38898. private _scene;
  38899. private _targetedAnimations;
  38900. private _animatables;
  38901. private _from;
  38902. private _to;
  38903. private _isStarted;
  38904. private _isPaused;
  38905. private _speedRatio;
  38906. private _loopAnimation;
  38907. private _isAdditive;
  38908. /**
  38909. * Gets or sets the unique id of the node
  38910. */
  38911. uniqueId: number;
  38912. /**
  38913. * This observable will notify when one animation have ended
  38914. */
  38915. onAnimationEndObservable: Observable<TargetedAnimation>;
  38916. /**
  38917. * Observer raised when one animation loops
  38918. */
  38919. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38920. /**
  38921. * Observer raised when all animations have looped
  38922. */
  38923. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38924. /**
  38925. * This observable will notify when all animations have ended.
  38926. */
  38927. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38928. /**
  38929. * This observable will notify when all animations have paused.
  38930. */
  38931. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38932. /**
  38933. * This observable will notify when all animations are playing.
  38934. */
  38935. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38936. /**
  38937. * Gets the first frame
  38938. */
  38939. get from(): number;
  38940. /**
  38941. * Gets the last frame
  38942. */
  38943. get to(): number;
  38944. /**
  38945. * Define if the animations are started
  38946. */
  38947. get isStarted(): boolean;
  38948. /**
  38949. * Gets a value indicating that the current group is playing
  38950. */
  38951. get isPlaying(): boolean;
  38952. /**
  38953. * Gets or sets the speed ratio to use for all animations
  38954. */
  38955. get speedRatio(): number;
  38956. /**
  38957. * Gets or sets the speed ratio to use for all animations
  38958. */
  38959. set speedRatio(value: number);
  38960. /**
  38961. * Gets or sets if all animations should loop or not
  38962. */
  38963. get loopAnimation(): boolean;
  38964. set loopAnimation(value: boolean);
  38965. /**
  38966. * Gets or sets if all animations should be evaluated additively
  38967. */
  38968. get isAdditive(): boolean;
  38969. set isAdditive(value: boolean);
  38970. /**
  38971. * Gets the targeted animations for this animation group
  38972. */
  38973. get targetedAnimations(): Array<TargetedAnimation>;
  38974. /**
  38975. * returning the list of animatables controlled by this animation group.
  38976. */
  38977. get animatables(): Array<Animatable>;
  38978. /**
  38979. * Gets the list of target animations
  38980. */
  38981. get children(): TargetedAnimation[];
  38982. /**
  38983. * Instantiates a new Animation Group.
  38984. * This helps managing several animations at once.
  38985. * @see https://doc.babylonjs.com/how_to/group
  38986. * @param name Defines the name of the group
  38987. * @param scene Defines the scene the group belongs to
  38988. */
  38989. constructor(
  38990. /** The name of the animation group */
  38991. name: string, scene?: Nullable<Scene>);
  38992. /**
  38993. * Add an animation (with its target) in the group
  38994. * @param animation defines the animation we want to add
  38995. * @param target defines the target of the animation
  38996. * @returns the TargetedAnimation object
  38997. */
  38998. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38999. /**
  39000. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39001. * It can add constant keys at begin or end
  39002. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39003. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39004. * @returns the animation group
  39005. */
  39006. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39007. private _animationLoopCount;
  39008. private _animationLoopFlags;
  39009. private _processLoop;
  39010. /**
  39011. * Start all animations on given targets
  39012. * @param loop defines if animations must loop
  39013. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39014. * @param from defines the from key (optional)
  39015. * @param to defines the to key (optional)
  39016. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39017. * @returns the current animation group
  39018. */
  39019. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39020. /**
  39021. * Pause all animations
  39022. * @returns the animation group
  39023. */
  39024. pause(): AnimationGroup;
  39025. /**
  39026. * Play all animations to initial state
  39027. * This function will start() the animations if they were not started or will restart() them if they were paused
  39028. * @param loop defines if animations must loop
  39029. * @returns the animation group
  39030. */
  39031. play(loop?: boolean): AnimationGroup;
  39032. /**
  39033. * Reset all animations to initial state
  39034. * @returns the animation group
  39035. */
  39036. reset(): AnimationGroup;
  39037. /**
  39038. * Restart animations from key 0
  39039. * @returns the animation group
  39040. */
  39041. restart(): AnimationGroup;
  39042. /**
  39043. * Stop all animations
  39044. * @returns the animation group
  39045. */
  39046. stop(): AnimationGroup;
  39047. /**
  39048. * Set animation weight for all animatables
  39049. * @param weight defines the weight to use
  39050. * @return the animationGroup
  39051. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39052. */
  39053. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39054. /**
  39055. * Synchronize and normalize all animatables with a source animatable
  39056. * @param root defines the root animatable to synchronize with
  39057. * @return the animationGroup
  39058. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39059. */
  39060. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39061. /**
  39062. * Goes to a specific frame in this animation group
  39063. * @param frame the frame number to go to
  39064. * @return the animationGroup
  39065. */
  39066. goToFrame(frame: number): AnimationGroup;
  39067. /**
  39068. * Dispose all associated resources
  39069. */
  39070. dispose(): void;
  39071. private _checkAnimationGroupEnded;
  39072. /**
  39073. * Clone the current animation group and returns a copy
  39074. * @param newName defines the name of the new group
  39075. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39076. * @returns the new aniamtion group
  39077. */
  39078. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39079. /**
  39080. * Serializes the animationGroup to an object
  39081. * @returns Serialized object
  39082. */
  39083. serialize(): any;
  39084. /**
  39085. * Returns a new AnimationGroup object parsed from the source provided.
  39086. * @param parsedAnimationGroup defines the source
  39087. * @param scene defines the scene that will receive the animationGroup
  39088. * @returns a new AnimationGroup
  39089. */
  39090. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39091. /**
  39092. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39093. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39094. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39095. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39096. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39097. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39098. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39099. */
  39100. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39101. /**
  39102. * Returns the string "AnimationGroup"
  39103. * @returns "AnimationGroup"
  39104. */
  39105. getClassName(): string;
  39106. /**
  39107. * Creates a detailled string about the object
  39108. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39109. * @returns a string representing the object
  39110. */
  39111. toString(fullDetails?: boolean): string;
  39112. }
  39113. }
  39114. declare module BABYLON {
  39115. /**
  39116. * Define an interface for all classes that will hold resources
  39117. */
  39118. export interface IDisposable {
  39119. /**
  39120. * Releases all held resources
  39121. */
  39122. dispose(): void;
  39123. }
  39124. /** Interface defining initialization parameters for Scene class */
  39125. export interface SceneOptions {
  39126. /**
  39127. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39128. * It will improve performance when the number of geometries becomes important.
  39129. */
  39130. useGeometryUniqueIdsMap?: boolean;
  39131. /**
  39132. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39133. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39134. */
  39135. useMaterialMeshMap?: boolean;
  39136. /**
  39137. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39138. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39139. */
  39140. useClonedMeshMap?: boolean;
  39141. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39142. virtual?: boolean;
  39143. }
  39144. /**
  39145. * Represents a scene to be rendered by the engine.
  39146. * @see https://doc.babylonjs.com/features/scene
  39147. */
  39148. export class Scene extends AbstractScene implements IAnimatable {
  39149. /** The fog is deactivated */
  39150. static readonly FOGMODE_NONE: number;
  39151. /** The fog density is following an exponential function */
  39152. static readonly FOGMODE_EXP: number;
  39153. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39154. static readonly FOGMODE_EXP2: number;
  39155. /** The fog density is following a linear function. */
  39156. static readonly FOGMODE_LINEAR: number;
  39157. /**
  39158. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39159. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39160. */
  39161. static MinDeltaTime: number;
  39162. /**
  39163. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39164. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39165. */
  39166. static MaxDeltaTime: number;
  39167. /**
  39168. * Factory used to create the default material.
  39169. * @param name The name of the material to create
  39170. * @param scene The scene to create the material for
  39171. * @returns The default material
  39172. */
  39173. static DefaultMaterialFactory(scene: Scene): Material;
  39174. /**
  39175. * Factory used to create the a collision coordinator.
  39176. * @returns The collision coordinator
  39177. */
  39178. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39179. /** @hidden */
  39180. _inputManager: InputManager;
  39181. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39182. cameraToUseForPointers: Nullable<Camera>;
  39183. /** @hidden */
  39184. readonly _isScene: boolean;
  39185. /** @hidden */
  39186. _blockEntityCollection: boolean;
  39187. /**
  39188. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39189. */
  39190. autoClear: boolean;
  39191. /**
  39192. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39193. */
  39194. autoClearDepthAndStencil: boolean;
  39195. /**
  39196. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39197. */
  39198. clearColor: Color4;
  39199. /**
  39200. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39201. */
  39202. ambientColor: Color3;
  39203. /**
  39204. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39205. * It should only be one of the following (if not the default embedded one):
  39206. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39207. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39208. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39209. * The material properties need to be setup according to the type of texture in use.
  39210. */
  39211. environmentBRDFTexture: BaseTexture;
  39212. /** @hidden */
  39213. protected _environmentTexture: Nullable<BaseTexture>;
  39214. /**
  39215. * Texture used in all pbr material as the reflection texture.
  39216. * As in the majority of the scene they are the same (exception for multi room and so on),
  39217. * this is easier to reference from here than from all the materials.
  39218. */
  39219. get environmentTexture(): Nullable<BaseTexture>;
  39220. /**
  39221. * Texture used in all pbr material as the reflection texture.
  39222. * As in the majority of the scene they are the same (exception for multi room and so on),
  39223. * this is easier to set here than in all the materials.
  39224. */
  39225. set environmentTexture(value: Nullable<BaseTexture>);
  39226. /** @hidden */
  39227. protected _environmentIntensity: number;
  39228. /**
  39229. * Intensity of the environment in all pbr material.
  39230. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39231. * As in the majority of the scene they are the same (exception for multi room and so on),
  39232. * this is easier to reference from here than from all the materials.
  39233. */
  39234. get environmentIntensity(): number;
  39235. /**
  39236. * Intensity of the environment in all pbr material.
  39237. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39238. * As in the majority of the scene they are the same (exception for multi room and so on),
  39239. * this is easier to set here than in all the materials.
  39240. */
  39241. set environmentIntensity(value: number);
  39242. /** @hidden */
  39243. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39244. /**
  39245. * Default image processing configuration used either in the rendering
  39246. * Forward main pass or through the imageProcessingPostProcess if present.
  39247. * As in the majority of the scene they are the same (exception for multi camera),
  39248. * this is easier to reference from here than from all the materials and post process.
  39249. *
  39250. * No setter as we it is a shared configuration, you can set the values instead.
  39251. */
  39252. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39253. private _forceWireframe;
  39254. /**
  39255. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39256. */
  39257. set forceWireframe(value: boolean);
  39258. get forceWireframe(): boolean;
  39259. private _skipFrustumClipping;
  39260. /**
  39261. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39262. */
  39263. set skipFrustumClipping(value: boolean);
  39264. get skipFrustumClipping(): boolean;
  39265. private _forcePointsCloud;
  39266. /**
  39267. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39268. */
  39269. set forcePointsCloud(value: boolean);
  39270. get forcePointsCloud(): boolean;
  39271. /**
  39272. * Gets or sets the active clipplane 1
  39273. */
  39274. clipPlane: Nullable<Plane>;
  39275. /**
  39276. * Gets or sets the active clipplane 2
  39277. */
  39278. clipPlane2: Nullable<Plane>;
  39279. /**
  39280. * Gets or sets the active clipplane 3
  39281. */
  39282. clipPlane3: Nullable<Plane>;
  39283. /**
  39284. * Gets or sets the active clipplane 4
  39285. */
  39286. clipPlane4: Nullable<Plane>;
  39287. /**
  39288. * Gets or sets the active clipplane 5
  39289. */
  39290. clipPlane5: Nullable<Plane>;
  39291. /**
  39292. * Gets or sets the active clipplane 6
  39293. */
  39294. clipPlane6: Nullable<Plane>;
  39295. /**
  39296. * Gets or sets a boolean indicating if animations are enabled
  39297. */
  39298. animationsEnabled: boolean;
  39299. private _animationPropertiesOverride;
  39300. /**
  39301. * Gets or sets the animation properties override
  39302. */
  39303. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39304. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39305. /**
  39306. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39307. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39308. */
  39309. useConstantAnimationDeltaTime: boolean;
  39310. /**
  39311. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39312. * Please note that it requires to run a ray cast through the scene on every frame
  39313. */
  39314. constantlyUpdateMeshUnderPointer: boolean;
  39315. /**
  39316. * Defines the HTML cursor to use when hovering over interactive elements
  39317. */
  39318. hoverCursor: string;
  39319. /**
  39320. * Defines the HTML default cursor to use (empty by default)
  39321. */
  39322. defaultCursor: string;
  39323. /**
  39324. * Defines whether cursors are handled by the scene.
  39325. */
  39326. doNotHandleCursors: boolean;
  39327. /**
  39328. * This is used to call preventDefault() on pointer down
  39329. * in order to block unwanted artifacts like system double clicks
  39330. */
  39331. preventDefaultOnPointerDown: boolean;
  39332. /**
  39333. * This is used to call preventDefault() on pointer up
  39334. * in order to block unwanted artifacts like system double clicks
  39335. */
  39336. preventDefaultOnPointerUp: boolean;
  39337. /**
  39338. * Gets or sets user defined metadata
  39339. */
  39340. metadata: any;
  39341. /**
  39342. * For internal use only. Please do not use.
  39343. */
  39344. reservedDataStore: any;
  39345. /**
  39346. * Gets the name of the plugin used to load this scene (null by default)
  39347. */
  39348. loadingPluginName: string;
  39349. /**
  39350. * Use this array to add regular expressions used to disable offline support for specific urls
  39351. */
  39352. disableOfflineSupportExceptionRules: RegExp[];
  39353. /**
  39354. * An event triggered when the scene is disposed.
  39355. */
  39356. onDisposeObservable: Observable<Scene>;
  39357. private _onDisposeObserver;
  39358. /** Sets a function to be executed when this scene is disposed. */
  39359. set onDispose(callback: () => void);
  39360. /**
  39361. * An event triggered before rendering the scene (right after animations and physics)
  39362. */
  39363. onBeforeRenderObservable: Observable<Scene>;
  39364. private _onBeforeRenderObserver;
  39365. /** Sets a function to be executed before rendering this scene */
  39366. set beforeRender(callback: Nullable<() => void>);
  39367. /**
  39368. * An event triggered after rendering the scene
  39369. */
  39370. onAfterRenderObservable: Observable<Scene>;
  39371. /**
  39372. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39373. */
  39374. onAfterRenderCameraObservable: Observable<Camera>;
  39375. private _onAfterRenderObserver;
  39376. /** Sets a function to be executed after rendering this scene */
  39377. set afterRender(callback: Nullable<() => void>);
  39378. /**
  39379. * An event triggered before animating the scene
  39380. */
  39381. onBeforeAnimationsObservable: Observable<Scene>;
  39382. /**
  39383. * An event triggered after animations processing
  39384. */
  39385. onAfterAnimationsObservable: Observable<Scene>;
  39386. /**
  39387. * An event triggered before draw calls are ready to be sent
  39388. */
  39389. onBeforeDrawPhaseObservable: Observable<Scene>;
  39390. /**
  39391. * An event triggered after draw calls have been sent
  39392. */
  39393. onAfterDrawPhaseObservable: Observable<Scene>;
  39394. /**
  39395. * An event triggered when the scene is ready
  39396. */
  39397. onReadyObservable: Observable<Scene>;
  39398. /**
  39399. * An event triggered before rendering a camera
  39400. */
  39401. onBeforeCameraRenderObservable: Observable<Camera>;
  39402. private _onBeforeCameraRenderObserver;
  39403. /** Sets a function to be executed before rendering a camera*/
  39404. set beforeCameraRender(callback: () => void);
  39405. /**
  39406. * An event triggered after rendering a camera
  39407. */
  39408. onAfterCameraRenderObservable: Observable<Camera>;
  39409. private _onAfterCameraRenderObserver;
  39410. /** Sets a function to be executed after rendering a camera*/
  39411. set afterCameraRender(callback: () => void);
  39412. /**
  39413. * An event triggered when active meshes evaluation is about to start
  39414. */
  39415. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39416. /**
  39417. * An event triggered when active meshes evaluation is done
  39418. */
  39419. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39420. /**
  39421. * An event triggered when particles rendering is about to start
  39422. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39423. */
  39424. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39425. /**
  39426. * An event triggered when particles rendering is done
  39427. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39428. */
  39429. onAfterParticlesRenderingObservable: Observable<Scene>;
  39430. /**
  39431. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39432. */
  39433. onDataLoadedObservable: Observable<Scene>;
  39434. /**
  39435. * An event triggered when a camera is created
  39436. */
  39437. onNewCameraAddedObservable: Observable<Camera>;
  39438. /**
  39439. * An event triggered when a camera is removed
  39440. */
  39441. onCameraRemovedObservable: Observable<Camera>;
  39442. /**
  39443. * An event triggered when a light is created
  39444. */
  39445. onNewLightAddedObservable: Observable<Light>;
  39446. /**
  39447. * An event triggered when a light is removed
  39448. */
  39449. onLightRemovedObservable: Observable<Light>;
  39450. /**
  39451. * An event triggered when a geometry is created
  39452. */
  39453. onNewGeometryAddedObservable: Observable<Geometry>;
  39454. /**
  39455. * An event triggered when a geometry is removed
  39456. */
  39457. onGeometryRemovedObservable: Observable<Geometry>;
  39458. /**
  39459. * An event triggered when a transform node is created
  39460. */
  39461. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39462. /**
  39463. * An event triggered when a transform node is removed
  39464. */
  39465. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39466. /**
  39467. * An event triggered when a mesh is created
  39468. */
  39469. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39470. /**
  39471. * An event triggered when a mesh is removed
  39472. */
  39473. onMeshRemovedObservable: Observable<AbstractMesh>;
  39474. /**
  39475. * An event triggered when a skeleton is created
  39476. */
  39477. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39478. /**
  39479. * An event triggered when a skeleton is removed
  39480. */
  39481. onSkeletonRemovedObservable: Observable<Skeleton>;
  39482. /**
  39483. * An event triggered when a material is created
  39484. */
  39485. onNewMaterialAddedObservable: Observable<Material>;
  39486. /**
  39487. * An event triggered when a material is removed
  39488. */
  39489. onMaterialRemovedObservable: Observable<Material>;
  39490. /**
  39491. * An event triggered when a texture is created
  39492. */
  39493. onNewTextureAddedObservable: Observable<BaseTexture>;
  39494. /**
  39495. * An event triggered when a texture is removed
  39496. */
  39497. onTextureRemovedObservable: Observable<BaseTexture>;
  39498. /**
  39499. * An event triggered when render targets are about to be rendered
  39500. * Can happen multiple times per frame.
  39501. */
  39502. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39503. /**
  39504. * An event triggered when render targets were rendered.
  39505. * Can happen multiple times per frame.
  39506. */
  39507. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39508. /**
  39509. * An event triggered before calculating deterministic simulation step
  39510. */
  39511. onBeforeStepObservable: Observable<Scene>;
  39512. /**
  39513. * An event triggered after calculating deterministic simulation step
  39514. */
  39515. onAfterStepObservable: Observable<Scene>;
  39516. /**
  39517. * An event triggered when the activeCamera property is updated
  39518. */
  39519. onActiveCameraChanged: Observable<Scene>;
  39520. /**
  39521. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39522. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39523. * 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)
  39524. */
  39525. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39526. /**
  39527. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39528. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39529. * 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)
  39530. */
  39531. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39532. /**
  39533. * This Observable will when a mesh has been imported into the scene.
  39534. */
  39535. onMeshImportedObservable: Observable<AbstractMesh>;
  39536. /**
  39537. * This Observable will when an animation file has been imported into the scene.
  39538. */
  39539. onAnimationFileImportedObservable: Observable<Scene>;
  39540. /**
  39541. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39542. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39543. */
  39544. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39545. /** @hidden */
  39546. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39547. /**
  39548. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39549. */
  39550. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39551. /**
  39552. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39553. */
  39554. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39555. /**
  39556. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39557. */
  39558. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39559. /** Callback called when a pointer move is detected */
  39560. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39561. /** Callback called when a pointer down is detected */
  39562. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39563. /** Callback called when a pointer up is detected */
  39564. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39565. /** Callback called when a pointer pick is detected */
  39566. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39567. /**
  39568. * 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).
  39569. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39570. */
  39571. onPrePointerObservable: Observable<PointerInfoPre>;
  39572. /**
  39573. * Observable event triggered each time an input event is received from the rendering canvas
  39574. */
  39575. onPointerObservable: Observable<PointerInfo>;
  39576. /**
  39577. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39578. */
  39579. get unTranslatedPointer(): Vector2;
  39580. /**
  39581. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39582. */
  39583. static get DragMovementThreshold(): number;
  39584. static set DragMovementThreshold(value: number);
  39585. /**
  39586. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39587. */
  39588. static get LongPressDelay(): number;
  39589. static set LongPressDelay(value: number);
  39590. /**
  39591. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39592. */
  39593. static get DoubleClickDelay(): number;
  39594. static set DoubleClickDelay(value: number);
  39595. /** If you need to check double click without raising a single click at first click, enable this flag */
  39596. static get ExclusiveDoubleClickMode(): boolean;
  39597. static set ExclusiveDoubleClickMode(value: boolean);
  39598. /** @hidden */
  39599. _mirroredCameraPosition: Nullable<Vector3>;
  39600. /**
  39601. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39602. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39603. */
  39604. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39605. /**
  39606. * Observable event triggered each time an keyboard event is received from the hosting window
  39607. */
  39608. onKeyboardObservable: Observable<KeyboardInfo>;
  39609. private _useRightHandedSystem;
  39610. /**
  39611. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39612. */
  39613. set useRightHandedSystem(value: boolean);
  39614. get useRightHandedSystem(): boolean;
  39615. private _timeAccumulator;
  39616. private _currentStepId;
  39617. private _currentInternalStep;
  39618. /**
  39619. * Sets the step Id used by deterministic lock step
  39620. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39621. * @param newStepId defines the step Id
  39622. */
  39623. setStepId(newStepId: number): void;
  39624. /**
  39625. * Gets the step Id used by deterministic lock step
  39626. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39627. * @returns the step Id
  39628. */
  39629. getStepId(): number;
  39630. /**
  39631. * Gets the internal step used by deterministic lock step
  39632. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39633. * @returns the internal step
  39634. */
  39635. getInternalStep(): number;
  39636. private _fogEnabled;
  39637. /**
  39638. * Gets or sets a boolean indicating if fog is enabled on this scene
  39639. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39640. * (Default is true)
  39641. */
  39642. set fogEnabled(value: boolean);
  39643. get fogEnabled(): boolean;
  39644. private _fogMode;
  39645. /**
  39646. * Gets or sets the fog mode to use
  39647. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39648. * | mode | value |
  39649. * | --- | --- |
  39650. * | FOGMODE_NONE | 0 |
  39651. * | FOGMODE_EXP | 1 |
  39652. * | FOGMODE_EXP2 | 2 |
  39653. * | FOGMODE_LINEAR | 3 |
  39654. */
  39655. set fogMode(value: number);
  39656. get fogMode(): number;
  39657. /**
  39658. * Gets or sets the fog color to use
  39659. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39660. * (Default is Color3(0.2, 0.2, 0.3))
  39661. */
  39662. fogColor: Color3;
  39663. /**
  39664. * Gets or sets the fog density to use
  39665. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39666. * (Default is 0.1)
  39667. */
  39668. fogDensity: number;
  39669. /**
  39670. * Gets or sets the fog start distance to use
  39671. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39672. * (Default is 0)
  39673. */
  39674. fogStart: number;
  39675. /**
  39676. * Gets or sets the fog end distance to use
  39677. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39678. * (Default is 1000)
  39679. */
  39680. fogEnd: number;
  39681. /**
  39682. * Flag indicating that the frame buffer binding is handled by another component
  39683. */
  39684. prePass: boolean;
  39685. private _shadowsEnabled;
  39686. /**
  39687. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39688. */
  39689. set shadowsEnabled(value: boolean);
  39690. get shadowsEnabled(): boolean;
  39691. private _lightsEnabled;
  39692. /**
  39693. * Gets or sets a boolean indicating if lights are enabled on this scene
  39694. */
  39695. set lightsEnabled(value: boolean);
  39696. get lightsEnabled(): boolean;
  39697. /** All of the active cameras added to this scene. */
  39698. activeCameras: Camera[];
  39699. /** @hidden */
  39700. _activeCamera: Nullable<Camera>;
  39701. /** Gets or sets the current active camera */
  39702. get activeCamera(): Nullable<Camera>;
  39703. set activeCamera(value: Nullable<Camera>);
  39704. private _defaultMaterial;
  39705. /** The default material used on meshes when no material is affected */
  39706. get defaultMaterial(): Material;
  39707. /** The default material used on meshes when no material is affected */
  39708. set defaultMaterial(value: Material);
  39709. private _texturesEnabled;
  39710. /**
  39711. * Gets or sets a boolean indicating if textures are enabled on this scene
  39712. */
  39713. set texturesEnabled(value: boolean);
  39714. get texturesEnabled(): boolean;
  39715. /**
  39716. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39717. */
  39718. physicsEnabled: boolean;
  39719. /**
  39720. * Gets or sets a boolean indicating if particles are enabled on this scene
  39721. */
  39722. particlesEnabled: boolean;
  39723. /**
  39724. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39725. */
  39726. spritesEnabled: boolean;
  39727. private _skeletonsEnabled;
  39728. /**
  39729. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39730. */
  39731. set skeletonsEnabled(value: boolean);
  39732. get skeletonsEnabled(): boolean;
  39733. /**
  39734. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39735. */
  39736. lensFlaresEnabled: boolean;
  39737. /**
  39738. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39739. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39740. */
  39741. collisionsEnabled: boolean;
  39742. private _collisionCoordinator;
  39743. /** @hidden */
  39744. get collisionCoordinator(): ICollisionCoordinator;
  39745. /**
  39746. * Defines the gravity applied to this scene (used only for collisions)
  39747. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39748. */
  39749. gravity: Vector3;
  39750. /**
  39751. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39752. */
  39753. postProcessesEnabled: boolean;
  39754. /**
  39755. * The list of postprocesses added to the scene
  39756. */
  39757. postProcesses: PostProcess[];
  39758. /**
  39759. * Gets the current postprocess manager
  39760. */
  39761. postProcessManager: PostProcessManager;
  39762. /**
  39763. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39764. */
  39765. renderTargetsEnabled: boolean;
  39766. /**
  39767. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39768. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39769. */
  39770. dumpNextRenderTargets: boolean;
  39771. /**
  39772. * The list of user defined render targets added to the scene
  39773. */
  39774. customRenderTargets: RenderTargetTexture[];
  39775. /**
  39776. * Defines if texture loading must be delayed
  39777. * If true, textures will only be loaded when they need to be rendered
  39778. */
  39779. useDelayedTextureLoading: boolean;
  39780. /**
  39781. * Gets the list of meshes imported to the scene through SceneLoader
  39782. */
  39783. importedMeshesFiles: String[];
  39784. /**
  39785. * Gets or sets a boolean indicating if probes are enabled on this scene
  39786. */
  39787. probesEnabled: boolean;
  39788. /**
  39789. * Gets or sets the current offline provider to use to store scene data
  39790. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39791. */
  39792. offlineProvider: IOfflineProvider;
  39793. /**
  39794. * Gets or sets the action manager associated with the scene
  39795. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39796. */
  39797. actionManager: AbstractActionManager;
  39798. private _meshesForIntersections;
  39799. /**
  39800. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39801. */
  39802. proceduralTexturesEnabled: boolean;
  39803. private _engine;
  39804. private _totalVertices;
  39805. /** @hidden */
  39806. _activeIndices: PerfCounter;
  39807. /** @hidden */
  39808. _activeParticles: PerfCounter;
  39809. /** @hidden */
  39810. _activeBones: PerfCounter;
  39811. private _animationRatio;
  39812. /** @hidden */
  39813. _animationTimeLast: number;
  39814. /** @hidden */
  39815. _animationTime: number;
  39816. /**
  39817. * Gets or sets a general scale for animation speed
  39818. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39819. */
  39820. animationTimeScale: number;
  39821. /** @hidden */
  39822. _cachedMaterial: Nullable<Material>;
  39823. /** @hidden */
  39824. _cachedEffect: Nullable<Effect>;
  39825. /** @hidden */
  39826. _cachedVisibility: Nullable<number>;
  39827. private _renderId;
  39828. private _frameId;
  39829. private _executeWhenReadyTimeoutId;
  39830. private _intermediateRendering;
  39831. private _viewUpdateFlag;
  39832. private _projectionUpdateFlag;
  39833. /** @hidden */
  39834. _toBeDisposed: Nullable<IDisposable>[];
  39835. private _activeRequests;
  39836. /** @hidden */
  39837. _pendingData: any[];
  39838. private _isDisposed;
  39839. /**
  39840. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39841. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39842. */
  39843. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39844. private _activeMeshes;
  39845. private _processedMaterials;
  39846. private _renderTargets;
  39847. /** @hidden */
  39848. _activeParticleSystems: SmartArray<IParticleSystem>;
  39849. private _activeSkeletons;
  39850. private _softwareSkinnedMeshes;
  39851. private _renderingManager;
  39852. /** @hidden */
  39853. _activeAnimatables: Animatable[];
  39854. private _transformMatrix;
  39855. private _sceneUbo;
  39856. /** @hidden */
  39857. _viewMatrix: Matrix;
  39858. private _projectionMatrix;
  39859. /** @hidden */
  39860. _forcedViewPosition: Nullable<Vector3>;
  39861. /** @hidden */
  39862. _frustumPlanes: Plane[];
  39863. /**
  39864. * Gets the list of frustum planes (built from the active camera)
  39865. */
  39866. get frustumPlanes(): Plane[];
  39867. /**
  39868. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39869. * This is useful if there are more lights that the maximum simulteanous authorized
  39870. */
  39871. requireLightSorting: boolean;
  39872. /** @hidden */
  39873. readonly useMaterialMeshMap: boolean;
  39874. /** @hidden */
  39875. readonly useClonedMeshMap: boolean;
  39876. private _externalData;
  39877. private _uid;
  39878. /**
  39879. * @hidden
  39880. * Backing store of defined scene components.
  39881. */
  39882. _components: ISceneComponent[];
  39883. /**
  39884. * @hidden
  39885. * Backing store of defined scene components.
  39886. */
  39887. _serializableComponents: ISceneSerializableComponent[];
  39888. /**
  39889. * List of components to register on the next registration step.
  39890. */
  39891. private _transientComponents;
  39892. /**
  39893. * Registers the transient components if needed.
  39894. */
  39895. private _registerTransientComponents;
  39896. /**
  39897. * @hidden
  39898. * Add a component to the scene.
  39899. * Note that the ccomponent could be registered on th next frame if this is called after
  39900. * the register component stage.
  39901. * @param component Defines the component to add to the scene
  39902. */
  39903. _addComponent(component: ISceneComponent): void;
  39904. /**
  39905. * @hidden
  39906. * Gets a component from the scene.
  39907. * @param name defines the name of the component to retrieve
  39908. * @returns the component or null if not present
  39909. */
  39910. _getComponent(name: string): Nullable<ISceneComponent>;
  39911. /**
  39912. * @hidden
  39913. * Defines the actions happening before camera updates.
  39914. */
  39915. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39916. /**
  39917. * @hidden
  39918. * Defines the actions happening before clear the canvas.
  39919. */
  39920. _beforeClearStage: Stage<SimpleStageAction>;
  39921. /**
  39922. * @hidden
  39923. * Defines the actions when collecting render targets for the frame.
  39924. */
  39925. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39926. /**
  39927. * @hidden
  39928. * Defines the actions happening for one camera in the frame.
  39929. */
  39930. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39931. /**
  39932. * @hidden
  39933. * Defines the actions happening during the per mesh ready checks.
  39934. */
  39935. _isReadyForMeshStage: Stage<MeshStageAction>;
  39936. /**
  39937. * @hidden
  39938. * Defines the actions happening before evaluate active mesh checks.
  39939. */
  39940. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39941. /**
  39942. * @hidden
  39943. * Defines the actions happening during the evaluate sub mesh checks.
  39944. */
  39945. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39946. /**
  39947. * @hidden
  39948. * Defines the actions happening during the active mesh stage.
  39949. */
  39950. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39951. /**
  39952. * @hidden
  39953. * Defines the actions happening during the per camera render target step.
  39954. */
  39955. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39956. /**
  39957. * @hidden
  39958. * Defines the actions happening just before the active camera is drawing.
  39959. */
  39960. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39961. /**
  39962. * @hidden
  39963. * Defines the actions happening just before a render target is drawing.
  39964. */
  39965. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39966. /**
  39967. * @hidden
  39968. * Defines the actions happening just before a rendering group is drawing.
  39969. */
  39970. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39971. /**
  39972. * @hidden
  39973. * Defines the actions happening just before a mesh is drawing.
  39974. */
  39975. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39976. /**
  39977. * @hidden
  39978. * Defines the actions happening just after a mesh has been drawn.
  39979. */
  39980. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39981. /**
  39982. * @hidden
  39983. * Defines the actions happening just after a rendering group has been drawn.
  39984. */
  39985. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39986. /**
  39987. * @hidden
  39988. * Defines the actions happening just after the active camera has been drawn.
  39989. */
  39990. _afterCameraDrawStage: Stage<CameraStageAction>;
  39991. /**
  39992. * @hidden
  39993. * Defines the actions happening just after a render target has been drawn.
  39994. */
  39995. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39996. /**
  39997. * @hidden
  39998. * Defines the actions happening just after rendering all cameras and computing intersections.
  39999. */
  40000. _afterRenderStage: Stage<SimpleStageAction>;
  40001. /**
  40002. * @hidden
  40003. * Defines the actions happening when a pointer move event happens.
  40004. */
  40005. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40006. /**
  40007. * @hidden
  40008. * Defines the actions happening when a pointer down event happens.
  40009. */
  40010. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40011. /**
  40012. * @hidden
  40013. * Defines the actions happening when a pointer up event happens.
  40014. */
  40015. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40016. /**
  40017. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40018. */
  40019. private geometriesByUniqueId;
  40020. /**
  40021. * Creates a new Scene
  40022. * @param engine defines the engine to use to render this scene
  40023. * @param options defines the scene options
  40024. */
  40025. constructor(engine: Engine, options?: SceneOptions);
  40026. /**
  40027. * Gets a string idenfifying the name of the class
  40028. * @returns "Scene" string
  40029. */
  40030. getClassName(): string;
  40031. private _defaultMeshCandidates;
  40032. /**
  40033. * @hidden
  40034. */
  40035. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40036. private _defaultSubMeshCandidates;
  40037. /**
  40038. * @hidden
  40039. */
  40040. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40041. /**
  40042. * Sets the default candidate providers for the scene.
  40043. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40044. * and getCollidingSubMeshCandidates to their default function
  40045. */
  40046. setDefaultCandidateProviders(): void;
  40047. /**
  40048. * Gets the mesh that is currently under the pointer
  40049. */
  40050. get meshUnderPointer(): Nullable<AbstractMesh>;
  40051. /**
  40052. * Gets or sets the current on-screen X position of the pointer
  40053. */
  40054. get pointerX(): number;
  40055. set pointerX(value: number);
  40056. /**
  40057. * Gets or sets the current on-screen Y position of the pointer
  40058. */
  40059. get pointerY(): number;
  40060. set pointerY(value: number);
  40061. /**
  40062. * Gets the cached material (ie. the latest rendered one)
  40063. * @returns the cached material
  40064. */
  40065. getCachedMaterial(): Nullable<Material>;
  40066. /**
  40067. * Gets the cached effect (ie. the latest rendered one)
  40068. * @returns the cached effect
  40069. */
  40070. getCachedEffect(): Nullable<Effect>;
  40071. /**
  40072. * Gets the cached visibility state (ie. the latest rendered one)
  40073. * @returns the cached visibility state
  40074. */
  40075. getCachedVisibility(): Nullable<number>;
  40076. /**
  40077. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40078. * @param material defines the current material
  40079. * @param effect defines the current effect
  40080. * @param visibility defines the current visibility state
  40081. * @returns true if one parameter is not cached
  40082. */
  40083. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40084. /**
  40085. * Gets the engine associated with the scene
  40086. * @returns an Engine
  40087. */
  40088. getEngine(): Engine;
  40089. /**
  40090. * Gets the total number of vertices rendered per frame
  40091. * @returns the total number of vertices rendered per frame
  40092. */
  40093. getTotalVertices(): number;
  40094. /**
  40095. * Gets the performance counter for total vertices
  40096. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40097. */
  40098. get totalVerticesPerfCounter(): PerfCounter;
  40099. /**
  40100. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40101. * @returns the total number of active indices rendered per frame
  40102. */
  40103. getActiveIndices(): number;
  40104. /**
  40105. * Gets the performance counter for active indices
  40106. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40107. */
  40108. get totalActiveIndicesPerfCounter(): PerfCounter;
  40109. /**
  40110. * Gets the total number of active particles rendered per frame
  40111. * @returns the total number of active particles rendered per frame
  40112. */
  40113. getActiveParticles(): number;
  40114. /**
  40115. * Gets the performance counter for active particles
  40116. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40117. */
  40118. get activeParticlesPerfCounter(): PerfCounter;
  40119. /**
  40120. * Gets the total number of active bones rendered per frame
  40121. * @returns the total number of active bones rendered per frame
  40122. */
  40123. getActiveBones(): number;
  40124. /**
  40125. * Gets the performance counter for active bones
  40126. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40127. */
  40128. get activeBonesPerfCounter(): PerfCounter;
  40129. /**
  40130. * Gets the array of active meshes
  40131. * @returns an array of AbstractMesh
  40132. */
  40133. getActiveMeshes(): SmartArray<AbstractMesh>;
  40134. /**
  40135. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40136. * @returns a number
  40137. */
  40138. getAnimationRatio(): number;
  40139. /**
  40140. * Gets an unique Id for the current render phase
  40141. * @returns a number
  40142. */
  40143. getRenderId(): number;
  40144. /**
  40145. * Gets an unique Id for the current frame
  40146. * @returns a number
  40147. */
  40148. getFrameId(): number;
  40149. /** Call this function if you want to manually increment the render Id*/
  40150. incrementRenderId(): void;
  40151. private _createUbo;
  40152. /**
  40153. * Use this method to simulate a pointer move on a mesh
  40154. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40155. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40156. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40157. * @returns the current scene
  40158. */
  40159. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40160. /**
  40161. * Use this method to simulate a pointer down on a mesh
  40162. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40163. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40164. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40165. * @returns the current scene
  40166. */
  40167. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40168. /**
  40169. * Use this method to simulate a pointer up on a mesh
  40170. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40171. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40172. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40173. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40174. * @returns the current scene
  40175. */
  40176. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40177. /**
  40178. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40179. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40180. * @returns true if the pointer was captured
  40181. */
  40182. isPointerCaptured(pointerId?: number): boolean;
  40183. /**
  40184. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40185. * @param attachUp defines if you want to attach events to pointerup
  40186. * @param attachDown defines if you want to attach events to pointerdown
  40187. * @param attachMove defines if you want to attach events to pointermove
  40188. */
  40189. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40190. /** Detaches all event handlers*/
  40191. detachControl(): void;
  40192. /**
  40193. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40194. * Delay loaded resources are not taking in account
  40195. * @return true if all required resources are ready
  40196. */
  40197. isReady(): boolean;
  40198. /** Resets all cached information relative to material (including effect and visibility) */
  40199. resetCachedMaterial(): void;
  40200. /**
  40201. * Registers a function to be called before every frame render
  40202. * @param func defines the function to register
  40203. */
  40204. registerBeforeRender(func: () => void): void;
  40205. /**
  40206. * Unregisters a function called before every frame render
  40207. * @param func defines the function to unregister
  40208. */
  40209. unregisterBeforeRender(func: () => void): void;
  40210. /**
  40211. * Registers a function to be called after every frame render
  40212. * @param func defines the function to register
  40213. */
  40214. registerAfterRender(func: () => void): void;
  40215. /**
  40216. * Unregisters a function called after every frame render
  40217. * @param func defines the function to unregister
  40218. */
  40219. unregisterAfterRender(func: () => void): void;
  40220. private _executeOnceBeforeRender;
  40221. /**
  40222. * The provided function will run before render once and will be disposed afterwards.
  40223. * A timeout delay can be provided so that the function will be executed in N ms.
  40224. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40225. * @param func The function to be executed.
  40226. * @param timeout optional delay in ms
  40227. */
  40228. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40229. /** @hidden */
  40230. _addPendingData(data: any): void;
  40231. /** @hidden */
  40232. _removePendingData(data: any): void;
  40233. /**
  40234. * Returns the number of items waiting to be loaded
  40235. * @returns the number of items waiting to be loaded
  40236. */
  40237. getWaitingItemsCount(): number;
  40238. /**
  40239. * Returns a boolean indicating if the scene is still loading data
  40240. */
  40241. get isLoading(): boolean;
  40242. /**
  40243. * Registers a function to be executed when the scene is ready
  40244. * @param {Function} func - the function to be executed
  40245. */
  40246. executeWhenReady(func: () => void): void;
  40247. /**
  40248. * Returns a promise that resolves when the scene is ready
  40249. * @returns A promise that resolves when the scene is ready
  40250. */
  40251. whenReadyAsync(): Promise<void>;
  40252. /** @hidden */
  40253. _checkIsReady(): void;
  40254. /**
  40255. * Gets all animatable attached to the scene
  40256. */
  40257. get animatables(): Animatable[];
  40258. /**
  40259. * Resets the last animation time frame.
  40260. * Useful to override when animations start running when loading a scene for the first time.
  40261. */
  40262. resetLastAnimationTimeFrame(): void;
  40263. /**
  40264. * Gets the current view matrix
  40265. * @returns a Matrix
  40266. */
  40267. getViewMatrix(): Matrix;
  40268. /**
  40269. * Gets the current projection matrix
  40270. * @returns a Matrix
  40271. */
  40272. getProjectionMatrix(): Matrix;
  40273. /**
  40274. * Gets the current transform matrix
  40275. * @returns a Matrix made of View * Projection
  40276. */
  40277. getTransformMatrix(): Matrix;
  40278. /**
  40279. * Sets the current transform matrix
  40280. * @param viewL defines the View matrix to use
  40281. * @param projectionL defines the Projection matrix to use
  40282. * @param viewR defines the right View matrix to use (if provided)
  40283. * @param projectionR defines the right Projection matrix to use (if provided)
  40284. */
  40285. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40286. /**
  40287. * Gets the uniform buffer used to store scene data
  40288. * @returns a UniformBuffer
  40289. */
  40290. getSceneUniformBuffer(): UniformBuffer;
  40291. /**
  40292. * Gets an unique (relatively to the current scene) Id
  40293. * @returns an unique number for the scene
  40294. */
  40295. getUniqueId(): number;
  40296. /**
  40297. * Add a mesh to the list of scene's meshes
  40298. * @param newMesh defines the mesh to add
  40299. * @param recursive if all child meshes should also be added to the scene
  40300. */
  40301. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40302. /**
  40303. * Remove a mesh for the list of scene's meshes
  40304. * @param toRemove defines the mesh to remove
  40305. * @param recursive if all child meshes should also be removed from the scene
  40306. * @returns the index where the mesh was in the mesh list
  40307. */
  40308. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40309. /**
  40310. * Add a transform node to the list of scene's transform nodes
  40311. * @param newTransformNode defines the transform node to add
  40312. */
  40313. addTransformNode(newTransformNode: TransformNode): void;
  40314. /**
  40315. * Remove a transform node for the list of scene's transform nodes
  40316. * @param toRemove defines the transform node to remove
  40317. * @returns the index where the transform node was in the transform node list
  40318. */
  40319. removeTransformNode(toRemove: TransformNode): number;
  40320. /**
  40321. * Remove a skeleton for the list of scene's skeletons
  40322. * @param toRemove defines the skeleton to remove
  40323. * @returns the index where the skeleton was in the skeleton list
  40324. */
  40325. removeSkeleton(toRemove: Skeleton): number;
  40326. /**
  40327. * Remove a morph target for the list of scene's morph targets
  40328. * @param toRemove defines the morph target to remove
  40329. * @returns the index where the morph target was in the morph target list
  40330. */
  40331. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40332. /**
  40333. * Remove a light for the list of scene's lights
  40334. * @param toRemove defines the light to remove
  40335. * @returns the index where the light was in the light list
  40336. */
  40337. removeLight(toRemove: Light): number;
  40338. /**
  40339. * Remove a camera for the list of scene's cameras
  40340. * @param toRemove defines the camera to remove
  40341. * @returns the index where the camera was in the camera list
  40342. */
  40343. removeCamera(toRemove: Camera): number;
  40344. /**
  40345. * Remove a particle system for the list of scene's particle systems
  40346. * @param toRemove defines the particle system to remove
  40347. * @returns the index where the particle system was in the particle system list
  40348. */
  40349. removeParticleSystem(toRemove: IParticleSystem): number;
  40350. /**
  40351. * Remove a animation for the list of scene's animations
  40352. * @param toRemove defines the animation to remove
  40353. * @returns the index where the animation was in the animation list
  40354. */
  40355. removeAnimation(toRemove: Animation): number;
  40356. /**
  40357. * Will stop the animation of the given target
  40358. * @param target - the target
  40359. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40360. * @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)
  40361. */
  40362. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40363. /**
  40364. * Removes the given animation group from this scene.
  40365. * @param toRemove The animation group to remove
  40366. * @returns The index of the removed animation group
  40367. */
  40368. removeAnimationGroup(toRemove: AnimationGroup): number;
  40369. /**
  40370. * Removes the given multi-material from this scene.
  40371. * @param toRemove The multi-material to remove
  40372. * @returns The index of the removed multi-material
  40373. */
  40374. removeMultiMaterial(toRemove: MultiMaterial): number;
  40375. /**
  40376. * Removes the given material from this scene.
  40377. * @param toRemove The material to remove
  40378. * @returns The index of the removed material
  40379. */
  40380. removeMaterial(toRemove: Material): number;
  40381. /**
  40382. * Removes the given action manager from this scene.
  40383. * @param toRemove The action manager to remove
  40384. * @returns The index of the removed action manager
  40385. */
  40386. removeActionManager(toRemove: AbstractActionManager): number;
  40387. /**
  40388. * Removes the given texture from this scene.
  40389. * @param toRemove The texture to remove
  40390. * @returns The index of the removed texture
  40391. */
  40392. removeTexture(toRemove: BaseTexture): number;
  40393. /**
  40394. * Adds the given light to this scene
  40395. * @param newLight The light to add
  40396. */
  40397. addLight(newLight: Light): void;
  40398. /**
  40399. * Sorts the list list based on light priorities
  40400. */
  40401. sortLightsByPriority(): void;
  40402. /**
  40403. * Adds the given camera to this scene
  40404. * @param newCamera The camera to add
  40405. */
  40406. addCamera(newCamera: Camera): void;
  40407. /**
  40408. * Adds the given skeleton to this scene
  40409. * @param newSkeleton The skeleton to add
  40410. */
  40411. addSkeleton(newSkeleton: Skeleton): void;
  40412. /**
  40413. * Adds the given particle system to this scene
  40414. * @param newParticleSystem The particle system to add
  40415. */
  40416. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40417. /**
  40418. * Adds the given animation to this scene
  40419. * @param newAnimation The animation to add
  40420. */
  40421. addAnimation(newAnimation: Animation): void;
  40422. /**
  40423. * Adds the given animation group to this scene.
  40424. * @param newAnimationGroup The animation group to add
  40425. */
  40426. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40427. /**
  40428. * Adds the given multi-material to this scene
  40429. * @param newMultiMaterial The multi-material to add
  40430. */
  40431. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40432. /**
  40433. * Adds the given material to this scene
  40434. * @param newMaterial The material to add
  40435. */
  40436. addMaterial(newMaterial: Material): void;
  40437. /**
  40438. * Adds the given morph target to this scene
  40439. * @param newMorphTargetManager The morph target to add
  40440. */
  40441. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40442. /**
  40443. * Adds the given geometry to this scene
  40444. * @param newGeometry The geometry to add
  40445. */
  40446. addGeometry(newGeometry: Geometry): void;
  40447. /**
  40448. * Adds the given action manager to this scene
  40449. * @param newActionManager The action manager to add
  40450. */
  40451. addActionManager(newActionManager: AbstractActionManager): void;
  40452. /**
  40453. * Adds the given texture to this scene.
  40454. * @param newTexture The texture to add
  40455. */
  40456. addTexture(newTexture: BaseTexture): void;
  40457. /**
  40458. * Switch active camera
  40459. * @param newCamera defines the new active camera
  40460. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40461. */
  40462. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40463. /**
  40464. * sets the active camera of the scene using its ID
  40465. * @param id defines the camera's ID
  40466. * @return the new active camera or null if none found.
  40467. */
  40468. setActiveCameraByID(id: string): Nullable<Camera>;
  40469. /**
  40470. * sets the active camera of the scene using its name
  40471. * @param name defines the camera's name
  40472. * @returns the new active camera or null if none found.
  40473. */
  40474. setActiveCameraByName(name: string): Nullable<Camera>;
  40475. /**
  40476. * get an animation group using its name
  40477. * @param name defines the material's name
  40478. * @return the animation group or null if none found.
  40479. */
  40480. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40481. /**
  40482. * Get a material using its unique id
  40483. * @param uniqueId defines the material's unique id
  40484. * @return the material or null if none found.
  40485. */
  40486. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40487. /**
  40488. * get a material using its id
  40489. * @param id defines the material's ID
  40490. * @return the material or null if none found.
  40491. */
  40492. getMaterialByID(id: string): Nullable<Material>;
  40493. /**
  40494. * Gets a the last added material using a given id
  40495. * @param id defines the material's ID
  40496. * @return the last material with the given id or null if none found.
  40497. */
  40498. getLastMaterialByID(id: string): Nullable<Material>;
  40499. /**
  40500. * Gets a material using its name
  40501. * @param name defines the material's name
  40502. * @return the material or null if none found.
  40503. */
  40504. getMaterialByName(name: string): Nullable<Material>;
  40505. /**
  40506. * Get a texture using its unique id
  40507. * @param uniqueId defines the texture's unique id
  40508. * @return the texture or null if none found.
  40509. */
  40510. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40511. /**
  40512. * Gets a camera using its id
  40513. * @param id defines the id to look for
  40514. * @returns the camera or null if not found
  40515. */
  40516. getCameraByID(id: string): Nullable<Camera>;
  40517. /**
  40518. * Gets a camera using its unique id
  40519. * @param uniqueId defines the unique id to look for
  40520. * @returns the camera or null if not found
  40521. */
  40522. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40523. /**
  40524. * Gets a camera using its name
  40525. * @param name defines the camera's name
  40526. * @return the camera or null if none found.
  40527. */
  40528. getCameraByName(name: string): Nullable<Camera>;
  40529. /**
  40530. * Gets a bone using its id
  40531. * @param id defines the bone's id
  40532. * @return the bone or null if not found
  40533. */
  40534. getBoneByID(id: string): Nullable<Bone>;
  40535. /**
  40536. * Gets a bone using its id
  40537. * @param name defines the bone's name
  40538. * @return the bone or null if not found
  40539. */
  40540. getBoneByName(name: string): Nullable<Bone>;
  40541. /**
  40542. * Gets a light node using its name
  40543. * @param name defines the the light's name
  40544. * @return the light or null if none found.
  40545. */
  40546. getLightByName(name: string): Nullable<Light>;
  40547. /**
  40548. * Gets a light node using its id
  40549. * @param id defines the light's id
  40550. * @return the light or null if none found.
  40551. */
  40552. getLightByID(id: string): Nullable<Light>;
  40553. /**
  40554. * Gets a light node using its scene-generated unique ID
  40555. * @param uniqueId defines the light's unique id
  40556. * @return the light or null if none found.
  40557. */
  40558. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40559. /**
  40560. * Gets a particle system by id
  40561. * @param id defines the particle system id
  40562. * @return the corresponding system or null if none found
  40563. */
  40564. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40565. /**
  40566. * Gets a geometry using its ID
  40567. * @param id defines the geometry's id
  40568. * @return the geometry or null if none found.
  40569. */
  40570. getGeometryByID(id: string): Nullable<Geometry>;
  40571. private _getGeometryByUniqueID;
  40572. /**
  40573. * Add a new geometry to this scene
  40574. * @param geometry defines the geometry to be added to the scene.
  40575. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40576. * @return a boolean defining if the geometry was added or not
  40577. */
  40578. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40579. /**
  40580. * Removes an existing geometry
  40581. * @param geometry defines the geometry to be removed from the scene
  40582. * @return a boolean defining if the geometry was removed or not
  40583. */
  40584. removeGeometry(geometry: Geometry): boolean;
  40585. /**
  40586. * Gets the list of geometries attached to the scene
  40587. * @returns an array of Geometry
  40588. */
  40589. getGeometries(): Geometry[];
  40590. /**
  40591. * Gets the first added mesh found of a given ID
  40592. * @param id defines the id to search for
  40593. * @return the mesh found or null if not found at all
  40594. */
  40595. getMeshByID(id: string): Nullable<AbstractMesh>;
  40596. /**
  40597. * Gets a list of meshes using their id
  40598. * @param id defines the id to search for
  40599. * @returns a list of meshes
  40600. */
  40601. getMeshesByID(id: string): Array<AbstractMesh>;
  40602. /**
  40603. * Gets the first added transform node found of a given ID
  40604. * @param id defines the id to search for
  40605. * @return the found transform node or null if not found at all.
  40606. */
  40607. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40608. /**
  40609. * Gets a transform node with its auto-generated unique id
  40610. * @param uniqueId efines the unique id to search for
  40611. * @return the found transform node or null if not found at all.
  40612. */
  40613. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40614. /**
  40615. * Gets a list of transform nodes using their id
  40616. * @param id defines the id to search for
  40617. * @returns a list of transform nodes
  40618. */
  40619. getTransformNodesByID(id: string): Array<TransformNode>;
  40620. /**
  40621. * Gets a mesh with its auto-generated unique id
  40622. * @param uniqueId defines the unique id to search for
  40623. * @return the found mesh or null if not found at all.
  40624. */
  40625. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40626. /**
  40627. * Gets a the last added mesh using a given id
  40628. * @param id defines the id to search for
  40629. * @return the found mesh or null if not found at all.
  40630. */
  40631. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40632. /**
  40633. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40634. * @param id defines the id to search for
  40635. * @return the found node or null if not found at all
  40636. */
  40637. getLastEntryByID(id: string): Nullable<Node>;
  40638. /**
  40639. * Gets a node (Mesh, Camera, Light) using a given id
  40640. * @param id defines the id to search for
  40641. * @return the found node or null if not found at all
  40642. */
  40643. getNodeByID(id: string): Nullable<Node>;
  40644. /**
  40645. * Gets a node (Mesh, Camera, Light) using a given name
  40646. * @param name defines the name to search for
  40647. * @return the found node or null if not found at all.
  40648. */
  40649. getNodeByName(name: string): Nullable<Node>;
  40650. /**
  40651. * Gets a mesh using a given name
  40652. * @param name defines the name to search for
  40653. * @return the found mesh or null if not found at all.
  40654. */
  40655. getMeshByName(name: string): Nullable<AbstractMesh>;
  40656. /**
  40657. * Gets a transform node using a given name
  40658. * @param name defines the name to search for
  40659. * @return the found transform node or null if not found at all.
  40660. */
  40661. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40662. /**
  40663. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40664. * @param id defines the id to search for
  40665. * @return the found skeleton or null if not found at all.
  40666. */
  40667. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40668. /**
  40669. * Gets a skeleton using a given auto generated unique id
  40670. * @param uniqueId defines the unique id to search for
  40671. * @return the found skeleton or null if not found at all.
  40672. */
  40673. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40674. /**
  40675. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40676. * @param id defines the id to search for
  40677. * @return the found skeleton or null if not found at all.
  40678. */
  40679. getSkeletonById(id: string): Nullable<Skeleton>;
  40680. /**
  40681. * Gets a skeleton using a given name
  40682. * @param name defines the name to search for
  40683. * @return the found skeleton or null if not found at all.
  40684. */
  40685. getSkeletonByName(name: string): Nullable<Skeleton>;
  40686. /**
  40687. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40688. * @param id defines the id to search for
  40689. * @return the found morph target manager or null if not found at all.
  40690. */
  40691. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40692. /**
  40693. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40694. * @param id defines the id to search for
  40695. * @return the found morph target or null if not found at all.
  40696. */
  40697. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40698. /**
  40699. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40700. * @param name defines the name to search for
  40701. * @return the found morph target or null if not found at all.
  40702. */
  40703. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40704. /**
  40705. * Gets a boolean indicating if the given mesh is active
  40706. * @param mesh defines the mesh to look for
  40707. * @returns true if the mesh is in the active list
  40708. */
  40709. isActiveMesh(mesh: AbstractMesh): boolean;
  40710. /**
  40711. * Return a unique id as a string which can serve as an identifier for the scene
  40712. */
  40713. get uid(): string;
  40714. /**
  40715. * Add an externaly attached data from its key.
  40716. * This method call will fail and return false, if such key already exists.
  40717. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40718. * @param key the unique key that identifies the data
  40719. * @param data the data object to associate to the key for this Engine instance
  40720. * @return true if no such key were already present and the data was added successfully, false otherwise
  40721. */
  40722. addExternalData<T>(key: string, data: T): boolean;
  40723. /**
  40724. * Get an externaly attached data from its key
  40725. * @param key the unique key that identifies the data
  40726. * @return the associated data, if present (can be null), or undefined if not present
  40727. */
  40728. getExternalData<T>(key: string): Nullable<T>;
  40729. /**
  40730. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40731. * @param key the unique key that identifies the data
  40732. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40733. * @return the associated data, can be null if the factory returned null.
  40734. */
  40735. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40736. /**
  40737. * Remove an externaly attached data from the Engine instance
  40738. * @param key the unique key that identifies the data
  40739. * @return true if the data was successfully removed, false if it doesn't exist
  40740. */
  40741. removeExternalData(key: string): boolean;
  40742. private _evaluateSubMesh;
  40743. /**
  40744. * Clear the processed materials smart array preventing retention point in material dispose.
  40745. */
  40746. freeProcessedMaterials(): void;
  40747. private _preventFreeActiveMeshesAndRenderingGroups;
  40748. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40749. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40750. * when disposing several meshes in a row or a hierarchy of meshes.
  40751. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40752. */
  40753. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40754. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40755. /**
  40756. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40757. */
  40758. freeActiveMeshes(): void;
  40759. /**
  40760. * Clear the info related to rendering groups preventing retention points during dispose.
  40761. */
  40762. freeRenderingGroups(): void;
  40763. /** @hidden */
  40764. _isInIntermediateRendering(): boolean;
  40765. /**
  40766. * Lambda returning the list of potentially active meshes.
  40767. */
  40768. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40769. /**
  40770. * Lambda returning the list of potentially active sub meshes.
  40771. */
  40772. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40773. /**
  40774. * Lambda returning the list of potentially intersecting sub meshes.
  40775. */
  40776. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40777. /**
  40778. * Lambda returning the list of potentially colliding sub meshes.
  40779. */
  40780. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40781. private _activeMeshesFrozen;
  40782. private _skipEvaluateActiveMeshesCompletely;
  40783. /**
  40784. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40785. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40786. * @returns the current scene
  40787. */
  40788. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40789. /**
  40790. * Use this function to restart evaluating active meshes on every frame
  40791. * @returns the current scene
  40792. */
  40793. unfreezeActiveMeshes(): Scene;
  40794. private _evaluateActiveMeshes;
  40795. private _activeMesh;
  40796. /**
  40797. * Update the transform matrix to update from the current active camera
  40798. * @param force defines a boolean used to force the update even if cache is up to date
  40799. */
  40800. updateTransformMatrix(force?: boolean): void;
  40801. private _bindFrameBuffer;
  40802. /** @hidden */
  40803. _allowPostProcessClearColor: boolean;
  40804. /** @hidden */
  40805. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40806. private _processSubCameras;
  40807. private _checkIntersections;
  40808. /** @hidden */
  40809. _advancePhysicsEngineStep(step: number): void;
  40810. /**
  40811. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40812. */
  40813. getDeterministicFrameTime: () => number;
  40814. /** @hidden */
  40815. _animate(): void;
  40816. /** Execute all animations (for a frame) */
  40817. animate(): void;
  40818. /**
  40819. * Render the scene
  40820. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40821. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40822. */
  40823. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40824. /**
  40825. * Freeze all materials
  40826. * A frozen material will not be updatable but should be faster to render
  40827. */
  40828. freezeMaterials(): void;
  40829. /**
  40830. * Unfreeze all materials
  40831. * A frozen material will not be updatable but should be faster to render
  40832. */
  40833. unfreezeMaterials(): void;
  40834. /**
  40835. * Releases all held ressources
  40836. */
  40837. dispose(): void;
  40838. /**
  40839. * Gets if the scene is already disposed
  40840. */
  40841. get isDisposed(): boolean;
  40842. /**
  40843. * Call this function to reduce memory footprint of the scene.
  40844. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40845. */
  40846. clearCachedVertexData(): void;
  40847. /**
  40848. * This function will remove the local cached buffer data from texture.
  40849. * It will save memory but will prevent the texture from being rebuilt
  40850. */
  40851. cleanCachedTextureBuffer(): void;
  40852. /**
  40853. * Get the world extend vectors with an optional filter
  40854. *
  40855. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40856. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40857. */
  40858. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40859. min: Vector3;
  40860. max: Vector3;
  40861. };
  40862. /**
  40863. * Creates a ray that can be used to pick in the scene
  40864. * @param x defines the x coordinate of the origin (on-screen)
  40865. * @param y defines the y coordinate of the origin (on-screen)
  40866. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40867. * @param camera defines the camera to use for the picking
  40868. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40869. * @returns a Ray
  40870. */
  40871. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40872. /**
  40873. * Creates a ray that can be used to pick in the scene
  40874. * @param x defines the x coordinate of the origin (on-screen)
  40875. * @param y defines the y coordinate of the origin (on-screen)
  40876. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40877. * @param result defines the ray where to store the picking ray
  40878. * @param camera defines the camera to use for the picking
  40879. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40880. * @returns the current scene
  40881. */
  40882. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40883. /**
  40884. * Creates a ray that can be used to pick in the scene
  40885. * @param x defines the x coordinate of the origin (on-screen)
  40886. * @param y defines the y coordinate of the origin (on-screen)
  40887. * @param camera defines the camera to use for the picking
  40888. * @returns a Ray
  40889. */
  40890. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40891. /**
  40892. * Creates a ray that can be used to pick in the scene
  40893. * @param x defines the x coordinate of the origin (on-screen)
  40894. * @param y defines the y coordinate of the origin (on-screen)
  40895. * @param result defines the ray where to store the picking ray
  40896. * @param camera defines the camera to use for the picking
  40897. * @returns the current scene
  40898. */
  40899. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40900. /** Launch a ray to try to pick a mesh in the scene
  40901. * @param x position on screen
  40902. * @param y position on screen
  40903. * @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
  40904. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40905. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40906. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40907. * @returns a PickingInfo
  40908. */
  40909. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40910. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40911. * @param x position on screen
  40912. * @param y position on screen
  40913. * @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
  40914. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40915. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40916. * @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)
  40917. */
  40918. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40919. /** Use the given ray to pick a mesh in the scene
  40920. * @param ray The ray to use to pick meshes
  40921. * @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
  40922. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40923. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40924. * @returns a PickingInfo
  40925. */
  40926. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40927. /**
  40928. * Launch a ray to try to pick a mesh in the scene
  40929. * @param x X position on screen
  40930. * @param y Y position on screen
  40931. * @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
  40932. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40933. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40934. * @returns an array of PickingInfo
  40935. */
  40936. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40937. /**
  40938. * Launch a ray to try to pick a mesh in the scene
  40939. * @param ray Ray to use
  40940. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  40941. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40942. * @returns an array of PickingInfo
  40943. */
  40944. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40945. /**
  40946. * Force the value of meshUnderPointer
  40947. * @param mesh defines the mesh to use
  40948. */
  40949. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40950. /**
  40951. * Gets the mesh under the pointer
  40952. * @returns a Mesh or null if no mesh is under the pointer
  40953. */
  40954. getPointerOverMesh(): Nullable<AbstractMesh>;
  40955. /** @hidden */
  40956. _rebuildGeometries(): void;
  40957. /** @hidden */
  40958. _rebuildTextures(): void;
  40959. private _getByTags;
  40960. /**
  40961. * Get a list of meshes by tags
  40962. * @param tagsQuery defines the tags query to use
  40963. * @param forEach defines a predicate used to filter results
  40964. * @returns an array of Mesh
  40965. */
  40966. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40967. /**
  40968. * Get a list of cameras by tags
  40969. * @param tagsQuery defines the tags query to use
  40970. * @param forEach defines a predicate used to filter results
  40971. * @returns an array of Camera
  40972. */
  40973. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40974. /**
  40975. * Get a list of lights by tags
  40976. * @param tagsQuery defines the tags query to use
  40977. * @param forEach defines a predicate used to filter results
  40978. * @returns an array of Light
  40979. */
  40980. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40981. /**
  40982. * Get a list of materials by tags
  40983. * @param tagsQuery defines the tags query to use
  40984. * @param forEach defines a predicate used to filter results
  40985. * @returns an array of Material
  40986. */
  40987. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40988. /**
  40989. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40990. * This allowed control for front to back rendering or reversly depending of the special needs.
  40991. *
  40992. * @param renderingGroupId The rendering group id corresponding to its index
  40993. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40994. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40995. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40996. */
  40997. 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;
  40998. /**
  40999. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41000. *
  41001. * @param renderingGroupId The rendering group id corresponding to its index
  41002. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41003. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41004. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41005. */
  41006. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41007. /**
  41008. * Gets the current auto clear configuration for one rendering group of the rendering
  41009. * manager.
  41010. * @param index the rendering group index to get the information for
  41011. * @returns The auto clear setup for the requested rendering group
  41012. */
  41013. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41014. private _blockMaterialDirtyMechanism;
  41015. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41016. get blockMaterialDirtyMechanism(): boolean;
  41017. set blockMaterialDirtyMechanism(value: boolean);
  41018. /**
  41019. * Will flag all materials as dirty to trigger new shader compilation
  41020. * @param flag defines the flag used to specify which material part must be marked as dirty
  41021. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41022. */
  41023. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41024. /** @hidden */
  41025. _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;
  41026. /** @hidden */
  41027. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41028. /** @hidden */
  41029. _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;
  41030. /** @hidden */
  41031. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41032. /** @hidden */
  41033. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41034. /** @hidden */
  41035. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41036. }
  41037. }
  41038. declare module BABYLON {
  41039. /**
  41040. * Set of assets to keep when moving a scene into an asset container.
  41041. */
  41042. export class KeepAssets extends AbstractScene {
  41043. }
  41044. /**
  41045. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41046. */
  41047. export class InstantiatedEntries {
  41048. /**
  41049. * List of new root nodes (eg. nodes with no parent)
  41050. */
  41051. rootNodes: TransformNode[];
  41052. /**
  41053. * List of new skeletons
  41054. */
  41055. skeletons: Skeleton[];
  41056. /**
  41057. * List of new animation groups
  41058. */
  41059. animationGroups: AnimationGroup[];
  41060. }
  41061. /**
  41062. * Container with a set of assets that can be added or removed from a scene.
  41063. */
  41064. export class AssetContainer extends AbstractScene {
  41065. private _wasAddedToScene;
  41066. /**
  41067. * The scene the AssetContainer belongs to.
  41068. */
  41069. scene: Scene;
  41070. /**
  41071. * Instantiates an AssetContainer.
  41072. * @param scene The scene the AssetContainer belongs to.
  41073. */
  41074. constructor(scene: Scene);
  41075. /**
  41076. * Instantiate or clone all meshes and add the new ones to the scene.
  41077. * Skeletons and animation groups will all be cloned
  41078. * @param nameFunction defines an optional function used to get new names for clones
  41079. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41080. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41081. */
  41082. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41083. /**
  41084. * Adds all the assets from the container to the scene.
  41085. */
  41086. addAllToScene(): void;
  41087. /**
  41088. * Removes all the assets in the container from the scene
  41089. */
  41090. removeAllFromScene(): void;
  41091. /**
  41092. * Disposes all the assets in the container
  41093. */
  41094. dispose(): void;
  41095. private _moveAssets;
  41096. /**
  41097. * Removes all the assets contained in the scene and adds them to the container.
  41098. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41099. */
  41100. moveAllFromScene(keepAssets?: KeepAssets): void;
  41101. /**
  41102. * 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.
  41103. * @returns the root mesh
  41104. */
  41105. createRootMesh(): Mesh;
  41106. /**
  41107. * Merge animations (direct and animation groups) from this asset container into a scene
  41108. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41109. * @param animatables set of animatables to retarget to a node from the scene
  41110. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41111. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41112. */
  41113. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41114. }
  41115. }
  41116. declare module BABYLON {
  41117. /**
  41118. * Defines how the parser contract is defined.
  41119. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41120. */
  41121. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41122. /**
  41123. * Defines how the individual parser contract is defined.
  41124. * These parser can parse an individual asset
  41125. */
  41126. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41127. /**
  41128. * Base class of the scene acting as a container for the different elements composing a scene.
  41129. * This class is dynamically extended by the different components of the scene increasing
  41130. * flexibility and reducing coupling
  41131. */
  41132. export abstract class AbstractScene {
  41133. /**
  41134. * Stores the list of available parsers in the application.
  41135. */
  41136. private static _BabylonFileParsers;
  41137. /**
  41138. * Stores the list of available individual parsers in the application.
  41139. */
  41140. private static _IndividualBabylonFileParsers;
  41141. /**
  41142. * Adds a parser in the list of available ones
  41143. * @param name Defines the name of the parser
  41144. * @param parser Defines the parser to add
  41145. */
  41146. static AddParser(name: string, parser: BabylonFileParser): void;
  41147. /**
  41148. * Gets a general parser from the list of avaialble ones
  41149. * @param name Defines the name of the parser
  41150. * @returns the requested parser or null
  41151. */
  41152. static GetParser(name: string): Nullable<BabylonFileParser>;
  41153. /**
  41154. * Adds n individual parser in the list of available ones
  41155. * @param name Defines the name of the parser
  41156. * @param parser Defines the parser to add
  41157. */
  41158. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41159. /**
  41160. * Gets an individual parser from the list of avaialble ones
  41161. * @param name Defines the name of the parser
  41162. * @returns the requested parser or null
  41163. */
  41164. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41165. /**
  41166. * Parser json data and populate both a scene and its associated container object
  41167. * @param jsonData Defines the data to parse
  41168. * @param scene Defines the scene to parse the data for
  41169. * @param container Defines the container attached to the parsing sequence
  41170. * @param rootUrl Defines the root url of the data
  41171. */
  41172. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41173. /**
  41174. * Gets the list of root nodes (ie. nodes with no parent)
  41175. */
  41176. rootNodes: Node[];
  41177. /** All of the cameras added to this scene
  41178. * @see https://doc.babylonjs.com/babylon101/cameras
  41179. */
  41180. cameras: Camera[];
  41181. /**
  41182. * All of the lights added to this scene
  41183. * @see https://doc.babylonjs.com/babylon101/lights
  41184. */
  41185. lights: Light[];
  41186. /**
  41187. * All of the (abstract) meshes added to this scene
  41188. */
  41189. meshes: AbstractMesh[];
  41190. /**
  41191. * The list of skeletons added to the scene
  41192. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41193. */
  41194. skeletons: Skeleton[];
  41195. /**
  41196. * All of the particle systems added to this scene
  41197. * @see https://doc.babylonjs.com/babylon101/particles
  41198. */
  41199. particleSystems: IParticleSystem[];
  41200. /**
  41201. * Gets a list of Animations associated with the scene
  41202. */
  41203. animations: Animation[];
  41204. /**
  41205. * All of the animation groups added to this scene
  41206. * @see https://doc.babylonjs.com/how_to/group
  41207. */
  41208. animationGroups: AnimationGroup[];
  41209. /**
  41210. * All of the multi-materials added to this scene
  41211. * @see https://doc.babylonjs.com/how_to/multi_materials
  41212. */
  41213. multiMaterials: MultiMaterial[];
  41214. /**
  41215. * All of the materials added to this scene
  41216. * In the context of a Scene, it is not supposed to be modified manually.
  41217. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41218. * Note also that the order of the Material within the array is not significant and might change.
  41219. * @see https://doc.babylonjs.com/babylon101/materials
  41220. */
  41221. materials: Material[];
  41222. /**
  41223. * The list of morph target managers added to the scene
  41224. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41225. */
  41226. morphTargetManagers: MorphTargetManager[];
  41227. /**
  41228. * The list of geometries used in the scene.
  41229. */
  41230. geometries: Geometry[];
  41231. /**
  41232. * All of the tranform nodes added to this scene
  41233. * In the context of a Scene, it is not supposed to be modified manually.
  41234. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41235. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41236. * @see https://doc.babylonjs.com/how_to/transformnode
  41237. */
  41238. transformNodes: TransformNode[];
  41239. /**
  41240. * ActionManagers available on the scene.
  41241. */
  41242. actionManagers: AbstractActionManager[];
  41243. /**
  41244. * Textures to keep.
  41245. */
  41246. textures: BaseTexture[];
  41247. /**
  41248. * Environment texture for the scene
  41249. */
  41250. environmentTexture: Nullable<BaseTexture>;
  41251. /**
  41252. * @returns all meshes, lights, cameras, transformNodes and bones
  41253. */
  41254. getNodes(): Array<Node>;
  41255. }
  41256. }
  41257. declare module BABYLON {
  41258. /**
  41259. * Interface used to define options for Sound class
  41260. */
  41261. export interface ISoundOptions {
  41262. /**
  41263. * Does the sound autoplay once loaded.
  41264. */
  41265. autoplay?: boolean;
  41266. /**
  41267. * Does the sound loop after it finishes playing once.
  41268. */
  41269. loop?: boolean;
  41270. /**
  41271. * Sound's volume
  41272. */
  41273. volume?: number;
  41274. /**
  41275. * Is it a spatial sound?
  41276. */
  41277. spatialSound?: boolean;
  41278. /**
  41279. * Maximum distance to hear that sound
  41280. */
  41281. maxDistance?: number;
  41282. /**
  41283. * Uses user defined attenuation function
  41284. */
  41285. useCustomAttenuation?: boolean;
  41286. /**
  41287. * Define the roll off factor of spatial sounds.
  41288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41289. */
  41290. rolloffFactor?: number;
  41291. /**
  41292. * Define the reference distance the sound should be heard perfectly.
  41293. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41294. */
  41295. refDistance?: number;
  41296. /**
  41297. * Define the distance attenuation model the sound will follow.
  41298. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41299. */
  41300. distanceModel?: string;
  41301. /**
  41302. * Defines the playback speed (1 by default)
  41303. */
  41304. playbackRate?: number;
  41305. /**
  41306. * Defines if the sound is from a streaming source
  41307. */
  41308. streaming?: boolean;
  41309. /**
  41310. * Defines an optional length (in seconds) inside the sound file
  41311. */
  41312. length?: number;
  41313. /**
  41314. * Defines an optional offset (in seconds) inside the sound file
  41315. */
  41316. offset?: number;
  41317. /**
  41318. * If true, URLs will not be required to state the audio file codec to use.
  41319. */
  41320. skipCodecCheck?: boolean;
  41321. }
  41322. /**
  41323. * Defines a sound that can be played in the application.
  41324. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41325. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41326. */
  41327. export class Sound {
  41328. /**
  41329. * The name of the sound in the scene.
  41330. */
  41331. name: string;
  41332. /**
  41333. * Does the sound autoplay once loaded.
  41334. */
  41335. autoplay: boolean;
  41336. /**
  41337. * Does the sound loop after it finishes playing once.
  41338. */
  41339. loop: boolean;
  41340. /**
  41341. * Does the sound use a custom attenuation curve to simulate the falloff
  41342. * happening when the source gets further away from the camera.
  41343. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41344. */
  41345. useCustomAttenuation: boolean;
  41346. /**
  41347. * The sound track id this sound belongs to.
  41348. */
  41349. soundTrackId: number;
  41350. /**
  41351. * Is this sound currently played.
  41352. */
  41353. isPlaying: boolean;
  41354. /**
  41355. * Is this sound currently paused.
  41356. */
  41357. isPaused: boolean;
  41358. /**
  41359. * Does this sound enables spatial sound.
  41360. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41361. */
  41362. spatialSound: boolean;
  41363. /**
  41364. * Define the reference distance the sound should be heard perfectly.
  41365. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41366. */
  41367. refDistance: number;
  41368. /**
  41369. * Define the roll off factor of spatial sounds.
  41370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41371. */
  41372. rolloffFactor: number;
  41373. /**
  41374. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41375. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41376. */
  41377. maxDistance: number;
  41378. /**
  41379. * Define the distance attenuation model the sound will follow.
  41380. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41381. */
  41382. distanceModel: string;
  41383. /**
  41384. * @hidden
  41385. * Back Compat
  41386. **/
  41387. onended: () => any;
  41388. /**
  41389. * Gets or sets an object used to store user defined information for the sound.
  41390. */
  41391. metadata: any;
  41392. /**
  41393. * Observable event when the current playing sound finishes.
  41394. */
  41395. onEndedObservable: Observable<Sound>;
  41396. private _panningModel;
  41397. private _playbackRate;
  41398. private _streaming;
  41399. private _startTime;
  41400. private _startOffset;
  41401. private _position;
  41402. /** @hidden */
  41403. _positionInEmitterSpace: boolean;
  41404. private _localDirection;
  41405. private _volume;
  41406. private _isReadyToPlay;
  41407. private _isDirectional;
  41408. private _readyToPlayCallback;
  41409. private _audioBuffer;
  41410. private _soundSource;
  41411. private _streamingSource;
  41412. private _soundPanner;
  41413. private _soundGain;
  41414. private _inputAudioNode;
  41415. private _outputAudioNode;
  41416. private _coneInnerAngle;
  41417. private _coneOuterAngle;
  41418. private _coneOuterGain;
  41419. private _scene;
  41420. private _connectedTransformNode;
  41421. private _customAttenuationFunction;
  41422. private _registerFunc;
  41423. private _isOutputConnected;
  41424. private _htmlAudioElement;
  41425. private _urlType;
  41426. private _length?;
  41427. private _offset?;
  41428. /** @hidden */
  41429. static _SceneComponentInitialization: (scene: Scene) => void;
  41430. /**
  41431. * Create a sound and attach it to a scene
  41432. * @param name Name of your sound
  41433. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41434. * @param scene defines the scene the sound belongs to
  41435. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41436. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41437. */
  41438. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41439. /**
  41440. * Release the sound and its associated resources
  41441. */
  41442. dispose(): void;
  41443. /**
  41444. * Gets if the sounds is ready to be played or not.
  41445. * @returns true if ready, otherwise false
  41446. */
  41447. isReady(): boolean;
  41448. private _soundLoaded;
  41449. /**
  41450. * Sets the data of the sound from an audiobuffer
  41451. * @param audioBuffer The audioBuffer containing the data
  41452. */
  41453. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41454. /**
  41455. * Updates the current sounds options such as maxdistance, loop...
  41456. * @param options A JSON object containing values named as the object properties
  41457. */
  41458. updateOptions(options: ISoundOptions): void;
  41459. private _createSpatialParameters;
  41460. private _updateSpatialParameters;
  41461. /**
  41462. * Switch the panning model to HRTF:
  41463. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41465. */
  41466. switchPanningModelToHRTF(): void;
  41467. /**
  41468. * Switch the panning model to Equal Power:
  41469. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41470. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41471. */
  41472. switchPanningModelToEqualPower(): void;
  41473. private _switchPanningModel;
  41474. /**
  41475. * Connect this sound to a sound track audio node like gain...
  41476. * @param soundTrackAudioNode the sound track audio node to connect to
  41477. */
  41478. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41479. /**
  41480. * Transform this sound into a directional source
  41481. * @param coneInnerAngle Size of the inner cone in degree
  41482. * @param coneOuterAngle Size of the outer cone in degree
  41483. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41484. */
  41485. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41486. /**
  41487. * Gets or sets the inner angle for the directional cone.
  41488. */
  41489. get directionalConeInnerAngle(): number;
  41490. /**
  41491. * Gets or sets the inner angle for the directional cone.
  41492. */
  41493. set directionalConeInnerAngle(value: number);
  41494. /**
  41495. * Gets or sets the outer angle for the directional cone.
  41496. */
  41497. get directionalConeOuterAngle(): number;
  41498. /**
  41499. * Gets or sets the outer angle for the directional cone.
  41500. */
  41501. set directionalConeOuterAngle(value: number);
  41502. /**
  41503. * Sets the position of the emitter if spatial sound is enabled
  41504. * @param newPosition Defines the new posisiton
  41505. */
  41506. setPosition(newPosition: Vector3): void;
  41507. /**
  41508. * Sets the local direction of the emitter if spatial sound is enabled
  41509. * @param newLocalDirection Defines the new local direction
  41510. */
  41511. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41512. private _updateDirection;
  41513. /** @hidden */
  41514. updateDistanceFromListener(): void;
  41515. /**
  41516. * Sets a new custom attenuation function for the sound.
  41517. * @param callback Defines the function used for the attenuation
  41518. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41519. */
  41520. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41521. /**
  41522. * Play the sound
  41523. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41524. * @param offset (optional) Start the sound at a specific time in seconds
  41525. * @param length (optional) Sound duration (in seconds)
  41526. */
  41527. play(time?: number, offset?: number, length?: number): void;
  41528. private _onended;
  41529. /**
  41530. * Stop the sound
  41531. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41532. */
  41533. stop(time?: number): void;
  41534. /**
  41535. * Put the sound in pause
  41536. */
  41537. pause(): void;
  41538. /**
  41539. * Sets a dedicated volume for this sounds
  41540. * @param newVolume Define the new volume of the sound
  41541. * @param time Define time for gradual change to new volume
  41542. */
  41543. setVolume(newVolume: number, time?: number): void;
  41544. /**
  41545. * Set the sound play back rate
  41546. * @param newPlaybackRate Define the playback rate the sound should be played at
  41547. */
  41548. setPlaybackRate(newPlaybackRate: number): void;
  41549. /**
  41550. * Gets the volume of the sound.
  41551. * @returns the volume of the sound
  41552. */
  41553. getVolume(): number;
  41554. /**
  41555. * Attach the sound to a dedicated mesh
  41556. * @param transformNode The transform node to connect the sound with
  41557. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41558. */
  41559. attachToMesh(transformNode: TransformNode): void;
  41560. /**
  41561. * Detach the sound from the previously attached mesh
  41562. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41563. */
  41564. detachFromMesh(): void;
  41565. private _onRegisterAfterWorldMatrixUpdate;
  41566. /**
  41567. * Clone the current sound in the scene.
  41568. * @returns the new sound clone
  41569. */
  41570. clone(): Nullable<Sound>;
  41571. /**
  41572. * Gets the current underlying audio buffer containing the data
  41573. * @returns the audio buffer
  41574. */
  41575. getAudioBuffer(): Nullable<AudioBuffer>;
  41576. /**
  41577. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41578. * @returns the source node
  41579. */
  41580. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41581. /**
  41582. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41583. * @returns the gain node
  41584. */
  41585. getSoundGain(): Nullable<GainNode>;
  41586. /**
  41587. * Serializes the Sound in a JSON representation
  41588. * @returns the JSON representation of the sound
  41589. */
  41590. serialize(): any;
  41591. /**
  41592. * Parse a JSON representation of a sound to innstantiate in a given scene
  41593. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41594. * @param scene Define the scene the new parsed sound should be created in
  41595. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41596. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41597. * @returns the newly parsed sound
  41598. */
  41599. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41600. }
  41601. }
  41602. declare module BABYLON {
  41603. /**
  41604. * This defines an action helpful to play a defined sound on a triggered action.
  41605. */
  41606. export class PlaySoundAction extends Action {
  41607. private _sound;
  41608. /**
  41609. * Instantiate the action
  41610. * @param triggerOptions defines the trigger options
  41611. * @param sound defines the sound to play
  41612. * @param condition defines the trigger related conditions
  41613. */
  41614. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41615. /** @hidden */
  41616. _prepare(): void;
  41617. /**
  41618. * Execute the action and play the sound.
  41619. */
  41620. execute(): void;
  41621. /**
  41622. * Serializes the actions and its related information.
  41623. * @param parent defines the object to serialize in
  41624. * @returns the serialized object
  41625. */
  41626. serialize(parent: any): any;
  41627. }
  41628. /**
  41629. * This defines an action helpful to stop a defined sound on a triggered action.
  41630. */
  41631. export class StopSoundAction extends Action {
  41632. private _sound;
  41633. /**
  41634. * Instantiate the action
  41635. * @param triggerOptions defines the trigger options
  41636. * @param sound defines the sound to stop
  41637. * @param condition defines the trigger related conditions
  41638. */
  41639. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41640. /** @hidden */
  41641. _prepare(): void;
  41642. /**
  41643. * Execute the action and stop the sound.
  41644. */
  41645. execute(): void;
  41646. /**
  41647. * Serializes the actions and its related information.
  41648. * @param parent defines the object to serialize in
  41649. * @returns the serialized object
  41650. */
  41651. serialize(parent: any): any;
  41652. }
  41653. }
  41654. declare module BABYLON {
  41655. /**
  41656. * This defines an action responsible to change the value of a property
  41657. * by interpolating between its current value and the newly set one once triggered.
  41658. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41659. */
  41660. export class InterpolateValueAction extends Action {
  41661. /**
  41662. * Defines the path of the property where the value should be interpolated
  41663. */
  41664. propertyPath: string;
  41665. /**
  41666. * Defines the target value at the end of the interpolation.
  41667. */
  41668. value: any;
  41669. /**
  41670. * Defines the time it will take for the property to interpolate to the value.
  41671. */
  41672. duration: number;
  41673. /**
  41674. * Defines if the other scene animations should be stopped when the action has been triggered
  41675. */
  41676. stopOtherAnimations?: boolean;
  41677. /**
  41678. * Defines a callback raised once the interpolation animation has been done.
  41679. */
  41680. onInterpolationDone?: () => void;
  41681. /**
  41682. * Observable triggered once the interpolation animation has been done.
  41683. */
  41684. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41685. private _target;
  41686. private _effectiveTarget;
  41687. private _property;
  41688. /**
  41689. * Instantiate the action
  41690. * @param triggerOptions defines the trigger options
  41691. * @param target defines the object containing the value to interpolate
  41692. * @param propertyPath defines the path to the property in the target object
  41693. * @param value defines the target value at the end of the interpolation
  41694. * @param duration deines the time it will take for the property to interpolate to the value.
  41695. * @param condition defines the trigger related conditions
  41696. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41697. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41698. */
  41699. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41700. /** @hidden */
  41701. _prepare(): void;
  41702. /**
  41703. * Execute the action starts the value interpolation.
  41704. */
  41705. execute(): void;
  41706. /**
  41707. * Serializes the actions and its related information.
  41708. * @param parent defines the object to serialize in
  41709. * @returns the serialized object
  41710. */
  41711. serialize(parent: any): any;
  41712. }
  41713. }
  41714. declare module BABYLON {
  41715. /**
  41716. * Options allowed during the creation of a sound track.
  41717. */
  41718. export interface ISoundTrackOptions {
  41719. /**
  41720. * The volume the sound track should take during creation
  41721. */
  41722. volume?: number;
  41723. /**
  41724. * Define if the sound track is the main sound track of the scene
  41725. */
  41726. mainTrack?: boolean;
  41727. }
  41728. /**
  41729. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41730. * It will be also used in a future release to apply effects on a specific track.
  41731. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41732. */
  41733. export class SoundTrack {
  41734. /**
  41735. * The unique identifier of the sound track in the scene.
  41736. */
  41737. id: number;
  41738. /**
  41739. * The list of sounds included in the sound track.
  41740. */
  41741. soundCollection: Array<Sound>;
  41742. private _outputAudioNode;
  41743. private _scene;
  41744. private _connectedAnalyser;
  41745. private _options;
  41746. private _isInitialized;
  41747. /**
  41748. * Creates a new sound track.
  41749. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41750. * @param scene Define the scene the sound track belongs to
  41751. * @param options
  41752. */
  41753. constructor(scene: Scene, options?: ISoundTrackOptions);
  41754. private _initializeSoundTrackAudioGraph;
  41755. /**
  41756. * Release the sound track and its associated resources
  41757. */
  41758. dispose(): void;
  41759. /**
  41760. * Adds a sound to this sound track
  41761. * @param sound define the cound to add
  41762. * @ignoreNaming
  41763. */
  41764. AddSound(sound: Sound): void;
  41765. /**
  41766. * Removes a sound to this sound track
  41767. * @param sound define the cound to remove
  41768. * @ignoreNaming
  41769. */
  41770. RemoveSound(sound: Sound): void;
  41771. /**
  41772. * Set a global volume for the full sound track.
  41773. * @param newVolume Define the new volume of the sound track
  41774. */
  41775. setVolume(newVolume: number): void;
  41776. /**
  41777. * Switch the panning model to HRTF:
  41778. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41779. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41780. */
  41781. switchPanningModelToHRTF(): void;
  41782. /**
  41783. * Switch the panning model to Equal Power:
  41784. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41785. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41786. */
  41787. switchPanningModelToEqualPower(): void;
  41788. /**
  41789. * Connect the sound track to an audio analyser allowing some amazing
  41790. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41791. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41792. * @param analyser The analyser to connect to the engine
  41793. */
  41794. connectToAnalyser(analyser: Analyser): void;
  41795. }
  41796. }
  41797. declare module BABYLON {
  41798. interface AbstractScene {
  41799. /**
  41800. * The list of sounds used in the scene.
  41801. */
  41802. sounds: Nullable<Array<Sound>>;
  41803. }
  41804. interface Scene {
  41805. /**
  41806. * @hidden
  41807. * Backing field
  41808. */
  41809. _mainSoundTrack: SoundTrack;
  41810. /**
  41811. * The main sound track played by the scene.
  41812. * It cotains your primary collection of sounds.
  41813. */
  41814. mainSoundTrack: SoundTrack;
  41815. /**
  41816. * The list of sound tracks added to the scene
  41817. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41818. */
  41819. soundTracks: Nullable<Array<SoundTrack>>;
  41820. /**
  41821. * Gets a sound using a given name
  41822. * @param name defines the name to search for
  41823. * @return the found sound or null if not found at all.
  41824. */
  41825. getSoundByName(name: string): Nullable<Sound>;
  41826. /**
  41827. * Gets or sets if audio support is enabled
  41828. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41829. */
  41830. audioEnabled: boolean;
  41831. /**
  41832. * Gets or sets if audio will be output to headphones
  41833. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41834. */
  41835. headphone: boolean;
  41836. /**
  41837. * Gets or sets custom audio listener position provider
  41838. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41839. */
  41840. audioListenerPositionProvider: Nullable<() => Vector3>;
  41841. /**
  41842. * Gets or sets a refresh rate when using 3D audio positioning
  41843. */
  41844. audioPositioningRefreshRate: number;
  41845. }
  41846. /**
  41847. * Defines the sound scene component responsible to manage any sounds
  41848. * in a given scene.
  41849. */
  41850. export class AudioSceneComponent implements ISceneSerializableComponent {
  41851. /**
  41852. * The component name helpfull to identify the component in the list of scene components.
  41853. */
  41854. readonly name: string;
  41855. /**
  41856. * The scene the component belongs to.
  41857. */
  41858. scene: Scene;
  41859. private _audioEnabled;
  41860. /**
  41861. * Gets whether audio is enabled or not.
  41862. * Please use related enable/disable method to switch state.
  41863. */
  41864. get audioEnabled(): boolean;
  41865. private _headphone;
  41866. /**
  41867. * Gets whether audio is outputing to headphone or not.
  41868. * Please use the according Switch methods to change output.
  41869. */
  41870. get headphone(): boolean;
  41871. /**
  41872. * Gets or sets a refresh rate when using 3D audio positioning
  41873. */
  41874. audioPositioningRefreshRate: number;
  41875. private _audioListenerPositionProvider;
  41876. /**
  41877. * Gets the current audio listener position provider
  41878. */
  41879. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41880. /**
  41881. * Sets a custom listener position for all sounds in the scene
  41882. * By default, this is the position of the first active camera
  41883. */
  41884. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41885. /**
  41886. * Creates a new instance of the component for the given scene
  41887. * @param scene Defines the scene to register the component in
  41888. */
  41889. constructor(scene: Scene);
  41890. /**
  41891. * Registers the component in a given scene
  41892. */
  41893. register(): void;
  41894. /**
  41895. * Rebuilds the elements related to this component in case of
  41896. * context lost for instance.
  41897. */
  41898. rebuild(): void;
  41899. /**
  41900. * Serializes the component data to the specified json object
  41901. * @param serializationObject The object to serialize to
  41902. */
  41903. serialize(serializationObject: any): void;
  41904. /**
  41905. * Adds all the elements from the container to the scene
  41906. * @param container the container holding the elements
  41907. */
  41908. addFromContainer(container: AbstractScene): void;
  41909. /**
  41910. * Removes all the elements in the container from the scene
  41911. * @param container contains the elements to remove
  41912. * @param dispose if the removed element should be disposed (default: false)
  41913. */
  41914. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41915. /**
  41916. * Disposes the component and the associated ressources.
  41917. */
  41918. dispose(): void;
  41919. /**
  41920. * Disables audio in the associated scene.
  41921. */
  41922. disableAudio(): void;
  41923. /**
  41924. * Enables audio in the associated scene.
  41925. */
  41926. enableAudio(): void;
  41927. /**
  41928. * Switch audio to headphone output.
  41929. */
  41930. switchAudioModeForHeadphones(): void;
  41931. /**
  41932. * Switch audio to normal speakers.
  41933. */
  41934. switchAudioModeForNormalSpeakers(): void;
  41935. private _cachedCameraDirection;
  41936. private _cachedCameraPosition;
  41937. private _lastCheck;
  41938. private _afterRender;
  41939. }
  41940. }
  41941. declare module BABYLON {
  41942. /**
  41943. * Wraps one or more Sound objects and selects one with random weight for playback.
  41944. */
  41945. export class WeightedSound {
  41946. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41947. loop: boolean;
  41948. private _coneInnerAngle;
  41949. private _coneOuterAngle;
  41950. private _volume;
  41951. /** A Sound is currently playing. */
  41952. isPlaying: boolean;
  41953. /** A Sound is currently paused. */
  41954. isPaused: boolean;
  41955. private _sounds;
  41956. private _weights;
  41957. private _currentIndex?;
  41958. /**
  41959. * Creates a new WeightedSound from the list of sounds given.
  41960. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41961. * @param sounds Array of Sounds that will be selected from.
  41962. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41963. */
  41964. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41965. /**
  41966. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41967. */
  41968. get directionalConeInnerAngle(): number;
  41969. /**
  41970. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41971. */
  41972. set directionalConeInnerAngle(value: number);
  41973. /**
  41974. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41975. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41976. */
  41977. get directionalConeOuterAngle(): number;
  41978. /**
  41979. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41980. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41981. */
  41982. set directionalConeOuterAngle(value: number);
  41983. /**
  41984. * Playback volume.
  41985. */
  41986. get volume(): number;
  41987. /**
  41988. * Playback volume.
  41989. */
  41990. set volume(value: number);
  41991. private _onended;
  41992. /**
  41993. * Suspend playback
  41994. */
  41995. pause(): void;
  41996. /**
  41997. * Stop playback
  41998. */
  41999. stop(): void;
  42000. /**
  42001. * Start playback.
  42002. * @param startOffset Position the clip head at a specific time in seconds.
  42003. */
  42004. play(startOffset?: number): void;
  42005. }
  42006. }
  42007. declare module BABYLON {
  42008. /**
  42009. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42010. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42011. */
  42012. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42013. /**
  42014. * Gets the name of the behavior.
  42015. */
  42016. get name(): string;
  42017. /**
  42018. * The easing function used by animations
  42019. */
  42020. static EasingFunction: BackEase;
  42021. /**
  42022. * The easing mode used by animations
  42023. */
  42024. static EasingMode: number;
  42025. /**
  42026. * The duration of the animation, in milliseconds
  42027. */
  42028. transitionDuration: number;
  42029. /**
  42030. * Length of the distance animated by the transition when lower radius is reached
  42031. */
  42032. lowerRadiusTransitionRange: number;
  42033. /**
  42034. * Length of the distance animated by the transition when upper radius is reached
  42035. */
  42036. upperRadiusTransitionRange: number;
  42037. private _autoTransitionRange;
  42038. /**
  42039. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42040. */
  42041. get autoTransitionRange(): boolean;
  42042. /**
  42043. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42044. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42045. */
  42046. set autoTransitionRange(value: boolean);
  42047. private _attachedCamera;
  42048. private _onAfterCheckInputsObserver;
  42049. private _onMeshTargetChangedObserver;
  42050. /**
  42051. * Initializes the behavior.
  42052. */
  42053. init(): void;
  42054. /**
  42055. * Attaches the behavior to its arc rotate camera.
  42056. * @param camera Defines the camera to attach the behavior to
  42057. */
  42058. attach(camera: ArcRotateCamera): void;
  42059. /**
  42060. * Detaches the behavior from its current arc rotate camera.
  42061. */
  42062. detach(): void;
  42063. private _radiusIsAnimating;
  42064. private _radiusBounceTransition;
  42065. private _animatables;
  42066. private _cachedWheelPrecision;
  42067. /**
  42068. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42069. * @param radiusLimit The limit to check against.
  42070. * @return Bool to indicate if at limit.
  42071. */
  42072. private _isRadiusAtLimit;
  42073. /**
  42074. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42075. * @param radiusDelta The delta by which to animate to. Can be negative.
  42076. */
  42077. private _applyBoundRadiusAnimation;
  42078. /**
  42079. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42080. */
  42081. protected _clearAnimationLocks(): void;
  42082. /**
  42083. * Stops and removes all animations that have been applied to the camera
  42084. */
  42085. stopAllAnimations(): void;
  42086. }
  42087. }
  42088. declare module BABYLON {
  42089. /**
  42090. * 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.
  42091. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42092. */
  42093. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42094. /**
  42095. * Gets the name of the behavior.
  42096. */
  42097. get name(): string;
  42098. private _mode;
  42099. private _radiusScale;
  42100. private _positionScale;
  42101. private _defaultElevation;
  42102. private _elevationReturnTime;
  42103. private _elevationReturnWaitTime;
  42104. private _zoomStopsAnimation;
  42105. private _framingTime;
  42106. /**
  42107. * The easing function used by animations
  42108. */
  42109. static EasingFunction: ExponentialEase;
  42110. /**
  42111. * The easing mode used by animations
  42112. */
  42113. static EasingMode: number;
  42114. /**
  42115. * Sets the current mode used by the behavior
  42116. */
  42117. set mode(mode: number);
  42118. /**
  42119. * Gets current mode used by the behavior.
  42120. */
  42121. get mode(): number;
  42122. /**
  42123. * Sets the scale applied to the radius (1 by default)
  42124. */
  42125. set radiusScale(radius: number);
  42126. /**
  42127. * Gets the scale applied to the radius
  42128. */
  42129. get radiusScale(): number;
  42130. /**
  42131. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42132. */
  42133. set positionScale(scale: number);
  42134. /**
  42135. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42136. */
  42137. get positionScale(): number;
  42138. /**
  42139. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42140. * behaviour is triggered, in radians.
  42141. */
  42142. set defaultElevation(elevation: number);
  42143. /**
  42144. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42145. * behaviour is triggered, in radians.
  42146. */
  42147. get defaultElevation(): number;
  42148. /**
  42149. * Sets the time (in milliseconds) taken to return to the default beta position.
  42150. * Negative value indicates camera should not return to default.
  42151. */
  42152. set elevationReturnTime(speed: number);
  42153. /**
  42154. * Gets the time (in milliseconds) taken to return to the default beta position.
  42155. * Negative value indicates camera should not return to default.
  42156. */
  42157. get elevationReturnTime(): number;
  42158. /**
  42159. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42160. */
  42161. set elevationReturnWaitTime(time: number);
  42162. /**
  42163. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42164. */
  42165. get elevationReturnWaitTime(): number;
  42166. /**
  42167. * Sets the flag that indicates if user zooming should stop animation.
  42168. */
  42169. set zoomStopsAnimation(flag: boolean);
  42170. /**
  42171. * Gets the flag that indicates if user zooming should stop animation.
  42172. */
  42173. get zoomStopsAnimation(): boolean;
  42174. /**
  42175. * Sets the transition time when framing the mesh, in milliseconds
  42176. */
  42177. set framingTime(time: number);
  42178. /**
  42179. * Gets the transition time when framing the mesh, in milliseconds
  42180. */
  42181. get framingTime(): number;
  42182. /**
  42183. * Define if the behavior should automatically change the configured
  42184. * camera limits and sensibilities.
  42185. */
  42186. autoCorrectCameraLimitsAndSensibility: boolean;
  42187. private _onPrePointerObservableObserver;
  42188. private _onAfterCheckInputsObserver;
  42189. private _onMeshTargetChangedObserver;
  42190. private _attachedCamera;
  42191. private _isPointerDown;
  42192. private _lastInteractionTime;
  42193. /**
  42194. * Initializes the behavior.
  42195. */
  42196. init(): void;
  42197. /**
  42198. * Attaches the behavior to its arc rotate camera.
  42199. * @param camera Defines the camera to attach the behavior to
  42200. */
  42201. attach(camera: ArcRotateCamera): void;
  42202. /**
  42203. * Detaches the behavior from its current arc rotate camera.
  42204. */
  42205. detach(): void;
  42206. private _animatables;
  42207. private _betaIsAnimating;
  42208. private _betaTransition;
  42209. private _radiusTransition;
  42210. private _vectorTransition;
  42211. /**
  42212. * Targets the given mesh and updates zoom level accordingly.
  42213. * @param mesh The mesh to target.
  42214. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42215. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42216. */
  42217. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42218. /**
  42219. * Targets the given mesh with its children and updates zoom level accordingly.
  42220. * @param mesh The mesh to target.
  42221. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42222. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42223. */
  42224. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42225. /**
  42226. * Targets the given meshes with their children and updates zoom level accordingly.
  42227. * @param meshes The mesh to target.
  42228. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42229. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42230. */
  42231. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42232. /**
  42233. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42234. * @param minimumWorld Determines the smaller position of the bounding box extend
  42235. * @param maximumWorld Determines the bigger position of the bounding box extend
  42236. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42237. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42238. */
  42239. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42240. /**
  42241. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42242. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42243. * frustum width.
  42244. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42245. * to fully enclose the mesh in the viewing frustum.
  42246. */
  42247. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42248. /**
  42249. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42250. * is automatically returned to its default position (expected to be above ground plane).
  42251. */
  42252. private _maintainCameraAboveGround;
  42253. /**
  42254. * Returns the frustum slope based on the canvas ratio and camera FOV
  42255. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42256. */
  42257. private _getFrustumSlope;
  42258. /**
  42259. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42260. */
  42261. private _clearAnimationLocks;
  42262. /**
  42263. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42264. */
  42265. private _applyUserInteraction;
  42266. /**
  42267. * Stops and removes all animations that have been applied to the camera
  42268. */
  42269. stopAllAnimations(): void;
  42270. /**
  42271. * Gets a value indicating if the user is moving the camera
  42272. */
  42273. get isUserIsMoving(): boolean;
  42274. /**
  42275. * The camera can move all the way towards the mesh.
  42276. */
  42277. static IgnoreBoundsSizeMode: number;
  42278. /**
  42279. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42280. */
  42281. static FitFrustumSidesMode: number;
  42282. }
  42283. }
  42284. declare module BABYLON {
  42285. /**
  42286. * Base class for Camera Pointer Inputs.
  42287. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42288. * for example usage.
  42289. */
  42290. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42291. /**
  42292. * Defines the camera the input is attached to.
  42293. */
  42294. abstract camera: Camera;
  42295. /**
  42296. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42297. */
  42298. protected _altKey: boolean;
  42299. protected _ctrlKey: boolean;
  42300. protected _metaKey: boolean;
  42301. protected _shiftKey: boolean;
  42302. /**
  42303. * Which mouse buttons were pressed at time of last mouse event.
  42304. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42305. */
  42306. protected _buttonsPressed: number;
  42307. /**
  42308. * Defines the buttons associated with the input to handle camera move.
  42309. */
  42310. buttons: number[];
  42311. /**
  42312. * Attach the input controls to a specific dom element to get the input from.
  42313. * @param element Defines the element the controls should be listened from
  42314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42315. */
  42316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42317. /**
  42318. * Detach the current controls from the specified dom element.
  42319. * @param element Defines the element to stop listening the inputs from
  42320. */
  42321. detachControl(element: Nullable<HTMLElement>): void;
  42322. /**
  42323. * Gets the class name of the current input.
  42324. * @returns the class name
  42325. */
  42326. getClassName(): string;
  42327. /**
  42328. * Get the friendly name associated with the input class.
  42329. * @returns the input friendly name
  42330. */
  42331. getSimpleName(): string;
  42332. /**
  42333. * Called on pointer POINTERDOUBLETAP event.
  42334. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42335. */
  42336. protected onDoubleTap(type: string): void;
  42337. /**
  42338. * Called on pointer POINTERMOVE event if only a single touch is active.
  42339. * Override this method to provide functionality.
  42340. */
  42341. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42342. /**
  42343. * Called on pointer POINTERMOVE event if multiple touches are active.
  42344. * Override this method to provide functionality.
  42345. */
  42346. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42347. /**
  42348. * Called on JS contextmenu event.
  42349. * Override this method to provide functionality.
  42350. */
  42351. protected onContextMenu(evt: PointerEvent): void;
  42352. /**
  42353. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42354. * press.
  42355. * Override this method to provide functionality.
  42356. */
  42357. protected onButtonDown(evt: PointerEvent): void;
  42358. /**
  42359. * Called each time a new POINTERUP event occurs. Ie, for each button
  42360. * release.
  42361. * Override this method to provide functionality.
  42362. */
  42363. protected onButtonUp(evt: PointerEvent): void;
  42364. /**
  42365. * Called when window becomes inactive.
  42366. * Override this method to provide functionality.
  42367. */
  42368. protected onLostFocus(): void;
  42369. private _pointerInput;
  42370. private _observer;
  42371. private _onLostFocus;
  42372. private pointA;
  42373. private pointB;
  42374. }
  42375. }
  42376. declare module BABYLON {
  42377. /**
  42378. * Manage the pointers inputs to control an arc rotate camera.
  42379. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42380. */
  42381. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42382. /**
  42383. * Defines the camera the input is attached to.
  42384. */
  42385. camera: ArcRotateCamera;
  42386. /**
  42387. * Gets the class name of the current input.
  42388. * @returns the class name
  42389. */
  42390. getClassName(): string;
  42391. /**
  42392. * Defines the buttons associated with the input to handle camera move.
  42393. */
  42394. buttons: number[];
  42395. /**
  42396. * Defines the pointer angular sensibility along the X axis or how fast is
  42397. * the camera rotating.
  42398. */
  42399. angularSensibilityX: number;
  42400. /**
  42401. * Defines the pointer angular sensibility along the Y axis or how fast is
  42402. * the camera rotating.
  42403. */
  42404. angularSensibilityY: number;
  42405. /**
  42406. * Defines the pointer pinch precision or how fast is the camera zooming.
  42407. */
  42408. pinchPrecision: number;
  42409. /**
  42410. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42411. * from 0.
  42412. * It defines the percentage of current camera.radius to use as delta when
  42413. * pinch zoom is used.
  42414. */
  42415. pinchDeltaPercentage: number;
  42416. /**
  42417. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42418. * that any object in the plane at the camera's target point will scale
  42419. * perfectly with finger motion.
  42420. * Overrides pinchDeltaPercentage and pinchPrecision.
  42421. */
  42422. useNaturalPinchZoom: boolean;
  42423. /**
  42424. * Defines the pointer panning sensibility or how fast is the camera moving.
  42425. */
  42426. panningSensibility: number;
  42427. /**
  42428. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42429. */
  42430. multiTouchPanning: boolean;
  42431. /**
  42432. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42433. * zoom (pinch) through multitouch.
  42434. */
  42435. multiTouchPanAndZoom: boolean;
  42436. /**
  42437. * Revers pinch action direction.
  42438. */
  42439. pinchInwards: boolean;
  42440. private _isPanClick;
  42441. private _twoFingerActivityCount;
  42442. private _isPinching;
  42443. /**
  42444. * Called on pointer POINTERMOVE event if only a single touch is active.
  42445. */
  42446. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42447. /**
  42448. * Called on pointer POINTERDOUBLETAP event.
  42449. */
  42450. protected onDoubleTap(type: string): void;
  42451. /**
  42452. * Called on pointer POINTERMOVE event if multiple touches are active.
  42453. */
  42454. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42455. /**
  42456. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42457. * press.
  42458. */
  42459. protected onButtonDown(evt: PointerEvent): void;
  42460. /**
  42461. * Called each time a new POINTERUP event occurs. Ie, for each button
  42462. * release.
  42463. */
  42464. protected onButtonUp(evt: PointerEvent): void;
  42465. /**
  42466. * Called when window becomes inactive.
  42467. */
  42468. protected onLostFocus(): void;
  42469. }
  42470. }
  42471. declare module BABYLON {
  42472. /**
  42473. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42474. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42475. */
  42476. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42477. /**
  42478. * Defines the camera the input is attached to.
  42479. */
  42480. camera: ArcRotateCamera;
  42481. /**
  42482. * Defines the list of key codes associated with the up action (increase alpha)
  42483. */
  42484. keysUp: number[];
  42485. /**
  42486. * Defines the list of key codes associated with the down action (decrease alpha)
  42487. */
  42488. keysDown: number[];
  42489. /**
  42490. * Defines the list of key codes associated with the left action (increase beta)
  42491. */
  42492. keysLeft: number[];
  42493. /**
  42494. * Defines the list of key codes associated with the right action (decrease beta)
  42495. */
  42496. keysRight: number[];
  42497. /**
  42498. * Defines the list of key codes associated with the reset action.
  42499. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42500. */
  42501. keysReset: number[];
  42502. /**
  42503. * Defines the panning sensibility of the inputs.
  42504. * (How fast is the camera panning)
  42505. */
  42506. panningSensibility: number;
  42507. /**
  42508. * Defines the zooming sensibility of the inputs.
  42509. * (How fast is the camera zooming)
  42510. */
  42511. zoomingSensibility: number;
  42512. /**
  42513. * Defines whether maintaining the alt key down switch the movement mode from
  42514. * orientation to zoom.
  42515. */
  42516. useAltToZoom: boolean;
  42517. /**
  42518. * Rotation speed of the camera
  42519. */
  42520. angularSpeed: number;
  42521. private _keys;
  42522. private _ctrlPressed;
  42523. private _altPressed;
  42524. private _onCanvasBlurObserver;
  42525. private _onKeyboardObserver;
  42526. private _engine;
  42527. private _scene;
  42528. /**
  42529. * Attach the input controls to a specific dom element to get the input from.
  42530. * @param element Defines the element the controls should be listened from
  42531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42532. */
  42533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42534. /**
  42535. * Detach the current controls from the specified dom element.
  42536. * @param element Defines the element to stop listening the inputs from
  42537. */
  42538. detachControl(element: Nullable<HTMLElement>): void;
  42539. /**
  42540. * Update the current camera state depending on the inputs that have been used this frame.
  42541. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42542. */
  42543. checkInputs(): void;
  42544. /**
  42545. * Gets the class name of the current intput.
  42546. * @returns the class name
  42547. */
  42548. getClassName(): string;
  42549. /**
  42550. * Get the friendly name associated with the input class.
  42551. * @returns the input friendly name
  42552. */
  42553. getSimpleName(): string;
  42554. }
  42555. }
  42556. declare module BABYLON {
  42557. /**
  42558. * Manage the mouse wheel inputs to control an arc rotate camera.
  42559. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42560. */
  42561. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42562. /**
  42563. * Defines the camera the input is attached to.
  42564. */
  42565. camera: ArcRotateCamera;
  42566. /**
  42567. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42568. */
  42569. wheelPrecision: number;
  42570. /**
  42571. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42572. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42573. */
  42574. wheelDeltaPercentage: number;
  42575. private _wheel;
  42576. private _observer;
  42577. private computeDeltaFromMouseWheelLegacyEvent;
  42578. /**
  42579. * Attach the input controls to a specific dom element to get the input from.
  42580. * @param element Defines the element the controls should be listened from
  42581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42582. */
  42583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42584. /**
  42585. * Detach the current controls from the specified dom element.
  42586. * @param element Defines the element to stop listening the inputs from
  42587. */
  42588. detachControl(element: Nullable<HTMLElement>): void;
  42589. /**
  42590. * Gets the class name of the current intput.
  42591. * @returns the class name
  42592. */
  42593. getClassName(): string;
  42594. /**
  42595. * Get the friendly name associated with the input class.
  42596. * @returns the input friendly name
  42597. */
  42598. getSimpleName(): string;
  42599. }
  42600. }
  42601. declare module BABYLON {
  42602. /**
  42603. * Default Inputs manager for the ArcRotateCamera.
  42604. * It groups all the default supported inputs for ease of use.
  42605. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42606. */
  42607. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42608. /**
  42609. * Instantiates a new ArcRotateCameraInputsManager.
  42610. * @param camera Defines the camera the inputs belong to
  42611. */
  42612. constructor(camera: ArcRotateCamera);
  42613. /**
  42614. * Add mouse wheel input support to the input manager.
  42615. * @returns the current input manager
  42616. */
  42617. addMouseWheel(): ArcRotateCameraInputsManager;
  42618. /**
  42619. * Add pointers input support to the input manager.
  42620. * @returns the current input manager
  42621. */
  42622. addPointers(): ArcRotateCameraInputsManager;
  42623. /**
  42624. * Add keyboard input support to the input manager.
  42625. * @returns the current input manager
  42626. */
  42627. addKeyboard(): ArcRotateCameraInputsManager;
  42628. }
  42629. }
  42630. declare module BABYLON {
  42631. /**
  42632. * This represents an orbital type of camera.
  42633. *
  42634. * 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.
  42635. * 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.
  42636. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42637. */
  42638. export class ArcRotateCamera extends TargetCamera {
  42639. /**
  42640. * Defines the rotation angle of the camera along the longitudinal axis.
  42641. */
  42642. alpha: number;
  42643. /**
  42644. * Defines the rotation angle of the camera along the latitudinal axis.
  42645. */
  42646. beta: number;
  42647. /**
  42648. * Defines the radius of the camera from it s target point.
  42649. */
  42650. radius: number;
  42651. protected _target: Vector3;
  42652. protected _targetHost: Nullable<AbstractMesh>;
  42653. /**
  42654. * Defines the target point of the camera.
  42655. * The camera looks towards it form the radius distance.
  42656. */
  42657. get target(): Vector3;
  42658. set target(value: Vector3);
  42659. /**
  42660. * Define the current local position of the camera in the scene
  42661. */
  42662. get position(): Vector3;
  42663. set position(newPosition: Vector3);
  42664. protected _upVector: Vector3;
  42665. protected _upToYMatrix: Matrix;
  42666. protected _YToUpMatrix: Matrix;
  42667. /**
  42668. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42669. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42670. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42671. */
  42672. set upVector(vec: Vector3);
  42673. get upVector(): Vector3;
  42674. /**
  42675. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42676. */
  42677. setMatUp(): void;
  42678. /**
  42679. * Current inertia value on the longitudinal axis.
  42680. * The bigger this number the longer it will take for the camera to stop.
  42681. */
  42682. inertialAlphaOffset: number;
  42683. /**
  42684. * Current inertia value on the latitudinal axis.
  42685. * The bigger this number the longer it will take for the camera to stop.
  42686. */
  42687. inertialBetaOffset: number;
  42688. /**
  42689. * Current inertia value on the radius axis.
  42690. * The bigger this number the longer it will take for the camera to stop.
  42691. */
  42692. inertialRadiusOffset: number;
  42693. /**
  42694. * Minimum allowed angle on the longitudinal axis.
  42695. * This can help limiting how the Camera is able to move in the scene.
  42696. */
  42697. lowerAlphaLimit: Nullable<number>;
  42698. /**
  42699. * Maximum allowed angle on the longitudinal axis.
  42700. * This can help limiting how the Camera is able to move in the scene.
  42701. */
  42702. upperAlphaLimit: Nullable<number>;
  42703. /**
  42704. * Minimum allowed angle on the latitudinal axis.
  42705. * This can help limiting how the Camera is able to move in the scene.
  42706. */
  42707. lowerBetaLimit: number;
  42708. /**
  42709. * Maximum allowed angle on the latitudinal axis.
  42710. * This can help limiting how the Camera is able to move in the scene.
  42711. */
  42712. upperBetaLimit: number;
  42713. /**
  42714. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42715. * This can help limiting how the Camera is able to move in the scene.
  42716. */
  42717. lowerRadiusLimit: Nullable<number>;
  42718. /**
  42719. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42720. * This can help limiting how the Camera is able to move in the scene.
  42721. */
  42722. upperRadiusLimit: Nullable<number>;
  42723. /**
  42724. * Defines the current inertia value used during panning of the camera along the X axis.
  42725. */
  42726. inertialPanningX: number;
  42727. /**
  42728. * Defines the current inertia value used during panning of the camera along the Y axis.
  42729. */
  42730. inertialPanningY: number;
  42731. /**
  42732. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42733. * Basically if your fingers moves away from more than this distance you will be considered
  42734. * in pinch mode.
  42735. */
  42736. pinchToPanMaxDistance: number;
  42737. /**
  42738. * Defines the maximum distance the camera can pan.
  42739. * This could help keeping the cammera always in your scene.
  42740. */
  42741. panningDistanceLimit: Nullable<number>;
  42742. /**
  42743. * Defines the target of the camera before paning.
  42744. */
  42745. panningOriginTarget: Vector3;
  42746. /**
  42747. * Defines the value of the inertia used during panning.
  42748. * 0 would mean stop inertia and one would mean no decelleration at all.
  42749. */
  42750. panningInertia: number;
  42751. /**
  42752. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42753. */
  42754. get angularSensibilityX(): number;
  42755. set angularSensibilityX(value: number);
  42756. /**
  42757. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42758. */
  42759. get angularSensibilityY(): number;
  42760. set angularSensibilityY(value: number);
  42761. /**
  42762. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42763. */
  42764. get pinchPrecision(): number;
  42765. set pinchPrecision(value: number);
  42766. /**
  42767. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42768. * It will be used instead of pinchDeltaPrecision if different from 0.
  42769. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42770. */
  42771. get pinchDeltaPercentage(): number;
  42772. set pinchDeltaPercentage(value: number);
  42773. /**
  42774. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42775. * and pinch delta percentage.
  42776. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42777. * that any object in the plane at the camera's target point will scale
  42778. * perfectly with finger motion.
  42779. */
  42780. get useNaturalPinchZoom(): boolean;
  42781. set useNaturalPinchZoom(value: boolean);
  42782. /**
  42783. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42784. */
  42785. get panningSensibility(): number;
  42786. set panningSensibility(value: number);
  42787. /**
  42788. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42789. */
  42790. get keysUp(): number[];
  42791. set keysUp(value: number[]);
  42792. /**
  42793. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42794. */
  42795. get keysDown(): number[];
  42796. set keysDown(value: number[]);
  42797. /**
  42798. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42799. */
  42800. get keysLeft(): number[];
  42801. set keysLeft(value: number[]);
  42802. /**
  42803. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42804. */
  42805. get keysRight(): number[];
  42806. set keysRight(value: number[]);
  42807. /**
  42808. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42809. */
  42810. get wheelPrecision(): number;
  42811. set wheelPrecision(value: number);
  42812. /**
  42813. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42814. * It will be used instead of pinchDeltaPrecision if different from 0.
  42815. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42816. */
  42817. get wheelDeltaPercentage(): number;
  42818. set wheelDeltaPercentage(value: number);
  42819. /**
  42820. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42821. */
  42822. zoomOnFactor: number;
  42823. /**
  42824. * Defines a screen offset for the camera position.
  42825. */
  42826. targetScreenOffset: Vector2;
  42827. /**
  42828. * Allows the camera to be completely reversed.
  42829. * If false the camera can not arrive upside down.
  42830. */
  42831. allowUpsideDown: boolean;
  42832. /**
  42833. * Define if double tap/click is used to restore the previously saved state of the camera.
  42834. */
  42835. useInputToRestoreState: boolean;
  42836. /** @hidden */
  42837. _viewMatrix: Matrix;
  42838. /** @hidden */
  42839. _useCtrlForPanning: boolean;
  42840. /** @hidden */
  42841. _panningMouseButton: number;
  42842. /**
  42843. * Defines the input associated to the camera.
  42844. */
  42845. inputs: ArcRotateCameraInputsManager;
  42846. /** @hidden */
  42847. _reset: () => void;
  42848. /**
  42849. * Defines the allowed panning axis.
  42850. */
  42851. panningAxis: Vector3;
  42852. protected _localDirection: Vector3;
  42853. protected _transformedDirection: Vector3;
  42854. private _bouncingBehavior;
  42855. /**
  42856. * Gets the bouncing behavior of the camera if it has been enabled.
  42857. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42858. */
  42859. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42860. /**
  42861. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42862. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42863. */
  42864. get useBouncingBehavior(): boolean;
  42865. set useBouncingBehavior(value: boolean);
  42866. private _framingBehavior;
  42867. /**
  42868. * Gets the framing behavior of the camera if it has been enabled.
  42869. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42870. */
  42871. get framingBehavior(): Nullable<FramingBehavior>;
  42872. /**
  42873. * Defines if the framing behavior of the camera is enabled on the camera.
  42874. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42875. */
  42876. get useFramingBehavior(): boolean;
  42877. set useFramingBehavior(value: boolean);
  42878. private _autoRotationBehavior;
  42879. /**
  42880. * Gets the auto rotation behavior of the camera if it has been enabled.
  42881. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42882. */
  42883. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42884. /**
  42885. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42886. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42887. */
  42888. get useAutoRotationBehavior(): boolean;
  42889. set useAutoRotationBehavior(value: boolean);
  42890. /**
  42891. * Observable triggered when the mesh target has been changed on the camera.
  42892. */
  42893. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42894. /**
  42895. * Event raised when the camera is colliding with a mesh.
  42896. */
  42897. onCollide: (collidedMesh: AbstractMesh) => void;
  42898. /**
  42899. * Defines whether the camera should check collision with the objects oh the scene.
  42900. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42901. */
  42902. checkCollisions: boolean;
  42903. /**
  42904. * Defines the collision radius of the camera.
  42905. * This simulates a sphere around the camera.
  42906. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42907. */
  42908. collisionRadius: Vector3;
  42909. protected _collider: Collider;
  42910. protected _previousPosition: Vector3;
  42911. protected _collisionVelocity: Vector3;
  42912. protected _newPosition: Vector3;
  42913. protected _previousAlpha: number;
  42914. protected _previousBeta: number;
  42915. protected _previousRadius: number;
  42916. protected _collisionTriggered: boolean;
  42917. protected _targetBoundingCenter: Nullable<Vector3>;
  42918. private _computationVector;
  42919. /**
  42920. * Instantiates a new ArcRotateCamera in a given scene
  42921. * @param name Defines the name of the camera
  42922. * @param alpha Defines the camera rotation along the logitudinal axis
  42923. * @param beta Defines the camera rotation along the latitudinal axis
  42924. * @param radius Defines the camera distance from its target
  42925. * @param target Defines the camera target
  42926. * @param scene Defines the scene the camera belongs to
  42927. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42928. */
  42929. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42930. /** @hidden */
  42931. _initCache(): void;
  42932. /** @hidden */
  42933. _updateCache(ignoreParentClass?: boolean): void;
  42934. protected _getTargetPosition(): Vector3;
  42935. private _storedAlpha;
  42936. private _storedBeta;
  42937. private _storedRadius;
  42938. private _storedTarget;
  42939. private _storedTargetScreenOffset;
  42940. /**
  42941. * Stores the current state of the camera (alpha, beta, radius and target)
  42942. * @returns the camera itself
  42943. */
  42944. storeState(): Camera;
  42945. /**
  42946. * @hidden
  42947. * Restored camera state. You must call storeState() first
  42948. */
  42949. _restoreStateValues(): boolean;
  42950. /** @hidden */
  42951. _isSynchronizedViewMatrix(): boolean;
  42952. /**
  42953. * Attached controls to the current camera.
  42954. * @param element Defines the element the controls should be listened from
  42955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42956. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42957. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42958. */
  42959. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42960. /**
  42961. * Detach the current controls from the camera.
  42962. * The camera will stop reacting to inputs.
  42963. * @param element Defines the element to stop listening the inputs from
  42964. */
  42965. detachControl(element: HTMLElement): void;
  42966. /** @hidden */
  42967. _checkInputs(): void;
  42968. protected _checkLimits(): void;
  42969. /**
  42970. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42971. */
  42972. rebuildAnglesAndRadius(): void;
  42973. /**
  42974. * Use a position to define the current camera related information like alpha, beta and radius
  42975. * @param position Defines the position to set the camera at
  42976. */
  42977. setPosition(position: Vector3): void;
  42978. /**
  42979. * Defines the target the camera should look at.
  42980. * This will automatically adapt alpha beta and radius to fit within the new target.
  42981. * @param target Defines the new target as a Vector or a mesh
  42982. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42983. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42984. */
  42985. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42986. /** @hidden */
  42987. _getViewMatrix(): Matrix;
  42988. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42989. /**
  42990. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42991. * @param meshes Defines the mesh to zoom on
  42992. * @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)
  42993. */
  42994. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42995. /**
  42996. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42997. * The target will be changed but the radius
  42998. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42999. * @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)
  43000. */
  43001. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43002. min: Vector3;
  43003. max: Vector3;
  43004. distance: number;
  43005. }, doNotUpdateMaxZ?: boolean): void;
  43006. /**
  43007. * @override
  43008. * Override Camera.createRigCamera
  43009. */
  43010. createRigCamera(name: string, cameraIndex: number): Camera;
  43011. /**
  43012. * @hidden
  43013. * @override
  43014. * Override Camera._updateRigCameras
  43015. */
  43016. _updateRigCameras(): void;
  43017. /**
  43018. * Destroy the camera and release the current resources hold by it.
  43019. */
  43020. dispose(): void;
  43021. /**
  43022. * Gets the current object class name.
  43023. * @return the class name
  43024. */
  43025. getClassName(): string;
  43026. }
  43027. }
  43028. declare module BABYLON {
  43029. /**
  43030. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43031. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43032. */
  43033. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43034. /**
  43035. * Gets the name of the behavior.
  43036. */
  43037. get name(): string;
  43038. private _zoomStopsAnimation;
  43039. private _idleRotationSpeed;
  43040. private _idleRotationWaitTime;
  43041. private _idleRotationSpinupTime;
  43042. /**
  43043. * Sets the flag that indicates if user zooming should stop animation.
  43044. */
  43045. set zoomStopsAnimation(flag: boolean);
  43046. /**
  43047. * Gets the flag that indicates if user zooming should stop animation.
  43048. */
  43049. get zoomStopsAnimation(): boolean;
  43050. /**
  43051. * Sets the default speed at which the camera rotates around the model.
  43052. */
  43053. set idleRotationSpeed(speed: number);
  43054. /**
  43055. * Gets the default speed at which the camera rotates around the model.
  43056. */
  43057. get idleRotationSpeed(): number;
  43058. /**
  43059. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43060. */
  43061. set idleRotationWaitTime(time: number);
  43062. /**
  43063. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43064. */
  43065. get idleRotationWaitTime(): number;
  43066. /**
  43067. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43068. */
  43069. set idleRotationSpinupTime(time: number);
  43070. /**
  43071. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43072. */
  43073. get idleRotationSpinupTime(): number;
  43074. /**
  43075. * Gets a value indicating if the camera is currently rotating because of this behavior
  43076. */
  43077. get rotationInProgress(): boolean;
  43078. private _onPrePointerObservableObserver;
  43079. private _onAfterCheckInputsObserver;
  43080. private _attachedCamera;
  43081. private _isPointerDown;
  43082. private _lastFrameTime;
  43083. private _lastInteractionTime;
  43084. private _cameraRotationSpeed;
  43085. /**
  43086. * Initializes the behavior.
  43087. */
  43088. init(): void;
  43089. /**
  43090. * Attaches the behavior to its arc rotate camera.
  43091. * @param camera Defines the camera to attach the behavior to
  43092. */
  43093. attach(camera: ArcRotateCamera): void;
  43094. /**
  43095. * Detaches the behavior from its current arc rotate camera.
  43096. */
  43097. detach(): void;
  43098. /**
  43099. * Returns true if user is scrolling.
  43100. * @return true if user is scrolling.
  43101. */
  43102. private _userIsZooming;
  43103. private _lastFrameRadius;
  43104. private _shouldAnimationStopForInteraction;
  43105. /**
  43106. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43107. */
  43108. private _applyUserInteraction;
  43109. private _userIsMoving;
  43110. }
  43111. }
  43112. declare module BABYLON {
  43113. /**
  43114. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43115. */
  43116. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43117. private ui;
  43118. /**
  43119. * The name of the behavior
  43120. */
  43121. name: string;
  43122. /**
  43123. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43124. */
  43125. distanceAwayFromFace: number;
  43126. /**
  43127. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43128. */
  43129. distanceAwayFromBottomOfFace: number;
  43130. private _faceVectors;
  43131. private _target;
  43132. private _scene;
  43133. private _onRenderObserver;
  43134. private _tmpMatrix;
  43135. private _tmpVector;
  43136. /**
  43137. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43138. * @param ui The transform node that should be attched to the mesh
  43139. */
  43140. constructor(ui: TransformNode);
  43141. /**
  43142. * Initializes the behavior
  43143. */
  43144. init(): void;
  43145. private _closestFace;
  43146. private _zeroVector;
  43147. private _lookAtTmpMatrix;
  43148. private _lookAtToRef;
  43149. /**
  43150. * Attaches the AttachToBoxBehavior to the passed in mesh
  43151. * @param target The mesh that the specified node will be attached to
  43152. */
  43153. attach(target: Mesh): void;
  43154. /**
  43155. * Detaches the behavior from the mesh
  43156. */
  43157. detach(): void;
  43158. }
  43159. }
  43160. declare module BABYLON {
  43161. /**
  43162. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43163. */
  43164. export class FadeInOutBehavior implements Behavior<Mesh> {
  43165. /**
  43166. * Time in milliseconds to delay before fading in (Default: 0)
  43167. */
  43168. delay: number;
  43169. /**
  43170. * Time in milliseconds for the mesh to fade in (Default: 300)
  43171. */
  43172. fadeInTime: number;
  43173. private _millisecondsPerFrame;
  43174. private _hovered;
  43175. private _hoverValue;
  43176. private _ownerNode;
  43177. /**
  43178. * Instatiates the FadeInOutBehavior
  43179. */
  43180. constructor();
  43181. /**
  43182. * The name of the behavior
  43183. */
  43184. get name(): string;
  43185. /**
  43186. * Initializes the behavior
  43187. */
  43188. init(): void;
  43189. /**
  43190. * Attaches the fade behavior on the passed in mesh
  43191. * @param ownerNode The mesh that will be faded in/out once attached
  43192. */
  43193. attach(ownerNode: Mesh): void;
  43194. /**
  43195. * Detaches the behavior from the mesh
  43196. */
  43197. detach(): void;
  43198. /**
  43199. * Triggers the mesh to begin fading in or out
  43200. * @param value if the object should fade in or out (true to fade in)
  43201. */
  43202. fadeIn(value: boolean): void;
  43203. private _update;
  43204. private _setAllVisibility;
  43205. }
  43206. }
  43207. declare module BABYLON {
  43208. /**
  43209. * Class containing a set of static utilities functions for managing Pivots
  43210. * @hidden
  43211. */
  43212. export class PivotTools {
  43213. private static _PivotCached;
  43214. private static _OldPivotPoint;
  43215. private static _PivotTranslation;
  43216. private static _PivotTmpVector;
  43217. /** @hidden */
  43218. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43219. /** @hidden */
  43220. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43221. }
  43222. }
  43223. declare module BABYLON {
  43224. /**
  43225. * Class containing static functions to help procedurally build meshes
  43226. */
  43227. export class PlaneBuilder {
  43228. /**
  43229. * Creates a plane mesh
  43230. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43231. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43232. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43234. * * 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
  43235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43236. * @param name defines the name of the mesh
  43237. * @param options defines the options used to create the mesh
  43238. * @param scene defines the hosting scene
  43239. * @returns the plane mesh
  43240. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43241. */
  43242. static CreatePlane(name: string, options: {
  43243. size?: number;
  43244. width?: number;
  43245. height?: number;
  43246. sideOrientation?: number;
  43247. frontUVs?: Vector4;
  43248. backUVs?: Vector4;
  43249. updatable?: boolean;
  43250. sourcePlane?: Plane;
  43251. }, scene?: Nullable<Scene>): Mesh;
  43252. }
  43253. }
  43254. declare module BABYLON {
  43255. /**
  43256. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43257. */
  43258. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43259. private static _AnyMouseID;
  43260. /**
  43261. * Abstract mesh the behavior is set on
  43262. */
  43263. attachedNode: AbstractMesh;
  43264. private _dragPlane;
  43265. private _scene;
  43266. private _pointerObserver;
  43267. private _beforeRenderObserver;
  43268. private static _planeScene;
  43269. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43270. /**
  43271. * 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)
  43272. */
  43273. maxDragAngle: number;
  43274. /**
  43275. * @hidden
  43276. */
  43277. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43278. /**
  43279. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43280. */
  43281. currentDraggingPointerID: number;
  43282. /**
  43283. * The last position where the pointer hit the drag plane in world space
  43284. */
  43285. lastDragPosition: Vector3;
  43286. /**
  43287. * If the behavior is currently in a dragging state
  43288. */
  43289. dragging: boolean;
  43290. /**
  43291. * 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)
  43292. */
  43293. dragDeltaRatio: number;
  43294. /**
  43295. * If the drag plane orientation should be updated during the dragging (Default: true)
  43296. */
  43297. updateDragPlane: boolean;
  43298. private _debugMode;
  43299. private _moving;
  43300. /**
  43301. * Fires each time the attached mesh is dragged with the pointer
  43302. * * delta between last drag position and current drag position in world space
  43303. * * dragDistance along the drag axis
  43304. * * dragPlaneNormal normal of the current drag plane used during the drag
  43305. * * dragPlanePoint in world space where the drag intersects the drag plane
  43306. */
  43307. onDragObservable: Observable<{
  43308. delta: Vector3;
  43309. dragPlanePoint: Vector3;
  43310. dragPlaneNormal: Vector3;
  43311. dragDistance: number;
  43312. pointerId: number;
  43313. }>;
  43314. /**
  43315. * Fires each time a drag begins (eg. mouse down on mesh)
  43316. */
  43317. onDragStartObservable: Observable<{
  43318. dragPlanePoint: Vector3;
  43319. pointerId: number;
  43320. }>;
  43321. /**
  43322. * Fires each time a drag ends (eg. mouse release after drag)
  43323. */
  43324. onDragEndObservable: Observable<{
  43325. dragPlanePoint: Vector3;
  43326. pointerId: number;
  43327. }>;
  43328. /**
  43329. * If the attached mesh should be moved when dragged
  43330. */
  43331. moveAttached: boolean;
  43332. /**
  43333. * If the drag behavior will react to drag events (Default: true)
  43334. */
  43335. enabled: boolean;
  43336. /**
  43337. * If pointer events should start and release the drag (Default: true)
  43338. */
  43339. startAndReleaseDragOnPointerEvents: boolean;
  43340. /**
  43341. * If camera controls should be detached during the drag
  43342. */
  43343. detachCameraControls: boolean;
  43344. /**
  43345. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43346. */
  43347. useObjectOrientationForDragging: boolean;
  43348. private _options;
  43349. /**
  43350. * Gets the options used by the behavior
  43351. */
  43352. get options(): {
  43353. dragAxis?: Vector3;
  43354. dragPlaneNormal?: Vector3;
  43355. };
  43356. /**
  43357. * Sets the options used by the behavior
  43358. */
  43359. set options(options: {
  43360. dragAxis?: Vector3;
  43361. dragPlaneNormal?: Vector3;
  43362. });
  43363. /**
  43364. * Creates a pointer drag behavior that can be attached to a mesh
  43365. * @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)
  43366. */
  43367. constructor(options?: {
  43368. dragAxis?: Vector3;
  43369. dragPlaneNormal?: Vector3;
  43370. });
  43371. /**
  43372. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43373. */
  43374. validateDrag: (targetPosition: Vector3) => boolean;
  43375. /**
  43376. * The name of the behavior
  43377. */
  43378. get name(): string;
  43379. /**
  43380. * Initializes the behavior
  43381. */
  43382. init(): void;
  43383. private _tmpVector;
  43384. private _alternatePickedPoint;
  43385. private _worldDragAxis;
  43386. private _targetPosition;
  43387. private _attachedElement;
  43388. /**
  43389. * Attaches the drag behavior the passed in mesh
  43390. * @param ownerNode The mesh that will be dragged around once attached
  43391. * @param predicate Predicate to use for pick filtering
  43392. */
  43393. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43394. /**
  43395. * Force relase the drag action by code.
  43396. */
  43397. releaseDrag(): void;
  43398. private _startDragRay;
  43399. private _lastPointerRay;
  43400. /**
  43401. * Simulates the start of a pointer drag event on the behavior
  43402. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43403. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43404. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43405. */
  43406. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43407. private _startDrag;
  43408. private _dragDelta;
  43409. private _moveDrag;
  43410. private _pickWithRayOnDragPlane;
  43411. private _pointA;
  43412. private _pointC;
  43413. private _localAxis;
  43414. private _lookAt;
  43415. private _updateDragPlanePosition;
  43416. /**
  43417. * Detaches the behavior from the mesh
  43418. */
  43419. detach(): void;
  43420. }
  43421. }
  43422. declare module BABYLON {
  43423. /**
  43424. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43425. */
  43426. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43427. private _dragBehaviorA;
  43428. private _dragBehaviorB;
  43429. private _startDistance;
  43430. private _initialScale;
  43431. private _targetScale;
  43432. private _ownerNode;
  43433. private _sceneRenderObserver;
  43434. /**
  43435. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43436. */
  43437. constructor();
  43438. /**
  43439. * The name of the behavior
  43440. */
  43441. get name(): string;
  43442. /**
  43443. * Initializes the behavior
  43444. */
  43445. init(): void;
  43446. private _getCurrentDistance;
  43447. /**
  43448. * Attaches the scale behavior the passed in mesh
  43449. * @param ownerNode The mesh that will be scaled around once attached
  43450. */
  43451. attach(ownerNode: Mesh): void;
  43452. /**
  43453. * Detaches the behavior from the mesh
  43454. */
  43455. detach(): void;
  43456. }
  43457. }
  43458. declare module BABYLON {
  43459. /**
  43460. * 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
  43461. */
  43462. export class SixDofDragBehavior implements Behavior<Mesh> {
  43463. private static _virtualScene;
  43464. private _ownerNode;
  43465. private _sceneRenderObserver;
  43466. private _scene;
  43467. private _targetPosition;
  43468. private _virtualOriginMesh;
  43469. private _virtualDragMesh;
  43470. private _pointerObserver;
  43471. private _moving;
  43472. private _startingOrientation;
  43473. private _attachedElement;
  43474. /**
  43475. * 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)
  43476. */
  43477. private zDragFactor;
  43478. /**
  43479. * If the object should rotate to face the drag origin
  43480. */
  43481. rotateDraggedObject: boolean;
  43482. /**
  43483. * If the behavior is currently in a dragging state
  43484. */
  43485. dragging: boolean;
  43486. /**
  43487. * 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)
  43488. */
  43489. dragDeltaRatio: number;
  43490. /**
  43491. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43492. */
  43493. currentDraggingPointerID: number;
  43494. /**
  43495. * If camera controls should be detached during the drag
  43496. */
  43497. detachCameraControls: boolean;
  43498. /**
  43499. * Fires each time a drag starts
  43500. */
  43501. onDragStartObservable: Observable<{}>;
  43502. /**
  43503. * Fires each time a drag ends (eg. mouse release after drag)
  43504. */
  43505. onDragEndObservable: Observable<{}>;
  43506. /**
  43507. * 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
  43508. */
  43509. constructor();
  43510. /**
  43511. * The name of the behavior
  43512. */
  43513. get name(): string;
  43514. /**
  43515. * Initializes the behavior
  43516. */
  43517. init(): void;
  43518. /**
  43519. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43520. */
  43521. private get _pointerCamera();
  43522. /**
  43523. * Attaches the scale behavior the passed in mesh
  43524. * @param ownerNode The mesh that will be scaled around once attached
  43525. */
  43526. attach(ownerNode: Mesh): void;
  43527. /**
  43528. * Detaches the behavior from the mesh
  43529. */
  43530. detach(): void;
  43531. }
  43532. }
  43533. declare module BABYLON {
  43534. /**
  43535. * Class used to apply inverse kinematics to bones
  43536. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43537. */
  43538. export class BoneIKController {
  43539. private static _tmpVecs;
  43540. private static _tmpQuat;
  43541. private static _tmpMats;
  43542. /**
  43543. * Gets or sets the target mesh
  43544. */
  43545. targetMesh: AbstractMesh;
  43546. /** Gets or sets the mesh used as pole */
  43547. poleTargetMesh: AbstractMesh;
  43548. /**
  43549. * Gets or sets the bone used as pole
  43550. */
  43551. poleTargetBone: Nullable<Bone>;
  43552. /**
  43553. * Gets or sets the target position
  43554. */
  43555. targetPosition: Vector3;
  43556. /**
  43557. * Gets or sets the pole target position
  43558. */
  43559. poleTargetPosition: Vector3;
  43560. /**
  43561. * Gets or sets the pole target local offset
  43562. */
  43563. poleTargetLocalOffset: Vector3;
  43564. /**
  43565. * Gets or sets the pole angle
  43566. */
  43567. poleAngle: number;
  43568. /**
  43569. * Gets or sets the mesh associated with the controller
  43570. */
  43571. mesh: AbstractMesh;
  43572. /**
  43573. * 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)
  43574. */
  43575. slerpAmount: number;
  43576. private _bone1Quat;
  43577. private _bone1Mat;
  43578. private _bone2Ang;
  43579. private _bone1;
  43580. private _bone2;
  43581. private _bone1Length;
  43582. private _bone2Length;
  43583. private _maxAngle;
  43584. private _maxReach;
  43585. private _rightHandedSystem;
  43586. private _bendAxis;
  43587. private _slerping;
  43588. private _adjustRoll;
  43589. /**
  43590. * Gets or sets maximum allowed angle
  43591. */
  43592. get maxAngle(): number;
  43593. set maxAngle(value: number);
  43594. /**
  43595. * Creates a new BoneIKController
  43596. * @param mesh defines the mesh to control
  43597. * @param bone defines the bone to control
  43598. * @param options defines options to set up the controller
  43599. */
  43600. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43601. targetMesh?: AbstractMesh;
  43602. poleTargetMesh?: AbstractMesh;
  43603. poleTargetBone?: Bone;
  43604. poleTargetLocalOffset?: Vector3;
  43605. poleAngle?: number;
  43606. bendAxis?: Vector3;
  43607. maxAngle?: number;
  43608. slerpAmount?: number;
  43609. });
  43610. private _setMaxAngle;
  43611. /**
  43612. * Force the controller to update the bones
  43613. */
  43614. update(): void;
  43615. }
  43616. }
  43617. declare module BABYLON {
  43618. /**
  43619. * Class used to make a bone look toward a point in space
  43620. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43621. */
  43622. export class BoneLookController {
  43623. private static _tmpVecs;
  43624. private static _tmpQuat;
  43625. private static _tmpMats;
  43626. /**
  43627. * The target Vector3 that the bone will look at
  43628. */
  43629. target: Vector3;
  43630. /**
  43631. * The mesh that the bone is attached to
  43632. */
  43633. mesh: AbstractMesh;
  43634. /**
  43635. * The bone that will be looking to the target
  43636. */
  43637. bone: Bone;
  43638. /**
  43639. * The up axis of the coordinate system that is used when the bone is rotated
  43640. */
  43641. upAxis: Vector3;
  43642. /**
  43643. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43644. */
  43645. upAxisSpace: Space;
  43646. /**
  43647. * Used to make an adjustment to the yaw of the bone
  43648. */
  43649. adjustYaw: number;
  43650. /**
  43651. * Used to make an adjustment to the pitch of the bone
  43652. */
  43653. adjustPitch: number;
  43654. /**
  43655. * Used to make an adjustment to the roll of the bone
  43656. */
  43657. adjustRoll: number;
  43658. /**
  43659. * 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)
  43660. */
  43661. slerpAmount: number;
  43662. private _minYaw;
  43663. private _maxYaw;
  43664. private _minPitch;
  43665. private _maxPitch;
  43666. private _minYawSin;
  43667. private _minYawCos;
  43668. private _maxYawSin;
  43669. private _maxYawCos;
  43670. private _midYawConstraint;
  43671. private _minPitchTan;
  43672. private _maxPitchTan;
  43673. private _boneQuat;
  43674. private _slerping;
  43675. private _transformYawPitch;
  43676. private _transformYawPitchInv;
  43677. private _firstFrameSkipped;
  43678. private _yawRange;
  43679. private _fowardAxis;
  43680. /**
  43681. * Gets or sets the minimum yaw angle that the bone can look to
  43682. */
  43683. get minYaw(): number;
  43684. set minYaw(value: number);
  43685. /**
  43686. * Gets or sets the maximum yaw angle that the bone can look to
  43687. */
  43688. get maxYaw(): number;
  43689. set maxYaw(value: number);
  43690. /**
  43691. * Gets or sets the minimum pitch angle that the bone can look to
  43692. */
  43693. get minPitch(): number;
  43694. set minPitch(value: number);
  43695. /**
  43696. * Gets or sets the maximum pitch angle that the bone can look to
  43697. */
  43698. get maxPitch(): number;
  43699. set maxPitch(value: number);
  43700. /**
  43701. * Create a BoneLookController
  43702. * @param mesh the mesh that the bone belongs to
  43703. * @param bone the bone that will be looking to the target
  43704. * @param target the target Vector3 to look at
  43705. * @param options optional settings:
  43706. * * maxYaw: the maximum angle the bone will yaw to
  43707. * * minYaw: the minimum angle the bone will yaw to
  43708. * * maxPitch: the maximum angle the bone will pitch to
  43709. * * minPitch: the minimum angle the bone will yaw to
  43710. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43711. * * upAxis: the up axis of the coordinate system
  43712. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43713. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43714. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43715. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43716. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43717. * * adjustRoll: used to make an adjustment to the roll of the bone
  43718. **/
  43719. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43720. maxYaw?: number;
  43721. minYaw?: number;
  43722. maxPitch?: number;
  43723. minPitch?: number;
  43724. slerpAmount?: number;
  43725. upAxis?: Vector3;
  43726. upAxisSpace?: Space;
  43727. yawAxis?: Vector3;
  43728. pitchAxis?: Vector3;
  43729. adjustYaw?: number;
  43730. adjustPitch?: number;
  43731. adjustRoll?: number;
  43732. });
  43733. /**
  43734. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43735. */
  43736. update(): void;
  43737. private _getAngleDiff;
  43738. private _getAngleBetween;
  43739. private _isAngleBetween;
  43740. }
  43741. }
  43742. declare module BABYLON {
  43743. /**
  43744. * Manage the gamepad inputs to control an arc rotate camera.
  43745. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43746. */
  43747. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43748. /**
  43749. * Defines the camera the input is attached to.
  43750. */
  43751. camera: ArcRotateCamera;
  43752. /**
  43753. * Defines the gamepad the input is gathering event from.
  43754. */
  43755. gamepad: Nullable<Gamepad>;
  43756. /**
  43757. * Defines the gamepad rotation sensiblity.
  43758. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43759. */
  43760. gamepadRotationSensibility: number;
  43761. /**
  43762. * Defines the gamepad move sensiblity.
  43763. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43764. */
  43765. gamepadMoveSensibility: number;
  43766. private _yAxisScale;
  43767. /**
  43768. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43769. */
  43770. get invertYAxis(): boolean;
  43771. set invertYAxis(value: boolean);
  43772. private _onGamepadConnectedObserver;
  43773. private _onGamepadDisconnectedObserver;
  43774. /**
  43775. * Attach the input controls to a specific dom element to get the input from.
  43776. * @param element Defines the element the controls should be listened from
  43777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43778. */
  43779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43780. /**
  43781. * Detach the current controls from the specified dom element.
  43782. * @param element Defines the element to stop listening the inputs from
  43783. */
  43784. detachControl(element: Nullable<HTMLElement>): void;
  43785. /**
  43786. * Update the current camera state depending on the inputs that have been used this frame.
  43787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43788. */
  43789. checkInputs(): void;
  43790. /**
  43791. * Gets the class name of the current intput.
  43792. * @returns the class name
  43793. */
  43794. getClassName(): string;
  43795. /**
  43796. * Get the friendly name associated with the input class.
  43797. * @returns the input friendly name
  43798. */
  43799. getSimpleName(): string;
  43800. }
  43801. }
  43802. declare module BABYLON {
  43803. interface ArcRotateCameraInputsManager {
  43804. /**
  43805. * Add orientation input support to the input manager.
  43806. * @returns the current input manager
  43807. */
  43808. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43809. }
  43810. /**
  43811. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43812. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43813. */
  43814. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43815. /**
  43816. * Defines the camera the input is attached to.
  43817. */
  43818. camera: ArcRotateCamera;
  43819. /**
  43820. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43821. */
  43822. alphaCorrection: number;
  43823. /**
  43824. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43825. */
  43826. gammaCorrection: number;
  43827. private _alpha;
  43828. private _gamma;
  43829. private _dirty;
  43830. private _deviceOrientationHandler;
  43831. /**
  43832. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43833. */
  43834. constructor();
  43835. /**
  43836. * Attach the input controls to a specific dom element to get the input from.
  43837. * @param element Defines the element the controls should be listened from
  43838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43839. */
  43840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43841. /** @hidden */
  43842. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43843. /**
  43844. * Update the current camera state depending on the inputs that have been used this frame.
  43845. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43846. */
  43847. checkInputs(): void;
  43848. /**
  43849. * Detach the current controls from the specified dom element.
  43850. * @param element Defines the element to stop listening the inputs from
  43851. */
  43852. detachControl(element: Nullable<HTMLElement>): void;
  43853. /**
  43854. * Gets the class name of the current intput.
  43855. * @returns the class name
  43856. */
  43857. getClassName(): string;
  43858. /**
  43859. * Get the friendly name associated with the input class.
  43860. * @returns the input friendly name
  43861. */
  43862. getSimpleName(): string;
  43863. }
  43864. }
  43865. declare module BABYLON {
  43866. /**
  43867. * Listen to mouse events to control the camera.
  43868. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43869. */
  43870. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43871. /**
  43872. * Defines the camera the input is attached to.
  43873. */
  43874. camera: FlyCamera;
  43875. /**
  43876. * Defines if touch is enabled. (Default is true.)
  43877. */
  43878. touchEnabled: boolean;
  43879. /**
  43880. * Defines the buttons associated with the input to handle camera rotation.
  43881. */
  43882. buttons: number[];
  43883. /**
  43884. * Assign buttons for Yaw control.
  43885. */
  43886. buttonsYaw: number[];
  43887. /**
  43888. * Assign buttons for Pitch control.
  43889. */
  43890. buttonsPitch: number[];
  43891. /**
  43892. * Assign buttons for Roll control.
  43893. */
  43894. buttonsRoll: number[];
  43895. /**
  43896. * Detect if any button is being pressed while mouse is moved.
  43897. * -1 = Mouse locked.
  43898. * 0 = Left button.
  43899. * 1 = Middle Button.
  43900. * 2 = Right Button.
  43901. */
  43902. activeButton: number;
  43903. /**
  43904. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43905. * Higher values reduce its sensitivity.
  43906. */
  43907. angularSensibility: number;
  43908. private _mousemoveCallback;
  43909. private _observer;
  43910. private _rollObserver;
  43911. private previousPosition;
  43912. private noPreventDefault;
  43913. private element;
  43914. /**
  43915. * Listen to mouse events to control the camera.
  43916. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43917. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43918. */
  43919. constructor(touchEnabled?: boolean);
  43920. /**
  43921. * Attach the mouse control to the HTML DOM element.
  43922. * @param element Defines the element that listens to the input events.
  43923. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43924. */
  43925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43926. /**
  43927. * Detach the current controls from the specified dom element.
  43928. * @param element Defines the element to stop listening the inputs from
  43929. */
  43930. detachControl(element: Nullable<HTMLElement>): void;
  43931. /**
  43932. * Gets the class name of the current input.
  43933. * @returns the class name.
  43934. */
  43935. getClassName(): string;
  43936. /**
  43937. * Get the friendly name associated with the input class.
  43938. * @returns the input's friendly name.
  43939. */
  43940. getSimpleName(): string;
  43941. private _pointerInput;
  43942. private _onMouseMove;
  43943. /**
  43944. * Rotate camera by mouse offset.
  43945. */
  43946. private rotateCamera;
  43947. }
  43948. }
  43949. declare module BABYLON {
  43950. /**
  43951. * Default Inputs manager for the FlyCamera.
  43952. * It groups all the default supported inputs for ease of use.
  43953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43954. */
  43955. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43956. /**
  43957. * Instantiates a new FlyCameraInputsManager.
  43958. * @param camera Defines the camera the inputs belong to.
  43959. */
  43960. constructor(camera: FlyCamera);
  43961. /**
  43962. * Add keyboard input support to the input manager.
  43963. * @returns the new FlyCameraKeyboardMoveInput().
  43964. */
  43965. addKeyboard(): FlyCameraInputsManager;
  43966. /**
  43967. * Add mouse input support to the input manager.
  43968. * @param touchEnabled Enable touch screen support.
  43969. * @returns the new FlyCameraMouseInput().
  43970. */
  43971. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43972. }
  43973. }
  43974. declare module BABYLON {
  43975. /**
  43976. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43977. * such as in a 3D Space Shooter or a Flight Simulator.
  43978. */
  43979. export class FlyCamera extends TargetCamera {
  43980. /**
  43981. * Define the collision ellipsoid of the camera.
  43982. * This is helpful for simulating a camera body, like a player's body.
  43983. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43984. */
  43985. ellipsoid: Vector3;
  43986. /**
  43987. * Define an offset for the position of the ellipsoid around the camera.
  43988. * This can be helpful if the camera is attached away from the player's body center,
  43989. * such as at its head.
  43990. */
  43991. ellipsoidOffset: Vector3;
  43992. /**
  43993. * Enable or disable collisions of the camera with the rest of the scene objects.
  43994. */
  43995. checkCollisions: boolean;
  43996. /**
  43997. * Enable or disable gravity on the camera.
  43998. */
  43999. applyGravity: boolean;
  44000. /**
  44001. * Define the current direction the camera is moving to.
  44002. */
  44003. cameraDirection: Vector3;
  44004. /**
  44005. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44006. * This overrides and empties cameraRotation.
  44007. */
  44008. rotationQuaternion: Quaternion;
  44009. /**
  44010. * Track Roll to maintain the wanted Rolling when looking around.
  44011. */
  44012. _trackRoll: number;
  44013. /**
  44014. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44015. */
  44016. rollCorrect: number;
  44017. /**
  44018. * Mimic a banked turn, Rolling the camera when Yawing.
  44019. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44020. */
  44021. bankedTurn: boolean;
  44022. /**
  44023. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44024. */
  44025. bankedTurnLimit: number;
  44026. /**
  44027. * Value of 0 disables the banked Roll.
  44028. * Value of 1 is equal to the Yaw angle in radians.
  44029. */
  44030. bankedTurnMultiplier: number;
  44031. /**
  44032. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44033. */
  44034. inputs: FlyCameraInputsManager;
  44035. /**
  44036. * Gets the input sensibility for mouse input.
  44037. * Higher values reduce sensitivity.
  44038. */
  44039. get angularSensibility(): number;
  44040. /**
  44041. * Sets the input sensibility for a mouse input.
  44042. * Higher values reduce sensitivity.
  44043. */
  44044. set angularSensibility(value: number);
  44045. /**
  44046. * Get the keys for camera movement forward.
  44047. */
  44048. get keysForward(): number[];
  44049. /**
  44050. * Set the keys for camera movement forward.
  44051. */
  44052. set keysForward(value: number[]);
  44053. /**
  44054. * Get the keys for camera movement backward.
  44055. */
  44056. get keysBackward(): number[];
  44057. set keysBackward(value: number[]);
  44058. /**
  44059. * Get the keys for camera movement up.
  44060. */
  44061. get keysUp(): number[];
  44062. /**
  44063. * Set the keys for camera movement up.
  44064. */
  44065. set keysUp(value: number[]);
  44066. /**
  44067. * Get the keys for camera movement down.
  44068. */
  44069. get keysDown(): number[];
  44070. /**
  44071. * Set the keys for camera movement down.
  44072. */
  44073. set keysDown(value: number[]);
  44074. /**
  44075. * Get the keys for camera movement left.
  44076. */
  44077. get keysLeft(): number[];
  44078. /**
  44079. * Set the keys for camera movement left.
  44080. */
  44081. set keysLeft(value: number[]);
  44082. /**
  44083. * Set the keys for camera movement right.
  44084. */
  44085. get keysRight(): number[];
  44086. /**
  44087. * Set the keys for camera movement right.
  44088. */
  44089. set keysRight(value: number[]);
  44090. /**
  44091. * Event raised when the camera collides with a mesh in the scene.
  44092. */
  44093. onCollide: (collidedMesh: AbstractMesh) => void;
  44094. private _collider;
  44095. private _needMoveForGravity;
  44096. private _oldPosition;
  44097. private _diffPosition;
  44098. private _newPosition;
  44099. /** @hidden */
  44100. _localDirection: Vector3;
  44101. /** @hidden */
  44102. _transformedDirection: Vector3;
  44103. /**
  44104. * Instantiates a FlyCamera.
  44105. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44106. * such as in a 3D Space Shooter or a Flight Simulator.
  44107. * @param name Define the name of the camera in the scene.
  44108. * @param position Define the starting position of the camera in the scene.
  44109. * @param scene Define the scene the camera belongs to.
  44110. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44111. */
  44112. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44113. /**
  44114. * Attach a control to the HTML DOM element.
  44115. * @param element Defines the element that listens to the input events.
  44116. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44117. */
  44118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44119. /**
  44120. * Detach a control from the HTML DOM element.
  44121. * The camera will stop reacting to that input.
  44122. * @param element Defines the element that listens to the input events.
  44123. */
  44124. detachControl(element: HTMLElement): void;
  44125. private _collisionMask;
  44126. /**
  44127. * Get the mask that the camera ignores in collision events.
  44128. */
  44129. get collisionMask(): number;
  44130. /**
  44131. * Set the mask that the camera ignores in collision events.
  44132. */
  44133. set collisionMask(mask: number);
  44134. /** @hidden */
  44135. _collideWithWorld(displacement: Vector3): void;
  44136. /** @hidden */
  44137. private _onCollisionPositionChange;
  44138. /** @hidden */
  44139. _checkInputs(): void;
  44140. /** @hidden */
  44141. _decideIfNeedsToMove(): boolean;
  44142. /** @hidden */
  44143. _updatePosition(): void;
  44144. /**
  44145. * Restore the Roll to its target value at the rate specified.
  44146. * @param rate - Higher means slower restoring.
  44147. * @hidden
  44148. */
  44149. restoreRoll(rate: number): void;
  44150. /**
  44151. * Destroy the camera and release the current resources held by it.
  44152. */
  44153. dispose(): void;
  44154. /**
  44155. * Get the current object class name.
  44156. * @returns the class name.
  44157. */
  44158. getClassName(): string;
  44159. }
  44160. }
  44161. declare module BABYLON {
  44162. /**
  44163. * Listen to keyboard events to control the camera.
  44164. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44165. */
  44166. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44167. /**
  44168. * Defines the camera the input is attached to.
  44169. */
  44170. camera: FlyCamera;
  44171. /**
  44172. * The list of keyboard keys used to control the forward move of the camera.
  44173. */
  44174. keysForward: number[];
  44175. /**
  44176. * The list of keyboard keys used to control the backward move of the camera.
  44177. */
  44178. keysBackward: number[];
  44179. /**
  44180. * The list of keyboard keys used to control the forward move of the camera.
  44181. */
  44182. keysUp: number[];
  44183. /**
  44184. * The list of keyboard keys used to control the backward move of the camera.
  44185. */
  44186. keysDown: number[];
  44187. /**
  44188. * The list of keyboard keys used to control the right strafe move of the camera.
  44189. */
  44190. keysRight: number[];
  44191. /**
  44192. * The list of keyboard keys used to control the left strafe move of the camera.
  44193. */
  44194. keysLeft: number[];
  44195. private _keys;
  44196. private _onCanvasBlurObserver;
  44197. private _onKeyboardObserver;
  44198. private _engine;
  44199. private _scene;
  44200. /**
  44201. * Attach the input controls to a specific dom element to get the input from.
  44202. * @param element Defines the element the controls should be listened from
  44203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44204. */
  44205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44206. /**
  44207. * Detach the current controls from the specified dom element.
  44208. * @param element Defines the element to stop listening the inputs from
  44209. */
  44210. detachControl(element: Nullable<HTMLElement>): void;
  44211. /**
  44212. * Gets the class name of the current intput.
  44213. * @returns the class name
  44214. */
  44215. getClassName(): string;
  44216. /** @hidden */
  44217. _onLostFocus(e: FocusEvent): void;
  44218. /**
  44219. * Get the friendly name associated with the input class.
  44220. * @returns the input friendly name
  44221. */
  44222. getSimpleName(): string;
  44223. /**
  44224. * Update the current camera state depending on the inputs that have been used this frame.
  44225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44226. */
  44227. checkInputs(): void;
  44228. }
  44229. }
  44230. declare module BABYLON {
  44231. /**
  44232. * Manage the mouse wheel inputs to control a follow camera.
  44233. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44234. */
  44235. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44236. /**
  44237. * Defines the camera the input is attached to.
  44238. */
  44239. camera: FollowCamera;
  44240. /**
  44241. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44242. */
  44243. axisControlRadius: boolean;
  44244. /**
  44245. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44246. */
  44247. axisControlHeight: boolean;
  44248. /**
  44249. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44250. */
  44251. axisControlRotation: boolean;
  44252. /**
  44253. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44254. * relation to mouseWheel events.
  44255. */
  44256. wheelPrecision: number;
  44257. /**
  44258. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44259. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44260. */
  44261. wheelDeltaPercentage: number;
  44262. private _wheel;
  44263. private _observer;
  44264. /**
  44265. * Attach the input controls to a specific dom element to get the input from.
  44266. * @param element Defines the element the controls should be listened from
  44267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44268. */
  44269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44270. /**
  44271. * Detach the current controls from the specified dom element.
  44272. * @param element Defines the element to stop listening the inputs from
  44273. */
  44274. detachControl(element: Nullable<HTMLElement>): void;
  44275. /**
  44276. * Gets the class name of the current intput.
  44277. * @returns the class name
  44278. */
  44279. getClassName(): string;
  44280. /**
  44281. * Get the friendly name associated with the input class.
  44282. * @returns the input friendly name
  44283. */
  44284. getSimpleName(): string;
  44285. }
  44286. }
  44287. declare module BABYLON {
  44288. /**
  44289. * Manage the pointers inputs to control an follow camera.
  44290. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44291. */
  44292. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44293. /**
  44294. * Defines the camera the input is attached to.
  44295. */
  44296. camera: FollowCamera;
  44297. /**
  44298. * Gets the class name of the current input.
  44299. * @returns the class name
  44300. */
  44301. getClassName(): string;
  44302. /**
  44303. * Defines the pointer angular sensibility along the X axis or how fast is
  44304. * the camera rotating.
  44305. * A negative number will reverse the axis direction.
  44306. */
  44307. angularSensibilityX: number;
  44308. /**
  44309. * Defines the pointer angular sensibility along the Y axis or how fast is
  44310. * the camera rotating.
  44311. * A negative number will reverse the axis direction.
  44312. */
  44313. angularSensibilityY: number;
  44314. /**
  44315. * Defines the pointer pinch precision or how fast is the camera zooming.
  44316. * A negative number will reverse the axis direction.
  44317. */
  44318. pinchPrecision: number;
  44319. /**
  44320. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44321. * from 0.
  44322. * It defines the percentage of current camera.radius to use as delta when
  44323. * pinch zoom is used.
  44324. */
  44325. pinchDeltaPercentage: number;
  44326. /**
  44327. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44328. */
  44329. axisXControlRadius: boolean;
  44330. /**
  44331. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44332. */
  44333. axisXControlHeight: boolean;
  44334. /**
  44335. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44336. */
  44337. axisXControlRotation: boolean;
  44338. /**
  44339. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44340. */
  44341. axisYControlRadius: boolean;
  44342. /**
  44343. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44344. */
  44345. axisYControlHeight: boolean;
  44346. /**
  44347. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44348. */
  44349. axisYControlRotation: boolean;
  44350. /**
  44351. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44352. */
  44353. axisPinchControlRadius: boolean;
  44354. /**
  44355. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44356. */
  44357. axisPinchControlHeight: boolean;
  44358. /**
  44359. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44360. */
  44361. axisPinchControlRotation: boolean;
  44362. /**
  44363. * Log error messages if basic misconfiguration has occurred.
  44364. */
  44365. warningEnable: boolean;
  44366. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44367. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44368. private _warningCounter;
  44369. private _warning;
  44370. }
  44371. }
  44372. declare module BABYLON {
  44373. /**
  44374. * Default Inputs manager for the FollowCamera.
  44375. * It groups all the default supported inputs for ease of use.
  44376. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44377. */
  44378. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44379. /**
  44380. * Instantiates a new FollowCameraInputsManager.
  44381. * @param camera Defines the camera the inputs belong to
  44382. */
  44383. constructor(camera: FollowCamera);
  44384. /**
  44385. * Add keyboard input support to the input manager.
  44386. * @returns the current input manager
  44387. */
  44388. addKeyboard(): FollowCameraInputsManager;
  44389. /**
  44390. * Add mouse wheel input support to the input manager.
  44391. * @returns the current input manager
  44392. */
  44393. addMouseWheel(): FollowCameraInputsManager;
  44394. /**
  44395. * Add pointers input support to the input manager.
  44396. * @returns the current input manager
  44397. */
  44398. addPointers(): FollowCameraInputsManager;
  44399. /**
  44400. * Add orientation input support to the input manager.
  44401. * @returns the current input manager
  44402. */
  44403. addVRDeviceOrientation(): FollowCameraInputsManager;
  44404. }
  44405. }
  44406. declare module BABYLON {
  44407. /**
  44408. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44409. * an arc rotate version arcFollowCamera are available.
  44410. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44411. */
  44412. export class FollowCamera extends TargetCamera {
  44413. /**
  44414. * Distance the follow camera should follow an object at
  44415. */
  44416. radius: number;
  44417. /**
  44418. * Minimum allowed distance of the camera to the axis of rotation
  44419. * (The camera can not get closer).
  44420. * This can help limiting how the Camera is able to move in the scene.
  44421. */
  44422. lowerRadiusLimit: Nullable<number>;
  44423. /**
  44424. * Maximum allowed distance of the camera to the axis of rotation
  44425. * (The camera can not get further).
  44426. * This can help limiting how the Camera is able to move in the scene.
  44427. */
  44428. upperRadiusLimit: Nullable<number>;
  44429. /**
  44430. * Define a rotation offset between the camera and the object it follows
  44431. */
  44432. rotationOffset: number;
  44433. /**
  44434. * Minimum allowed angle to camera position relative to target object.
  44435. * This can help limiting how the Camera is able to move in the scene.
  44436. */
  44437. lowerRotationOffsetLimit: Nullable<number>;
  44438. /**
  44439. * Maximum allowed angle to camera position relative to target object.
  44440. * This can help limiting how the Camera is able to move in the scene.
  44441. */
  44442. upperRotationOffsetLimit: Nullable<number>;
  44443. /**
  44444. * Define a height offset between the camera and the object it follows.
  44445. * It can help following an object from the top (like a car chaing a plane)
  44446. */
  44447. heightOffset: number;
  44448. /**
  44449. * Minimum allowed height of camera position relative to target object.
  44450. * This can help limiting how the Camera is able to move in the scene.
  44451. */
  44452. lowerHeightOffsetLimit: Nullable<number>;
  44453. /**
  44454. * Maximum allowed height of camera position relative to target object.
  44455. * This can help limiting how the Camera is able to move in the scene.
  44456. */
  44457. upperHeightOffsetLimit: Nullable<number>;
  44458. /**
  44459. * Define how fast the camera can accelerate to follow it s target.
  44460. */
  44461. cameraAcceleration: number;
  44462. /**
  44463. * Define the speed limit of the camera following an object.
  44464. */
  44465. maxCameraSpeed: number;
  44466. /**
  44467. * Define the target of the camera.
  44468. */
  44469. lockedTarget: Nullable<AbstractMesh>;
  44470. /**
  44471. * Defines the input associated with the camera.
  44472. */
  44473. inputs: FollowCameraInputsManager;
  44474. /**
  44475. * Instantiates the follow camera.
  44476. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44477. * @param name Define the name of the camera in the scene
  44478. * @param position Define the position of the camera
  44479. * @param scene Define the scene the camera belong to
  44480. * @param lockedTarget Define the target of the camera
  44481. */
  44482. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44483. private _follow;
  44484. /**
  44485. * Attached controls to the current camera.
  44486. * @param element Defines the element the controls should be listened from
  44487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44488. */
  44489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44490. /**
  44491. * Detach the current controls from the camera.
  44492. * The camera will stop reacting to inputs.
  44493. * @param element Defines the element to stop listening the inputs from
  44494. */
  44495. detachControl(element: HTMLElement): void;
  44496. /** @hidden */
  44497. _checkInputs(): void;
  44498. private _checkLimits;
  44499. /**
  44500. * Gets the camera class name.
  44501. * @returns the class name
  44502. */
  44503. getClassName(): string;
  44504. }
  44505. /**
  44506. * Arc Rotate version of the follow camera.
  44507. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44508. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44509. */
  44510. export class ArcFollowCamera extends TargetCamera {
  44511. /** The longitudinal angle of the camera */
  44512. alpha: number;
  44513. /** The latitudinal angle of the camera */
  44514. beta: number;
  44515. /** The radius of the camera from its target */
  44516. radius: number;
  44517. /** Define the camera target (the mesh it should follow) */
  44518. target: Nullable<AbstractMesh>;
  44519. private _cartesianCoordinates;
  44520. /**
  44521. * Instantiates a new ArcFollowCamera
  44522. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44523. * @param name Define the name of the camera
  44524. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44525. * @param beta Define the rotation angle of the camera around the elevation axis
  44526. * @param radius Define the radius of the camera from its target point
  44527. * @param target Define the target of the camera
  44528. * @param scene Define the scene the camera belongs to
  44529. */
  44530. constructor(name: string,
  44531. /** The longitudinal angle of the camera */
  44532. alpha: number,
  44533. /** The latitudinal angle of the camera */
  44534. beta: number,
  44535. /** The radius of the camera from its target */
  44536. radius: number,
  44537. /** Define the camera target (the mesh it should follow) */
  44538. target: Nullable<AbstractMesh>, scene: Scene);
  44539. private _follow;
  44540. /** @hidden */
  44541. _checkInputs(): void;
  44542. /**
  44543. * Returns the class name of the object.
  44544. * It is mostly used internally for serialization purposes.
  44545. */
  44546. getClassName(): string;
  44547. }
  44548. }
  44549. declare module BABYLON {
  44550. /**
  44551. * Manage the keyboard inputs to control the movement of a follow camera.
  44552. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44553. */
  44554. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44555. /**
  44556. * Defines the camera the input is attached to.
  44557. */
  44558. camera: FollowCamera;
  44559. /**
  44560. * Defines the list of key codes associated with the up action (increase heightOffset)
  44561. */
  44562. keysHeightOffsetIncr: number[];
  44563. /**
  44564. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44565. */
  44566. keysHeightOffsetDecr: number[];
  44567. /**
  44568. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44569. */
  44570. keysHeightOffsetModifierAlt: boolean;
  44571. /**
  44572. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44573. */
  44574. keysHeightOffsetModifierCtrl: boolean;
  44575. /**
  44576. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44577. */
  44578. keysHeightOffsetModifierShift: boolean;
  44579. /**
  44580. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44581. */
  44582. keysRotationOffsetIncr: number[];
  44583. /**
  44584. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44585. */
  44586. keysRotationOffsetDecr: number[];
  44587. /**
  44588. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44589. */
  44590. keysRotationOffsetModifierAlt: boolean;
  44591. /**
  44592. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44593. */
  44594. keysRotationOffsetModifierCtrl: boolean;
  44595. /**
  44596. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44597. */
  44598. keysRotationOffsetModifierShift: boolean;
  44599. /**
  44600. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44601. */
  44602. keysRadiusIncr: number[];
  44603. /**
  44604. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44605. */
  44606. keysRadiusDecr: number[];
  44607. /**
  44608. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44609. */
  44610. keysRadiusModifierAlt: boolean;
  44611. /**
  44612. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44613. */
  44614. keysRadiusModifierCtrl: boolean;
  44615. /**
  44616. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44617. */
  44618. keysRadiusModifierShift: boolean;
  44619. /**
  44620. * Defines the rate of change of heightOffset.
  44621. */
  44622. heightSensibility: number;
  44623. /**
  44624. * Defines the rate of change of rotationOffset.
  44625. */
  44626. rotationSensibility: number;
  44627. /**
  44628. * Defines the rate of change of radius.
  44629. */
  44630. radiusSensibility: number;
  44631. private _keys;
  44632. private _ctrlPressed;
  44633. private _altPressed;
  44634. private _shiftPressed;
  44635. private _onCanvasBlurObserver;
  44636. private _onKeyboardObserver;
  44637. private _engine;
  44638. private _scene;
  44639. /**
  44640. * Attach the input controls to a specific dom element to get the input from.
  44641. * @param element Defines the element the controls should be listened from
  44642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44643. */
  44644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44645. /**
  44646. * Detach the current controls from the specified dom element.
  44647. * @param element Defines the element to stop listening the inputs from
  44648. */
  44649. detachControl(element: Nullable<HTMLElement>): void;
  44650. /**
  44651. * Update the current camera state depending on the inputs that have been used this frame.
  44652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44653. */
  44654. checkInputs(): void;
  44655. /**
  44656. * Gets the class name of the current input.
  44657. * @returns the class name
  44658. */
  44659. getClassName(): string;
  44660. /**
  44661. * Get the friendly name associated with the input class.
  44662. * @returns the input friendly name
  44663. */
  44664. getSimpleName(): string;
  44665. /**
  44666. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44667. * allow modification of the heightOffset value.
  44668. */
  44669. private _modifierHeightOffset;
  44670. /**
  44671. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44672. * allow modification of the rotationOffset value.
  44673. */
  44674. private _modifierRotationOffset;
  44675. /**
  44676. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44677. * allow modification of the radius value.
  44678. */
  44679. private _modifierRadius;
  44680. }
  44681. }
  44682. declare module BABYLON {
  44683. interface FreeCameraInputsManager {
  44684. /**
  44685. * @hidden
  44686. */
  44687. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44688. /**
  44689. * Add orientation input support to the input manager.
  44690. * @returns the current input manager
  44691. */
  44692. addDeviceOrientation(): FreeCameraInputsManager;
  44693. }
  44694. /**
  44695. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44696. * Screen rotation is taken into account.
  44697. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44698. */
  44699. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44700. private _camera;
  44701. private _screenOrientationAngle;
  44702. private _constantTranform;
  44703. private _screenQuaternion;
  44704. private _alpha;
  44705. private _beta;
  44706. private _gamma;
  44707. /**
  44708. * Can be used to detect if a device orientation sensor is available on a device
  44709. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44710. * @returns a promise that will resolve on orientation change
  44711. */
  44712. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44713. /**
  44714. * @hidden
  44715. */
  44716. _onDeviceOrientationChangedObservable: Observable<void>;
  44717. /**
  44718. * Instantiates a new input
  44719. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44720. */
  44721. constructor();
  44722. /**
  44723. * Define the camera controlled by the input.
  44724. */
  44725. get camera(): FreeCamera;
  44726. set camera(camera: FreeCamera);
  44727. /**
  44728. * Attach the input controls to a specific dom element to get the input from.
  44729. * @param element Defines the element the controls should be listened from
  44730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44731. */
  44732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44733. private _orientationChanged;
  44734. private _deviceOrientation;
  44735. /**
  44736. * Detach the current controls from the specified dom element.
  44737. * @param element Defines the element to stop listening the inputs from
  44738. */
  44739. detachControl(element: Nullable<HTMLElement>): void;
  44740. /**
  44741. * Update the current camera state depending on the inputs that have been used this frame.
  44742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44743. */
  44744. checkInputs(): void;
  44745. /**
  44746. * Gets the class name of the current intput.
  44747. * @returns the class name
  44748. */
  44749. getClassName(): string;
  44750. /**
  44751. * Get the friendly name associated with the input class.
  44752. * @returns the input friendly name
  44753. */
  44754. getSimpleName(): string;
  44755. }
  44756. }
  44757. declare module BABYLON {
  44758. /**
  44759. * Manage the gamepad inputs to control a free camera.
  44760. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44761. */
  44762. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44763. /**
  44764. * Define the camera the input is attached to.
  44765. */
  44766. camera: FreeCamera;
  44767. /**
  44768. * Define the Gamepad controlling the input
  44769. */
  44770. gamepad: Nullable<Gamepad>;
  44771. /**
  44772. * Defines the gamepad rotation sensiblity.
  44773. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44774. */
  44775. gamepadAngularSensibility: number;
  44776. /**
  44777. * Defines the gamepad move sensiblity.
  44778. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44779. */
  44780. gamepadMoveSensibility: number;
  44781. private _yAxisScale;
  44782. /**
  44783. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44784. */
  44785. get invertYAxis(): boolean;
  44786. set invertYAxis(value: boolean);
  44787. private _onGamepadConnectedObserver;
  44788. private _onGamepadDisconnectedObserver;
  44789. private _cameraTransform;
  44790. private _deltaTransform;
  44791. private _vector3;
  44792. private _vector2;
  44793. /**
  44794. * Attach the input controls to a specific dom element to get the input from.
  44795. * @param element Defines the element the controls should be listened from
  44796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44797. */
  44798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44799. /**
  44800. * Detach the current controls from the specified dom element.
  44801. * @param element Defines the element to stop listening the inputs from
  44802. */
  44803. detachControl(element: Nullable<HTMLElement>): void;
  44804. /**
  44805. * Update the current camera state depending on the inputs that have been used this frame.
  44806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44807. */
  44808. checkInputs(): void;
  44809. /**
  44810. * Gets the class name of the current intput.
  44811. * @returns the class name
  44812. */
  44813. getClassName(): string;
  44814. /**
  44815. * Get the friendly name associated with the input class.
  44816. * @returns the input friendly name
  44817. */
  44818. getSimpleName(): string;
  44819. }
  44820. }
  44821. declare module BABYLON {
  44822. /**
  44823. * Defines the potential axis of a Joystick
  44824. */
  44825. export enum JoystickAxis {
  44826. /** X axis */
  44827. X = 0,
  44828. /** Y axis */
  44829. Y = 1,
  44830. /** Z axis */
  44831. Z = 2
  44832. }
  44833. /**
  44834. * Represents the different customization options available
  44835. * for VirtualJoystick
  44836. */
  44837. interface VirtualJoystickCustomizations {
  44838. /**
  44839. * Size of the joystick's puck
  44840. */
  44841. puckSize: number;
  44842. /**
  44843. * Size of the joystick's container
  44844. */
  44845. containerSize: number;
  44846. /**
  44847. * Color of the joystick && puck
  44848. */
  44849. color: string;
  44850. /**
  44851. * Image URL for the joystick's puck
  44852. */
  44853. puckImage?: string;
  44854. /**
  44855. * Image URL for the joystick's container
  44856. */
  44857. containerImage?: string;
  44858. /**
  44859. * Defines the unmoving position of the joystick container
  44860. */
  44861. position?: {
  44862. x: number;
  44863. y: number;
  44864. };
  44865. /**
  44866. * Defines whether or not the joystick container is always visible
  44867. */
  44868. alwaysVisible: boolean;
  44869. /**
  44870. * Defines whether or not to limit the movement of the puck to the joystick's container
  44871. */
  44872. limitToContainer: boolean;
  44873. }
  44874. /**
  44875. * Class used to define virtual joystick (used in touch mode)
  44876. */
  44877. export class VirtualJoystick {
  44878. /**
  44879. * Gets or sets a boolean indicating that left and right values must be inverted
  44880. */
  44881. reverseLeftRight: boolean;
  44882. /**
  44883. * Gets or sets a boolean indicating that up and down values must be inverted
  44884. */
  44885. reverseUpDown: boolean;
  44886. /**
  44887. * Gets the offset value for the position (ie. the change of the position value)
  44888. */
  44889. deltaPosition: Vector3;
  44890. /**
  44891. * Gets a boolean indicating if the virtual joystick was pressed
  44892. */
  44893. pressed: boolean;
  44894. /**
  44895. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44896. */
  44897. static Canvas: Nullable<HTMLCanvasElement>;
  44898. /**
  44899. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44900. */
  44901. limitToContainer: boolean;
  44902. private static _globalJoystickIndex;
  44903. private static _alwaysVisibleSticks;
  44904. private static vjCanvasContext;
  44905. private static vjCanvasWidth;
  44906. private static vjCanvasHeight;
  44907. private static halfWidth;
  44908. private static _GetDefaultOptions;
  44909. private _action;
  44910. private _axisTargetedByLeftAndRight;
  44911. private _axisTargetedByUpAndDown;
  44912. private _joystickSensibility;
  44913. private _inversedSensibility;
  44914. private _joystickPointerID;
  44915. private _joystickColor;
  44916. private _joystickPointerPos;
  44917. private _joystickPreviousPointerPos;
  44918. private _joystickPointerStartPos;
  44919. private _deltaJoystickVector;
  44920. private _leftJoystick;
  44921. private _touches;
  44922. private _joystickPosition;
  44923. private _alwaysVisible;
  44924. private _puckImage;
  44925. private _containerImage;
  44926. private _joystickPuckSize;
  44927. private _joystickContainerSize;
  44928. private _clearPuckSize;
  44929. private _clearContainerSize;
  44930. private _clearPuckSizeOffset;
  44931. private _clearContainerSizeOffset;
  44932. private _onPointerDownHandlerRef;
  44933. private _onPointerMoveHandlerRef;
  44934. private _onPointerUpHandlerRef;
  44935. private _onResize;
  44936. /**
  44937. * Creates a new virtual joystick
  44938. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44939. * @param customizations Defines the options we want to customize the VirtualJoystick
  44940. */
  44941. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44942. /**
  44943. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44944. * @param newJoystickSensibility defines the new sensibility
  44945. */
  44946. setJoystickSensibility(newJoystickSensibility: number): void;
  44947. private _onPointerDown;
  44948. private _onPointerMove;
  44949. private _onPointerUp;
  44950. /**
  44951. * Change the color of the virtual joystick
  44952. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44953. */
  44954. setJoystickColor(newColor: string): void;
  44955. /**
  44956. * Size of the joystick's container
  44957. */
  44958. set containerSize(newSize: number);
  44959. get containerSize(): number;
  44960. /**
  44961. * Size of the joystick's puck
  44962. */
  44963. set puckSize(newSize: number);
  44964. get puckSize(): number;
  44965. /**
  44966. * Clears the set position of the joystick
  44967. */
  44968. clearPosition(): void;
  44969. /**
  44970. * Defines whether or not the joystick container is always visible
  44971. */
  44972. set alwaysVisible(value: boolean);
  44973. get alwaysVisible(): boolean;
  44974. /**
  44975. * Sets the constant position of the Joystick container
  44976. * @param x X axis coordinate
  44977. * @param y Y axis coordinate
  44978. */
  44979. setPosition(x: number, y: number): void;
  44980. /**
  44981. * Defines a callback to call when the joystick is touched
  44982. * @param action defines the callback
  44983. */
  44984. setActionOnTouch(action: () => any): void;
  44985. /**
  44986. * Defines which axis you'd like to control for left & right
  44987. * @param axis defines the axis to use
  44988. */
  44989. setAxisForLeftRight(axis: JoystickAxis): void;
  44990. /**
  44991. * Defines which axis you'd like to control for up & down
  44992. * @param axis defines the axis to use
  44993. */
  44994. setAxisForUpDown(axis: JoystickAxis): void;
  44995. /**
  44996. * Clears the canvas from the previous puck / container draw
  44997. */
  44998. private _clearPreviousDraw;
  44999. /**
  45000. * Loads `urlPath` to be used for the container's image
  45001. * @param urlPath defines the urlPath of an image to use
  45002. */
  45003. setContainerImage(urlPath: string): void;
  45004. /**
  45005. * Loads `urlPath` to be used for the puck's image
  45006. * @param urlPath defines the urlPath of an image to use
  45007. */
  45008. setPuckImage(urlPath: string): void;
  45009. /**
  45010. * Draws the Virtual Joystick's container
  45011. */
  45012. private _drawContainer;
  45013. /**
  45014. * Draws the Virtual Joystick's puck
  45015. */
  45016. private _drawPuck;
  45017. private _drawVirtualJoystick;
  45018. /**
  45019. * Release internal HTML canvas
  45020. */
  45021. releaseCanvas(): void;
  45022. }
  45023. }
  45024. declare module BABYLON {
  45025. interface FreeCameraInputsManager {
  45026. /**
  45027. * Add virtual joystick input support to the input manager.
  45028. * @returns the current input manager
  45029. */
  45030. addVirtualJoystick(): FreeCameraInputsManager;
  45031. }
  45032. /**
  45033. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45034. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45035. */
  45036. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45037. /**
  45038. * Defines the camera the input is attached to.
  45039. */
  45040. camera: FreeCamera;
  45041. private _leftjoystick;
  45042. private _rightjoystick;
  45043. /**
  45044. * Gets the left stick of the virtual joystick.
  45045. * @returns The virtual Joystick
  45046. */
  45047. getLeftJoystick(): VirtualJoystick;
  45048. /**
  45049. * Gets the right stick of the virtual joystick.
  45050. * @returns The virtual Joystick
  45051. */
  45052. getRightJoystick(): VirtualJoystick;
  45053. /**
  45054. * Update the current camera state depending on the inputs that have been used this frame.
  45055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45056. */
  45057. checkInputs(): void;
  45058. /**
  45059. * Attach the input controls to a specific dom element to get the input from.
  45060. * @param element Defines the element the controls should be listened from
  45061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45062. */
  45063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45064. /**
  45065. * Detach the current controls from the specified dom element.
  45066. * @param element Defines the element to stop listening the inputs from
  45067. */
  45068. detachControl(element: Nullable<HTMLElement>): void;
  45069. /**
  45070. * Gets the class name of the current intput.
  45071. * @returns the class name
  45072. */
  45073. getClassName(): string;
  45074. /**
  45075. * Get the friendly name associated with the input class.
  45076. * @returns the input friendly name
  45077. */
  45078. getSimpleName(): string;
  45079. }
  45080. }
  45081. declare module BABYLON {
  45082. /**
  45083. * This represents a FPS type of camera controlled by touch.
  45084. * This is like a universal camera minus the Gamepad controls.
  45085. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45086. */
  45087. export class TouchCamera extends FreeCamera {
  45088. /**
  45089. * Defines the touch sensibility for rotation.
  45090. * The higher the faster.
  45091. */
  45092. get touchAngularSensibility(): number;
  45093. set touchAngularSensibility(value: number);
  45094. /**
  45095. * Defines the touch sensibility for move.
  45096. * The higher the faster.
  45097. */
  45098. get touchMoveSensibility(): number;
  45099. set touchMoveSensibility(value: number);
  45100. /**
  45101. * Instantiates a new touch camera.
  45102. * This represents a FPS type of camera controlled by touch.
  45103. * This is like a universal camera minus the Gamepad controls.
  45104. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45105. * @param name Define the name of the camera in the scene
  45106. * @param position Define the start position of the camera in the scene
  45107. * @param scene Define the scene the camera belongs to
  45108. */
  45109. constructor(name: string, position: Vector3, scene: Scene);
  45110. /**
  45111. * Gets the current object class name.
  45112. * @return the class name
  45113. */
  45114. getClassName(): string;
  45115. /** @hidden */
  45116. _setupInputs(): void;
  45117. }
  45118. }
  45119. declare module BABYLON {
  45120. /**
  45121. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45122. * being tilted forward or back and left or right.
  45123. */
  45124. export class DeviceOrientationCamera extends FreeCamera {
  45125. private _initialQuaternion;
  45126. private _quaternionCache;
  45127. private _tmpDragQuaternion;
  45128. private _disablePointerInputWhenUsingDeviceOrientation;
  45129. /**
  45130. * Creates a new device orientation camera
  45131. * @param name The name of the camera
  45132. * @param position The start position camera
  45133. * @param scene The scene the camera belongs to
  45134. */
  45135. constructor(name: string, position: Vector3, scene: Scene);
  45136. /**
  45137. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45138. */
  45139. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45140. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45141. private _dragFactor;
  45142. /**
  45143. * Enabled turning on the y axis when the orientation sensor is active
  45144. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45145. */
  45146. enableHorizontalDragging(dragFactor?: number): void;
  45147. /**
  45148. * Gets the current instance class name ("DeviceOrientationCamera").
  45149. * This helps avoiding instanceof at run time.
  45150. * @returns the class name
  45151. */
  45152. getClassName(): string;
  45153. /**
  45154. * @hidden
  45155. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45156. */
  45157. _checkInputs(): void;
  45158. /**
  45159. * Reset the camera to its default orientation on the specified axis only.
  45160. * @param axis The axis to reset
  45161. */
  45162. resetToCurrentRotation(axis?: Axis): void;
  45163. }
  45164. }
  45165. declare module BABYLON {
  45166. /**
  45167. * Defines supported buttons for XBox360 compatible gamepads
  45168. */
  45169. export enum Xbox360Button {
  45170. /** A */
  45171. A = 0,
  45172. /** B */
  45173. B = 1,
  45174. /** X */
  45175. X = 2,
  45176. /** Y */
  45177. Y = 3,
  45178. /** Left button */
  45179. LB = 4,
  45180. /** Right button */
  45181. RB = 5,
  45182. /** Back */
  45183. Back = 8,
  45184. /** Start */
  45185. Start = 9,
  45186. /** Left stick */
  45187. LeftStick = 10,
  45188. /** Right stick */
  45189. RightStick = 11
  45190. }
  45191. /** Defines values for XBox360 DPad */
  45192. export enum Xbox360Dpad {
  45193. /** Up */
  45194. Up = 12,
  45195. /** Down */
  45196. Down = 13,
  45197. /** Left */
  45198. Left = 14,
  45199. /** Right */
  45200. Right = 15
  45201. }
  45202. /**
  45203. * Defines a XBox360 gamepad
  45204. */
  45205. export class Xbox360Pad extends Gamepad {
  45206. private _leftTrigger;
  45207. private _rightTrigger;
  45208. private _onlefttriggerchanged;
  45209. private _onrighttriggerchanged;
  45210. private _onbuttondown;
  45211. private _onbuttonup;
  45212. private _ondpaddown;
  45213. private _ondpadup;
  45214. /** Observable raised when a button is pressed */
  45215. onButtonDownObservable: Observable<Xbox360Button>;
  45216. /** Observable raised when a button is released */
  45217. onButtonUpObservable: Observable<Xbox360Button>;
  45218. /** Observable raised when a pad is pressed */
  45219. onPadDownObservable: Observable<Xbox360Dpad>;
  45220. /** Observable raised when a pad is released */
  45221. onPadUpObservable: Observable<Xbox360Dpad>;
  45222. private _buttonA;
  45223. private _buttonB;
  45224. private _buttonX;
  45225. private _buttonY;
  45226. private _buttonBack;
  45227. private _buttonStart;
  45228. private _buttonLB;
  45229. private _buttonRB;
  45230. private _buttonLeftStick;
  45231. private _buttonRightStick;
  45232. private _dPadUp;
  45233. private _dPadDown;
  45234. private _dPadLeft;
  45235. private _dPadRight;
  45236. private _isXboxOnePad;
  45237. /**
  45238. * Creates a new XBox360 gamepad object
  45239. * @param id defines the id of this gamepad
  45240. * @param index defines its index
  45241. * @param gamepad defines the internal HTML gamepad object
  45242. * @param xboxOne defines if it is a XBox One gamepad
  45243. */
  45244. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45245. /**
  45246. * Defines the callback to call when left trigger is pressed
  45247. * @param callback defines the callback to use
  45248. */
  45249. onlefttriggerchanged(callback: (value: number) => void): void;
  45250. /**
  45251. * Defines the callback to call when right trigger is pressed
  45252. * @param callback defines the callback to use
  45253. */
  45254. onrighttriggerchanged(callback: (value: number) => void): void;
  45255. /**
  45256. * Gets the left trigger value
  45257. */
  45258. get leftTrigger(): number;
  45259. /**
  45260. * Sets the left trigger value
  45261. */
  45262. set leftTrigger(newValue: number);
  45263. /**
  45264. * Gets the right trigger value
  45265. */
  45266. get rightTrigger(): number;
  45267. /**
  45268. * Sets the right trigger value
  45269. */
  45270. set rightTrigger(newValue: number);
  45271. /**
  45272. * Defines the callback to call when a button is pressed
  45273. * @param callback defines the callback to use
  45274. */
  45275. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45276. /**
  45277. * Defines the callback to call when a button is released
  45278. * @param callback defines the callback to use
  45279. */
  45280. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45281. /**
  45282. * Defines the callback to call when a pad is pressed
  45283. * @param callback defines the callback to use
  45284. */
  45285. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45286. /**
  45287. * Defines the callback to call when a pad is released
  45288. * @param callback defines the callback to use
  45289. */
  45290. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45291. private _setButtonValue;
  45292. private _setDPadValue;
  45293. /**
  45294. * Gets the value of the `A` button
  45295. */
  45296. get buttonA(): number;
  45297. /**
  45298. * Sets the value of the `A` button
  45299. */
  45300. set buttonA(value: number);
  45301. /**
  45302. * Gets the value of the `B` button
  45303. */
  45304. get buttonB(): number;
  45305. /**
  45306. * Sets the value of the `B` button
  45307. */
  45308. set buttonB(value: number);
  45309. /**
  45310. * Gets the value of the `X` button
  45311. */
  45312. get buttonX(): number;
  45313. /**
  45314. * Sets the value of the `X` button
  45315. */
  45316. set buttonX(value: number);
  45317. /**
  45318. * Gets the value of the `Y` button
  45319. */
  45320. get buttonY(): number;
  45321. /**
  45322. * Sets the value of the `Y` button
  45323. */
  45324. set buttonY(value: number);
  45325. /**
  45326. * Gets the value of the `Start` button
  45327. */
  45328. get buttonStart(): number;
  45329. /**
  45330. * Sets the value of the `Start` button
  45331. */
  45332. set buttonStart(value: number);
  45333. /**
  45334. * Gets the value of the `Back` button
  45335. */
  45336. get buttonBack(): number;
  45337. /**
  45338. * Sets the value of the `Back` button
  45339. */
  45340. set buttonBack(value: number);
  45341. /**
  45342. * Gets the value of the `Left` button
  45343. */
  45344. get buttonLB(): number;
  45345. /**
  45346. * Sets the value of the `Left` button
  45347. */
  45348. set buttonLB(value: number);
  45349. /**
  45350. * Gets the value of the `Right` button
  45351. */
  45352. get buttonRB(): number;
  45353. /**
  45354. * Sets the value of the `Right` button
  45355. */
  45356. set buttonRB(value: number);
  45357. /**
  45358. * Gets the value of the Left joystick
  45359. */
  45360. get buttonLeftStick(): number;
  45361. /**
  45362. * Sets the value of the Left joystick
  45363. */
  45364. set buttonLeftStick(value: number);
  45365. /**
  45366. * Gets the value of the Right joystick
  45367. */
  45368. get buttonRightStick(): number;
  45369. /**
  45370. * Sets the value of the Right joystick
  45371. */
  45372. set buttonRightStick(value: number);
  45373. /**
  45374. * Gets the value of D-pad up
  45375. */
  45376. get dPadUp(): number;
  45377. /**
  45378. * Sets the value of D-pad up
  45379. */
  45380. set dPadUp(value: number);
  45381. /**
  45382. * Gets the value of D-pad down
  45383. */
  45384. get dPadDown(): number;
  45385. /**
  45386. * Sets the value of D-pad down
  45387. */
  45388. set dPadDown(value: number);
  45389. /**
  45390. * Gets the value of D-pad left
  45391. */
  45392. get dPadLeft(): number;
  45393. /**
  45394. * Sets the value of D-pad left
  45395. */
  45396. set dPadLeft(value: number);
  45397. /**
  45398. * Gets the value of D-pad right
  45399. */
  45400. get dPadRight(): number;
  45401. /**
  45402. * Sets the value of D-pad right
  45403. */
  45404. set dPadRight(value: number);
  45405. /**
  45406. * Force the gamepad to synchronize with device values
  45407. */
  45408. update(): void;
  45409. /**
  45410. * Disposes the gamepad
  45411. */
  45412. dispose(): void;
  45413. }
  45414. }
  45415. declare module BABYLON {
  45416. /**
  45417. * Defines supported buttons for DualShock compatible gamepads
  45418. */
  45419. export enum DualShockButton {
  45420. /** Cross */
  45421. Cross = 0,
  45422. /** Circle */
  45423. Circle = 1,
  45424. /** Square */
  45425. Square = 2,
  45426. /** Triangle */
  45427. Triangle = 3,
  45428. /** L1 */
  45429. L1 = 4,
  45430. /** R1 */
  45431. R1 = 5,
  45432. /** Share */
  45433. Share = 8,
  45434. /** Options */
  45435. Options = 9,
  45436. /** Left stick */
  45437. LeftStick = 10,
  45438. /** Right stick */
  45439. RightStick = 11
  45440. }
  45441. /** Defines values for DualShock DPad */
  45442. export enum DualShockDpad {
  45443. /** Up */
  45444. Up = 12,
  45445. /** Down */
  45446. Down = 13,
  45447. /** Left */
  45448. Left = 14,
  45449. /** Right */
  45450. Right = 15
  45451. }
  45452. /**
  45453. * Defines a DualShock gamepad
  45454. */
  45455. export class DualShockPad extends Gamepad {
  45456. private _leftTrigger;
  45457. private _rightTrigger;
  45458. private _onlefttriggerchanged;
  45459. private _onrighttriggerchanged;
  45460. private _onbuttondown;
  45461. private _onbuttonup;
  45462. private _ondpaddown;
  45463. private _ondpadup;
  45464. /** Observable raised when a button is pressed */
  45465. onButtonDownObservable: Observable<DualShockButton>;
  45466. /** Observable raised when a button is released */
  45467. onButtonUpObservable: Observable<DualShockButton>;
  45468. /** Observable raised when a pad is pressed */
  45469. onPadDownObservable: Observable<DualShockDpad>;
  45470. /** Observable raised when a pad is released */
  45471. onPadUpObservable: Observable<DualShockDpad>;
  45472. private _buttonCross;
  45473. private _buttonCircle;
  45474. private _buttonSquare;
  45475. private _buttonTriangle;
  45476. private _buttonShare;
  45477. private _buttonOptions;
  45478. private _buttonL1;
  45479. private _buttonR1;
  45480. private _buttonLeftStick;
  45481. private _buttonRightStick;
  45482. private _dPadUp;
  45483. private _dPadDown;
  45484. private _dPadLeft;
  45485. private _dPadRight;
  45486. /**
  45487. * Creates a new DualShock gamepad object
  45488. * @param id defines the id of this gamepad
  45489. * @param index defines its index
  45490. * @param gamepad defines the internal HTML gamepad object
  45491. */
  45492. constructor(id: string, index: number, gamepad: any);
  45493. /**
  45494. * Defines the callback to call when left trigger is pressed
  45495. * @param callback defines the callback to use
  45496. */
  45497. onlefttriggerchanged(callback: (value: number) => void): void;
  45498. /**
  45499. * Defines the callback to call when right trigger is pressed
  45500. * @param callback defines the callback to use
  45501. */
  45502. onrighttriggerchanged(callback: (value: number) => void): void;
  45503. /**
  45504. * Gets the left trigger value
  45505. */
  45506. get leftTrigger(): number;
  45507. /**
  45508. * Sets the left trigger value
  45509. */
  45510. set leftTrigger(newValue: number);
  45511. /**
  45512. * Gets the right trigger value
  45513. */
  45514. get rightTrigger(): number;
  45515. /**
  45516. * Sets the right trigger value
  45517. */
  45518. set rightTrigger(newValue: number);
  45519. /**
  45520. * Defines the callback to call when a button is pressed
  45521. * @param callback defines the callback to use
  45522. */
  45523. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45524. /**
  45525. * Defines the callback to call when a button is released
  45526. * @param callback defines the callback to use
  45527. */
  45528. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45529. /**
  45530. * Defines the callback to call when a pad is pressed
  45531. * @param callback defines the callback to use
  45532. */
  45533. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45534. /**
  45535. * Defines the callback to call when a pad is released
  45536. * @param callback defines the callback to use
  45537. */
  45538. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45539. private _setButtonValue;
  45540. private _setDPadValue;
  45541. /**
  45542. * Gets the value of the `Cross` button
  45543. */
  45544. get buttonCross(): number;
  45545. /**
  45546. * Sets the value of the `Cross` button
  45547. */
  45548. set buttonCross(value: number);
  45549. /**
  45550. * Gets the value of the `Circle` button
  45551. */
  45552. get buttonCircle(): number;
  45553. /**
  45554. * Sets the value of the `Circle` button
  45555. */
  45556. set buttonCircle(value: number);
  45557. /**
  45558. * Gets the value of the `Square` button
  45559. */
  45560. get buttonSquare(): number;
  45561. /**
  45562. * Sets the value of the `Square` button
  45563. */
  45564. set buttonSquare(value: number);
  45565. /**
  45566. * Gets the value of the `Triangle` button
  45567. */
  45568. get buttonTriangle(): number;
  45569. /**
  45570. * Sets the value of the `Triangle` button
  45571. */
  45572. set buttonTriangle(value: number);
  45573. /**
  45574. * Gets the value of the `Options` button
  45575. */
  45576. get buttonOptions(): number;
  45577. /**
  45578. * Sets the value of the `Options` button
  45579. */
  45580. set buttonOptions(value: number);
  45581. /**
  45582. * Gets the value of the `Share` button
  45583. */
  45584. get buttonShare(): number;
  45585. /**
  45586. * Sets the value of the `Share` button
  45587. */
  45588. set buttonShare(value: number);
  45589. /**
  45590. * Gets the value of the `L1` button
  45591. */
  45592. get buttonL1(): number;
  45593. /**
  45594. * Sets the value of the `L1` button
  45595. */
  45596. set buttonL1(value: number);
  45597. /**
  45598. * Gets the value of the `R1` button
  45599. */
  45600. get buttonR1(): number;
  45601. /**
  45602. * Sets the value of the `R1` button
  45603. */
  45604. set buttonR1(value: number);
  45605. /**
  45606. * Gets the value of the Left joystick
  45607. */
  45608. get buttonLeftStick(): number;
  45609. /**
  45610. * Sets the value of the Left joystick
  45611. */
  45612. set buttonLeftStick(value: number);
  45613. /**
  45614. * Gets the value of the Right joystick
  45615. */
  45616. get buttonRightStick(): number;
  45617. /**
  45618. * Sets the value of the Right joystick
  45619. */
  45620. set buttonRightStick(value: number);
  45621. /**
  45622. * Gets the value of D-pad up
  45623. */
  45624. get dPadUp(): number;
  45625. /**
  45626. * Sets the value of D-pad up
  45627. */
  45628. set dPadUp(value: number);
  45629. /**
  45630. * Gets the value of D-pad down
  45631. */
  45632. get dPadDown(): number;
  45633. /**
  45634. * Sets the value of D-pad down
  45635. */
  45636. set dPadDown(value: number);
  45637. /**
  45638. * Gets the value of D-pad left
  45639. */
  45640. get dPadLeft(): number;
  45641. /**
  45642. * Sets the value of D-pad left
  45643. */
  45644. set dPadLeft(value: number);
  45645. /**
  45646. * Gets the value of D-pad right
  45647. */
  45648. get dPadRight(): number;
  45649. /**
  45650. * Sets the value of D-pad right
  45651. */
  45652. set dPadRight(value: number);
  45653. /**
  45654. * Force the gamepad to synchronize with device values
  45655. */
  45656. update(): void;
  45657. /**
  45658. * Disposes the gamepad
  45659. */
  45660. dispose(): void;
  45661. }
  45662. }
  45663. declare module BABYLON {
  45664. /**
  45665. * Manager for handling gamepads
  45666. */
  45667. export class GamepadManager {
  45668. private _scene?;
  45669. private _babylonGamepads;
  45670. private _oneGamepadConnected;
  45671. /** @hidden */
  45672. _isMonitoring: boolean;
  45673. private _gamepadEventSupported;
  45674. private _gamepadSupport?;
  45675. /**
  45676. * observable to be triggered when the gamepad controller has been connected
  45677. */
  45678. onGamepadConnectedObservable: Observable<Gamepad>;
  45679. /**
  45680. * observable to be triggered when the gamepad controller has been disconnected
  45681. */
  45682. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45683. private _onGamepadConnectedEvent;
  45684. private _onGamepadDisconnectedEvent;
  45685. /**
  45686. * Initializes the gamepad manager
  45687. * @param _scene BabylonJS scene
  45688. */
  45689. constructor(_scene?: Scene | undefined);
  45690. /**
  45691. * The gamepads in the game pad manager
  45692. */
  45693. get gamepads(): Gamepad[];
  45694. /**
  45695. * Get the gamepad controllers based on type
  45696. * @param type The type of gamepad controller
  45697. * @returns Nullable gamepad
  45698. */
  45699. getGamepadByType(type?: number): Nullable<Gamepad>;
  45700. /**
  45701. * Disposes the gamepad manager
  45702. */
  45703. dispose(): void;
  45704. private _addNewGamepad;
  45705. private _startMonitoringGamepads;
  45706. private _stopMonitoringGamepads;
  45707. /** @hidden */
  45708. _checkGamepadsStatus(): void;
  45709. private _updateGamepadObjects;
  45710. }
  45711. }
  45712. declare module BABYLON {
  45713. interface Scene {
  45714. /** @hidden */
  45715. _gamepadManager: Nullable<GamepadManager>;
  45716. /**
  45717. * Gets the gamepad manager associated with the scene
  45718. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45719. */
  45720. gamepadManager: GamepadManager;
  45721. }
  45722. /**
  45723. * Interface representing a free camera inputs manager
  45724. */
  45725. interface FreeCameraInputsManager {
  45726. /**
  45727. * Adds gamepad input support to the FreeCameraInputsManager.
  45728. * @returns the FreeCameraInputsManager
  45729. */
  45730. addGamepad(): FreeCameraInputsManager;
  45731. }
  45732. /**
  45733. * Interface representing an arc rotate camera inputs manager
  45734. */
  45735. interface ArcRotateCameraInputsManager {
  45736. /**
  45737. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45738. * @returns the camera inputs manager
  45739. */
  45740. addGamepad(): ArcRotateCameraInputsManager;
  45741. }
  45742. /**
  45743. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45744. */
  45745. export class GamepadSystemSceneComponent implements ISceneComponent {
  45746. /**
  45747. * The component name helpfull to identify the component in the list of scene components.
  45748. */
  45749. readonly name: string;
  45750. /**
  45751. * The scene the component belongs to.
  45752. */
  45753. scene: Scene;
  45754. /**
  45755. * Creates a new instance of the component for the given scene
  45756. * @param scene Defines the scene to register the component in
  45757. */
  45758. constructor(scene: Scene);
  45759. /**
  45760. * Registers the component in a given scene
  45761. */
  45762. register(): void;
  45763. /**
  45764. * Rebuilds the elements related to this component in case of
  45765. * context lost for instance.
  45766. */
  45767. rebuild(): void;
  45768. /**
  45769. * Disposes the component and the associated ressources
  45770. */
  45771. dispose(): void;
  45772. private _beforeCameraUpdate;
  45773. }
  45774. }
  45775. declare module BABYLON {
  45776. /**
  45777. * 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,
  45778. * which still works and will still be found in many Playgrounds.
  45779. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45780. */
  45781. export class UniversalCamera extends TouchCamera {
  45782. /**
  45783. * Defines the gamepad rotation sensiblity.
  45784. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45785. */
  45786. get gamepadAngularSensibility(): number;
  45787. set gamepadAngularSensibility(value: number);
  45788. /**
  45789. * Defines the gamepad move sensiblity.
  45790. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45791. */
  45792. get gamepadMoveSensibility(): number;
  45793. set gamepadMoveSensibility(value: number);
  45794. /**
  45795. * 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,
  45796. * which still works and will still be found in many Playgrounds.
  45797. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45798. * @param name Define the name of the camera in the scene
  45799. * @param position Define the start position of the camera in the scene
  45800. * @param scene Define the scene the camera belongs to
  45801. */
  45802. constructor(name: string, position: Vector3, scene: Scene);
  45803. /**
  45804. * Gets the current object class name.
  45805. * @return the class name
  45806. */
  45807. getClassName(): string;
  45808. }
  45809. }
  45810. declare module BABYLON {
  45811. /**
  45812. * This represents a FPS type of camera. This is only here for back compat purpose.
  45813. * Please use the UniversalCamera instead as both are identical.
  45814. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45815. */
  45816. export class GamepadCamera extends UniversalCamera {
  45817. /**
  45818. * Instantiates a new Gamepad Camera
  45819. * This represents a FPS type of camera. This is only here for back compat purpose.
  45820. * Please use the UniversalCamera instead as both are identical.
  45821. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45822. * @param name Define the name of the camera in the scene
  45823. * @param position Define the start position of the camera in the scene
  45824. * @param scene Define the scene the camera belongs to
  45825. */
  45826. constructor(name: string, position: Vector3, scene: Scene);
  45827. /**
  45828. * Gets the current object class name.
  45829. * @return the class name
  45830. */
  45831. getClassName(): string;
  45832. }
  45833. }
  45834. declare module BABYLON {
  45835. /** @hidden */
  45836. export var passPixelShader: {
  45837. name: string;
  45838. shader: string;
  45839. };
  45840. }
  45841. declare module BABYLON {
  45842. /** @hidden */
  45843. export var passCubePixelShader: {
  45844. name: string;
  45845. shader: string;
  45846. };
  45847. }
  45848. declare module BABYLON {
  45849. /**
  45850. * PassPostProcess which produces an output the same as it's input
  45851. */
  45852. export class PassPostProcess extends PostProcess {
  45853. /**
  45854. * Creates the PassPostProcess
  45855. * @param name The name of the effect.
  45856. * @param options The required width/height ratio to downsize to before computing the render pass.
  45857. * @param camera The camera to apply the render pass to.
  45858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45859. * @param engine The engine which the post process will be applied. (default: current engine)
  45860. * @param reusable If the post process can be reused on the same frame. (default: false)
  45861. * @param textureType The type of texture to be used when performing the post processing.
  45862. * @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)
  45863. */
  45864. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45865. }
  45866. /**
  45867. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45868. */
  45869. export class PassCubePostProcess extends PostProcess {
  45870. private _face;
  45871. /**
  45872. * Gets or sets the cube face to display.
  45873. * * 0 is +X
  45874. * * 1 is -X
  45875. * * 2 is +Y
  45876. * * 3 is -Y
  45877. * * 4 is +Z
  45878. * * 5 is -Z
  45879. */
  45880. get face(): number;
  45881. set face(value: number);
  45882. /**
  45883. * Creates the PassCubePostProcess
  45884. * @param name The name of the effect.
  45885. * @param options The required width/height ratio to downsize to before computing the render pass.
  45886. * @param camera The camera to apply the render pass to.
  45887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45888. * @param engine The engine which the post process will be applied. (default: current engine)
  45889. * @param reusable If the post process can be reused on the same frame. (default: false)
  45890. * @param textureType The type of texture to be used when performing the post processing.
  45891. * @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)
  45892. */
  45893. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45894. }
  45895. }
  45896. declare module BABYLON {
  45897. /** @hidden */
  45898. export var anaglyphPixelShader: {
  45899. name: string;
  45900. shader: string;
  45901. };
  45902. }
  45903. declare module BABYLON {
  45904. /**
  45905. * Postprocess used to generate anaglyphic rendering
  45906. */
  45907. export class AnaglyphPostProcess extends PostProcess {
  45908. private _passedProcess;
  45909. /**
  45910. * Creates a new AnaglyphPostProcess
  45911. * @param name defines postprocess name
  45912. * @param options defines creation options or target ratio scale
  45913. * @param rigCameras defines cameras using this postprocess
  45914. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45915. * @param engine defines hosting engine
  45916. * @param reusable defines if the postprocess will be reused multiple times per frame
  45917. */
  45918. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45919. }
  45920. }
  45921. declare module BABYLON {
  45922. /**
  45923. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45924. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45925. */
  45926. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45927. /**
  45928. * Creates a new AnaglyphArcRotateCamera
  45929. * @param name defines camera name
  45930. * @param alpha defines alpha angle (in radians)
  45931. * @param beta defines beta angle (in radians)
  45932. * @param radius defines radius
  45933. * @param target defines camera target
  45934. * @param interaxialDistance defines distance between each color axis
  45935. * @param scene defines the hosting scene
  45936. */
  45937. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45938. /**
  45939. * Gets camera class name
  45940. * @returns AnaglyphArcRotateCamera
  45941. */
  45942. getClassName(): string;
  45943. }
  45944. }
  45945. declare module BABYLON {
  45946. /**
  45947. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45948. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45949. */
  45950. export class AnaglyphFreeCamera extends FreeCamera {
  45951. /**
  45952. * Creates a new AnaglyphFreeCamera
  45953. * @param name defines camera name
  45954. * @param position defines initial position
  45955. * @param interaxialDistance defines distance between each color axis
  45956. * @param scene defines the hosting scene
  45957. */
  45958. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45959. /**
  45960. * Gets camera class name
  45961. * @returns AnaglyphFreeCamera
  45962. */
  45963. getClassName(): string;
  45964. }
  45965. }
  45966. declare module BABYLON {
  45967. /**
  45968. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45969. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45970. */
  45971. export class AnaglyphGamepadCamera extends GamepadCamera {
  45972. /**
  45973. * Creates a new AnaglyphGamepadCamera
  45974. * @param name defines camera name
  45975. * @param position defines initial position
  45976. * @param interaxialDistance defines distance between each color axis
  45977. * @param scene defines the hosting scene
  45978. */
  45979. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45980. /**
  45981. * Gets camera class name
  45982. * @returns AnaglyphGamepadCamera
  45983. */
  45984. getClassName(): string;
  45985. }
  45986. }
  45987. declare module BABYLON {
  45988. /**
  45989. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45990. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45991. */
  45992. export class AnaglyphUniversalCamera extends UniversalCamera {
  45993. /**
  45994. * Creates a new AnaglyphUniversalCamera
  45995. * @param name defines camera name
  45996. * @param position defines initial position
  45997. * @param interaxialDistance defines distance between each color axis
  45998. * @param scene defines the hosting scene
  45999. */
  46000. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46001. /**
  46002. * Gets camera class name
  46003. * @returns AnaglyphUniversalCamera
  46004. */
  46005. getClassName(): string;
  46006. }
  46007. }
  46008. declare module BABYLON {
  46009. /**
  46010. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46011. * @see https://doc.babylonjs.com/features/cameras
  46012. */
  46013. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46014. /**
  46015. * Creates a new StereoscopicArcRotateCamera
  46016. * @param name defines camera name
  46017. * @param alpha defines alpha angle (in radians)
  46018. * @param beta defines beta angle (in radians)
  46019. * @param radius defines radius
  46020. * @param target defines camera target
  46021. * @param interaxialDistance defines distance between each color axis
  46022. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46023. * @param scene defines the hosting scene
  46024. */
  46025. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46026. /**
  46027. * Gets camera class name
  46028. * @returns StereoscopicArcRotateCamera
  46029. */
  46030. getClassName(): string;
  46031. }
  46032. }
  46033. declare module BABYLON {
  46034. /**
  46035. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46036. * @see https://doc.babylonjs.com/features/cameras
  46037. */
  46038. export class StereoscopicFreeCamera extends FreeCamera {
  46039. /**
  46040. * Creates a new StereoscopicFreeCamera
  46041. * @param name defines camera name
  46042. * @param position defines initial position
  46043. * @param interaxialDistance defines distance between each color axis
  46044. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46045. * @param scene defines the hosting scene
  46046. */
  46047. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46048. /**
  46049. * Gets camera class name
  46050. * @returns StereoscopicFreeCamera
  46051. */
  46052. getClassName(): string;
  46053. }
  46054. }
  46055. declare module BABYLON {
  46056. /**
  46057. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46058. * @see https://doc.babylonjs.com/features/cameras
  46059. */
  46060. export class StereoscopicGamepadCamera extends GamepadCamera {
  46061. /**
  46062. * Creates a new StereoscopicGamepadCamera
  46063. * @param name defines camera name
  46064. * @param position defines initial position
  46065. * @param interaxialDistance defines distance between each color axis
  46066. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46067. * @param scene defines the hosting scene
  46068. */
  46069. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46070. /**
  46071. * Gets camera class name
  46072. * @returns StereoscopicGamepadCamera
  46073. */
  46074. getClassName(): string;
  46075. }
  46076. }
  46077. declare module BABYLON {
  46078. /**
  46079. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46080. * @see https://doc.babylonjs.com/features/cameras
  46081. */
  46082. export class StereoscopicUniversalCamera extends UniversalCamera {
  46083. /**
  46084. * Creates a new StereoscopicUniversalCamera
  46085. * @param name defines camera name
  46086. * @param position defines initial position
  46087. * @param interaxialDistance defines distance between each color axis
  46088. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46089. * @param scene defines the hosting scene
  46090. */
  46091. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46092. /**
  46093. * Gets camera class name
  46094. * @returns StereoscopicUniversalCamera
  46095. */
  46096. getClassName(): string;
  46097. }
  46098. }
  46099. declare module BABYLON {
  46100. /**
  46101. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46102. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46103. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46104. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46105. */
  46106. export class VirtualJoysticksCamera extends FreeCamera {
  46107. /**
  46108. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46109. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46110. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46111. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46112. * @param name Define the name of the camera in the scene
  46113. * @param position Define the start position of the camera in the scene
  46114. * @param scene Define the scene the camera belongs to
  46115. */
  46116. constructor(name: string, position: Vector3, scene: Scene);
  46117. /**
  46118. * Gets the current object class name.
  46119. * @return the class name
  46120. */
  46121. getClassName(): string;
  46122. }
  46123. }
  46124. declare module BABYLON {
  46125. /**
  46126. * This represents all the required metrics to create a VR camera.
  46127. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46128. */
  46129. export class VRCameraMetrics {
  46130. /**
  46131. * Define the horizontal resolution off the screen.
  46132. */
  46133. hResolution: number;
  46134. /**
  46135. * Define the vertical resolution off the screen.
  46136. */
  46137. vResolution: number;
  46138. /**
  46139. * Define the horizontal screen size.
  46140. */
  46141. hScreenSize: number;
  46142. /**
  46143. * Define the vertical screen size.
  46144. */
  46145. vScreenSize: number;
  46146. /**
  46147. * Define the vertical screen center position.
  46148. */
  46149. vScreenCenter: number;
  46150. /**
  46151. * Define the distance of the eyes to the screen.
  46152. */
  46153. eyeToScreenDistance: number;
  46154. /**
  46155. * Define the distance between both lenses
  46156. */
  46157. lensSeparationDistance: number;
  46158. /**
  46159. * Define the distance between both viewer's eyes.
  46160. */
  46161. interpupillaryDistance: number;
  46162. /**
  46163. * Define the distortion factor of the VR postprocess.
  46164. * Please, touch with care.
  46165. */
  46166. distortionK: number[];
  46167. /**
  46168. * Define the chromatic aberration correction factors for the VR post process.
  46169. */
  46170. chromaAbCorrection: number[];
  46171. /**
  46172. * Define the scale factor of the post process.
  46173. * The smaller the better but the slower.
  46174. */
  46175. postProcessScaleFactor: number;
  46176. /**
  46177. * Define an offset for the lens center.
  46178. */
  46179. lensCenterOffset: number;
  46180. /**
  46181. * Define if the current vr camera should compensate the distortion of the lense or not.
  46182. */
  46183. compensateDistortion: boolean;
  46184. /**
  46185. * Defines if multiview should be enabled when rendering (Default: false)
  46186. */
  46187. multiviewEnabled: boolean;
  46188. /**
  46189. * Gets the rendering aspect ratio based on the provided resolutions.
  46190. */
  46191. get aspectRatio(): number;
  46192. /**
  46193. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46194. */
  46195. get aspectRatioFov(): number;
  46196. /**
  46197. * @hidden
  46198. */
  46199. get leftHMatrix(): Matrix;
  46200. /**
  46201. * @hidden
  46202. */
  46203. get rightHMatrix(): Matrix;
  46204. /**
  46205. * @hidden
  46206. */
  46207. get leftPreViewMatrix(): Matrix;
  46208. /**
  46209. * @hidden
  46210. */
  46211. get rightPreViewMatrix(): Matrix;
  46212. /**
  46213. * Get the default VRMetrics based on the most generic setup.
  46214. * @returns the default vr metrics
  46215. */
  46216. static GetDefault(): VRCameraMetrics;
  46217. }
  46218. }
  46219. declare module BABYLON {
  46220. /** @hidden */
  46221. export var vrDistortionCorrectionPixelShader: {
  46222. name: string;
  46223. shader: string;
  46224. };
  46225. }
  46226. declare module BABYLON {
  46227. /**
  46228. * VRDistortionCorrectionPostProcess used for mobile VR
  46229. */
  46230. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46231. private _isRightEye;
  46232. private _distortionFactors;
  46233. private _postProcessScaleFactor;
  46234. private _lensCenterOffset;
  46235. private _scaleIn;
  46236. private _scaleFactor;
  46237. private _lensCenter;
  46238. /**
  46239. * Initializes the VRDistortionCorrectionPostProcess
  46240. * @param name The name of the effect.
  46241. * @param camera The camera to apply the render pass to.
  46242. * @param isRightEye If this is for the right eye distortion
  46243. * @param vrMetrics All the required metrics for the VR camera
  46244. */
  46245. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46246. }
  46247. }
  46248. declare module BABYLON {
  46249. /**
  46250. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46251. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46252. */
  46253. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46254. /**
  46255. * Creates a new VRDeviceOrientationArcRotateCamera
  46256. * @param name defines camera name
  46257. * @param alpha defines the camera rotation along the logitudinal axis
  46258. * @param beta defines the camera rotation along the latitudinal axis
  46259. * @param radius defines the camera distance from its target
  46260. * @param target defines the camera target
  46261. * @param scene defines the scene the camera belongs to
  46262. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46263. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46264. */
  46265. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46266. /**
  46267. * Gets camera class name
  46268. * @returns VRDeviceOrientationArcRotateCamera
  46269. */
  46270. getClassName(): string;
  46271. }
  46272. }
  46273. declare module BABYLON {
  46274. /**
  46275. * Camera used to simulate VR rendering (based on FreeCamera)
  46276. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46277. */
  46278. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46279. /**
  46280. * Creates a new VRDeviceOrientationFreeCamera
  46281. * @param name defines camera name
  46282. * @param position defines the start position of the camera
  46283. * @param scene defines the scene the camera belongs to
  46284. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46285. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46286. */
  46287. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46288. /**
  46289. * Gets camera class name
  46290. * @returns VRDeviceOrientationFreeCamera
  46291. */
  46292. getClassName(): string;
  46293. }
  46294. }
  46295. declare module BABYLON {
  46296. /**
  46297. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46298. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46299. */
  46300. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46301. /**
  46302. * Creates a new VRDeviceOrientationGamepadCamera
  46303. * @param name defines camera name
  46304. * @param position defines the start position of the camera
  46305. * @param scene defines the scene the camera belongs to
  46306. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46307. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46308. */
  46309. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46310. /**
  46311. * Gets camera class name
  46312. * @returns VRDeviceOrientationGamepadCamera
  46313. */
  46314. getClassName(): string;
  46315. }
  46316. }
  46317. declare module BABYLON {
  46318. /**
  46319. * A class extending Texture allowing drawing on a texture
  46320. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46321. */
  46322. export class DynamicTexture extends Texture {
  46323. private _generateMipMaps;
  46324. private _canvas;
  46325. private _context;
  46326. /**
  46327. * Creates a DynamicTexture
  46328. * @param name defines the name of the texture
  46329. * @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
  46330. * @param scene defines the scene where you want the texture
  46331. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46332. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46333. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46334. */
  46335. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46336. /**
  46337. * Get the current class name of the texture useful for serialization or dynamic coding.
  46338. * @returns "DynamicTexture"
  46339. */
  46340. getClassName(): string;
  46341. /**
  46342. * Gets the current state of canRescale
  46343. */
  46344. get canRescale(): boolean;
  46345. private _recreate;
  46346. /**
  46347. * Scales the texture
  46348. * @param ratio the scale factor to apply to both width and height
  46349. */
  46350. scale(ratio: number): void;
  46351. /**
  46352. * Resizes the texture
  46353. * @param width the new width
  46354. * @param height the new height
  46355. */
  46356. scaleTo(width: number, height: number): void;
  46357. /**
  46358. * Gets the context of the canvas used by the texture
  46359. * @returns the canvas context of the dynamic texture
  46360. */
  46361. getContext(): CanvasRenderingContext2D;
  46362. /**
  46363. * Clears the texture
  46364. */
  46365. clear(): void;
  46366. /**
  46367. * Updates the texture
  46368. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46369. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46370. */
  46371. update(invertY?: boolean, premulAlpha?: boolean): void;
  46372. /**
  46373. * Draws text onto the texture
  46374. * @param text defines the text to be drawn
  46375. * @param x defines the placement of the text from the left
  46376. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46377. * @param font defines the font to be used with font-style, font-size, font-name
  46378. * @param color defines the color used for the text
  46379. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46380. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46381. * @param update defines whether texture is immediately update (default is true)
  46382. */
  46383. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46384. /**
  46385. * Clones the texture
  46386. * @returns the clone of the texture.
  46387. */
  46388. clone(): DynamicTexture;
  46389. /**
  46390. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46391. * @returns a serialized dynamic texture object
  46392. */
  46393. serialize(): any;
  46394. private _IsCanvasElement;
  46395. /** @hidden */
  46396. _rebuild(): void;
  46397. }
  46398. }
  46399. declare module BABYLON {
  46400. /**
  46401. * Class containing static functions to help procedurally build meshes
  46402. */
  46403. export class GroundBuilder {
  46404. /**
  46405. * Creates a ground mesh
  46406. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46407. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46409. * @param name defines the name of the mesh
  46410. * @param options defines the options used to create the mesh
  46411. * @param scene defines the hosting scene
  46412. * @returns the ground mesh
  46413. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46414. */
  46415. static CreateGround(name: string, options: {
  46416. width?: number;
  46417. height?: number;
  46418. subdivisions?: number;
  46419. subdivisionsX?: number;
  46420. subdivisionsY?: number;
  46421. updatable?: boolean;
  46422. }, scene: any): Mesh;
  46423. /**
  46424. * Creates a tiled ground mesh
  46425. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46426. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46427. * * 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
  46428. * * 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
  46429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46430. * @param name defines the name of the mesh
  46431. * @param options defines the options used to create the mesh
  46432. * @param scene defines the hosting scene
  46433. * @returns the tiled ground mesh
  46434. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46435. */
  46436. static CreateTiledGround(name: string, options: {
  46437. xmin: number;
  46438. zmin: number;
  46439. xmax: number;
  46440. zmax: number;
  46441. subdivisions?: {
  46442. w: number;
  46443. h: number;
  46444. };
  46445. precision?: {
  46446. w: number;
  46447. h: number;
  46448. };
  46449. updatable?: boolean;
  46450. }, scene?: Nullable<Scene>): Mesh;
  46451. /**
  46452. * Creates a ground mesh from a height map
  46453. * * The parameter `url` sets the URL of the height map image resource.
  46454. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46455. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46456. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46457. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46458. * * 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.
  46459. * * 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).
  46460. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46462. * @param name defines the name of the mesh
  46463. * @param url defines the url to the height map
  46464. * @param options defines the options used to create the mesh
  46465. * @param scene defines the hosting scene
  46466. * @returns the ground mesh
  46467. * @see https://doc.babylonjs.com/babylon101/height_map
  46468. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46469. */
  46470. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46471. width?: number;
  46472. height?: number;
  46473. subdivisions?: number;
  46474. minHeight?: number;
  46475. maxHeight?: number;
  46476. colorFilter?: Color3;
  46477. alphaFilter?: number;
  46478. updatable?: boolean;
  46479. onReady?: (mesh: GroundMesh) => void;
  46480. }, scene?: Nullable<Scene>): GroundMesh;
  46481. }
  46482. }
  46483. declare module BABYLON {
  46484. /**
  46485. * Class containing static functions to help procedurally build meshes
  46486. */
  46487. export class TorusBuilder {
  46488. /**
  46489. * Creates a torus mesh
  46490. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46491. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46492. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46494. * * 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
  46495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46496. * @param name defines the name of the mesh
  46497. * @param options defines the options used to create the mesh
  46498. * @param scene defines the hosting scene
  46499. * @returns the torus mesh
  46500. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46501. */
  46502. static CreateTorus(name: string, options: {
  46503. diameter?: number;
  46504. thickness?: number;
  46505. tessellation?: number;
  46506. updatable?: boolean;
  46507. sideOrientation?: number;
  46508. frontUVs?: Vector4;
  46509. backUVs?: Vector4;
  46510. }, scene: any): Mesh;
  46511. }
  46512. }
  46513. declare module BABYLON {
  46514. /**
  46515. * Class containing static functions to help procedurally build meshes
  46516. */
  46517. export class CylinderBuilder {
  46518. /**
  46519. * Creates a cylinder or a cone mesh
  46520. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46521. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46522. * * 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.
  46523. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46524. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46525. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46526. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46527. * * 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).
  46528. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46529. * * 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).
  46530. * * 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
  46531. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46532. * * 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
  46533. * * 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.
  46534. * * If `enclose` is false, a ring surface is one element.
  46535. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46536. * * 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
  46537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46538. * * 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
  46539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46540. * @param name defines the name of the mesh
  46541. * @param options defines the options used to create the mesh
  46542. * @param scene defines the hosting scene
  46543. * @returns the cylinder mesh
  46544. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46545. */
  46546. static CreateCylinder(name: string, options: {
  46547. height?: number;
  46548. diameterTop?: number;
  46549. diameterBottom?: number;
  46550. diameter?: number;
  46551. tessellation?: number;
  46552. subdivisions?: number;
  46553. arc?: number;
  46554. faceColors?: Color4[];
  46555. faceUV?: Vector4[];
  46556. updatable?: boolean;
  46557. hasRings?: boolean;
  46558. enclose?: boolean;
  46559. cap?: number;
  46560. sideOrientation?: number;
  46561. frontUVs?: Vector4;
  46562. backUVs?: Vector4;
  46563. }, scene: any): Mesh;
  46564. }
  46565. }
  46566. declare module BABYLON {
  46567. /**
  46568. * States of the webXR experience
  46569. */
  46570. export enum WebXRState {
  46571. /**
  46572. * Transitioning to being in XR mode
  46573. */
  46574. ENTERING_XR = 0,
  46575. /**
  46576. * Transitioning to non XR mode
  46577. */
  46578. EXITING_XR = 1,
  46579. /**
  46580. * In XR mode and presenting
  46581. */
  46582. IN_XR = 2,
  46583. /**
  46584. * Not entered XR mode
  46585. */
  46586. NOT_IN_XR = 3
  46587. }
  46588. /**
  46589. * Abstraction of the XR render target
  46590. */
  46591. export interface WebXRRenderTarget extends IDisposable {
  46592. /**
  46593. * xrpresent context of the canvas which can be used to display/mirror xr content
  46594. */
  46595. canvasContext: WebGLRenderingContext;
  46596. /**
  46597. * xr layer for the canvas
  46598. */
  46599. xrLayer: Nullable<XRWebGLLayer>;
  46600. /**
  46601. * Initializes the xr layer for the session
  46602. * @param xrSession xr session
  46603. * @returns a promise that will resolve once the XR Layer has been created
  46604. */
  46605. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46606. }
  46607. }
  46608. declare module BABYLON {
  46609. /**
  46610. * COnfiguration object for WebXR output canvas
  46611. */
  46612. export class WebXRManagedOutputCanvasOptions {
  46613. /**
  46614. * An optional canvas in case you wish to create it yourself and provide it here.
  46615. * If not provided, a new canvas will be created
  46616. */
  46617. canvasElement?: HTMLCanvasElement;
  46618. /**
  46619. * Options for this XR Layer output
  46620. */
  46621. canvasOptions?: XRWebGLLayerOptions;
  46622. /**
  46623. * CSS styling for a newly created canvas (if not provided)
  46624. */
  46625. newCanvasCssStyle?: string;
  46626. /**
  46627. * Get the default values of the configuration object
  46628. * @returns default values of this configuration object
  46629. */
  46630. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46631. }
  46632. /**
  46633. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46634. */
  46635. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46636. private _options;
  46637. private _canvas;
  46638. private _engine;
  46639. private _originalCanvasSize;
  46640. /**
  46641. * Rendering context of the canvas which can be used to display/mirror xr content
  46642. */
  46643. canvasContext: WebGLRenderingContext;
  46644. /**
  46645. * xr layer for the canvas
  46646. */
  46647. xrLayer: Nullable<XRWebGLLayer>;
  46648. /**
  46649. * Obseervers registered here will be triggered when the xr layer was initialized
  46650. */
  46651. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46652. /**
  46653. * Initializes the canvas to be added/removed upon entering/exiting xr
  46654. * @param _xrSessionManager The XR Session manager
  46655. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46656. */
  46657. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46658. /**
  46659. * Disposes of the object
  46660. */
  46661. dispose(): void;
  46662. /**
  46663. * Initializes the xr layer for the session
  46664. * @param xrSession xr session
  46665. * @returns a promise that will resolve once the XR Layer has been created
  46666. */
  46667. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46668. private _addCanvas;
  46669. private _removeCanvas;
  46670. private _setCanvasSize;
  46671. private _setManagedOutputCanvas;
  46672. }
  46673. }
  46674. declare module BABYLON {
  46675. /**
  46676. * Manages an XRSession to work with Babylon's engine
  46677. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46678. */
  46679. export class WebXRSessionManager implements IDisposable {
  46680. /** The scene which the session should be created for */
  46681. scene: Scene;
  46682. private _referenceSpace;
  46683. private _rttProvider;
  46684. private _sessionEnded;
  46685. private _xrNavigator;
  46686. private baseLayer;
  46687. /**
  46688. * The base reference space from which the session started. good if you want to reset your
  46689. * reference space
  46690. */
  46691. baseReferenceSpace: XRReferenceSpace;
  46692. /**
  46693. * Current XR frame
  46694. */
  46695. currentFrame: Nullable<XRFrame>;
  46696. /** WebXR timestamp updated every frame */
  46697. currentTimestamp: number;
  46698. /**
  46699. * Used just in case of a failure to initialize an immersive session.
  46700. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46701. */
  46702. defaultHeightCompensation: number;
  46703. /**
  46704. * Fires every time a new xrFrame arrives which can be used to update the camera
  46705. */
  46706. onXRFrameObservable: Observable<XRFrame>;
  46707. /**
  46708. * Fires when the reference space changed
  46709. */
  46710. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46711. /**
  46712. * Fires when the xr session is ended either by the device or manually done
  46713. */
  46714. onXRSessionEnded: Observable<any>;
  46715. /**
  46716. * Fires when the xr session is ended either by the device or manually done
  46717. */
  46718. onXRSessionInit: Observable<XRSession>;
  46719. /**
  46720. * Underlying xr session
  46721. */
  46722. session: XRSession;
  46723. /**
  46724. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46725. * or get the offset the player is currently at.
  46726. */
  46727. viewerReferenceSpace: XRReferenceSpace;
  46728. /**
  46729. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46730. * @param scene The scene which the session should be created for
  46731. */
  46732. constructor(
  46733. /** The scene which the session should be created for */
  46734. scene: Scene);
  46735. /**
  46736. * The current reference space used in this session. This reference space can constantly change!
  46737. * It is mainly used to offset the camera's position.
  46738. */
  46739. get referenceSpace(): XRReferenceSpace;
  46740. /**
  46741. * Set a new reference space and triggers the observable
  46742. */
  46743. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46744. /**
  46745. * Disposes of the session manager
  46746. */
  46747. dispose(): void;
  46748. /**
  46749. * Stops the xrSession and restores the render loop
  46750. * @returns Promise which resolves after it exits XR
  46751. */
  46752. exitXRAsync(): Promise<void>;
  46753. /**
  46754. * Gets the correct render target texture to be rendered this frame for this eye
  46755. * @param eye the eye for which to get the render target
  46756. * @returns the render target for the specified eye
  46757. */
  46758. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46759. /**
  46760. * Creates a WebXRRenderTarget object for the XR session
  46761. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46762. * @param options optional options to provide when creating a new render target
  46763. * @returns a WebXR render target to which the session can render
  46764. */
  46765. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46766. /**
  46767. * Initializes the manager
  46768. * After initialization enterXR can be called to start an XR session
  46769. * @returns Promise which resolves after it is initialized
  46770. */
  46771. initializeAsync(): Promise<void>;
  46772. /**
  46773. * Initializes an xr session
  46774. * @param xrSessionMode mode to initialize
  46775. * @param xrSessionInit defines optional and required values to pass to the session builder
  46776. * @returns a promise which will resolve once the session has been initialized
  46777. */
  46778. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46779. /**
  46780. * Checks if a session would be supported for the creation options specified
  46781. * @param sessionMode session mode to check if supported eg. immersive-vr
  46782. * @returns A Promise that resolves to true if supported and false if not
  46783. */
  46784. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46785. /**
  46786. * Resets the reference space to the one started the session
  46787. */
  46788. resetReferenceSpace(): void;
  46789. /**
  46790. * Starts rendering to the xr layer
  46791. */
  46792. runXRRenderLoop(): void;
  46793. /**
  46794. * Sets the reference space on the xr session
  46795. * @param referenceSpaceType space to set
  46796. * @returns a promise that will resolve once the reference space has been set
  46797. */
  46798. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46799. /**
  46800. * Updates the render state of the session
  46801. * @param state state to set
  46802. * @returns a promise that resolves once the render state has been updated
  46803. */
  46804. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46805. /**
  46806. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46807. * @param sessionMode defines the session to test
  46808. * @returns a promise with boolean as final value
  46809. */
  46810. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46811. private _createRenderTargetTexture;
  46812. }
  46813. }
  46814. declare module BABYLON {
  46815. /**
  46816. * WebXR Camera which holds the views for the xrSession
  46817. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46818. */
  46819. export class WebXRCamera extends FreeCamera {
  46820. private _xrSessionManager;
  46821. private _firstFrame;
  46822. private _referenceQuaternion;
  46823. private _referencedPosition;
  46824. private _xrInvPositionCache;
  46825. private _xrInvQuaternionCache;
  46826. /**
  46827. * Should position compensation execute on first frame.
  46828. * This is used when copying the position from a native (non XR) camera
  46829. */
  46830. compensateOnFirstFrame: boolean;
  46831. /**
  46832. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46833. * @param name the name of the camera
  46834. * @param scene the scene to add the camera to
  46835. * @param _xrSessionManager a constructed xr session manager
  46836. */
  46837. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46838. /**
  46839. * Return the user's height, unrelated to the current ground.
  46840. * This will be the y position of this camera, when ground level is 0.
  46841. */
  46842. get realWorldHeight(): number;
  46843. /** @hidden */
  46844. _updateForDualEyeDebugging(): void;
  46845. /**
  46846. * Sets this camera's transformation based on a non-vr camera
  46847. * @param otherCamera the non-vr camera to copy the transformation from
  46848. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46849. */
  46850. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46851. /**
  46852. * Gets the current instance class name ("WebXRCamera").
  46853. * @returns the class name
  46854. */
  46855. getClassName(): string;
  46856. private _rotate180;
  46857. private _updateFromXRSession;
  46858. private _updateNumberOfRigCameras;
  46859. private _updateReferenceSpace;
  46860. private _updateReferenceSpaceOffset;
  46861. }
  46862. }
  46863. declare module BABYLON {
  46864. /**
  46865. * Defining the interface required for a (webxr) feature
  46866. */
  46867. export interface IWebXRFeature extends IDisposable {
  46868. /**
  46869. * Is this feature attached
  46870. */
  46871. attached: boolean;
  46872. /**
  46873. * Should auto-attach be disabled?
  46874. */
  46875. disableAutoAttach: boolean;
  46876. /**
  46877. * Attach the feature to the session
  46878. * Will usually be called by the features manager
  46879. *
  46880. * @param force should attachment be forced (even when already attached)
  46881. * @returns true if successful.
  46882. */
  46883. attach(force?: boolean): boolean;
  46884. /**
  46885. * Detach the feature from the session
  46886. * Will usually be called by the features manager
  46887. *
  46888. * @returns true if successful.
  46889. */
  46890. detach(): boolean;
  46891. /**
  46892. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  46893. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  46894. *
  46895. * @returns whether or not the feature is compatible in this environment
  46896. */
  46897. isCompatible(): boolean;
  46898. /**
  46899. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  46900. */
  46901. xrNativeFeatureName?: string;
  46902. }
  46903. /**
  46904. * A list of the currently available features without referencing them
  46905. */
  46906. export class WebXRFeatureName {
  46907. /**
  46908. * The name of the anchor system feature
  46909. */
  46910. static ANCHOR_SYSTEM: string;
  46911. /**
  46912. * The name of the background remover feature
  46913. */
  46914. static BACKGROUND_REMOVER: string;
  46915. /**
  46916. * The name of the hit test feature
  46917. */
  46918. static HIT_TEST: string;
  46919. /**
  46920. * physics impostors for xr controllers feature
  46921. */
  46922. static PHYSICS_CONTROLLERS: string;
  46923. /**
  46924. * The name of the plane detection feature
  46925. */
  46926. static PLANE_DETECTION: string;
  46927. /**
  46928. * The name of the pointer selection feature
  46929. */
  46930. static POINTER_SELECTION: string;
  46931. /**
  46932. * The name of the teleportation feature
  46933. */
  46934. static TELEPORTATION: string;
  46935. }
  46936. /**
  46937. * Defining the constructor of a feature. Used to register the modules.
  46938. */
  46939. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  46940. /**
  46941. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46942. * It is mainly used in AR sessions.
  46943. *
  46944. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46945. */
  46946. export class WebXRFeaturesManager implements IDisposable {
  46947. private _xrSessionManager;
  46948. private static readonly _AvailableFeatures;
  46949. private _features;
  46950. /**
  46951. * constructs a new features manages.
  46952. *
  46953. * @param _xrSessionManager an instance of WebXRSessionManager
  46954. */
  46955. constructor(_xrSessionManager: WebXRSessionManager);
  46956. /**
  46957. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46958. * Mainly used internally.
  46959. *
  46960. * @param featureName the name of the feature to register
  46961. * @param constructorFunction the function used to construct the module
  46962. * @param version the (babylon) version of the module
  46963. * @param stable is that a stable version of this module
  46964. */
  46965. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46966. /**
  46967. * Returns a constructor of a specific feature.
  46968. *
  46969. * @param featureName the name of the feature to construct
  46970. * @param version the version of the feature to load
  46971. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46972. * @param options optional options provided to the module.
  46973. * @returns a function that, when called, will return a new instance of this feature
  46974. */
  46975. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  46976. /**
  46977. * Can be used to return the list of features currently registered
  46978. *
  46979. * @returns an Array of available features
  46980. */
  46981. static GetAvailableFeatures(): string[];
  46982. /**
  46983. * Gets the versions available for a specific feature
  46984. * @param featureName the name of the feature
  46985. * @returns an array with the available versions
  46986. */
  46987. static GetAvailableVersions(featureName: string): string[];
  46988. /**
  46989. * Return the latest unstable version of this feature
  46990. * @param featureName the name of the feature to search
  46991. * @returns the version number. if not found will return -1
  46992. */
  46993. static GetLatestVersionOfFeature(featureName: string): number;
  46994. /**
  46995. * Return the latest stable version of this feature
  46996. * @param featureName the name of the feature to search
  46997. * @returns the version number. if not found will return -1
  46998. */
  46999. static GetStableVersionOfFeature(featureName: string): number;
  47000. /**
  47001. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47002. * Can be used during a session to start a feature
  47003. * @param featureName the name of feature to attach
  47004. */
  47005. attachFeature(featureName: string): void;
  47006. /**
  47007. * Can be used inside a session or when the session ends to detach a specific feature
  47008. * @param featureName the name of the feature to detach
  47009. */
  47010. detachFeature(featureName: string): void;
  47011. /**
  47012. * Used to disable an already-enabled feature
  47013. * The feature will be disposed and will be recreated once enabled.
  47014. * @param featureName the feature to disable
  47015. * @returns true if disable was successful
  47016. */
  47017. disableFeature(featureName: string | {
  47018. Name: string;
  47019. }): boolean;
  47020. /**
  47021. * dispose this features manager
  47022. */
  47023. dispose(): void;
  47024. /**
  47025. * 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.
  47026. * 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.
  47027. *
  47028. * @param featureName the name of the feature to load or the class of the feature
  47029. * @param version optional version to load. if not provided the latest version will be enabled
  47030. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47031. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47032. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47033. * @returns a new constructed feature or throws an error if feature not found.
  47034. */
  47035. enableFeature(featureName: string | {
  47036. Name: string;
  47037. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47038. /**
  47039. * get the implementation of an enabled feature.
  47040. * @param featureName the name of the feature to load
  47041. * @returns the feature class, if found
  47042. */
  47043. getEnabledFeature(featureName: string): IWebXRFeature;
  47044. /**
  47045. * Get the list of enabled features
  47046. * @returns an array of enabled features
  47047. */
  47048. getEnabledFeatures(): string[];
  47049. /**
  47050. * This function will exten the session creation configuration object with enabled features.
  47051. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47052. * according to the defined "required" variable, provided during enableFeature call
  47053. * @param xrSessionInit the xr Session init object to extend
  47054. *
  47055. * @returns an extended XRSessionInit object
  47056. */
  47057. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47058. }
  47059. }
  47060. declare module BABYLON {
  47061. /**
  47062. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47063. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47064. */
  47065. export class WebXRExperienceHelper implements IDisposable {
  47066. private scene;
  47067. private _nonVRCamera;
  47068. private _originalSceneAutoClear;
  47069. private _supported;
  47070. /**
  47071. * Camera used to render xr content
  47072. */
  47073. camera: WebXRCamera;
  47074. /** A features manager for this xr session */
  47075. featuresManager: WebXRFeaturesManager;
  47076. /**
  47077. * Observers registered here will be triggered after the camera's initial transformation is set
  47078. * This can be used to set a different ground level or an extra rotation.
  47079. *
  47080. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47081. * to the position set after this observable is done executing.
  47082. */
  47083. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47084. /**
  47085. * Fires when the state of the experience helper has changed
  47086. */
  47087. onStateChangedObservable: Observable<WebXRState>;
  47088. /** Session manager used to keep track of xr session */
  47089. sessionManager: WebXRSessionManager;
  47090. /**
  47091. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47092. */
  47093. state: WebXRState;
  47094. /**
  47095. * Creates a WebXRExperienceHelper
  47096. * @param scene The scene the helper should be created in
  47097. */
  47098. private constructor();
  47099. /**
  47100. * Creates the experience helper
  47101. * @param scene the scene to attach the experience helper to
  47102. * @returns a promise for the experience helper
  47103. */
  47104. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47105. /**
  47106. * Disposes of the experience helper
  47107. */
  47108. dispose(): void;
  47109. /**
  47110. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47111. * @param sessionMode options for the XR session
  47112. * @param referenceSpaceType frame of reference of the XR session
  47113. * @param renderTarget the output canvas that will be used to enter XR mode
  47114. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47115. * @returns promise that resolves after xr mode has entered
  47116. */
  47117. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47118. /**
  47119. * Exits XR mode and returns the scene to its original state
  47120. * @returns promise that resolves after xr mode has exited
  47121. */
  47122. exitXRAsync(): Promise<void>;
  47123. private _nonXRToXRCamera;
  47124. private _setState;
  47125. }
  47126. }
  47127. declare module BABYLON {
  47128. /**
  47129. * X-Y values for axes in WebXR
  47130. */
  47131. export interface IWebXRMotionControllerAxesValue {
  47132. /**
  47133. * The value of the x axis
  47134. */
  47135. x: number;
  47136. /**
  47137. * The value of the y-axis
  47138. */
  47139. y: number;
  47140. }
  47141. /**
  47142. * changed / previous values for the values of this component
  47143. */
  47144. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47145. /**
  47146. * current (this frame) value
  47147. */
  47148. current: T;
  47149. /**
  47150. * previous (last change) value
  47151. */
  47152. previous: T;
  47153. }
  47154. /**
  47155. * Represents changes in the component between current frame and last values recorded
  47156. */
  47157. export interface IWebXRMotionControllerComponentChanges {
  47158. /**
  47159. * will be populated with previous and current values if axes changed
  47160. */
  47161. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47162. /**
  47163. * will be populated with previous and current values if pressed changed
  47164. */
  47165. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47166. /**
  47167. * will be populated with previous and current values if touched changed
  47168. */
  47169. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47170. /**
  47171. * will be populated with previous and current values if value changed
  47172. */
  47173. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47174. }
  47175. /**
  47176. * This class represents a single component (for example button or thumbstick) of a motion controller
  47177. */
  47178. export class WebXRControllerComponent implements IDisposable {
  47179. /**
  47180. * the id of this component
  47181. */
  47182. id: string;
  47183. /**
  47184. * the type of the component
  47185. */
  47186. type: MotionControllerComponentType;
  47187. private _buttonIndex;
  47188. private _axesIndices;
  47189. private _axes;
  47190. private _changes;
  47191. private _currentValue;
  47192. private _hasChanges;
  47193. private _pressed;
  47194. private _touched;
  47195. /**
  47196. * button component type
  47197. */
  47198. static BUTTON_TYPE: MotionControllerComponentType;
  47199. /**
  47200. * squeeze component type
  47201. */
  47202. static SQUEEZE_TYPE: MotionControllerComponentType;
  47203. /**
  47204. * Thumbstick component type
  47205. */
  47206. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47207. /**
  47208. * Touchpad component type
  47209. */
  47210. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47211. /**
  47212. * trigger component type
  47213. */
  47214. static TRIGGER_TYPE: MotionControllerComponentType;
  47215. /**
  47216. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47217. * the axes data changes
  47218. */
  47219. onAxisValueChangedObservable: Observable<{
  47220. x: number;
  47221. y: number;
  47222. }>;
  47223. /**
  47224. * Observers registered here will be triggered when the state of a button changes
  47225. * State change is either pressed / touched / value
  47226. */
  47227. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47228. /**
  47229. * Creates a new component for a motion controller.
  47230. * It is created by the motion controller itself
  47231. *
  47232. * @param id the id of this component
  47233. * @param type the type of the component
  47234. * @param _buttonIndex index in the buttons array of the gamepad
  47235. * @param _axesIndices indices of the values in the axes array of the gamepad
  47236. */
  47237. constructor(
  47238. /**
  47239. * the id of this component
  47240. */
  47241. id: string,
  47242. /**
  47243. * the type of the component
  47244. */
  47245. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47246. /**
  47247. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47248. */
  47249. get axes(): IWebXRMotionControllerAxesValue;
  47250. /**
  47251. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47252. */
  47253. get changes(): IWebXRMotionControllerComponentChanges;
  47254. /**
  47255. * Return whether or not the component changed the last frame
  47256. */
  47257. get hasChanges(): boolean;
  47258. /**
  47259. * is the button currently pressed
  47260. */
  47261. get pressed(): boolean;
  47262. /**
  47263. * is the button currently touched
  47264. */
  47265. get touched(): boolean;
  47266. /**
  47267. * Get the current value of this component
  47268. */
  47269. get value(): number;
  47270. /**
  47271. * Dispose this component
  47272. */
  47273. dispose(): void;
  47274. /**
  47275. * Are there axes correlating to this component
  47276. * @return true is axes data is available
  47277. */
  47278. isAxes(): boolean;
  47279. /**
  47280. * Is this component a button (hence - pressable)
  47281. * @returns true if can be pressed
  47282. */
  47283. isButton(): boolean;
  47284. /**
  47285. * update this component using the gamepad object it is in. Called on every frame
  47286. * @param nativeController the native gamepad controller object
  47287. */
  47288. update(nativeController: IMinimalMotionControllerObject): void;
  47289. }
  47290. }
  47291. declare module BABYLON {
  47292. /**
  47293. * Interface used to represent data loading progression
  47294. */
  47295. export interface ISceneLoaderProgressEvent {
  47296. /**
  47297. * Defines if data length to load can be evaluated
  47298. */
  47299. readonly lengthComputable: boolean;
  47300. /**
  47301. * Defines the loaded data length
  47302. */
  47303. readonly loaded: number;
  47304. /**
  47305. * Defines the data length to load
  47306. */
  47307. readonly total: number;
  47308. }
  47309. /**
  47310. * Interface used by SceneLoader plugins to define supported file extensions
  47311. */
  47312. export interface ISceneLoaderPluginExtensions {
  47313. /**
  47314. * Defines the list of supported extensions
  47315. */
  47316. [extension: string]: {
  47317. isBinary: boolean;
  47318. };
  47319. }
  47320. /**
  47321. * Interface used by SceneLoader plugin factory
  47322. */
  47323. export interface ISceneLoaderPluginFactory {
  47324. /**
  47325. * Defines the name of the factory
  47326. */
  47327. name: string;
  47328. /**
  47329. * Function called to create a new plugin
  47330. * @return the new plugin
  47331. */
  47332. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47333. /**
  47334. * The callback that returns true if the data can be directly loaded.
  47335. * @param data string containing the file data
  47336. * @returns if the data can be loaded directly
  47337. */
  47338. canDirectLoad?(data: string): boolean;
  47339. }
  47340. /**
  47341. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47342. */
  47343. export interface ISceneLoaderPluginBase {
  47344. /**
  47345. * The friendly name of this plugin.
  47346. */
  47347. name: string;
  47348. /**
  47349. * The file extensions supported by this plugin.
  47350. */
  47351. extensions: string | ISceneLoaderPluginExtensions;
  47352. /**
  47353. * The callback called when loading from a url.
  47354. * @param scene scene loading this url
  47355. * @param url url to load
  47356. * @param onSuccess callback called when the file successfully loads
  47357. * @param onProgress callback called while file is loading (if the server supports this mode)
  47358. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47359. * @param onError callback called when the file fails to load
  47360. * @returns a file request object
  47361. */
  47362. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47363. /**
  47364. * The callback called when loading from a file object.
  47365. * @param scene scene loading this file
  47366. * @param file defines the file to load
  47367. * @param onSuccess defines the callback to call when data is loaded
  47368. * @param onProgress defines the callback to call during loading process
  47369. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47370. * @param onError defines the callback to call when an error occurs
  47371. * @returns a file request object
  47372. */
  47373. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47374. /**
  47375. * The callback that returns true if the data can be directly loaded.
  47376. * @param data string containing the file data
  47377. * @returns if the data can be loaded directly
  47378. */
  47379. canDirectLoad?(data: string): boolean;
  47380. /**
  47381. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47382. * @param scene scene loading this data
  47383. * @param data string containing the data
  47384. * @returns data to pass to the plugin
  47385. */
  47386. directLoad?(scene: Scene, data: string): any;
  47387. /**
  47388. * The callback that allows custom handling of the root url based on the response url.
  47389. * @param rootUrl the original root url
  47390. * @param responseURL the response url if available
  47391. * @returns the new root url
  47392. */
  47393. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47394. }
  47395. /**
  47396. * Interface used to define a SceneLoader plugin
  47397. */
  47398. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47399. /**
  47400. * Import meshes into a scene.
  47401. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47402. * @param scene The scene to import into
  47403. * @param data The data to import
  47404. * @param rootUrl The root url for scene and resources
  47405. * @param meshes The meshes array to import into
  47406. * @param particleSystems The particle systems array to import into
  47407. * @param skeletons The skeletons array to import into
  47408. * @param onError The callback when import fails
  47409. * @returns True if successful or false otherwise
  47410. */
  47411. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47412. /**
  47413. * Load into a scene.
  47414. * @param scene The scene to load into
  47415. * @param data The data to import
  47416. * @param rootUrl The root url for scene and resources
  47417. * @param onError The callback when import fails
  47418. * @returns True if successful or false otherwise
  47419. */
  47420. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47421. /**
  47422. * Load into an asset container.
  47423. * @param scene The scene to load into
  47424. * @param data The data to import
  47425. * @param rootUrl The root url for scene and resources
  47426. * @param onError The callback when import fails
  47427. * @returns The loaded asset container
  47428. */
  47429. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47430. }
  47431. /**
  47432. * Interface used to define an async SceneLoader plugin
  47433. */
  47434. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47435. /**
  47436. * Import meshes into a scene.
  47437. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47438. * @param scene The scene to import into
  47439. * @param data The data to import
  47440. * @param rootUrl The root url for scene and resources
  47441. * @param onProgress The callback when the load progresses
  47442. * @param fileName Defines the name of the file to load
  47443. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47444. */
  47445. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47446. meshes: AbstractMesh[];
  47447. particleSystems: IParticleSystem[];
  47448. skeletons: Skeleton[];
  47449. animationGroups: AnimationGroup[];
  47450. }>;
  47451. /**
  47452. * Load into a scene.
  47453. * @param scene The scene to load into
  47454. * @param data The data to import
  47455. * @param rootUrl The root url for scene and resources
  47456. * @param onProgress The callback when the load progresses
  47457. * @param fileName Defines the name of the file to load
  47458. * @returns Nothing
  47459. */
  47460. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47461. /**
  47462. * Load into an asset container.
  47463. * @param scene The scene to load into
  47464. * @param data The data to import
  47465. * @param rootUrl The root url for scene and resources
  47466. * @param onProgress The callback when the load progresses
  47467. * @param fileName Defines the name of the file to load
  47468. * @returns The loaded asset container
  47469. */
  47470. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47471. }
  47472. /**
  47473. * Mode that determines how to handle old animation groups before loading new ones.
  47474. */
  47475. export enum SceneLoaderAnimationGroupLoadingMode {
  47476. /**
  47477. * Reset all old animations to initial state then dispose them.
  47478. */
  47479. Clean = 0,
  47480. /**
  47481. * Stop all old animations.
  47482. */
  47483. Stop = 1,
  47484. /**
  47485. * Restart old animations from first frame.
  47486. */
  47487. Sync = 2,
  47488. /**
  47489. * Old animations remains untouched.
  47490. */
  47491. NoSync = 3
  47492. }
  47493. /**
  47494. * Defines a plugin registered by the SceneLoader
  47495. */
  47496. interface IRegisteredPlugin {
  47497. /**
  47498. * Defines the plugin to use
  47499. */
  47500. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47501. /**
  47502. * Defines if the plugin supports binary data
  47503. */
  47504. isBinary: boolean;
  47505. }
  47506. /**
  47507. * Class used to load scene from various file formats using registered plugins
  47508. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47509. */
  47510. export class SceneLoader {
  47511. /**
  47512. * No logging while loading
  47513. */
  47514. static readonly NO_LOGGING: number;
  47515. /**
  47516. * Minimal logging while loading
  47517. */
  47518. static readonly MINIMAL_LOGGING: number;
  47519. /**
  47520. * Summary logging while loading
  47521. */
  47522. static readonly SUMMARY_LOGGING: number;
  47523. /**
  47524. * Detailled logging while loading
  47525. */
  47526. static readonly DETAILED_LOGGING: number;
  47527. /**
  47528. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47529. */
  47530. static get ForceFullSceneLoadingForIncremental(): boolean;
  47531. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47532. /**
  47533. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47534. */
  47535. static get ShowLoadingScreen(): boolean;
  47536. static set ShowLoadingScreen(value: boolean);
  47537. /**
  47538. * Defines the current logging level (while loading the scene)
  47539. * @ignorenaming
  47540. */
  47541. static get loggingLevel(): number;
  47542. static set loggingLevel(value: number);
  47543. /**
  47544. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47545. */
  47546. static get CleanBoneMatrixWeights(): boolean;
  47547. static set CleanBoneMatrixWeights(value: boolean);
  47548. /**
  47549. * Event raised when a plugin is used to load a scene
  47550. */
  47551. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47552. private static _registeredPlugins;
  47553. private static _showingLoadingScreen;
  47554. /**
  47555. * Gets the default plugin (used to load Babylon files)
  47556. * @returns the .babylon plugin
  47557. */
  47558. static GetDefaultPlugin(): IRegisteredPlugin;
  47559. private static _GetPluginForExtension;
  47560. private static _GetPluginForDirectLoad;
  47561. private static _GetPluginForFilename;
  47562. private static _GetDirectLoad;
  47563. private static _LoadData;
  47564. private static _GetFileInfo;
  47565. /**
  47566. * Gets a plugin that can load the given extension
  47567. * @param extension defines the extension to load
  47568. * @returns a plugin or null if none works
  47569. */
  47570. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47571. /**
  47572. * Gets a boolean indicating that the given extension can be loaded
  47573. * @param extension defines the extension to load
  47574. * @returns true if the extension is supported
  47575. */
  47576. static IsPluginForExtensionAvailable(extension: string): boolean;
  47577. /**
  47578. * Adds a new plugin to the list of registered plugins
  47579. * @param plugin defines the plugin to add
  47580. */
  47581. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47582. /**
  47583. * Import meshes into a scene
  47584. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47585. * @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)
  47586. * @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)
  47587. * @param scene the instance of BABYLON.Scene to append to
  47588. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47589. * @param onProgress a callback with a progress event for each file being loaded
  47590. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47591. * @param pluginExtension the extension used to determine the plugin
  47592. * @returns The loaded plugin
  47593. */
  47594. 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>;
  47595. /**
  47596. * Import meshes into a scene
  47597. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47598. * @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)
  47599. * @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)
  47600. * @param scene the instance of BABYLON.Scene to append to
  47601. * @param onProgress a callback with a progress event for each file being loaded
  47602. * @param pluginExtension the extension used to determine the plugin
  47603. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47604. */
  47605. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47606. meshes: AbstractMesh[];
  47607. particleSystems: IParticleSystem[];
  47608. skeletons: Skeleton[];
  47609. animationGroups: AnimationGroup[];
  47610. }>;
  47611. /**
  47612. * Load a scene
  47613. * @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)
  47614. * @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)
  47615. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47616. * @param onSuccess a callback with the scene when import succeeds
  47617. * @param onProgress a callback with a progress event for each file being loaded
  47618. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47619. * @param pluginExtension the extension used to determine the plugin
  47620. * @returns The loaded plugin
  47621. */
  47622. 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>;
  47623. /**
  47624. * Load a scene
  47625. * @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)
  47626. * @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)
  47627. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47628. * @param onProgress a callback with a progress event for each file being loaded
  47629. * @param pluginExtension the extension used to determine the plugin
  47630. * @returns The loaded scene
  47631. */
  47632. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47633. /**
  47634. * Append a scene
  47635. * @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)
  47636. * @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)
  47637. * @param scene is the instance of BABYLON.Scene to append to
  47638. * @param onSuccess a callback with the scene when import succeeds
  47639. * @param onProgress a callback with a progress event for each file being loaded
  47640. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47641. * @param pluginExtension the extension used to determine the plugin
  47642. * @returns The loaded plugin
  47643. */
  47644. 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>;
  47645. /**
  47646. * Append a scene
  47647. * @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)
  47648. * @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)
  47649. * @param scene is the instance of BABYLON.Scene to append to
  47650. * @param onProgress a callback with a progress event for each file being loaded
  47651. * @param pluginExtension the extension used to determine the plugin
  47652. * @returns The given scene
  47653. */
  47654. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47655. /**
  47656. * Load a scene into an asset container
  47657. * @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)
  47658. * @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)
  47659. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47660. * @param onSuccess a callback with the scene when import succeeds
  47661. * @param onProgress a callback with a progress event for each file being loaded
  47662. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47663. * @param pluginExtension the extension used to determine the plugin
  47664. * @returns The loaded plugin
  47665. */
  47666. 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>;
  47667. /**
  47668. * Load a scene into an asset container
  47669. * @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)
  47670. * @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)
  47671. * @param scene is the instance of Scene to append to
  47672. * @param onProgress a callback with a progress event for each file being loaded
  47673. * @param pluginExtension the extension used to determine the plugin
  47674. * @returns The loaded asset container
  47675. */
  47676. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47677. /**
  47678. * Import animations from a file into a scene
  47679. * @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)
  47680. * @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)
  47681. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47682. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47683. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47684. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47685. * @param onSuccess a callback with the scene when import succeeds
  47686. * @param onProgress a callback with a progress event for each file being loaded
  47687. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47688. * @param pluginExtension the extension used to determine the plugin
  47689. */
  47690. 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;
  47691. /**
  47692. * Import animations from a file into a scene
  47693. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  47694. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  47695. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47696. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47697. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47698. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47699. * @param onSuccess a callback with the scene when import succeeds
  47700. * @param onProgress a callback with a progress event for each file being loaded
  47701. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47702. * @param pluginExtension the extension used to determine the plugin
  47703. * @returns the updated scene with imported animations
  47704. */
  47705. 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>;
  47706. }
  47707. }
  47708. declare module BABYLON {
  47709. /**
  47710. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47711. */
  47712. export type MotionControllerHandedness = "none" | "left" | "right";
  47713. /**
  47714. * The type of components available in motion controllers.
  47715. * This is not the name of the component.
  47716. */
  47717. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47718. /**
  47719. * The state of a controller component
  47720. */
  47721. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47722. /**
  47723. * The schema of motion controller layout.
  47724. * No object will be initialized using this interface
  47725. * This is used just to define the profile.
  47726. */
  47727. export interface IMotionControllerLayout {
  47728. /**
  47729. * Path to load the assets. Usually relative to the base path
  47730. */
  47731. assetPath: string;
  47732. /**
  47733. * Available components (unsorted)
  47734. */
  47735. components: {
  47736. /**
  47737. * A map of component Ids
  47738. */
  47739. [componentId: string]: {
  47740. /**
  47741. * The type of input the component outputs
  47742. */
  47743. type: MotionControllerComponentType;
  47744. /**
  47745. * The indices of this component in the gamepad object
  47746. */
  47747. gamepadIndices: {
  47748. /**
  47749. * Index of button
  47750. */
  47751. button?: number;
  47752. /**
  47753. * If available, index of x-axis
  47754. */
  47755. xAxis?: number;
  47756. /**
  47757. * If available, index of y-axis
  47758. */
  47759. yAxis?: number;
  47760. };
  47761. /**
  47762. * The mesh's root node name
  47763. */
  47764. rootNodeName: string;
  47765. /**
  47766. * Animation definitions for this model
  47767. */
  47768. visualResponses: {
  47769. [stateKey: string]: {
  47770. /**
  47771. * What property will be animated
  47772. */
  47773. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47774. /**
  47775. * What states influence this visual response
  47776. */
  47777. states: MotionControllerComponentStateType[];
  47778. /**
  47779. * Type of animation - movement or visibility
  47780. */
  47781. valueNodeProperty: "transform" | "visibility";
  47782. /**
  47783. * Base node name to move. Its position will be calculated according to the min and max nodes
  47784. */
  47785. valueNodeName?: string;
  47786. /**
  47787. * Minimum movement node
  47788. */
  47789. minNodeName?: string;
  47790. /**
  47791. * Max movement node
  47792. */
  47793. maxNodeName?: string;
  47794. };
  47795. };
  47796. /**
  47797. * If touch enabled, what is the name of node to display user feedback
  47798. */
  47799. touchPointNodeName?: string;
  47800. };
  47801. };
  47802. /**
  47803. * Is it xr standard mapping or not
  47804. */
  47805. gamepadMapping: "" | "xr-standard";
  47806. /**
  47807. * Base root node of this entire model
  47808. */
  47809. rootNodeName: string;
  47810. /**
  47811. * Defines the main button component id
  47812. */
  47813. selectComponentId: string;
  47814. }
  47815. /**
  47816. * A definition for the layout map in the input profile
  47817. */
  47818. export interface IMotionControllerLayoutMap {
  47819. /**
  47820. * Layouts with handedness type as a key
  47821. */
  47822. [handedness: string]: IMotionControllerLayout;
  47823. }
  47824. /**
  47825. * The XR Input profile schema
  47826. * Profiles can be found here:
  47827. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47828. */
  47829. export interface IMotionControllerProfile {
  47830. /**
  47831. * fallback profiles for this profileId
  47832. */
  47833. fallbackProfileIds: string[];
  47834. /**
  47835. * The layout map, with handedness as key
  47836. */
  47837. layouts: IMotionControllerLayoutMap;
  47838. /**
  47839. * The id of this profile
  47840. * correlates to the profile(s) in the xrInput.profiles array
  47841. */
  47842. profileId: string;
  47843. }
  47844. /**
  47845. * A helper-interface for the 3 meshes needed for controller button animation
  47846. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47847. */
  47848. export interface IMotionControllerButtonMeshMap {
  47849. /**
  47850. * the mesh that defines the pressed value mesh position.
  47851. * This is used to find the max-position of this button
  47852. */
  47853. pressedMesh: AbstractMesh;
  47854. /**
  47855. * the mesh that defines the unpressed value mesh position.
  47856. * This is used to find the min (or initial) position of this button
  47857. */
  47858. unpressedMesh: AbstractMesh;
  47859. /**
  47860. * The mesh that will be changed when value changes
  47861. */
  47862. valueMesh: AbstractMesh;
  47863. }
  47864. /**
  47865. * A helper-interface for the 3 meshes needed for controller axis animation.
  47866. * This will be expanded when touchpad animations are fully supported
  47867. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47868. */
  47869. export interface IMotionControllerMeshMap {
  47870. /**
  47871. * the mesh that defines the maximum value mesh position.
  47872. */
  47873. maxMesh?: AbstractMesh;
  47874. /**
  47875. * the mesh that defines the minimum value mesh position.
  47876. */
  47877. minMesh?: AbstractMesh;
  47878. /**
  47879. * The mesh that will be changed when axis value changes
  47880. */
  47881. valueMesh: AbstractMesh;
  47882. }
  47883. /**
  47884. * The elements needed for change-detection of the gamepad objects in motion controllers
  47885. */
  47886. export interface IMinimalMotionControllerObject {
  47887. /**
  47888. * Available axes of this controller
  47889. */
  47890. axes: number[];
  47891. /**
  47892. * An array of available buttons
  47893. */
  47894. buttons: Array<{
  47895. /**
  47896. * Value of the button/trigger
  47897. */
  47898. value: number;
  47899. /**
  47900. * If the button/trigger is currently touched
  47901. */
  47902. touched: boolean;
  47903. /**
  47904. * If the button/trigger is currently pressed
  47905. */
  47906. pressed: boolean;
  47907. }>;
  47908. /**
  47909. * EXPERIMENTAL haptic support.
  47910. */
  47911. hapticActuators?: Array<{
  47912. pulse: (value: number, duration: number) => Promise<boolean>;
  47913. }>;
  47914. }
  47915. /**
  47916. * An Abstract Motion controller
  47917. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47918. * Each component has an observable to check for changes in value and state
  47919. */
  47920. export abstract class WebXRAbstractMotionController implements IDisposable {
  47921. protected scene: Scene;
  47922. protected layout: IMotionControllerLayout;
  47923. /**
  47924. * The gamepad object correlating to this controller
  47925. */
  47926. gamepadObject: IMinimalMotionControllerObject;
  47927. /**
  47928. * handedness (left/right/none) of this controller
  47929. */
  47930. handedness: MotionControllerHandedness;
  47931. private _initComponent;
  47932. private _modelReady;
  47933. /**
  47934. * A map of components (WebXRControllerComponent) in this motion controller
  47935. * Components have a ComponentType and can also have both button and axis definitions
  47936. */
  47937. readonly components: {
  47938. [id: string]: WebXRControllerComponent;
  47939. };
  47940. /**
  47941. * Disable the model's animation. Can be set at any time.
  47942. */
  47943. disableAnimation: boolean;
  47944. /**
  47945. * Observers registered here will be triggered when the model of this controller is done loading
  47946. */
  47947. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47948. /**
  47949. * The profile id of this motion controller
  47950. */
  47951. abstract profileId: string;
  47952. /**
  47953. * The root mesh of the model. It is null if the model was not yet initialized
  47954. */
  47955. rootMesh: Nullable<AbstractMesh>;
  47956. /**
  47957. * constructs a new abstract motion controller
  47958. * @param scene the scene to which the model of the controller will be added
  47959. * @param layout The profile layout to load
  47960. * @param gamepadObject The gamepad object correlating to this controller
  47961. * @param handedness handedness (left/right/none) of this controller
  47962. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47963. */
  47964. constructor(scene: Scene, layout: IMotionControllerLayout,
  47965. /**
  47966. * The gamepad object correlating to this controller
  47967. */
  47968. gamepadObject: IMinimalMotionControllerObject,
  47969. /**
  47970. * handedness (left/right/none) of this controller
  47971. */
  47972. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47973. /**
  47974. * Dispose this controller, the model mesh and all its components
  47975. */
  47976. dispose(): void;
  47977. /**
  47978. * Returns all components of specific type
  47979. * @param type the type to search for
  47980. * @return an array of components with this type
  47981. */
  47982. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47983. /**
  47984. * get a component based an its component id as defined in layout.components
  47985. * @param id the id of the component
  47986. * @returns the component correlates to the id or undefined if not found
  47987. */
  47988. getComponent(id: string): WebXRControllerComponent;
  47989. /**
  47990. * Get the list of components available in this motion controller
  47991. * @returns an array of strings correlating to available components
  47992. */
  47993. getComponentIds(): string[];
  47994. /**
  47995. * Get the first component of specific type
  47996. * @param type type of component to find
  47997. * @return a controller component or null if not found
  47998. */
  47999. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48000. /**
  48001. * Get the main (Select) component of this controller as defined in the layout
  48002. * @returns the main component of this controller
  48003. */
  48004. getMainComponent(): WebXRControllerComponent;
  48005. /**
  48006. * Loads the model correlating to this controller
  48007. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48008. * @returns A promise fulfilled with the result of the model loading
  48009. */
  48010. loadModel(): Promise<boolean>;
  48011. /**
  48012. * Update this model using the current XRFrame
  48013. * @param xrFrame the current xr frame to use and update the model
  48014. */
  48015. updateFromXRFrame(xrFrame: XRFrame): void;
  48016. /**
  48017. * Backwards compatibility due to a deeply-integrated typo
  48018. */
  48019. get handness(): XREye;
  48020. /**
  48021. * Pulse (vibrate) this controller
  48022. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48023. * Consecutive calls to this function will cancel the last pulse call
  48024. *
  48025. * @param value the strength of the pulse in 0.0...1.0 range
  48026. * @param duration Duration of the pulse in milliseconds
  48027. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48028. * @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
  48029. */
  48030. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48031. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48032. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48033. /**
  48034. * Moves the axis on the controller mesh based on its current state
  48035. * @param axis the index of the axis
  48036. * @param axisValue the value of the axis which determines the meshes new position
  48037. * @hidden
  48038. */
  48039. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48040. /**
  48041. * Update the model itself with the current frame data
  48042. * @param xrFrame the frame to use for updating the model mesh
  48043. */
  48044. protected updateModel(xrFrame: XRFrame): void;
  48045. /**
  48046. * Get the filename and path for this controller's model
  48047. * @returns a map of filename and path
  48048. */
  48049. protected abstract _getFilenameAndPath(): {
  48050. filename: string;
  48051. path: string;
  48052. };
  48053. /**
  48054. * This function is called before the mesh is loaded. It checks for loading constraints.
  48055. * For example, this function can check if the GLB loader is available
  48056. * If this function returns false, the generic controller will be loaded instead
  48057. * @returns Is the client ready to load the mesh
  48058. */
  48059. protected abstract _getModelLoadingConstraints(): boolean;
  48060. /**
  48061. * This function will be called after the model was successfully loaded and can be used
  48062. * for mesh transformations before it is available for the user
  48063. * @param meshes the loaded meshes
  48064. */
  48065. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48066. /**
  48067. * Set the root mesh for this controller. Important for the WebXR controller class
  48068. * @param meshes the loaded meshes
  48069. */
  48070. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48071. /**
  48072. * A function executed each frame that updates the mesh (if needed)
  48073. * @param xrFrame the current xrFrame
  48074. */
  48075. protected abstract _updateModel(xrFrame: XRFrame): void;
  48076. private _getGenericFilenameAndPath;
  48077. private _getGenericParentMesh;
  48078. }
  48079. }
  48080. declare module BABYLON {
  48081. /**
  48082. * A generic trigger-only motion controller for WebXR
  48083. */
  48084. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48085. /**
  48086. * Static version of the profile id of this controller
  48087. */
  48088. static ProfileId: string;
  48089. profileId: string;
  48090. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48091. protected _getFilenameAndPath(): {
  48092. filename: string;
  48093. path: string;
  48094. };
  48095. protected _getModelLoadingConstraints(): boolean;
  48096. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48097. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48098. protected _updateModel(): void;
  48099. }
  48100. }
  48101. declare module BABYLON {
  48102. /**
  48103. * Class containing static functions to help procedurally build meshes
  48104. */
  48105. export class SphereBuilder {
  48106. /**
  48107. * Creates a sphere mesh
  48108. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48109. * * 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`)
  48110. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48111. * * 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
  48112. * * 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)
  48113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48114. * * 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
  48115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48116. * @param name defines the name of the mesh
  48117. * @param options defines the options used to create the mesh
  48118. * @param scene defines the hosting scene
  48119. * @returns the sphere mesh
  48120. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48121. */
  48122. static CreateSphere(name: string, options: {
  48123. segments?: number;
  48124. diameter?: number;
  48125. diameterX?: number;
  48126. diameterY?: number;
  48127. diameterZ?: number;
  48128. arc?: number;
  48129. slice?: number;
  48130. sideOrientation?: number;
  48131. frontUVs?: Vector4;
  48132. backUVs?: Vector4;
  48133. updatable?: boolean;
  48134. }, scene?: Nullable<Scene>): Mesh;
  48135. }
  48136. }
  48137. declare module BABYLON {
  48138. /**
  48139. * A profiled motion controller has its profile loaded from an online repository.
  48140. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48141. */
  48142. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48143. private _repositoryUrl;
  48144. private _buttonMeshMapping;
  48145. private _touchDots;
  48146. /**
  48147. * The profile ID of this controller. Will be populated when the controller initializes.
  48148. */
  48149. profileId: string;
  48150. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48151. dispose(): void;
  48152. protected _getFilenameAndPath(): {
  48153. filename: string;
  48154. path: string;
  48155. };
  48156. protected _getModelLoadingConstraints(): boolean;
  48157. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48158. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48159. protected _updateModel(_xrFrame: XRFrame): void;
  48160. }
  48161. }
  48162. declare module BABYLON {
  48163. /**
  48164. * A construction function type to create a new controller based on an xrInput object
  48165. */
  48166. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48167. /**
  48168. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48169. *
  48170. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48171. * it should be replaced with auto-loaded controllers.
  48172. *
  48173. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48174. */
  48175. export class WebXRMotionControllerManager {
  48176. private static _AvailableControllers;
  48177. private static _Fallbacks;
  48178. private static _ProfileLoadingPromises;
  48179. private static _ProfilesList;
  48180. /**
  48181. * The base URL of the online controller repository. Can be changed at any time.
  48182. */
  48183. static BaseRepositoryUrl: string;
  48184. /**
  48185. * Which repository gets priority - local or online
  48186. */
  48187. static PrioritizeOnlineRepository: boolean;
  48188. /**
  48189. * Use the online repository, or use only locally-defined controllers
  48190. */
  48191. static UseOnlineRepository: boolean;
  48192. /**
  48193. * Clear the cache used for profile loading and reload when requested again
  48194. */
  48195. static ClearProfilesCache(): void;
  48196. /**
  48197. * Register the default fallbacks.
  48198. * This function is called automatically when this file is imported.
  48199. */
  48200. static DefaultFallbacks(): void;
  48201. /**
  48202. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48203. * @param profileId the profile to which a fallback needs to be found
  48204. * @return an array with corresponding fallback profiles
  48205. */
  48206. static FindFallbackWithProfileId(profileId: string): string[];
  48207. /**
  48208. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48209. * The order of search:
  48210. *
  48211. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48212. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48213. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48214. * 4) return the generic trigger controller if none were found
  48215. *
  48216. * @param xrInput the xrInput to which a new controller is initialized
  48217. * @param scene the scene to which the model will be added
  48218. * @param forceProfile force a certain profile for this controller
  48219. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48220. */
  48221. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48222. /**
  48223. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48224. *
  48225. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48226. *
  48227. * @param type the profile type to register
  48228. * @param constructFunction the function to be called when loading this profile
  48229. */
  48230. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48231. /**
  48232. * Register a fallback to a specific profile.
  48233. * @param profileId the profileId that will receive the fallbacks
  48234. * @param fallbacks A list of fallback profiles
  48235. */
  48236. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48237. /**
  48238. * Will update the list of profiles available in the repository
  48239. * @return a promise that resolves to a map of profiles available online
  48240. */
  48241. static UpdateProfilesList(): Promise<{
  48242. [profile: string]: string;
  48243. }>;
  48244. private static _LoadProfileFromRepository;
  48245. private static _LoadProfilesFromAvailableControllers;
  48246. }
  48247. }
  48248. declare module BABYLON {
  48249. /**
  48250. * Configuration options for the WebXR controller creation
  48251. */
  48252. export interface IWebXRControllerOptions {
  48253. /**
  48254. * Should the controller mesh be animated when a user interacts with it
  48255. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48256. */
  48257. disableMotionControllerAnimation?: boolean;
  48258. /**
  48259. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48260. */
  48261. doNotLoadControllerMesh?: boolean;
  48262. /**
  48263. * Force a specific controller type for this controller.
  48264. * This can be used when creating your own profile or when testing different controllers
  48265. */
  48266. forceControllerProfile?: string;
  48267. /**
  48268. * Defines a rendering group ID for meshes that will be loaded.
  48269. * This is for the default controllers only.
  48270. */
  48271. renderingGroupId?: number;
  48272. }
  48273. /**
  48274. * Represents an XR controller
  48275. */
  48276. export class WebXRInputSource {
  48277. private _scene;
  48278. /** The underlying input source for the controller */
  48279. inputSource: XRInputSource;
  48280. private _options;
  48281. private _tmpVector;
  48282. private _uniqueId;
  48283. /**
  48284. * 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
  48285. */
  48286. grip?: AbstractMesh;
  48287. /**
  48288. * If available, this is the gamepad object related to this controller.
  48289. * Using this object it is possible to get click events and trackpad changes of the
  48290. * webxr controller that is currently being used.
  48291. */
  48292. motionController?: WebXRAbstractMotionController;
  48293. /**
  48294. * Event that fires when the controller is removed/disposed.
  48295. * The object provided as event data is this controller, after associated assets were disposed.
  48296. * uniqueId is still available.
  48297. */
  48298. onDisposeObservable: Observable<WebXRInputSource>;
  48299. /**
  48300. * Will be triggered when the mesh associated with the motion controller is done loading.
  48301. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48302. * A shortened version of controller -> motion controller -> on mesh loaded.
  48303. */
  48304. onMeshLoadedObservable: Observable<AbstractMesh>;
  48305. /**
  48306. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48307. */
  48308. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48309. /**
  48310. * Pointer which can be used to select objects or attach a visible laser to
  48311. */
  48312. pointer: AbstractMesh;
  48313. /**
  48314. * Creates the input source object
  48315. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48316. * @param _scene the scene which the controller should be associated to
  48317. * @param inputSource the underlying input source for the controller
  48318. * @param _options options for this controller creation
  48319. */
  48320. constructor(_scene: Scene,
  48321. /** The underlying input source for the controller */
  48322. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48323. /**
  48324. * Get this controllers unique id
  48325. */
  48326. get uniqueId(): string;
  48327. /**
  48328. * Disposes of the object
  48329. */
  48330. dispose(): void;
  48331. /**
  48332. * Gets a world space ray coming from the pointer or grip
  48333. * @param result the resulting ray
  48334. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48335. */
  48336. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48337. /**
  48338. * Updates the controller pose based on the given XRFrame
  48339. * @param xrFrame xr frame to update the pose with
  48340. * @param referenceSpace reference space to use
  48341. */
  48342. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48343. }
  48344. }
  48345. declare module BABYLON {
  48346. /**
  48347. * The schema for initialization options of the XR Input class
  48348. */
  48349. export interface IWebXRInputOptions {
  48350. /**
  48351. * If set to true no model will be automatically loaded
  48352. */
  48353. doNotLoadControllerMeshes?: boolean;
  48354. /**
  48355. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48356. * If not found, the xr input profile data will be used.
  48357. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48358. */
  48359. forceInputProfile?: string;
  48360. /**
  48361. * Do not send a request to the controller repository to load the profile.
  48362. *
  48363. * Instead, use the controllers available in babylon itself.
  48364. */
  48365. disableOnlineControllerRepository?: boolean;
  48366. /**
  48367. * A custom URL for the controllers repository
  48368. */
  48369. customControllersRepositoryURL?: string;
  48370. /**
  48371. * Should the controller model's components not move according to the user input
  48372. */
  48373. disableControllerAnimation?: boolean;
  48374. /**
  48375. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48376. */
  48377. controllerOptions?: IWebXRControllerOptions;
  48378. }
  48379. /**
  48380. * XR input used to track XR inputs such as controllers/rays
  48381. */
  48382. export class WebXRInput implements IDisposable {
  48383. /**
  48384. * the xr session manager for this session
  48385. */
  48386. xrSessionManager: WebXRSessionManager;
  48387. /**
  48388. * the WebXR camera for this session. Mainly used for teleportation
  48389. */
  48390. xrCamera: WebXRCamera;
  48391. private readonly options;
  48392. /**
  48393. * XR controllers being tracked
  48394. */
  48395. controllers: Array<WebXRInputSource>;
  48396. private _frameObserver;
  48397. private _sessionEndedObserver;
  48398. private _sessionInitObserver;
  48399. /**
  48400. * Event when a controller has been connected/added
  48401. */
  48402. onControllerAddedObservable: Observable<WebXRInputSource>;
  48403. /**
  48404. * Event when a controller has been removed/disconnected
  48405. */
  48406. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48407. /**
  48408. * Initializes the WebXRInput
  48409. * @param xrSessionManager the xr session manager for this session
  48410. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48411. * @param options = initialization options for this xr input
  48412. */
  48413. constructor(
  48414. /**
  48415. * the xr session manager for this session
  48416. */
  48417. xrSessionManager: WebXRSessionManager,
  48418. /**
  48419. * the WebXR camera for this session. Mainly used for teleportation
  48420. */
  48421. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48422. private _onInputSourcesChange;
  48423. private _addAndRemoveControllers;
  48424. /**
  48425. * Disposes of the object
  48426. */
  48427. dispose(): void;
  48428. }
  48429. }
  48430. declare module BABYLON {
  48431. /**
  48432. * This is the base class for all WebXR features.
  48433. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48434. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48435. */
  48436. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48437. protected _xrSessionManager: WebXRSessionManager;
  48438. private _attached;
  48439. private _removeOnDetach;
  48440. /**
  48441. * Should auto-attach be disabled?
  48442. */
  48443. disableAutoAttach: boolean;
  48444. /**
  48445. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48446. */
  48447. xrNativeFeatureName: string;
  48448. /**
  48449. * Construct a new (abstract) WebXR feature
  48450. * @param _xrSessionManager the xr session manager for this feature
  48451. */
  48452. constructor(_xrSessionManager: WebXRSessionManager);
  48453. /**
  48454. * Is this feature attached
  48455. */
  48456. get attached(): boolean;
  48457. /**
  48458. * attach this feature
  48459. *
  48460. * @param force should attachment be forced (even when already attached)
  48461. * @returns true if successful, false is failed or already attached
  48462. */
  48463. attach(force?: boolean): boolean;
  48464. /**
  48465. * detach this feature.
  48466. *
  48467. * @returns true if successful, false if failed or already detached
  48468. */
  48469. detach(): boolean;
  48470. /**
  48471. * Dispose this feature and all of the resources attached
  48472. */
  48473. dispose(): void;
  48474. /**
  48475. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48476. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48477. *
  48478. * @returns whether or not the feature is compatible in this environment
  48479. */
  48480. isCompatible(): boolean;
  48481. /**
  48482. * This is used to register callbacks that will automatically be removed when detach is called.
  48483. * @param observable the observable to which the observer will be attached
  48484. * @param callback the callback to register
  48485. */
  48486. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48487. /**
  48488. * Code in this function will be executed on each xrFrame received from the browser.
  48489. * This function will not execute after the feature is detached.
  48490. * @param _xrFrame the current frame
  48491. */
  48492. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48493. }
  48494. }
  48495. declare module BABYLON {
  48496. /**
  48497. * Renders a layer on top of an existing scene
  48498. */
  48499. export class UtilityLayerRenderer implements IDisposable {
  48500. /** the original scene that will be rendered on top of */
  48501. originalScene: Scene;
  48502. private _pointerCaptures;
  48503. private _lastPointerEvents;
  48504. private static _DefaultUtilityLayer;
  48505. private static _DefaultKeepDepthUtilityLayer;
  48506. private _sharedGizmoLight;
  48507. private _renderCamera;
  48508. /**
  48509. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48510. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48511. * @returns the camera that is used when rendering the utility layer
  48512. */
  48513. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48514. /**
  48515. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48516. * @param cam the camera that should be used when rendering the utility layer
  48517. */
  48518. setRenderCamera(cam: Nullable<Camera>): void;
  48519. /**
  48520. * @hidden
  48521. * Light which used by gizmos to get light shading
  48522. */
  48523. _getSharedGizmoLight(): HemisphericLight;
  48524. /**
  48525. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48526. */
  48527. pickUtilitySceneFirst: boolean;
  48528. /**
  48529. * 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)
  48530. */
  48531. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48532. /**
  48533. * 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)
  48534. */
  48535. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48536. /**
  48537. * The scene that is rendered on top of the original scene
  48538. */
  48539. utilityLayerScene: Scene;
  48540. /**
  48541. * If the utility layer should automatically be rendered on top of existing scene
  48542. */
  48543. shouldRender: boolean;
  48544. /**
  48545. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48546. */
  48547. onlyCheckPointerDownEvents: boolean;
  48548. /**
  48549. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48550. */
  48551. processAllEvents: boolean;
  48552. /**
  48553. * Observable raised when the pointer move from the utility layer scene to the main scene
  48554. */
  48555. onPointerOutObservable: Observable<number>;
  48556. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48557. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48558. private _afterRenderObserver;
  48559. private _sceneDisposeObserver;
  48560. private _originalPointerObserver;
  48561. /**
  48562. * Instantiates a UtilityLayerRenderer
  48563. * @param originalScene the original scene that will be rendered on top of
  48564. * @param handleEvents boolean indicating if the utility layer should handle events
  48565. */
  48566. constructor(
  48567. /** the original scene that will be rendered on top of */
  48568. originalScene: Scene, handleEvents?: boolean);
  48569. private _notifyObservers;
  48570. /**
  48571. * Renders the utility layers scene on top of the original scene
  48572. */
  48573. render(): void;
  48574. /**
  48575. * Disposes of the renderer
  48576. */
  48577. dispose(): void;
  48578. private _updateCamera;
  48579. }
  48580. }
  48581. declare module BABYLON {
  48582. /**
  48583. * Options interface for the pointer selection module
  48584. */
  48585. export interface IWebXRControllerPointerSelectionOptions {
  48586. /**
  48587. * if provided, this scene will be used to render meshes.
  48588. */
  48589. customUtilityLayerScene?: Scene;
  48590. /**
  48591. * 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)
  48592. * If not disabled, the last picked point will be used to execute a pointer up event
  48593. * If disabled, pointer up event will be triggered right after the pointer down event.
  48594. * Used in screen and gaze target ray mode only
  48595. */
  48596. disablePointerUpOnTouchOut: boolean;
  48597. /**
  48598. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48599. */
  48600. forceGazeMode: boolean;
  48601. /**
  48602. * 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
  48603. * to start a new countdown to the pointer down event.
  48604. * Defaults to 1.
  48605. */
  48606. gazeModePointerMovedFactor?: number;
  48607. /**
  48608. * Different button type to use instead of the main component
  48609. */
  48610. overrideButtonId?: string;
  48611. /**
  48612. * use this rendering group id for the meshes (optional)
  48613. */
  48614. renderingGroupId?: number;
  48615. /**
  48616. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48617. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48618. * 3000 means 3 seconds between pointing at something and selecting it
  48619. */
  48620. timeToSelect?: number;
  48621. /**
  48622. * Should meshes created here be added to a utility layer or the main scene
  48623. */
  48624. useUtilityLayer?: boolean;
  48625. /**
  48626. * Optional WebXR camera to be used for gaze selection
  48627. */
  48628. gazeCamera?: WebXRCamera;
  48629. /**
  48630. * the xr input to use with this pointer selection
  48631. */
  48632. xrInput: WebXRInput;
  48633. }
  48634. /**
  48635. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48636. */
  48637. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48638. private readonly _options;
  48639. private static _idCounter;
  48640. private _attachController;
  48641. private _controllers;
  48642. private _scene;
  48643. private _tmpVectorForPickCompare;
  48644. /**
  48645. * The module's name
  48646. */
  48647. static readonly Name: string;
  48648. /**
  48649. * The (Babylon) version of this module.
  48650. * This is an integer representing the implementation version.
  48651. * This number does not correspond to the WebXR specs version
  48652. */
  48653. static readonly Version: number;
  48654. /**
  48655. * Disable lighting on the laser pointer (so it will always be visible)
  48656. */
  48657. disablePointerLighting: boolean;
  48658. /**
  48659. * Disable lighting on the selection mesh (so it will always be visible)
  48660. */
  48661. disableSelectionMeshLighting: boolean;
  48662. /**
  48663. * Should the laser pointer be displayed
  48664. */
  48665. displayLaserPointer: boolean;
  48666. /**
  48667. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48668. */
  48669. displaySelectionMesh: boolean;
  48670. /**
  48671. * This color will be set to the laser pointer when selection is triggered
  48672. */
  48673. laserPointerPickedColor: Color3;
  48674. /**
  48675. * Default color of the laser pointer
  48676. */
  48677. laserPointerDefaultColor: Color3;
  48678. /**
  48679. * default color of the selection ring
  48680. */
  48681. selectionMeshDefaultColor: Color3;
  48682. /**
  48683. * This color will be applied to the selection ring when selection is triggered
  48684. */
  48685. selectionMeshPickedColor: Color3;
  48686. /**
  48687. * Optional filter to be used for ray selection. This predicate shares behavior with
  48688. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48689. */
  48690. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48691. /**
  48692. * constructs a new background remover module
  48693. * @param _xrSessionManager the session manager for this module
  48694. * @param _options read-only options to be used in this module
  48695. */
  48696. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48697. /**
  48698. * attach this feature
  48699. * Will usually be called by the features manager
  48700. *
  48701. * @returns true if successful.
  48702. */
  48703. attach(): boolean;
  48704. /**
  48705. * detach this feature.
  48706. * Will usually be called by the features manager
  48707. *
  48708. * @returns true if successful.
  48709. */
  48710. detach(): boolean;
  48711. /**
  48712. * Will get the mesh under a specific pointer.
  48713. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48714. * @param controllerId the controllerId to check
  48715. * @returns The mesh under pointer or null if no mesh is under the pointer
  48716. */
  48717. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48718. /**
  48719. * Get the xr controller that correlates to the pointer id in the pointer event
  48720. *
  48721. * @param id the pointer id to search for
  48722. * @returns the controller that correlates to this id or null if not found
  48723. */
  48724. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48725. protected _onXRFrame(_xrFrame: XRFrame): void;
  48726. private _attachGazeMode;
  48727. private _attachScreenRayMode;
  48728. private _attachTrackedPointerRayMode;
  48729. private _convertNormalToDirectionOfRay;
  48730. private _detachController;
  48731. private _generateNewMeshPair;
  48732. private _pickingMoved;
  48733. private _updatePointerDistance;
  48734. /** @hidden */
  48735. get lasterPointerDefaultColor(): Color3;
  48736. }
  48737. }
  48738. declare module BABYLON {
  48739. /**
  48740. * Button which can be used to enter a different mode of XR
  48741. */
  48742. export class WebXREnterExitUIButton {
  48743. /** button element */
  48744. element: HTMLElement;
  48745. /** XR initialization options for the button */
  48746. sessionMode: XRSessionMode;
  48747. /** Reference space type */
  48748. referenceSpaceType: XRReferenceSpaceType;
  48749. /**
  48750. * Creates a WebXREnterExitUIButton
  48751. * @param element button element
  48752. * @param sessionMode XR initialization session mode
  48753. * @param referenceSpaceType the type of reference space to be used
  48754. */
  48755. constructor(
  48756. /** button element */
  48757. element: HTMLElement,
  48758. /** XR initialization options for the button */
  48759. sessionMode: XRSessionMode,
  48760. /** Reference space type */
  48761. referenceSpaceType: XRReferenceSpaceType);
  48762. /**
  48763. * Extendable function which can be used to update the button's visuals when the state changes
  48764. * @param activeButton the current active button in the UI
  48765. */
  48766. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48767. }
  48768. /**
  48769. * Options to create the webXR UI
  48770. */
  48771. export class WebXREnterExitUIOptions {
  48772. /**
  48773. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48774. */
  48775. customButtons?: Array<WebXREnterExitUIButton>;
  48776. /**
  48777. * A reference space type to use when creating the default button.
  48778. * Default is local-floor
  48779. */
  48780. referenceSpaceType?: XRReferenceSpaceType;
  48781. /**
  48782. * Context to enter xr with
  48783. */
  48784. renderTarget?: Nullable<WebXRRenderTarget>;
  48785. /**
  48786. * A session mode to use when creating the default button.
  48787. * Default is immersive-vr
  48788. */
  48789. sessionMode?: XRSessionMode;
  48790. /**
  48791. * A list of optional features to init the session with
  48792. */
  48793. optionalFeatures?: string[];
  48794. /**
  48795. * A list of optional features to init the session with
  48796. */
  48797. requiredFeatures?: string[];
  48798. }
  48799. /**
  48800. * UI to allow the user to enter/exit XR mode
  48801. */
  48802. export class WebXREnterExitUI implements IDisposable {
  48803. private scene;
  48804. /** version of the options passed to this UI */
  48805. options: WebXREnterExitUIOptions;
  48806. private _activeButton;
  48807. private _buttons;
  48808. private _overlay;
  48809. /**
  48810. * Fired every time the active button is changed.
  48811. *
  48812. * When xr is entered via a button that launches xr that button will be the callback parameter
  48813. *
  48814. * When exiting xr the callback parameter will be null)
  48815. */
  48816. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48817. /**
  48818. *
  48819. * @param scene babylon scene object to use
  48820. * @param options (read-only) version of the options passed to this UI
  48821. */
  48822. private constructor();
  48823. /**
  48824. * Creates UI to allow the user to enter/exit XR mode
  48825. * @param scene the scene to add the ui to
  48826. * @param helper the xr experience helper to enter/exit xr with
  48827. * @param options options to configure the UI
  48828. * @returns the created ui
  48829. */
  48830. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48831. /**
  48832. * Disposes of the XR UI component
  48833. */
  48834. dispose(): void;
  48835. private _updateButtons;
  48836. }
  48837. }
  48838. declare module BABYLON {
  48839. /**
  48840. * Class containing static functions to help procedurally build meshes
  48841. */
  48842. export class LinesBuilder {
  48843. /**
  48844. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48845. * * 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
  48846. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48847. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48848. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48849. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48850. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48851. * * 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
  48852. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48855. * @param name defines the name of the new line system
  48856. * @param options defines the options used to create the line system
  48857. * @param scene defines the hosting scene
  48858. * @returns a new line system mesh
  48859. */
  48860. static CreateLineSystem(name: string, options: {
  48861. lines: Vector3[][];
  48862. updatable?: boolean;
  48863. instance?: Nullable<LinesMesh>;
  48864. colors?: Nullable<Color4[][]>;
  48865. useVertexAlpha?: boolean;
  48866. }, scene: Nullable<Scene>): LinesMesh;
  48867. /**
  48868. * Creates a line mesh
  48869. * 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
  48870. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48871. * * The parameter `points` is an array successive Vector3
  48872. * * 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
  48873. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48874. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48875. * * When updating an instance, remember that only point positions can change, not the number of points
  48876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48878. * @param name defines the name of the new line system
  48879. * @param options defines the options used to create the line system
  48880. * @param scene defines the hosting scene
  48881. * @returns a new line mesh
  48882. */
  48883. static CreateLines(name: string, options: {
  48884. points: Vector3[];
  48885. updatable?: boolean;
  48886. instance?: Nullable<LinesMesh>;
  48887. colors?: Color4[];
  48888. useVertexAlpha?: boolean;
  48889. }, scene?: Nullable<Scene>): LinesMesh;
  48890. /**
  48891. * Creates a dashed line mesh
  48892. * * 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
  48893. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48894. * * The parameter `points` is an array successive Vector3
  48895. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48896. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48897. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48898. * * 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
  48899. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48900. * * When updating an instance, remember that only point positions can change, not the number of points
  48901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48902. * @param name defines the name of the mesh
  48903. * @param options defines the options used to create the mesh
  48904. * @param scene defines the hosting scene
  48905. * @returns the dashed line mesh
  48906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48907. */
  48908. static CreateDashedLines(name: string, options: {
  48909. points: Vector3[];
  48910. dashSize?: number;
  48911. gapSize?: number;
  48912. dashNb?: number;
  48913. updatable?: boolean;
  48914. instance?: LinesMesh;
  48915. useVertexAlpha?: boolean;
  48916. }, scene?: Nullable<Scene>): LinesMesh;
  48917. }
  48918. }
  48919. declare module BABYLON {
  48920. /**
  48921. * Construction options for a timer
  48922. */
  48923. export interface ITimerOptions<T> {
  48924. /**
  48925. * Time-to-end
  48926. */
  48927. timeout: number;
  48928. /**
  48929. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48930. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48931. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48932. */
  48933. contextObservable: Observable<T>;
  48934. /**
  48935. * Optional parameters when adding an observer to the observable
  48936. */
  48937. observableParameters?: {
  48938. mask?: number;
  48939. insertFirst?: boolean;
  48940. scope?: any;
  48941. };
  48942. /**
  48943. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48944. */
  48945. breakCondition?: (data?: ITimerData<T>) => boolean;
  48946. /**
  48947. * Will be triggered when the time condition has met
  48948. */
  48949. onEnded?: (data: ITimerData<any>) => void;
  48950. /**
  48951. * Will be triggered when the break condition has met (prematurely ended)
  48952. */
  48953. onAborted?: (data: ITimerData<any>) => void;
  48954. /**
  48955. * Optional function to execute on each tick (or count)
  48956. */
  48957. onTick?: (data: ITimerData<any>) => void;
  48958. }
  48959. /**
  48960. * An interface defining the data sent by the timer
  48961. */
  48962. export interface ITimerData<T> {
  48963. /**
  48964. * When did it start
  48965. */
  48966. startTime: number;
  48967. /**
  48968. * Time now
  48969. */
  48970. currentTime: number;
  48971. /**
  48972. * Time passed since started
  48973. */
  48974. deltaTime: number;
  48975. /**
  48976. * How much is completed, in [0.0...1.0].
  48977. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48978. */
  48979. completeRate: number;
  48980. /**
  48981. * What the registered observable sent in the last count
  48982. */
  48983. payload: T;
  48984. }
  48985. /**
  48986. * The current state of the timer
  48987. */
  48988. export enum TimerState {
  48989. /**
  48990. * Timer initialized, not yet started
  48991. */
  48992. INIT = 0,
  48993. /**
  48994. * Timer started and counting
  48995. */
  48996. STARTED = 1,
  48997. /**
  48998. * Timer ended (whether aborted or time reached)
  48999. */
  49000. ENDED = 2
  49001. }
  49002. /**
  49003. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49004. *
  49005. * @param options options with which to initialize this timer
  49006. */
  49007. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49008. /**
  49009. * An advanced implementation of a timer class
  49010. */
  49011. export class AdvancedTimer<T = any> implements IDisposable {
  49012. /**
  49013. * Will notify each time the timer calculates the remaining time
  49014. */
  49015. onEachCountObservable: Observable<ITimerData<T>>;
  49016. /**
  49017. * Will trigger when the timer was aborted due to the break condition
  49018. */
  49019. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49020. /**
  49021. * Will trigger when the timer ended successfully
  49022. */
  49023. onTimerEndedObservable: Observable<ITimerData<T>>;
  49024. /**
  49025. * Will trigger when the timer state has changed
  49026. */
  49027. onStateChangedObservable: Observable<TimerState>;
  49028. private _observer;
  49029. private _contextObservable;
  49030. private _observableParameters;
  49031. private _startTime;
  49032. private _timer;
  49033. private _state;
  49034. private _breakCondition;
  49035. private _timeToEnd;
  49036. private _breakOnNextTick;
  49037. /**
  49038. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49039. * @param options construction options for this advanced timer
  49040. */
  49041. constructor(options: ITimerOptions<T>);
  49042. /**
  49043. * set a breaking condition for this timer. Default is to never break during count
  49044. * @param predicate the new break condition. Returns true to break, false otherwise
  49045. */
  49046. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49047. /**
  49048. * Reset ALL associated observables in this advanced timer
  49049. */
  49050. clearObservables(): void;
  49051. /**
  49052. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49053. *
  49054. * @param timeToEnd how much time to measure until timer ended
  49055. */
  49056. start(timeToEnd?: number): void;
  49057. /**
  49058. * Will force a stop on the next tick.
  49059. */
  49060. stop(): void;
  49061. /**
  49062. * Dispose this timer, clearing all resources
  49063. */
  49064. dispose(): void;
  49065. private _setState;
  49066. private _tick;
  49067. private _stop;
  49068. }
  49069. }
  49070. declare module BABYLON {
  49071. /**
  49072. * The options container for the teleportation module
  49073. */
  49074. export interface IWebXRTeleportationOptions {
  49075. /**
  49076. * if provided, this scene will be used to render meshes.
  49077. */
  49078. customUtilityLayerScene?: Scene;
  49079. /**
  49080. * Values to configure the default target mesh
  49081. */
  49082. defaultTargetMeshOptions?: {
  49083. /**
  49084. * Fill color of the teleportation area
  49085. */
  49086. teleportationFillColor?: string;
  49087. /**
  49088. * Border color for the teleportation area
  49089. */
  49090. teleportationBorderColor?: string;
  49091. /**
  49092. * Disable the mesh's animation sequence
  49093. */
  49094. disableAnimation?: boolean;
  49095. /**
  49096. * Disable lighting on the material or the ring and arrow
  49097. */
  49098. disableLighting?: boolean;
  49099. /**
  49100. * Override the default material of the torus and arrow
  49101. */
  49102. torusArrowMaterial?: Material;
  49103. };
  49104. /**
  49105. * A list of meshes to use as floor meshes.
  49106. * Meshes can be added and removed after initializing the feature using the
  49107. * addFloorMesh and removeFloorMesh functions
  49108. * If empty, rotation will still work
  49109. */
  49110. floorMeshes?: AbstractMesh[];
  49111. /**
  49112. * use this rendering group id for the meshes (optional)
  49113. */
  49114. renderingGroupId?: number;
  49115. /**
  49116. * Should teleportation move only to snap points
  49117. */
  49118. snapPointsOnly?: boolean;
  49119. /**
  49120. * An array of points to which the teleportation will snap to.
  49121. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49122. */
  49123. snapPositions?: Vector3[];
  49124. /**
  49125. * How close should the teleportation ray be in order to snap to position.
  49126. * Default to 0.8 units (meters)
  49127. */
  49128. snapToPositionRadius?: number;
  49129. /**
  49130. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49131. * If you want to support rotation, make sure your mesh has a direction indicator.
  49132. *
  49133. * When left untouched, the default mesh will be initialized.
  49134. */
  49135. teleportationTargetMesh?: AbstractMesh;
  49136. /**
  49137. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49138. */
  49139. timeToTeleport?: number;
  49140. /**
  49141. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49142. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49143. */
  49144. useMainComponentOnly?: boolean;
  49145. /**
  49146. * Should meshes created here be added to a utility layer or the main scene
  49147. */
  49148. useUtilityLayer?: boolean;
  49149. /**
  49150. * Babylon XR Input class for controller
  49151. */
  49152. xrInput: WebXRInput;
  49153. }
  49154. /**
  49155. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49156. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49157. * the input of the attached controllers.
  49158. */
  49159. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49160. private _options;
  49161. private _controllers;
  49162. private _currentTeleportationControllerId;
  49163. private _floorMeshes;
  49164. private _quadraticBezierCurve;
  49165. private _selectionFeature;
  49166. private _snapToPositions;
  49167. private _snappedToPoint;
  49168. private _teleportationRingMaterial?;
  49169. private _tmpRay;
  49170. private _tmpVector;
  49171. /**
  49172. * The module's name
  49173. */
  49174. static readonly Name: string;
  49175. /**
  49176. * The (Babylon) version of this module.
  49177. * This is an integer representing the implementation version.
  49178. * This number does not correspond to the webxr specs version
  49179. */
  49180. static readonly Version: number;
  49181. /**
  49182. * Is movement backwards enabled
  49183. */
  49184. backwardsMovementEnabled: boolean;
  49185. /**
  49186. * Distance to travel when moving backwards
  49187. */
  49188. backwardsTeleportationDistance: number;
  49189. /**
  49190. * The distance from the user to the inspection point in the direction of the controller
  49191. * A higher number will allow the user to move further
  49192. * defaults to 5 (meters, in xr units)
  49193. */
  49194. parabolicCheckRadius: number;
  49195. /**
  49196. * Should the module support parabolic ray on top of direct ray
  49197. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49198. * Very helpful when moving between floors / different heights
  49199. */
  49200. parabolicRayEnabled: boolean;
  49201. /**
  49202. * How much rotation should be applied when rotating right and left
  49203. */
  49204. rotationAngle: number;
  49205. /**
  49206. * Is rotation enabled when moving forward?
  49207. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49208. */
  49209. rotationEnabled: boolean;
  49210. /**
  49211. * constructs a new anchor system
  49212. * @param _xrSessionManager an instance of WebXRSessionManager
  49213. * @param _options configuration object for this feature
  49214. */
  49215. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49216. /**
  49217. * Get the snapPointsOnly flag
  49218. */
  49219. get snapPointsOnly(): boolean;
  49220. /**
  49221. * Sets the snapPointsOnly flag
  49222. * @param snapToPoints should teleportation be exclusively to snap points
  49223. */
  49224. set snapPointsOnly(snapToPoints: boolean);
  49225. /**
  49226. * Add a new mesh to the floor meshes array
  49227. * @param mesh the mesh to use as floor mesh
  49228. */
  49229. addFloorMesh(mesh: AbstractMesh): void;
  49230. /**
  49231. * Add a new snap-to point to fix teleportation to this position
  49232. * @param newSnapPoint The new Snap-To point
  49233. */
  49234. addSnapPoint(newSnapPoint: Vector3): void;
  49235. attach(): boolean;
  49236. detach(): boolean;
  49237. dispose(): void;
  49238. /**
  49239. * Remove a mesh from the floor meshes array
  49240. * @param mesh the mesh to remove
  49241. */
  49242. removeFloorMesh(mesh: AbstractMesh): void;
  49243. /**
  49244. * Remove a mesh from the floor meshes array using its name
  49245. * @param name the mesh name to remove
  49246. */
  49247. removeFloorMeshByName(name: string): void;
  49248. /**
  49249. * 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
  49250. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49251. * @returns was the point found and removed or not
  49252. */
  49253. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49254. /**
  49255. * This function sets a selection feature that will be disabled when
  49256. * the forward ray is shown and will be reattached when hidden.
  49257. * This is used to remove the selection rays when moving.
  49258. * @param selectionFeature the feature to disable when forward movement is enabled
  49259. */
  49260. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49261. protected _onXRFrame(_xrFrame: XRFrame): void;
  49262. private _attachController;
  49263. private _createDefaultTargetMesh;
  49264. private _detachController;
  49265. private _findClosestSnapPointWithRadius;
  49266. private _setTargetMeshPosition;
  49267. private _setTargetMeshVisibility;
  49268. private _showParabolicPath;
  49269. private _teleportForward;
  49270. }
  49271. }
  49272. declare module BABYLON {
  49273. /**
  49274. * Options for the default xr helper
  49275. */
  49276. export class WebXRDefaultExperienceOptions {
  49277. /**
  49278. * Enable or disable default UI to enter XR
  49279. */
  49280. disableDefaultUI?: boolean;
  49281. /**
  49282. * Should teleportation not initialize. defaults to false.
  49283. */
  49284. disableTeleportation?: boolean;
  49285. /**
  49286. * Floor meshes that will be used for teleport
  49287. */
  49288. floorMeshes?: Array<AbstractMesh>;
  49289. /**
  49290. * If set to true, the first frame will not be used to reset position
  49291. * The first frame is mainly used when copying transformation from the old camera
  49292. * Mainly used in AR
  49293. */
  49294. ignoreNativeCameraTransformation?: boolean;
  49295. /**
  49296. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49297. */
  49298. inputOptions?: IWebXRInputOptions;
  49299. /**
  49300. * optional configuration for the output canvas
  49301. */
  49302. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49303. /**
  49304. * optional UI options. This can be used among other to change session mode and reference space type
  49305. */
  49306. uiOptions?: WebXREnterExitUIOptions;
  49307. /**
  49308. * When loading teleportation and pointer select, use stable versions instead of latest.
  49309. */
  49310. useStablePlugins?: boolean;
  49311. /**
  49312. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49313. */
  49314. renderingGroupId?: number;
  49315. /**
  49316. * A list of optional features to init the session with
  49317. * If set to true, all features we support will be added
  49318. */
  49319. optionalFeatures?: boolean | string[];
  49320. }
  49321. /**
  49322. * Default experience which provides a similar setup to the previous webVRExperience
  49323. */
  49324. export class WebXRDefaultExperience {
  49325. /**
  49326. * Base experience
  49327. */
  49328. baseExperience: WebXRExperienceHelper;
  49329. /**
  49330. * Enables ui for entering/exiting xr
  49331. */
  49332. enterExitUI: WebXREnterExitUI;
  49333. /**
  49334. * Input experience extension
  49335. */
  49336. input: WebXRInput;
  49337. /**
  49338. * Enables laser pointer and selection
  49339. */
  49340. pointerSelection: WebXRControllerPointerSelection;
  49341. /**
  49342. * Default target xr should render to
  49343. */
  49344. renderTarget: WebXRRenderTarget;
  49345. /**
  49346. * Enables teleportation
  49347. */
  49348. teleportation: WebXRMotionControllerTeleportation;
  49349. private constructor();
  49350. /**
  49351. * Creates the default xr experience
  49352. * @param scene scene
  49353. * @param options options for basic configuration
  49354. * @returns resulting WebXRDefaultExperience
  49355. */
  49356. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49357. /**
  49358. * DIsposes of the experience helper
  49359. */
  49360. dispose(): void;
  49361. }
  49362. }
  49363. declare module BABYLON {
  49364. /**
  49365. * Options to modify the vr teleportation behavior.
  49366. */
  49367. export interface VRTeleportationOptions {
  49368. /**
  49369. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49370. */
  49371. floorMeshName?: string;
  49372. /**
  49373. * A list of meshes to be used as the teleportation floor. (default: empty)
  49374. */
  49375. floorMeshes?: Mesh[];
  49376. /**
  49377. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49378. */
  49379. teleportationMode?: number;
  49380. /**
  49381. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49382. */
  49383. teleportationTime?: number;
  49384. /**
  49385. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49386. */
  49387. teleportationSpeed?: number;
  49388. /**
  49389. * The easing function used in the animation or null for Linear. (default CircleEase)
  49390. */
  49391. easingFunction?: EasingFunction;
  49392. }
  49393. /**
  49394. * Options to modify the vr experience helper's behavior.
  49395. */
  49396. export interface VRExperienceHelperOptions extends WebVROptions {
  49397. /**
  49398. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49399. */
  49400. createDeviceOrientationCamera?: boolean;
  49401. /**
  49402. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49403. */
  49404. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49405. /**
  49406. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49407. */
  49408. laserToggle?: boolean;
  49409. /**
  49410. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49411. */
  49412. floorMeshes?: Mesh[];
  49413. /**
  49414. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49415. */
  49416. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49417. /**
  49418. * Defines if WebXR should be used instead of WebVR (if available)
  49419. */
  49420. useXR?: boolean;
  49421. }
  49422. /**
  49423. * Event containing information after VR has been entered
  49424. */
  49425. export class OnAfterEnteringVRObservableEvent {
  49426. /**
  49427. * If entering vr was successful
  49428. */
  49429. success: boolean;
  49430. }
  49431. /**
  49432. * Helps to quickly add VR support to an existing scene.
  49433. * See https://doc.babylonjs.com/how_to/webvr_helper
  49434. */
  49435. export class VRExperienceHelper {
  49436. /** Options to modify the vr experience helper's behavior. */
  49437. webVROptions: VRExperienceHelperOptions;
  49438. private _scene;
  49439. private _position;
  49440. private _btnVR;
  49441. private _btnVRDisplayed;
  49442. private _webVRsupported;
  49443. private _webVRready;
  49444. private _webVRrequesting;
  49445. private _webVRpresenting;
  49446. private _hasEnteredVR;
  49447. private _fullscreenVRpresenting;
  49448. private _inputElement;
  49449. private _webVRCamera;
  49450. private _vrDeviceOrientationCamera;
  49451. private _deviceOrientationCamera;
  49452. private _existingCamera;
  49453. private _onKeyDown;
  49454. private _onVrDisplayPresentChange;
  49455. private _onVRDisplayChanged;
  49456. private _onVRRequestPresentStart;
  49457. private _onVRRequestPresentComplete;
  49458. /**
  49459. * 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)
  49460. */
  49461. enableGazeEvenWhenNoPointerLock: boolean;
  49462. /**
  49463. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49464. */
  49465. exitVROnDoubleTap: boolean;
  49466. /**
  49467. * Observable raised right before entering VR.
  49468. */
  49469. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49470. /**
  49471. * Observable raised when entering VR has completed.
  49472. */
  49473. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49474. /**
  49475. * Observable raised when exiting VR.
  49476. */
  49477. onExitingVRObservable: Observable<VRExperienceHelper>;
  49478. /**
  49479. * Observable raised when controller mesh is loaded.
  49480. */
  49481. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49482. /** Return this.onEnteringVRObservable
  49483. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49484. */
  49485. get onEnteringVR(): Observable<VRExperienceHelper>;
  49486. /** Return this.onExitingVRObservable
  49487. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49488. */
  49489. get onExitingVR(): Observable<VRExperienceHelper>;
  49490. /** Return this.onControllerMeshLoadedObservable
  49491. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49492. */
  49493. get onControllerMeshLoaded(): Observable<WebVRController>;
  49494. private _rayLength;
  49495. private _useCustomVRButton;
  49496. private _teleportationRequested;
  49497. private _teleportActive;
  49498. private _floorMeshName;
  49499. private _floorMeshesCollection;
  49500. private _teleportationMode;
  49501. private _teleportationTime;
  49502. private _teleportationSpeed;
  49503. private _teleportationEasing;
  49504. private _rotationAllowed;
  49505. private _teleportBackwardsVector;
  49506. private _teleportationTarget;
  49507. private _isDefaultTeleportationTarget;
  49508. private _postProcessMove;
  49509. private _teleportationFillColor;
  49510. private _teleportationBorderColor;
  49511. private _rotationAngle;
  49512. private _haloCenter;
  49513. private _cameraGazer;
  49514. private _padSensibilityUp;
  49515. private _padSensibilityDown;
  49516. private _leftController;
  49517. private _rightController;
  49518. private _gazeColor;
  49519. private _laserColor;
  49520. private _pickedLaserColor;
  49521. private _pickedGazeColor;
  49522. /**
  49523. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49524. */
  49525. onNewMeshSelected: Observable<AbstractMesh>;
  49526. /**
  49527. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49528. * This observable will provide the mesh and the controller used to select the mesh
  49529. */
  49530. onMeshSelectedWithController: Observable<{
  49531. mesh: AbstractMesh;
  49532. controller: WebVRController;
  49533. }>;
  49534. /**
  49535. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49536. */
  49537. onNewMeshPicked: Observable<PickingInfo>;
  49538. private _circleEase;
  49539. /**
  49540. * Observable raised before camera teleportation
  49541. */
  49542. onBeforeCameraTeleport: Observable<Vector3>;
  49543. /**
  49544. * Observable raised after camera teleportation
  49545. */
  49546. onAfterCameraTeleport: Observable<Vector3>;
  49547. /**
  49548. * Observable raised when current selected mesh gets unselected
  49549. */
  49550. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49551. private _raySelectionPredicate;
  49552. /**
  49553. * To be optionaly changed by user to define custom ray selection
  49554. */
  49555. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49556. /**
  49557. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49558. */
  49559. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49560. /**
  49561. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49562. */
  49563. teleportationEnabled: boolean;
  49564. private _defaultHeight;
  49565. private _teleportationInitialized;
  49566. private _interactionsEnabled;
  49567. private _interactionsRequested;
  49568. private _displayGaze;
  49569. private _displayLaserPointer;
  49570. /**
  49571. * The mesh used to display where the user is going to teleport.
  49572. */
  49573. get teleportationTarget(): Mesh;
  49574. /**
  49575. * Sets the mesh to be used to display where the user is going to teleport.
  49576. */
  49577. set teleportationTarget(value: Mesh);
  49578. /**
  49579. * 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
  49580. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49581. * See https://doc.babylonjs.com/resources/baking_transformations
  49582. */
  49583. get gazeTrackerMesh(): Mesh;
  49584. set gazeTrackerMesh(value: Mesh);
  49585. /**
  49586. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49587. */
  49588. updateGazeTrackerScale: boolean;
  49589. /**
  49590. * If the gaze trackers color should be updated when selecting meshes
  49591. */
  49592. updateGazeTrackerColor: boolean;
  49593. /**
  49594. * If the controller laser color should be updated when selecting meshes
  49595. */
  49596. updateControllerLaserColor: boolean;
  49597. /**
  49598. * The gaze tracking mesh corresponding to the left controller
  49599. */
  49600. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49601. /**
  49602. * The gaze tracking mesh corresponding to the right controller
  49603. */
  49604. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49605. /**
  49606. * If the ray of the gaze should be displayed.
  49607. */
  49608. get displayGaze(): boolean;
  49609. /**
  49610. * Sets if the ray of the gaze should be displayed.
  49611. */
  49612. set displayGaze(value: boolean);
  49613. /**
  49614. * If the ray of the LaserPointer should be displayed.
  49615. */
  49616. get displayLaserPointer(): boolean;
  49617. /**
  49618. * Sets if the ray of the LaserPointer should be displayed.
  49619. */
  49620. set displayLaserPointer(value: boolean);
  49621. /**
  49622. * The deviceOrientationCamera used as the camera when not in VR.
  49623. */
  49624. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49625. /**
  49626. * Based on the current WebVR support, returns the current VR camera used.
  49627. */
  49628. get currentVRCamera(): Nullable<Camera>;
  49629. /**
  49630. * The webVRCamera which is used when in VR.
  49631. */
  49632. get webVRCamera(): WebVRFreeCamera;
  49633. /**
  49634. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49635. */
  49636. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49637. /**
  49638. * The html button that is used to trigger entering into VR.
  49639. */
  49640. get vrButton(): Nullable<HTMLButtonElement>;
  49641. private get _teleportationRequestInitiated();
  49642. /**
  49643. * Defines whether or not Pointer lock should be requested when switching to
  49644. * full screen.
  49645. */
  49646. requestPointerLockOnFullScreen: boolean;
  49647. /**
  49648. * If asking to force XR, this will be populated with the default xr experience
  49649. */
  49650. xr: WebXRDefaultExperience;
  49651. /**
  49652. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49653. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49654. */
  49655. xrTestDone: boolean;
  49656. /**
  49657. * Instantiates a VRExperienceHelper.
  49658. * Helps to quickly add VR support to an existing scene.
  49659. * @param scene The scene the VRExperienceHelper belongs to.
  49660. * @param webVROptions Options to modify the vr experience helper's behavior.
  49661. */
  49662. constructor(scene: Scene,
  49663. /** Options to modify the vr experience helper's behavior. */
  49664. webVROptions?: VRExperienceHelperOptions);
  49665. private completeVRInit;
  49666. private _onDefaultMeshLoaded;
  49667. private _onResize;
  49668. private _onFullscreenChange;
  49669. /**
  49670. * Gets a value indicating if we are currently in VR mode.
  49671. */
  49672. get isInVRMode(): boolean;
  49673. private onVrDisplayPresentChange;
  49674. private onVRDisplayChanged;
  49675. private moveButtonToBottomRight;
  49676. private displayVRButton;
  49677. private updateButtonVisibility;
  49678. private _cachedAngularSensibility;
  49679. /**
  49680. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49681. * Otherwise, will use the fullscreen API.
  49682. */
  49683. enterVR(): void;
  49684. /**
  49685. * Attempt to exit VR, or fullscreen.
  49686. */
  49687. exitVR(): void;
  49688. /**
  49689. * The position of the vr experience helper.
  49690. */
  49691. get position(): Vector3;
  49692. /**
  49693. * Sets the position of the vr experience helper.
  49694. */
  49695. set position(value: Vector3);
  49696. /**
  49697. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49698. */
  49699. enableInteractions(): void;
  49700. private get _noControllerIsActive();
  49701. private beforeRender;
  49702. private _isTeleportationFloor;
  49703. /**
  49704. * Adds a floor mesh to be used for teleportation.
  49705. * @param floorMesh the mesh to be used for teleportation.
  49706. */
  49707. addFloorMesh(floorMesh: Mesh): void;
  49708. /**
  49709. * Removes a floor mesh from being used for teleportation.
  49710. * @param floorMesh the mesh to be removed.
  49711. */
  49712. removeFloorMesh(floorMesh: Mesh): void;
  49713. /**
  49714. * Enables interactions and teleportation using the VR controllers and gaze.
  49715. * @param vrTeleportationOptions options to modify teleportation behavior.
  49716. */
  49717. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49718. private _onNewGamepadConnected;
  49719. private _tryEnableInteractionOnController;
  49720. private _onNewGamepadDisconnected;
  49721. private _enableInteractionOnController;
  49722. private _checkTeleportWithRay;
  49723. private _checkRotate;
  49724. private _checkTeleportBackwards;
  49725. private _enableTeleportationOnController;
  49726. private _createTeleportationCircles;
  49727. private _displayTeleportationTarget;
  49728. private _hideTeleportationTarget;
  49729. private _rotateCamera;
  49730. private _moveTeleportationSelectorTo;
  49731. private _workingVector;
  49732. private _workingQuaternion;
  49733. private _workingMatrix;
  49734. /**
  49735. * Time Constant Teleportation Mode
  49736. */
  49737. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49738. /**
  49739. * Speed Constant Teleportation Mode
  49740. */
  49741. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49742. /**
  49743. * Teleports the users feet to the desired location
  49744. * @param location The location where the user's feet should be placed
  49745. */
  49746. teleportCamera(location: Vector3): void;
  49747. private _convertNormalToDirectionOfRay;
  49748. private _castRayAndSelectObject;
  49749. private _notifySelectedMeshUnselected;
  49750. /**
  49751. * Permanently set new colors for the laser pointer
  49752. * @param color the new laser color
  49753. * @param pickedColor the new laser color when picked mesh detected
  49754. */
  49755. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49756. /**
  49757. * Set lighting enabled / disabled on the laser pointer of both controllers
  49758. * @param enabled should the lighting be enabled on the laser pointer
  49759. */
  49760. setLaserLightingState(enabled?: boolean): void;
  49761. /**
  49762. * Permanently set new colors for the gaze pointer
  49763. * @param color the new gaze color
  49764. * @param pickedColor the new gaze color when picked mesh detected
  49765. */
  49766. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49767. /**
  49768. * Sets the color of the laser ray from the vr controllers.
  49769. * @param color new color for the ray.
  49770. */
  49771. changeLaserColor(color: Color3): void;
  49772. /**
  49773. * Sets the color of the ray from the vr headsets gaze.
  49774. * @param color new color for the ray.
  49775. */
  49776. changeGazeColor(color: Color3): void;
  49777. /**
  49778. * Exits VR and disposes of the vr experience helper
  49779. */
  49780. dispose(): void;
  49781. /**
  49782. * Gets the name of the VRExperienceHelper class
  49783. * @returns "VRExperienceHelper"
  49784. */
  49785. getClassName(): string;
  49786. }
  49787. }
  49788. declare module BABYLON {
  49789. /**
  49790. * Contains an array of blocks representing the octree
  49791. */
  49792. export interface IOctreeContainer<T> {
  49793. /**
  49794. * Blocks within the octree
  49795. */
  49796. blocks: Array<OctreeBlock<T>>;
  49797. }
  49798. /**
  49799. * Class used to store a cell in an octree
  49800. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49801. */
  49802. export class OctreeBlock<T> {
  49803. /**
  49804. * Gets the content of the current block
  49805. */
  49806. entries: T[];
  49807. /**
  49808. * Gets the list of block children
  49809. */
  49810. blocks: Array<OctreeBlock<T>>;
  49811. private _depth;
  49812. private _maxDepth;
  49813. private _capacity;
  49814. private _minPoint;
  49815. private _maxPoint;
  49816. private _boundingVectors;
  49817. private _creationFunc;
  49818. /**
  49819. * Creates a new block
  49820. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49821. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49822. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49823. * @param depth defines the current depth of this block in the octree
  49824. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49825. * @param creationFunc defines a callback to call when an element is added to the block
  49826. */
  49827. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49828. /**
  49829. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49830. */
  49831. get capacity(): number;
  49832. /**
  49833. * Gets the minimum vector (in world space) of the block's bounding box
  49834. */
  49835. get minPoint(): Vector3;
  49836. /**
  49837. * Gets the maximum vector (in world space) of the block's bounding box
  49838. */
  49839. get maxPoint(): Vector3;
  49840. /**
  49841. * Add a new element to this block
  49842. * @param entry defines the element to add
  49843. */
  49844. addEntry(entry: T): void;
  49845. /**
  49846. * Remove an element from this block
  49847. * @param entry defines the element to remove
  49848. */
  49849. removeEntry(entry: T): void;
  49850. /**
  49851. * Add an array of elements to this block
  49852. * @param entries defines the array of elements to add
  49853. */
  49854. addEntries(entries: T[]): void;
  49855. /**
  49856. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49857. * @param frustumPlanes defines the frustum planes to test
  49858. * @param selection defines the array to store current content if selection is positive
  49859. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49860. */
  49861. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49862. /**
  49863. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49864. * @param sphereCenter defines the bounding sphere center
  49865. * @param sphereRadius defines the bounding sphere radius
  49866. * @param selection defines the array to store current content if selection is positive
  49867. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49868. */
  49869. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49870. /**
  49871. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49872. * @param ray defines the ray to test with
  49873. * @param selection defines the array to store current content if selection is positive
  49874. */
  49875. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49876. /**
  49877. * Subdivide the content into child blocks (this block will then be empty)
  49878. */
  49879. createInnerBlocks(): void;
  49880. /**
  49881. * @hidden
  49882. */
  49883. 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;
  49884. }
  49885. }
  49886. declare module BABYLON {
  49887. /**
  49888. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49889. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49890. */
  49891. export class Octree<T> {
  49892. /** 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.) */
  49893. maxDepth: number;
  49894. /**
  49895. * Blocks within the octree containing objects
  49896. */
  49897. blocks: Array<OctreeBlock<T>>;
  49898. /**
  49899. * Content stored in the octree
  49900. */
  49901. dynamicContent: T[];
  49902. private _maxBlockCapacity;
  49903. private _selectionContent;
  49904. private _creationFunc;
  49905. /**
  49906. * Creates a octree
  49907. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49908. * @param creationFunc function to be used to instatiate the octree
  49909. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49910. * @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.)
  49911. */
  49912. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49913. /** 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.) */
  49914. maxDepth?: number);
  49915. /**
  49916. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49917. * @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);
  49918. * @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);
  49919. * @param entries meshes to be added to the octree blocks
  49920. */
  49921. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49922. /**
  49923. * Adds a mesh to the octree
  49924. * @param entry Mesh to add to the octree
  49925. */
  49926. addMesh(entry: T): void;
  49927. /**
  49928. * Remove an element from the octree
  49929. * @param entry defines the element to remove
  49930. */
  49931. removeMesh(entry: T): void;
  49932. /**
  49933. * Selects an array of meshes within the frustum
  49934. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49935. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49936. * @returns array of meshes within the frustum
  49937. */
  49938. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49939. /**
  49940. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49941. * @param sphereCenter defines the bounding sphere center
  49942. * @param sphereRadius defines the bounding sphere radius
  49943. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49944. * @returns an array of objects that intersect the sphere
  49945. */
  49946. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49947. /**
  49948. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49949. * @param ray defines the ray to test with
  49950. * @returns array of intersected objects
  49951. */
  49952. intersectsRay(ray: Ray): SmartArray<T>;
  49953. /**
  49954. * Adds a mesh into the octree block if it intersects the block
  49955. */
  49956. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49957. /**
  49958. * Adds a submesh into the octree block if it intersects the block
  49959. */
  49960. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49961. }
  49962. }
  49963. declare module BABYLON {
  49964. interface Scene {
  49965. /**
  49966. * @hidden
  49967. * Backing Filed
  49968. */
  49969. _selectionOctree: Octree<AbstractMesh>;
  49970. /**
  49971. * Gets the octree used to boost mesh selection (picking)
  49972. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49973. */
  49974. selectionOctree: Octree<AbstractMesh>;
  49975. /**
  49976. * Creates or updates the octree used to boost selection (picking)
  49977. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49978. * @param maxCapacity defines the maximum capacity per leaf
  49979. * @param maxDepth defines the maximum depth of the octree
  49980. * @returns an octree of AbstractMesh
  49981. */
  49982. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49983. }
  49984. interface AbstractMesh {
  49985. /**
  49986. * @hidden
  49987. * Backing Field
  49988. */
  49989. _submeshesOctree: Octree<SubMesh>;
  49990. /**
  49991. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49992. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49993. * @param maxCapacity defines the maximum size of each block (64 by default)
  49994. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49995. * @returns the new octree
  49996. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49997. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49998. */
  49999. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50000. }
  50001. /**
  50002. * Defines the octree scene component responsible to manage any octrees
  50003. * in a given scene.
  50004. */
  50005. export class OctreeSceneComponent {
  50006. /**
  50007. * The component name help to identify the component in the list of scene components.
  50008. */
  50009. readonly name: string;
  50010. /**
  50011. * The scene the component belongs to.
  50012. */
  50013. scene: Scene;
  50014. /**
  50015. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50016. */
  50017. readonly checksIsEnabled: boolean;
  50018. /**
  50019. * Creates a new instance of the component for the given scene
  50020. * @param scene Defines the scene to register the component in
  50021. */
  50022. constructor(scene: Scene);
  50023. /**
  50024. * Registers the component in a given scene
  50025. */
  50026. register(): void;
  50027. /**
  50028. * Return the list of active meshes
  50029. * @returns the list of active meshes
  50030. */
  50031. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50032. /**
  50033. * Return the list of active sub meshes
  50034. * @param mesh The mesh to get the candidates sub meshes from
  50035. * @returns the list of active sub meshes
  50036. */
  50037. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50038. private _tempRay;
  50039. /**
  50040. * Return the list of sub meshes intersecting with a given local ray
  50041. * @param mesh defines the mesh to find the submesh for
  50042. * @param localRay defines the ray in local space
  50043. * @returns the list of intersecting sub meshes
  50044. */
  50045. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50046. /**
  50047. * Return the list of sub meshes colliding with a collider
  50048. * @param mesh defines the mesh to find the submesh for
  50049. * @param collider defines the collider to evaluate the collision against
  50050. * @returns the list of colliding sub meshes
  50051. */
  50052. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50053. /**
  50054. * Rebuilds the elements related to this component in case of
  50055. * context lost for instance.
  50056. */
  50057. rebuild(): void;
  50058. /**
  50059. * Disposes the component and the associated ressources.
  50060. */
  50061. dispose(): void;
  50062. }
  50063. }
  50064. declare module BABYLON {
  50065. /**
  50066. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50067. */
  50068. export class Gizmo implements IDisposable {
  50069. /** The utility layer the gizmo will be added to */
  50070. gizmoLayer: UtilityLayerRenderer;
  50071. /**
  50072. * The root mesh of the gizmo
  50073. */
  50074. _rootMesh: Mesh;
  50075. private _attachedMesh;
  50076. private _attachedNode;
  50077. /**
  50078. * Ratio for the scale of the gizmo (Default: 1)
  50079. */
  50080. scaleRatio: number;
  50081. /**
  50082. * If a custom mesh has been set (Default: false)
  50083. */
  50084. protected _customMeshSet: boolean;
  50085. /**
  50086. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50087. * * When set, interactions will be enabled
  50088. */
  50089. get attachedMesh(): Nullable<AbstractMesh>;
  50090. set attachedMesh(value: Nullable<AbstractMesh>);
  50091. /**
  50092. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50093. * * When set, interactions will be enabled
  50094. */
  50095. get attachedNode(): Nullable<Node>;
  50096. set attachedNode(value: Nullable<Node>);
  50097. /**
  50098. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50099. * @param mesh The mesh to replace the default mesh of the gizmo
  50100. */
  50101. setCustomMesh(mesh: Mesh): void;
  50102. /**
  50103. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50104. */
  50105. updateGizmoRotationToMatchAttachedMesh: boolean;
  50106. /**
  50107. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50108. */
  50109. updateGizmoPositionToMatchAttachedMesh: boolean;
  50110. /**
  50111. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50112. */
  50113. updateScale: boolean;
  50114. protected _interactionsEnabled: boolean;
  50115. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50116. private _beforeRenderObserver;
  50117. private _tempVector;
  50118. /**
  50119. * Creates a gizmo
  50120. * @param gizmoLayer The utility layer the gizmo will be added to
  50121. */
  50122. constructor(
  50123. /** The utility layer the gizmo will be added to */
  50124. gizmoLayer?: UtilityLayerRenderer);
  50125. /**
  50126. * Updates the gizmo to match the attached mesh's position/rotation
  50127. */
  50128. protected _update(): void;
  50129. /**
  50130. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50131. * @param value Node, TransformNode or mesh
  50132. */
  50133. protected _matrixChanged(): void;
  50134. /**
  50135. * Disposes of the gizmo
  50136. */
  50137. dispose(): void;
  50138. }
  50139. }
  50140. declare module BABYLON {
  50141. /**
  50142. * Single plane drag gizmo
  50143. */
  50144. export class PlaneDragGizmo extends Gizmo {
  50145. /**
  50146. * Drag behavior responsible for the gizmos dragging interactions
  50147. */
  50148. dragBehavior: PointerDragBehavior;
  50149. private _pointerObserver;
  50150. /**
  50151. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50152. */
  50153. snapDistance: number;
  50154. /**
  50155. * Event that fires each time the gizmo snaps to a new location.
  50156. * * snapDistance is the the change in distance
  50157. */
  50158. onSnapObservable: Observable<{
  50159. snapDistance: number;
  50160. }>;
  50161. private _plane;
  50162. private _coloredMaterial;
  50163. private _hoverMaterial;
  50164. private _isEnabled;
  50165. private _parent;
  50166. /** @hidden */
  50167. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50168. /** @hidden */
  50169. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50170. /**
  50171. * Creates a PlaneDragGizmo
  50172. * @param gizmoLayer The utility layer the gizmo will be added to
  50173. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50174. * @param color The color of the gizmo
  50175. */
  50176. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50177. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50178. /**
  50179. * If the gizmo is enabled
  50180. */
  50181. set isEnabled(value: boolean);
  50182. get isEnabled(): boolean;
  50183. /**
  50184. * Disposes of the gizmo
  50185. */
  50186. dispose(): void;
  50187. }
  50188. }
  50189. declare module BABYLON {
  50190. /**
  50191. * Gizmo that enables dragging a mesh along 3 axis
  50192. */
  50193. export class PositionGizmo extends Gizmo {
  50194. /**
  50195. * Internal gizmo used for interactions on the x axis
  50196. */
  50197. xGizmo: AxisDragGizmo;
  50198. /**
  50199. * Internal gizmo used for interactions on the y axis
  50200. */
  50201. yGizmo: AxisDragGizmo;
  50202. /**
  50203. * Internal gizmo used for interactions on the z axis
  50204. */
  50205. zGizmo: AxisDragGizmo;
  50206. /**
  50207. * Internal gizmo used for interactions on the yz plane
  50208. */
  50209. xPlaneGizmo: PlaneDragGizmo;
  50210. /**
  50211. * Internal gizmo used for interactions on the xz plane
  50212. */
  50213. yPlaneGizmo: PlaneDragGizmo;
  50214. /**
  50215. * Internal gizmo used for interactions on the xy plane
  50216. */
  50217. zPlaneGizmo: PlaneDragGizmo;
  50218. /**
  50219. * private variables
  50220. */
  50221. private _meshAttached;
  50222. private _nodeAttached;
  50223. private _updateGizmoRotationToMatchAttachedMesh;
  50224. private _snapDistance;
  50225. private _scaleRatio;
  50226. /** Fires an event when any of it's sub gizmos are dragged */
  50227. onDragStartObservable: Observable<unknown>;
  50228. /** Fires an event when any of it's sub gizmos are released from dragging */
  50229. onDragEndObservable: Observable<unknown>;
  50230. /**
  50231. * If set to true, planar drag is enabled
  50232. */
  50233. private _planarGizmoEnabled;
  50234. get attachedMesh(): Nullable<AbstractMesh>;
  50235. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50236. get attachedNode(): Nullable<Node>;
  50237. set attachedNode(node: Nullable<Node>);
  50238. /**
  50239. * Creates a PositionGizmo
  50240. * @param gizmoLayer The utility layer the gizmo will be added to
  50241. @param thickness display gizmo axis thickness
  50242. */
  50243. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50244. /**
  50245. * If the planar drag gizmo is enabled
  50246. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50247. */
  50248. set planarGizmoEnabled(value: boolean);
  50249. get planarGizmoEnabled(): boolean;
  50250. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50251. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50252. /**
  50253. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50254. */
  50255. set snapDistance(value: number);
  50256. get snapDistance(): number;
  50257. /**
  50258. * Ratio for the scale of the gizmo (Default: 1)
  50259. */
  50260. set scaleRatio(value: number);
  50261. get scaleRatio(): number;
  50262. /**
  50263. * Disposes of the gizmo
  50264. */
  50265. dispose(): void;
  50266. /**
  50267. * CustomMeshes are not supported by this gizmo
  50268. * @param mesh The mesh to replace the default mesh of the gizmo
  50269. */
  50270. setCustomMesh(mesh: Mesh): void;
  50271. }
  50272. }
  50273. declare module BABYLON {
  50274. /**
  50275. * Single axis drag gizmo
  50276. */
  50277. export class AxisDragGizmo extends Gizmo {
  50278. /**
  50279. * Drag behavior responsible for the gizmos dragging interactions
  50280. */
  50281. dragBehavior: PointerDragBehavior;
  50282. private _pointerObserver;
  50283. /**
  50284. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50285. */
  50286. snapDistance: number;
  50287. /**
  50288. * Event that fires each time the gizmo snaps to a new location.
  50289. * * snapDistance is the the change in distance
  50290. */
  50291. onSnapObservable: Observable<{
  50292. snapDistance: number;
  50293. }>;
  50294. private _isEnabled;
  50295. private _parent;
  50296. private _arrow;
  50297. private _coloredMaterial;
  50298. private _hoverMaterial;
  50299. /** @hidden */
  50300. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50301. /** @hidden */
  50302. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50303. /**
  50304. * Creates an AxisDragGizmo
  50305. * @param gizmoLayer The utility layer the gizmo will be added to
  50306. * @param dragAxis The axis which the gizmo will be able to drag on
  50307. * @param color The color of the gizmo
  50308. * @param thickness display gizmo axis thickness
  50309. */
  50310. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50311. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50312. /**
  50313. * If the gizmo is enabled
  50314. */
  50315. set isEnabled(value: boolean);
  50316. get isEnabled(): boolean;
  50317. /**
  50318. * Disposes of the gizmo
  50319. */
  50320. dispose(): void;
  50321. }
  50322. }
  50323. declare module BABYLON.Debug {
  50324. /**
  50325. * The Axes viewer will show 3 axes in a specific point in space
  50326. */
  50327. export class AxesViewer {
  50328. private _xAxis;
  50329. private _yAxis;
  50330. private _zAxis;
  50331. private _scaleLinesFactor;
  50332. private _instanced;
  50333. /**
  50334. * Gets the hosting scene
  50335. */
  50336. scene: Scene;
  50337. /**
  50338. * Gets or sets a number used to scale line length
  50339. */
  50340. scaleLines: number;
  50341. /** Gets the node hierarchy used to render x-axis */
  50342. get xAxis(): TransformNode;
  50343. /** Gets the node hierarchy used to render y-axis */
  50344. get yAxis(): TransformNode;
  50345. /** Gets the node hierarchy used to render z-axis */
  50346. get zAxis(): TransformNode;
  50347. /**
  50348. * Creates a new AxesViewer
  50349. * @param scene defines the hosting scene
  50350. * @param scaleLines defines a number used to scale line length (1 by default)
  50351. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50352. * @param xAxis defines the node hierarchy used to render the x-axis
  50353. * @param yAxis defines the node hierarchy used to render the y-axis
  50354. * @param zAxis defines the node hierarchy used to render the z-axis
  50355. */
  50356. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50357. /**
  50358. * Force the viewer to update
  50359. * @param position defines the position of the viewer
  50360. * @param xaxis defines the x axis of the viewer
  50361. * @param yaxis defines the y axis of the viewer
  50362. * @param zaxis defines the z axis of the viewer
  50363. */
  50364. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50365. /**
  50366. * Creates an instance of this axes viewer.
  50367. * @returns a new axes viewer with instanced meshes
  50368. */
  50369. createInstance(): AxesViewer;
  50370. /** Releases resources */
  50371. dispose(): void;
  50372. private static _SetRenderingGroupId;
  50373. }
  50374. }
  50375. declare module BABYLON.Debug {
  50376. /**
  50377. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50378. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50379. */
  50380. export class BoneAxesViewer extends AxesViewer {
  50381. /**
  50382. * Gets or sets the target mesh where to display the axes viewer
  50383. */
  50384. mesh: Nullable<Mesh>;
  50385. /**
  50386. * Gets or sets the target bone where to display the axes viewer
  50387. */
  50388. bone: Nullable<Bone>;
  50389. /** Gets current position */
  50390. pos: Vector3;
  50391. /** Gets direction of X axis */
  50392. xaxis: Vector3;
  50393. /** Gets direction of Y axis */
  50394. yaxis: Vector3;
  50395. /** Gets direction of Z axis */
  50396. zaxis: Vector3;
  50397. /**
  50398. * Creates a new BoneAxesViewer
  50399. * @param scene defines the hosting scene
  50400. * @param bone defines the target bone
  50401. * @param mesh defines the target mesh
  50402. * @param scaleLines defines a scaling factor for line length (1 by default)
  50403. */
  50404. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50405. /**
  50406. * Force the viewer to update
  50407. */
  50408. update(): void;
  50409. /** Releases resources */
  50410. dispose(): void;
  50411. }
  50412. }
  50413. declare module BABYLON {
  50414. /**
  50415. * Interface used to define scene explorer extensibility option
  50416. */
  50417. export interface IExplorerExtensibilityOption {
  50418. /**
  50419. * Define the option label
  50420. */
  50421. label: string;
  50422. /**
  50423. * Defines the action to execute on click
  50424. */
  50425. action: (entity: any) => void;
  50426. }
  50427. /**
  50428. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50429. */
  50430. export interface IExplorerExtensibilityGroup {
  50431. /**
  50432. * Defines a predicate to test if a given type mut be extended
  50433. */
  50434. predicate: (entity: any) => boolean;
  50435. /**
  50436. * Gets the list of options added to a type
  50437. */
  50438. entries: IExplorerExtensibilityOption[];
  50439. }
  50440. /**
  50441. * Interface used to define the options to use to create the Inspector
  50442. */
  50443. export interface IInspectorOptions {
  50444. /**
  50445. * Display in overlay mode (default: false)
  50446. */
  50447. overlay?: boolean;
  50448. /**
  50449. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50450. */
  50451. globalRoot?: HTMLElement;
  50452. /**
  50453. * Display the Scene explorer
  50454. */
  50455. showExplorer?: boolean;
  50456. /**
  50457. * Display the property inspector
  50458. */
  50459. showInspector?: boolean;
  50460. /**
  50461. * Display in embed mode (both panes on the right)
  50462. */
  50463. embedMode?: boolean;
  50464. /**
  50465. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50466. */
  50467. handleResize?: boolean;
  50468. /**
  50469. * Allow the panes to popup (default: true)
  50470. */
  50471. enablePopup?: boolean;
  50472. /**
  50473. * Allow the panes to be closed by users (default: true)
  50474. */
  50475. enableClose?: boolean;
  50476. /**
  50477. * Optional list of extensibility entries
  50478. */
  50479. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50480. /**
  50481. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50482. */
  50483. inspectorURL?: string;
  50484. /**
  50485. * Optional initial tab (default to DebugLayerTab.Properties)
  50486. */
  50487. initialTab?: DebugLayerTab;
  50488. }
  50489. interface Scene {
  50490. /**
  50491. * @hidden
  50492. * Backing field
  50493. */
  50494. _debugLayer: DebugLayer;
  50495. /**
  50496. * Gets the debug layer (aka Inspector) associated with the scene
  50497. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50498. */
  50499. debugLayer: DebugLayer;
  50500. }
  50501. /**
  50502. * Enum of inspector action tab
  50503. */
  50504. export enum DebugLayerTab {
  50505. /**
  50506. * Properties tag (default)
  50507. */
  50508. Properties = 0,
  50509. /**
  50510. * Debug tab
  50511. */
  50512. Debug = 1,
  50513. /**
  50514. * Statistics tab
  50515. */
  50516. Statistics = 2,
  50517. /**
  50518. * Tools tab
  50519. */
  50520. Tools = 3,
  50521. /**
  50522. * Settings tab
  50523. */
  50524. Settings = 4
  50525. }
  50526. /**
  50527. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50528. * what is happening in your scene
  50529. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50530. */
  50531. export class DebugLayer {
  50532. /**
  50533. * Define the url to get the inspector script from.
  50534. * By default it uses the babylonjs CDN.
  50535. * @ignoreNaming
  50536. */
  50537. static InspectorURL: string;
  50538. private _scene;
  50539. private BJSINSPECTOR;
  50540. private _onPropertyChangedObservable?;
  50541. /**
  50542. * Observable triggered when a property is changed through the inspector.
  50543. */
  50544. get onPropertyChangedObservable(): any;
  50545. /**
  50546. * Instantiates a new debug layer.
  50547. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50548. * what is happening in your scene
  50549. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50550. * @param scene Defines the scene to inspect
  50551. */
  50552. constructor(scene: Scene);
  50553. /** Creates the inspector window. */
  50554. private _createInspector;
  50555. /**
  50556. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50557. * @param entity defines the entity to select
  50558. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50559. */
  50560. select(entity: any, lineContainerTitles?: string | string[]): void;
  50561. /** Get the inspector from bundle or global */
  50562. private _getGlobalInspector;
  50563. /**
  50564. * Get if the inspector is visible or not.
  50565. * @returns true if visible otherwise, false
  50566. */
  50567. isVisible(): boolean;
  50568. /**
  50569. * Hide the inspector and close its window.
  50570. */
  50571. hide(): void;
  50572. /**
  50573. * Update the scene in the inspector
  50574. */
  50575. setAsActiveScene(): void;
  50576. /**
  50577. * Launch the debugLayer.
  50578. * @param config Define the configuration of the inspector
  50579. * @return a promise fulfilled when the debug layer is visible
  50580. */
  50581. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50582. }
  50583. }
  50584. declare module BABYLON {
  50585. /**
  50586. * Class containing static functions to help procedurally build meshes
  50587. */
  50588. export class BoxBuilder {
  50589. /**
  50590. * Creates a box mesh
  50591. * * The parameter `size` sets the size (float) of each box side (default 1)
  50592. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50593. * * 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)
  50594. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50596. * * 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
  50597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50598. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50599. * @param name defines the name of the mesh
  50600. * @param options defines the options used to create the mesh
  50601. * @param scene defines the hosting scene
  50602. * @returns the box mesh
  50603. */
  50604. static CreateBox(name: string, options: {
  50605. size?: number;
  50606. width?: number;
  50607. height?: number;
  50608. depth?: number;
  50609. faceUV?: Vector4[];
  50610. faceColors?: Color4[];
  50611. sideOrientation?: number;
  50612. frontUVs?: Vector4;
  50613. backUVs?: Vector4;
  50614. wrap?: boolean;
  50615. topBaseAt?: number;
  50616. bottomBaseAt?: number;
  50617. updatable?: boolean;
  50618. }, scene?: Nullable<Scene>): Mesh;
  50619. }
  50620. }
  50621. declare module BABYLON.Debug {
  50622. /**
  50623. * Used to show the physics impostor around the specific mesh
  50624. */
  50625. export class PhysicsViewer {
  50626. /** @hidden */
  50627. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50628. /** @hidden */
  50629. protected _meshes: Array<Nullable<AbstractMesh>>;
  50630. /** @hidden */
  50631. protected _scene: Nullable<Scene>;
  50632. /** @hidden */
  50633. protected _numMeshes: number;
  50634. /** @hidden */
  50635. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50636. private _renderFunction;
  50637. private _utilityLayer;
  50638. private _debugBoxMesh;
  50639. private _debugSphereMesh;
  50640. private _debugCylinderMesh;
  50641. private _debugMaterial;
  50642. private _debugMeshMeshes;
  50643. /**
  50644. * Creates a new PhysicsViewer
  50645. * @param scene defines the hosting scene
  50646. */
  50647. constructor(scene: Scene);
  50648. /** @hidden */
  50649. protected _updateDebugMeshes(): void;
  50650. /**
  50651. * Renders a specified physic impostor
  50652. * @param impostor defines the impostor to render
  50653. * @param targetMesh defines the mesh represented by the impostor
  50654. * @returns the new debug mesh used to render the impostor
  50655. */
  50656. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50657. /**
  50658. * Hides a specified physic impostor
  50659. * @param impostor defines the impostor to hide
  50660. */
  50661. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50662. private _getDebugMaterial;
  50663. private _getDebugBoxMesh;
  50664. private _getDebugSphereMesh;
  50665. private _getDebugCylinderMesh;
  50666. private _getDebugMeshMesh;
  50667. private _getDebugMesh;
  50668. /** Releases all resources */
  50669. dispose(): void;
  50670. }
  50671. }
  50672. declare module BABYLON {
  50673. /**
  50674. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50675. * in order to better appreciate the issue one might have.
  50676. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50677. */
  50678. export class RayHelper {
  50679. /**
  50680. * Defines the ray we are currently tryin to visualize.
  50681. */
  50682. ray: Nullable<Ray>;
  50683. private _renderPoints;
  50684. private _renderLine;
  50685. private _renderFunction;
  50686. private _scene;
  50687. private _updateToMeshFunction;
  50688. private _attachedToMesh;
  50689. private _meshSpaceDirection;
  50690. private _meshSpaceOrigin;
  50691. /**
  50692. * Helper function to create a colored helper in a scene in one line.
  50693. * @param ray Defines the ray we are currently tryin to visualize
  50694. * @param scene Defines the scene the ray is used in
  50695. * @param color Defines the color we want to see the ray in
  50696. * @returns The newly created ray helper.
  50697. */
  50698. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50699. /**
  50700. * Instantiate a new ray helper.
  50701. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50702. * in order to better appreciate the issue one might have.
  50703. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50704. * @param ray Defines the ray we are currently tryin to visualize
  50705. */
  50706. constructor(ray: Ray);
  50707. /**
  50708. * Shows the ray we are willing to debug.
  50709. * @param scene Defines the scene the ray needs to be rendered in
  50710. * @param color Defines the color the ray needs to be rendered in
  50711. */
  50712. show(scene: Scene, color?: Color3): void;
  50713. /**
  50714. * Hides the ray we are debugging.
  50715. */
  50716. hide(): void;
  50717. private _render;
  50718. /**
  50719. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50720. * @param mesh Defines the mesh we want the helper attached to
  50721. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50722. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50723. * @param length Defines the length of the ray
  50724. */
  50725. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50726. /**
  50727. * Detach the ray helper from the mesh it has previously been attached to.
  50728. */
  50729. detachFromMesh(): void;
  50730. private _updateToMesh;
  50731. /**
  50732. * Dispose the helper and release its associated resources.
  50733. */
  50734. dispose(): void;
  50735. }
  50736. }
  50737. declare module BABYLON.Debug {
  50738. /**
  50739. * Class used to render a debug view of a given skeleton
  50740. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50741. */
  50742. export class SkeletonViewer {
  50743. /** defines the skeleton to render */
  50744. skeleton: Skeleton;
  50745. /** defines the mesh attached to the skeleton */
  50746. mesh: AbstractMesh;
  50747. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50748. autoUpdateBonesMatrices: boolean;
  50749. /** defines the rendering group id to use with the viewer */
  50750. renderingGroupId: number;
  50751. /** Gets or sets the color used to render the skeleton */
  50752. color: Color3;
  50753. private _scene;
  50754. private _debugLines;
  50755. private _debugMesh;
  50756. private _isEnabled;
  50757. private _renderFunction;
  50758. private _utilityLayer;
  50759. /**
  50760. * Returns the mesh used to render the bones
  50761. */
  50762. get debugMesh(): Nullable<LinesMesh>;
  50763. /**
  50764. * Creates a new SkeletonViewer
  50765. * @param skeleton defines the skeleton to render
  50766. * @param mesh defines the mesh attached to the skeleton
  50767. * @param scene defines the hosting scene
  50768. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50769. * @param renderingGroupId defines the rendering group id to use with the viewer
  50770. */
  50771. constructor(
  50772. /** defines the skeleton to render */
  50773. skeleton: Skeleton,
  50774. /** defines the mesh attached to the skeleton */
  50775. mesh: AbstractMesh, scene: Scene,
  50776. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50777. autoUpdateBonesMatrices?: boolean,
  50778. /** defines the rendering group id to use with the viewer */
  50779. renderingGroupId?: number);
  50780. /** Gets or sets a boolean indicating if the viewer is enabled */
  50781. set isEnabled(value: boolean);
  50782. get isEnabled(): boolean;
  50783. private _getBonePosition;
  50784. private _getLinesForBonesWithLength;
  50785. private _getLinesForBonesNoLength;
  50786. /** Update the viewer to sync with current skeleton state */
  50787. update(): void;
  50788. /** Release associated resources */
  50789. dispose(): void;
  50790. }
  50791. }
  50792. declare module BABYLON {
  50793. /**
  50794. * Enum for Device Types
  50795. */
  50796. export enum DeviceType {
  50797. /** Generic */
  50798. Generic = 0,
  50799. /** Keyboard */
  50800. Keyboard = 1,
  50801. /** Mouse */
  50802. Mouse = 2,
  50803. /** Touch Pointers */
  50804. Touch = 3,
  50805. /** PS4 Dual Shock */
  50806. DualShock = 4,
  50807. /** Xbox */
  50808. Xbox = 5,
  50809. /** Switch Controller */
  50810. Switch = 6
  50811. }
  50812. /**
  50813. * Enum for All Pointers (Touch/Mouse)
  50814. */
  50815. export enum PointerInput {
  50816. /** Horizontal Axis */
  50817. Horizontal = 0,
  50818. /** Vertical Axis */
  50819. Vertical = 1,
  50820. /** Left Click or Touch */
  50821. LeftClick = 2,
  50822. /** Middle Click */
  50823. MiddleClick = 3,
  50824. /** Right Click */
  50825. RightClick = 4,
  50826. /** Browser Back */
  50827. BrowserBack = 5,
  50828. /** Browser Forward */
  50829. BrowserForward = 6
  50830. }
  50831. /**
  50832. * Enum for Dual Shock Gamepad
  50833. */
  50834. export enum DualShockInput {
  50835. /** Cross */
  50836. Cross = 0,
  50837. /** Circle */
  50838. Circle = 1,
  50839. /** Square */
  50840. Square = 2,
  50841. /** Triangle */
  50842. Triangle = 3,
  50843. /** L1 */
  50844. L1 = 4,
  50845. /** R1 */
  50846. R1 = 5,
  50847. /** L2 */
  50848. L2 = 6,
  50849. /** R2 */
  50850. R2 = 7,
  50851. /** Share */
  50852. Share = 8,
  50853. /** Options */
  50854. Options = 9,
  50855. /** L3 */
  50856. L3 = 10,
  50857. /** R3 */
  50858. R3 = 11,
  50859. /** DPadUp */
  50860. DPadUp = 12,
  50861. /** DPadDown */
  50862. DPadDown = 13,
  50863. /** DPadLeft */
  50864. DPadLeft = 14,
  50865. /** DRight */
  50866. DPadRight = 15,
  50867. /** Home */
  50868. Home = 16,
  50869. /** TouchPad */
  50870. TouchPad = 17,
  50871. /** LStickXAxis */
  50872. LStickXAxis = 18,
  50873. /** LStickYAxis */
  50874. LStickYAxis = 19,
  50875. /** RStickXAxis */
  50876. RStickXAxis = 20,
  50877. /** RStickYAxis */
  50878. RStickYAxis = 21
  50879. }
  50880. /**
  50881. * Enum for Xbox Gamepad
  50882. */
  50883. export enum XboxInput {
  50884. /** A */
  50885. A = 0,
  50886. /** B */
  50887. B = 1,
  50888. /** X */
  50889. X = 2,
  50890. /** Y */
  50891. Y = 3,
  50892. /** LB */
  50893. LB = 4,
  50894. /** RB */
  50895. RB = 5,
  50896. /** LT */
  50897. LT = 6,
  50898. /** RT */
  50899. RT = 7,
  50900. /** Back */
  50901. Back = 8,
  50902. /** Start */
  50903. Start = 9,
  50904. /** LS */
  50905. LS = 10,
  50906. /** RS */
  50907. RS = 11,
  50908. /** DPadUp */
  50909. DPadUp = 12,
  50910. /** DPadDown */
  50911. DPadDown = 13,
  50912. /** DPadLeft */
  50913. DPadLeft = 14,
  50914. /** DRight */
  50915. DPadRight = 15,
  50916. /** Home */
  50917. Home = 16,
  50918. /** LStickXAxis */
  50919. LStickXAxis = 17,
  50920. /** LStickYAxis */
  50921. LStickYAxis = 18,
  50922. /** RStickXAxis */
  50923. RStickXAxis = 19,
  50924. /** RStickYAxis */
  50925. RStickYAxis = 20
  50926. }
  50927. /**
  50928. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50929. */
  50930. export enum SwitchInput {
  50931. /** B */
  50932. B = 0,
  50933. /** A */
  50934. A = 1,
  50935. /** Y */
  50936. Y = 2,
  50937. /** X */
  50938. X = 3,
  50939. /** L */
  50940. L = 4,
  50941. /** R */
  50942. R = 5,
  50943. /** ZL */
  50944. ZL = 6,
  50945. /** ZR */
  50946. ZR = 7,
  50947. /** Minus */
  50948. Minus = 8,
  50949. /** Plus */
  50950. Plus = 9,
  50951. /** LS */
  50952. LS = 10,
  50953. /** RS */
  50954. RS = 11,
  50955. /** DPadUp */
  50956. DPadUp = 12,
  50957. /** DPadDown */
  50958. DPadDown = 13,
  50959. /** DPadLeft */
  50960. DPadLeft = 14,
  50961. /** DRight */
  50962. DPadRight = 15,
  50963. /** Home */
  50964. Home = 16,
  50965. /** Capture */
  50966. Capture = 17,
  50967. /** LStickXAxis */
  50968. LStickXAxis = 18,
  50969. /** LStickYAxis */
  50970. LStickYAxis = 19,
  50971. /** RStickXAxis */
  50972. RStickXAxis = 20,
  50973. /** RStickYAxis */
  50974. RStickYAxis = 21
  50975. }
  50976. }
  50977. declare module BABYLON {
  50978. /**
  50979. * This class will take all inputs from Keyboard, Pointer, and
  50980. * any Gamepads and provide a polling system that all devices
  50981. * will use. This class assumes that there will only be one
  50982. * pointer device and one keyboard.
  50983. */
  50984. export class DeviceInputSystem implements IDisposable {
  50985. /**
  50986. * Callback to be triggered when a device is connected
  50987. */
  50988. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50989. /**
  50990. * Callback to be triggered when a device is disconnected
  50991. */
  50992. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50993. /**
  50994. * Callback to be triggered when event driven input is updated
  50995. */
  50996. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50997. private _inputs;
  50998. private _gamepads;
  50999. private _keyboardActive;
  51000. private _pointerActive;
  51001. private _elementToAttachTo;
  51002. private _keyboardDownEvent;
  51003. private _keyboardUpEvent;
  51004. private _pointerMoveEvent;
  51005. private _pointerDownEvent;
  51006. private _pointerUpEvent;
  51007. private _gamepadConnectedEvent;
  51008. private _gamepadDisconnectedEvent;
  51009. private static _MAX_KEYCODES;
  51010. private static _MAX_POINTER_INPUTS;
  51011. private constructor();
  51012. /**
  51013. * Creates a new DeviceInputSystem instance
  51014. * @param engine Engine to pull input element from
  51015. * @returns The new instance
  51016. */
  51017. static Create(engine: Engine): DeviceInputSystem;
  51018. /**
  51019. * Checks for current device input value, given an id and input index
  51020. * @param deviceName Id of connected device
  51021. * @param inputIndex Index of device input
  51022. * @returns Current value of input
  51023. */
  51024. /**
  51025. * Checks for current device input value, given an id and input index
  51026. * @param deviceType Enum specifiying device type
  51027. * @param deviceSlot "Slot" or index that device is referenced in
  51028. * @param inputIndex Id of input to be checked
  51029. * @returns Current value of input
  51030. */
  51031. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51032. /**
  51033. * Dispose of all the eventlisteners
  51034. */
  51035. dispose(): void;
  51036. /**
  51037. * Add device and inputs to device array
  51038. * @param deviceType Enum specifiying device type
  51039. * @param deviceSlot "Slot" or index that device is referenced in
  51040. * @param numberOfInputs Number of input entries to create for given device
  51041. */
  51042. private _registerDevice;
  51043. /**
  51044. * Given a specific device name, remove that device from the device map
  51045. * @param deviceType Enum specifiying device type
  51046. * @param deviceSlot "Slot" or index that device is referenced in
  51047. */
  51048. private _unregisterDevice;
  51049. /**
  51050. * Handle all actions that come from keyboard interaction
  51051. */
  51052. private _handleKeyActions;
  51053. /**
  51054. * Handle all actions that come from pointer interaction
  51055. */
  51056. private _handlePointerActions;
  51057. /**
  51058. * Handle all actions that come from gamepad interaction
  51059. */
  51060. private _handleGamepadActions;
  51061. /**
  51062. * Update all non-event based devices with each frame
  51063. * @param deviceType Enum specifiying device type
  51064. * @param deviceSlot "Slot" or index that device is referenced in
  51065. * @param inputIndex Id of input to be checked
  51066. */
  51067. private _updateDevice;
  51068. /**
  51069. * Gets DeviceType from the device name
  51070. * @param deviceName Name of Device from DeviceInputSystem
  51071. * @returns DeviceType enum value
  51072. */
  51073. private _getGamepadDeviceType;
  51074. }
  51075. }
  51076. declare module BABYLON {
  51077. /**
  51078. * Type to handle enforcement of inputs
  51079. */
  51080. 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;
  51081. }
  51082. declare module BABYLON {
  51083. /**
  51084. * Class that handles all input for a specific device
  51085. */
  51086. export class DeviceSource<T extends DeviceType> {
  51087. /** Type of device */
  51088. readonly deviceType: DeviceType;
  51089. /** "Slot" or index that device is referenced in */
  51090. readonly deviceSlot: number;
  51091. /**
  51092. * Observable to handle device input changes per device
  51093. */
  51094. readonly onInputChangedObservable: Observable<{
  51095. inputIndex: DeviceInput<T>;
  51096. previousState: Nullable<number>;
  51097. currentState: Nullable<number>;
  51098. }>;
  51099. private readonly _deviceInputSystem;
  51100. /**
  51101. * Default Constructor
  51102. * @param deviceInputSystem Reference to DeviceInputSystem
  51103. * @param deviceType Type of device
  51104. * @param deviceSlot "Slot" or index that device is referenced in
  51105. */
  51106. constructor(deviceInputSystem: DeviceInputSystem,
  51107. /** Type of device */
  51108. deviceType: DeviceType,
  51109. /** "Slot" or index that device is referenced in */
  51110. deviceSlot?: number);
  51111. /**
  51112. * Get input for specific input
  51113. * @param inputIndex index of specific input on device
  51114. * @returns Input value from DeviceInputSystem
  51115. */
  51116. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51117. }
  51118. /**
  51119. * Class to keep track of devices
  51120. */
  51121. export class DeviceSourceManager implements IDisposable {
  51122. /**
  51123. * Observable to be triggered when before a device is connected
  51124. */
  51125. readonly onBeforeDeviceConnectedObservable: Observable<{
  51126. deviceType: DeviceType;
  51127. deviceSlot: number;
  51128. }>;
  51129. /**
  51130. * Observable to be triggered when before a device is disconnected
  51131. */
  51132. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51133. deviceType: DeviceType;
  51134. deviceSlot: number;
  51135. }>;
  51136. /**
  51137. * Observable to be triggered when after a device is connected
  51138. */
  51139. readonly onAfterDeviceConnectedObservable: Observable<{
  51140. deviceType: DeviceType;
  51141. deviceSlot: number;
  51142. }>;
  51143. /**
  51144. * Observable to be triggered when after a device is disconnected
  51145. */
  51146. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51147. deviceType: DeviceType;
  51148. deviceSlot: number;
  51149. }>;
  51150. private readonly _devices;
  51151. private readonly _firstDevice;
  51152. private readonly _deviceInputSystem;
  51153. /**
  51154. * Default Constructor
  51155. * @param engine engine to pull input element from
  51156. */
  51157. constructor(engine: Engine);
  51158. /**
  51159. * Gets a DeviceSource, given a type and slot
  51160. * @param deviceType Enum specifying device type
  51161. * @param deviceSlot "Slot" or index that device is referenced in
  51162. * @returns DeviceSource object
  51163. */
  51164. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51165. /**
  51166. * Gets an array of DeviceSource objects for a given device type
  51167. * @param deviceType Enum specifying device type
  51168. * @returns Array of DeviceSource objects
  51169. */
  51170. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51171. /**
  51172. * Dispose of DeviceInputSystem and other parts
  51173. */
  51174. dispose(): void;
  51175. /**
  51176. * Function to add device name to device list
  51177. * @param deviceType Enum specifying device type
  51178. * @param deviceSlot "Slot" or index that device is referenced in
  51179. */
  51180. private _addDevice;
  51181. /**
  51182. * Function to remove device name to device list
  51183. * @param deviceType Enum specifying device type
  51184. * @param deviceSlot "Slot" or index that device is referenced in
  51185. */
  51186. private _removeDevice;
  51187. /**
  51188. * Updates array storing first connected device of each type
  51189. * @param type Type of Device
  51190. */
  51191. private _updateFirstDevices;
  51192. }
  51193. }
  51194. declare module BABYLON {
  51195. /**
  51196. * Options to create the null engine
  51197. */
  51198. export class NullEngineOptions {
  51199. /**
  51200. * Render width (Default: 512)
  51201. */
  51202. renderWidth: number;
  51203. /**
  51204. * Render height (Default: 256)
  51205. */
  51206. renderHeight: number;
  51207. /**
  51208. * Texture size (Default: 512)
  51209. */
  51210. textureSize: number;
  51211. /**
  51212. * If delta time between frames should be constant
  51213. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51214. */
  51215. deterministicLockstep: boolean;
  51216. /**
  51217. * Maximum about of steps between frames (Default: 4)
  51218. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51219. */
  51220. lockstepMaxSteps: number;
  51221. /**
  51222. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51223. */
  51224. useHighPrecisionMatrix?: boolean;
  51225. }
  51226. /**
  51227. * The null engine class provides support for headless version of babylon.js.
  51228. * This can be used in server side scenario or for testing purposes
  51229. */
  51230. export class NullEngine extends Engine {
  51231. private _options;
  51232. /**
  51233. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51234. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51235. * @returns true if engine is in deterministic lock step mode
  51236. */
  51237. isDeterministicLockStep(): boolean;
  51238. /**
  51239. * Gets the max steps when engine is running in deterministic lock step
  51240. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51241. * @returns the max steps
  51242. */
  51243. getLockstepMaxSteps(): number;
  51244. /**
  51245. * Gets the current hardware scaling level.
  51246. * By default the hardware scaling level is computed from the window device ratio.
  51247. * 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.
  51248. * @returns a number indicating the current hardware scaling level
  51249. */
  51250. getHardwareScalingLevel(): number;
  51251. constructor(options?: NullEngineOptions);
  51252. /**
  51253. * Creates a vertex buffer
  51254. * @param vertices the data for the vertex buffer
  51255. * @returns the new WebGL static buffer
  51256. */
  51257. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51258. /**
  51259. * Creates a new index buffer
  51260. * @param indices defines the content of the index buffer
  51261. * @param updatable defines if the index buffer must be updatable
  51262. * @returns a new webGL buffer
  51263. */
  51264. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51265. /**
  51266. * Clear the current render buffer or the current render target (if any is set up)
  51267. * @param color defines the color to use
  51268. * @param backBuffer defines if the back buffer must be cleared
  51269. * @param depth defines if the depth buffer must be cleared
  51270. * @param stencil defines if the stencil buffer must be cleared
  51271. */
  51272. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51273. /**
  51274. * Gets the current render width
  51275. * @param useScreen defines if screen size must be used (or the current render target if any)
  51276. * @returns a number defining the current render width
  51277. */
  51278. getRenderWidth(useScreen?: boolean): number;
  51279. /**
  51280. * Gets the current render height
  51281. * @param useScreen defines if screen size must be used (or the current render target if any)
  51282. * @returns a number defining the current render height
  51283. */
  51284. getRenderHeight(useScreen?: boolean): number;
  51285. /**
  51286. * Set the WebGL's viewport
  51287. * @param viewport defines the viewport element to be used
  51288. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51289. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51290. */
  51291. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51292. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51293. /**
  51294. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51295. * @param pipelineContext defines the pipeline context to use
  51296. * @param uniformsNames defines the list of uniform names
  51297. * @returns an array of webGL uniform locations
  51298. */
  51299. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51300. /**
  51301. * Gets the lsit of active attributes for a given webGL program
  51302. * @param pipelineContext defines the pipeline context to use
  51303. * @param attributesNames defines the list of attribute names to get
  51304. * @returns an array of indices indicating the offset of each attribute
  51305. */
  51306. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51307. /**
  51308. * Binds an effect to the webGL context
  51309. * @param effect defines the effect to bind
  51310. */
  51311. bindSamplers(effect: Effect): void;
  51312. /**
  51313. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51314. * @param effect defines the effect to activate
  51315. */
  51316. enableEffect(effect: Effect): void;
  51317. /**
  51318. * Set various states to the webGL context
  51319. * @param culling defines backface culling state
  51320. * @param zOffset defines the value to apply to zOffset (0 by default)
  51321. * @param force defines if states must be applied even if cache is up to date
  51322. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51323. */
  51324. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51325. /**
  51326. * Set the value of an uniform to an array of int32
  51327. * @param uniform defines the webGL uniform location where to store the value
  51328. * @param array defines the array of int32 to store
  51329. */
  51330. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51331. /**
  51332. * Set the value of an uniform to an array of int32 (stored as vec2)
  51333. * @param uniform defines the webGL uniform location where to store the value
  51334. * @param array defines the array of int32 to store
  51335. */
  51336. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51337. /**
  51338. * Set the value of an uniform to an array of int32 (stored as vec3)
  51339. * @param uniform defines the webGL uniform location where to store the value
  51340. * @param array defines the array of int32 to store
  51341. */
  51342. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51343. /**
  51344. * Set the value of an uniform to an array of int32 (stored as vec4)
  51345. * @param uniform defines the webGL uniform location where to store the value
  51346. * @param array defines the array of int32 to store
  51347. */
  51348. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51349. /**
  51350. * Set the value of an uniform to an array of float32
  51351. * @param uniform defines the webGL uniform location where to store the value
  51352. * @param array defines the array of float32 to store
  51353. */
  51354. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51355. /**
  51356. * Set the value of an uniform to an array of float32 (stored as vec2)
  51357. * @param uniform defines the webGL uniform location where to store the value
  51358. * @param array defines the array of float32 to store
  51359. */
  51360. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51361. /**
  51362. * Set the value of an uniform to an array of float32 (stored as vec3)
  51363. * @param uniform defines the webGL uniform location where to store the value
  51364. * @param array defines the array of float32 to store
  51365. */
  51366. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51367. /**
  51368. * Set the value of an uniform to an array of float32 (stored as vec4)
  51369. * @param uniform defines the webGL uniform location where to store the value
  51370. * @param array defines the array of float32 to store
  51371. */
  51372. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51373. /**
  51374. * Set the value of an uniform to an array of number
  51375. * @param uniform defines the webGL uniform location where to store the value
  51376. * @param array defines the array of number to store
  51377. */
  51378. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51379. /**
  51380. * Set the value of an uniform to an array of number (stored as vec2)
  51381. * @param uniform defines the webGL uniform location where to store the value
  51382. * @param array defines the array of number to store
  51383. */
  51384. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51385. /**
  51386. * Set the value of an uniform to an array of number (stored as vec3)
  51387. * @param uniform defines the webGL uniform location where to store the value
  51388. * @param array defines the array of number to store
  51389. */
  51390. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51391. /**
  51392. * Set the value of an uniform to an array of number (stored as vec4)
  51393. * @param uniform defines the webGL uniform location where to store the value
  51394. * @param array defines the array of number to store
  51395. */
  51396. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51397. /**
  51398. * Set the value of an uniform to an array of float32 (stored as matrices)
  51399. * @param uniform defines the webGL uniform location where to store the value
  51400. * @param matrices defines the array of float32 to store
  51401. */
  51402. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51403. /**
  51404. * Set the value of an uniform to a matrix (3x3)
  51405. * @param uniform defines the webGL uniform location where to store the value
  51406. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51407. */
  51408. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51409. /**
  51410. * Set the value of an uniform to a matrix (2x2)
  51411. * @param uniform defines the webGL uniform location where to store the value
  51412. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51413. */
  51414. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51415. /**
  51416. * Set the value of an uniform to a number (float)
  51417. * @param uniform defines the webGL uniform location where to store the value
  51418. * @param value defines the float number to store
  51419. */
  51420. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51421. /**
  51422. * Set the value of an uniform to a vec2
  51423. * @param uniform defines the webGL uniform location where to store the value
  51424. * @param x defines the 1st component of the value
  51425. * @param y defines the 2nd component of the value
  51426. */
  51427. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51428. /**
  51429. * Set the value of an uniform to a vec3
  51430. * @param uniform defines the webGL uniform location where to store the value
  51431. * @param x defines the 1st component of the value
  51432. * @param y defines the 2nd component of the value
  51433. * @param z defines the 3rd component of the value
  51434. */
  51435. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51436. /**
  51437. * Set the value of an uniform to a boolean
  51438. * @param uniform defines the webGL uniform location where to store the value
  51439. * @param bool defines the boolean to store
  51440. */
  51441. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51442. /**
  51443. * Set the value of an uniform to a vec4
  51444. * @param uniform defines the webGL uniform location where to store the value
  51445. * @param x defines the 1st component of the value
  51446. * @param y defines the 2nd component of the value
  51447. * @param z defines the 3rd component of the value
  51448. * @param w defines the 4th component of the value
  51449. */
  51450. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51451. /**
  51452. * Sets the current alpha mode
  51453. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51454. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51455. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51456. */
  51457. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51458. /**
  51459. * Bind webGl buffers directly to the webGL context
  51460. * @param vertexBuffers defines the vertex buffer to bind
  51461. * @param indexBuffer defines the index buffer to bind
  51462. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51463. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51464. * @param effect defines the effect associated with the vertex buffer
  51465. */
  51466. bindBuffers(vertexBuffers: {
  51467. [key: string]: VertexBuffer;
  51468. }, indexBuffer: DataBuffer, effect: Effect): void;
  51469. /**
  51470. * Force the entire cache to be cleared
  51471. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51472. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51473. */
  51474. wipeCaches(bruteForce?: boolean): void;
  51475. /**
  51476. * Send a draw order
  51477. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51478. * @param indexStart defines the starting index
  51479. * @param indexCount defines the number of index to draw
  51480. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51481. */
  51482. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51483. /**
  51484. * Draw a list of indexed primitives
  51485. * @param fillMode defines the primitive to use
  51486. * @param indexStart defines the starting index
  51487. * @param indexCount defines the number of index to draw
  51488. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51489. */
  51490. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51491. /**
  51492. * Draw a list of unindexed primitives
  51493. * @param fillMode defines the primitive to use
  51494. * @param verticesStart defines the index of first vertex to draw
  51495. * @param verticesCount defines the count of vertices to draw
  51496. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51497. */
  51498. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51499. /** @hidden */
  51500. _createTexture(): WebGLTexture;
  51501. /** @hidden */
  51502. _releaseTexture(texture: InternalTexture): void;
  51503. /**
  51504. * Usually called from Texture.ts.
  51505. * Passed information to create a WebGLTexture
  51506. * @param urlArg defines a value which contains one of the following:
  51507. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51508. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51509. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51510. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51511. * @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)
  51512. * @param scene needed for loading to the correct scene
  51513. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51514. * @param onLoad optional callback to be called upon successful completion
  51515. * @param onError optional callback to be called upon failure
  51516. * @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
  51517. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51518. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51519. * @param forcedExtension defines the extension to use to pick the right loader
  51520. * @param mimeType defines an optional mime type
  51521. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51522. */
  51523. 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;
  51524. /**
  51525. * Creates a new render target texture
  51526. * @param size defines the size of the texture
  51527. * @param options defines the options used to create the texture
  51528. * @returns a new render target texture stored in an InternalTexture
  51529. */
  51530. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51531. /**
  51532. * Update the sampling mode of a given texture
  51533. * @param samplingMode defines the required sampling mode
  51534. * @param texture defines the texture to update
  51535. */
  51536. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51537. /**
  51538. * Binds the frame buffer to the specified texture.
  51539. * @param texture The texture to render to or null for the default canvas
  51540. * @param faceIndex The face of the texture to render to in case of cube texture
  51541. * @param requiredWidth The width of the target to render to
  51542. * @param requiredHeight The height of the target to render to
  51543. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51544. * @param lodLevel defines le lod level to bind to the frame buffer
  51545. */
  51546. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51547. /**
  51548. * Unbind the current render target texture from the webGL context
  51549. * @param texture defines the render target texture to unbind
  51550. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51551. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51552. */
  51553. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51554. /**
  51555. * Creates a dynamic vertex buffer
  51556. * @param vertices the data for the dynamic vertex buffer
  51557. * @returns the new WebGL dynamic buffer
  51558. */
  51559. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51560. /**
  51561. * Update the content of a dynamic texture
  51562. * @param texture defines the texture to update
  51563. * @param canvas defines the canvas containing the source
  51564. * @param invertY defines if data must be stored with Y axis inverted
  51565. * @param premulAlpha defines if alpha is stored as premultiplied
  51566. * @param format defines the format of the data
  51567. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51568. */
  51569. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51570. /**
  51571. * Gets a boolean indicating if all created effects are ready
  51572. * @returns true if all effects are ready
  51573. */
  51574. areAllEffectsReady(): boolean;
  51575. /**
  51576. * @hidden
  51577. * Get the current error code of the webGL context
  51578. * @returns the error code
  51579. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51580. */
  51581. getError(): number;
  51582. /** @hidden */
  51583. _getUnpackAlignement(): number;
  51584. /** @hidden */
  51585. _unpackFlipY(value: boolean): void;
  51586. /**
  51587. * Update a dynamic index buffer
  51588. * @param indexBuffer defines the target index buffer
  51589. * @param indices defines the data to update
  51590. * @param offset defines the offset in the target index buffer where update should start
  51591. */
  51592. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51593. /**
  51594. * Updates a dynamic vertex buffer.
  51595. * @param vertexBuffer the vertex buffer to update
  51596. * @param vertices the data used to update the vertex buffer
  51597. * @param byteOffset the byte offset of the data (optional)
  51598. * @param byteLength the byte length of the data (optional)
  51599. */
  51600. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51601. /** @hidden */
  51602. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51603. /** @hidden */
  51604. _bindTexture(channel: number, texture: InternalTexture): void;
  51605. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51606. /**
  51607. * 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
  51608. */
  51609. releaseEffects(): void;
  51610. displayLoadingUI(): void;
  51611. hideLoadingUI(): void;
  51612. /** @hidden */
  51613. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51614. /** @hidden */
  51615. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51616. /** @hidden */
  51617. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51618. /** @hidden */
  51619. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51620. }
  51621. }
  51622. declare module BABYLON {
  51623. /**
  51624. * @hidden
  51625. **/
  51626. export class _TimeToken {
  51627. _startTimeQuery: Nullable<WebGLQuery>;
  51628. _endTimeQuery: Nullable<WebGLQuery>;
  51629. _timeElapsedQuery: Nullable<WebGLQuery>;
  51630. _timeElapsedQueryEnded: boolean;
  51631. }
  51632. }
  51633. declare module BABYLON {
  51634. /** @hidden */
  51635. export class _OcclusionDataStorage {
  51636. /** @hidden */
  51637. occlusionInternalRetryCounter: number;
  51638. /** @hidden */
  51639. isOcclusionQueryInProgress: boolean;
  51640. /** @hidden */
  51641. isOccluded: boolean;
  51642. /** @hidden */
  51643. occlusionRetryCount: number;
  51644. /** @hidden */
  51645. occlusionType: number;
  51646. /** @hidden */
  51647. occlusionQueryAlgorithmType: number;
  51648. }
  51649. interface Engine {
  51650. /**
  51651. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51652. * @return the new query
  51653. */
  51654. createQuery(): WebGLQuery;
  51655. /**
  51656. * Delete and release a webGL query
  51657. * @param query defines the query to delete
  51658. * @return the current engine
  51659. */
  51660. deleteQuery(query: WebGLQuery): Engine;
  51661. /**
  51662. * Check if a given query has resolved and got its value
  51663. * @param query defines the query to check
  51664. * @returns true if the query got its value
  51665. */
  51666. isQueryResultAvailable(query: WebGLQuery): boolean;
  51667. /**
  51668. * Gets the value of a given query
  51669. * @param query defines the query to check
  51670. * @returns the value of the query
  51671. */
  51672. getQueryResult(query: WebGLQuery): number;
  51673. /**
  51674. * Initiates an occlusion query
  51675. * @param algorithmType defines the algorithm to use
  51676. * @param query defines the query to use
  51677. * @returns the current engine
  51678. * @see https://doc.babylonjs.com/features/occlusionquery
  51679. */
  51680. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51681. /**
  51682. * Ends an occlusion query
  51683. * @see https://doc.babylonjs.com/features/occlusionquery
  51684. * @param algorithmType defines the algorithm to use
  51685. * @returns the current engine
  51686. */
  51687. endOcclusionQuery(algorithmType: number): Engine;
  51688. /**
  51689. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51690. * Please note that only one query can be issued at a time
  51691. * @returns a time token used to track the time span
  51692. */
  51693. startTimeQuery(): Nullable<_TimeToken>;
  51694. /**
  51695. * Ends a time query
  51696. * @param token defines the token used to measure the time span
  51697. * @returns the time spent (in ns)
  51698. */
  51699. endTimeQuery(token: _TimeToken): int;
  51700. /** @hidden */
  51701. _currentNonTimestampToken: Nullable<_TimeToken>;
  51702. /** @hidden */
  51703. _createTimeQuery(): WebGLQuery;
  51704. /** @hidden */
  51705. _deleteTimeQuery(query: WebGLQuery): void;
  51706. /** @hidden */
  51707. _getGlAlgorithmType(algorithmType: number): number;
  51708. /** @hidden */
  51709. _getTimeQueryResult(query: WebGLQuery): any;
  51710. /** @hidden */
  51711. _getTimeQueryAvailability(query: WebGLQuery): any;
  51712. }
  51713. interface AbstractMesh {
  51714. /**
  51715. * Backing filed
  51716. * @hidden
  51717. */
  51718. __occlusionDataStorage: _OcclusionDataStorage;
  51719. /**
  51720. * Access property
  51721. * @hidden
  51722. */
  51723. _occlusionDataStorage: _OcclusionDataStorage;
  51724. /**
  51725. * 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.
  51726. * The default value is -1 which means don't break the query and wait till the result
  51727. * @see https://doc.babylonjs.com/features/occlusionquery
  51728. */
  51729. occlusionRetryCount: number;
  51730. /**
  51731. * 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:
  51732. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51733. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51734. * * 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.
  51735. * @see https://doc.babylonjs.com/features/occlusionquery
  51736. */
  51737. occlusionType: number;
  51738. /**
  51739. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51740. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51741. * * 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.
  51742. * @see https://doc.babylonjs.com/features/occlusionquery
  51743. */
  51744. occlusionQueryAlgorithmType: number;
  51745. /**
  51746. * 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
  51747. * @see https://doc.babylonjs.com/features/occlusionquery
  51748. */
  51749. isOccluded: boolean;
  51750. /**
  51751. * Flag to check the progress status of the query
  51752. * @see https://doc.babylonjs.com/features/occlusionquery
  51753. */
  51754. isOcclusionQueryInProgress: boolean;
  51755. }
  51756. }
  51757. declare module BABYLON {
  51758. /** @hidden */
  51759. export var _forceTransformFeedbackToBundle: boolean;
  51760. interface Engine {
  51761. /**
  51762. * Creates a webGL transform feedback object
  51763. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51764. * @returns the webGL transform feedback object
  51765. */
  51766. createTransformFeedback(): WebGLTransformFeedback;
  51767. /**
  51768. * Delete a webGL transform feedback object
  51769. * @param value defines the webGL transform feedback object to delete
  51770. */
  51771. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51772. /**
  51773. * Bind a webGL transform feedback object to the webgl context
  51774. * @param value defines the webGL transform feedback object to bind
  51775. */
  51776. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51777. /**
  51778. * Begins a transform feedback operation
  51779. * @param usePoints defines if points or triangles must be used
  51780. */
  51781. beginTransformFeedback(usePoints: boolean): void;
  51782. /**
  51783. * Ends a transform feedback operation
  51784. */
  51785. endTransformFeedback(): void;
  51786. /**
  51787. * Specify the varyings to use with transform feedback
  51788. * @param program defines the associated webGL program
  51789. * @param value defines the list of strings representing the varying names
  51790. */
  51791. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51792. /**
  51793. * Bind a webGL buffer for a transform feedback operation
  51794. * @param value defines the webGL buffer to bind
  51795. */
  51796. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51797. }
  51798. }
  51799. declare module BABYLON {
  51800. /**
  51801. * Class used to define an additional view for the engine
  51802. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51803. */
  51804. export class EngineView {
  51805. /** Defines the canvas where to render the view */
  51806. target: HTMLCanvasElement;
  51807. /** Defines an optional camera used to render the view (will use active camera else) */
  51808. camera?: Camera;
  51809. }
  51810. interface Engine {
  51811. /**
  51812. * Gets or sets the HTML element to use for attaching events
  51813. */
  51814. inputElement: Nullable<HTMLElement>;
  51815. /**
  51816. * Gets the current engine view
  51817. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51818. */
  51819. activeView: Nullable<EngineView>;
  51820. /** Gets or sets the list of views */
  51821. views: EngineView[];
  51822. /**
  51823. * Register a new child canvas
  51824. * @param canvas defines the canvas to register
  51825. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51826. * @returns the associated view
  51827. */
  51828. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51829. /**
  51830. * Remove a registered child canvas
  51831. * @param canvas defines the canvas to remove
  51832. * @returns the current engine
  51833. */
  51834. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51835. }
  51836. }
  51837. declare module BABYLON {
  51838. interface Engine {
  51839. /** @hidden */
  51840. _excludedCompressedTextures: string[];
  51841. /** @hidden */
  51842. _textureFormatInUse: string;
  51843. /**
  51844. * Gets the list of texture formats supported
  51845. */
  51846. readonly texturesSupported: Array<string>;
  51847. /**
  51848. * Gets the texture format in use
  51849. */
  51850. readonly textureFormatInUse: Nullable<string>;
  51851. /**
  51852. * Set the compressed texture extensions or file names to skip.
  51853. *
  51854. * @param skippedFiles defines the list of those texture files you want to skip
  51855. * Example: [".dds", ".env", "myfile.png"]
  51856. */
  51857. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51858. /**
  51859. * Set the compressed texture format to use, based on the formats you have, and the formats
  51860. * supported by the hardware / browser.
  51861. *
  51862. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51863. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51864. * to API arguments needed to compressed textures. This puts the burden on the container
  51865. * generator to house the arcane code for determining these for current & future formats.
  51866. *
  51867. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51868. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51869. *
  51870. * Note: The result of this call is not taken into account when a texture is base64.
  51871. *
  51872. * @param formatsAvailable defines the list of those format families you have created
  51873. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51874. *
  51875. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51876. * @returns The extension selected.
  51877. */
  51878. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51879. }
  51880. }
  51881. declare module BABYLON {
  51882. /**
  51883. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51884. */
  51885. export interface CubeMapInfo {
  51886. /**
  51887. * The pixel array for the front face.
  51888. * This is stored in format, left to right, up to down format.
  51889. */
  51890. front: Nullable<ArrayBufferView>;
  51891. /**
  51892. * The pixel array for the back face.
  51893. * This is stored in format, left to right, up to down format.
  51894. */
  51895. back: Nullable<ArrayBufferView>;
  51896. /**
  51897. * The pixel array for the left face.
  51898. * This is stored in format, left to right, up to down format.
  51899. */
  51900. left: Nullable<ArrayBufferView>;
  51901. /**
  51902. * The pixel array for the right face.
  51903. * This is stored in format, left to right, up to down format.
  51904. */
  51905. right: Nullable<ArrayBufferView>;
  51906. /**
  51907. * The pixel array for the up face.
  51908. * This is stored in format, left to right, up to down format.
  51909. */
  51910. up: Nullable<ArrayBufferView>;
  51911. /**
  51912. * The pixel array for the down face.
  51913. * This is stored in format, left to right, up to down format.
  51914. */
  51915. down: Nullable<ArrayBufferView>;
  51916. /**
  51917. * The size of the cubemap stored.
  51918. *
  51919. * Each faces will be size * size pixels.
  51920. */
  51921. size: number;
  51922. /**
  51923. * The format of the texture.
  51924. *
  51925. * RGBA, RGB.
  51926. */
  51927. format: number;
  51928. /**
  51929. * The type of the texture data.
  51930. *
  51931. * UNSIGNED_INT, FLOAT.
  51932. */
  51933. type: number;
  51934. /**
  51935. * Specifies whether the texture is in gamma space.
  51936. */
  51937. gammaSpace: boolean;
  51938. }
  51939. /**
  51940. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51941. */
  51942. export class PanoramaToCubeMapTools {
  51943. private static FACE_LEFT;
  51944. private static FACE_RIGHT;
  51945. private static FACE_FRONT;
  51946. private static FACE_BACK;
  51947. private static FACE_DOWN;
  51948. private static FACE_UP;
  51949. /**
  51950. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51951. *
  51952. * @param float32Array The source data.
  51953. * @param inputWidth The width of the input panorama.
  51954. * @param inputHeight The height of the input panorama.
  51955. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51956. * @return The cubemap data
  51957. */
  51958. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51959. private static CreateCubemapTexture;
  51960. private static CalcProjectionSpherical;
  51961. }
  51962. }
  51963. declare module BABYLON {
  51964. /**
  51965. * Helper class dealing with the extraction of spherical polynomial dataArray
  51966. * from a cube map.
  51967. */
  51968. export class CubeMapToSphericalPolynomialTools {
  51969. private static FileFaces;
  51970. /**
  51971. * Converts a texture to the according Spherical Polynomial data.
  51972. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51973. *
  51974. * @param texture The texture to extract the information from.
  51975. * @return The Spherical Polynomial data.
  51976. */
  51977. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51978. /**
  51979. * Converts a cubemap to the according Spherical Polynomial data.
  51980. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51981. *
  51982. * @param cubeInfo The Cube map to extract the information from.
  51983. * @return The Spherical Polynomial data.
  51984. */
  51985. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51986. }
  51987. }
  51988. declare module BABYLON {
  51989. interface BaseTexture {
  51990. /**
  51991. * Get the polynomial representation of the texture data.
  51992. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51993. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51994. */
  51995. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51996. }
  51997. }
  51998. declare module BABYLON {
  51999. /** @hidden */
  52000. export var rgbdEncodePixelShader: {
  52001. name: string;
  52002. shader: string;
  52003. };
  52004. }
  52005. declare module BABYLON {
  52006. /** @hidden */
  52007. export var rgbdDecodePixelShader: {
  52008. name: string;
  52009. shader: string;
  52010. };
  52011. }
  52012. declare module BABYLON {
  52013. /**
  52014. * Raw texture data and descriptor sufficient for WebGL texture upload
  52015. */
  52016. export interface EnvironmentTextureInfo {
  52017. /**
  52018. * Version of the environment map
  52019. */
  52020. version: number;
  52021. /**
  52022. * Width of image
  52023. */
  52024. width: number;
  52025. /**
  52026. * Irradiance information stored in the file.
  52027. */
  52028. irradiance: any;
  52029. /**
  52030. * Specular information stored in the file.
  52031. */
  52032. specular: any;
  52033. }
  52034. /**
  52035. * Defines One Image in the file. It requires only the position in the file
  52036. * as well as the length.
  52037. */
  52038. interface BufferImageData {
  52039. /**
  52040. * Length of the image data.
  52041. */
  52042. length: number;
  52043. /**
  52044. * Position of the data from the null terminator delimiting the end of the JSON.
  52045. */
  52046. position: number;
  52047. }
  52048. /**
  52049. * Defines the specular data enclosed in the file.
  52050. * This corresponds to the version 1 of the data.
  52051. */
  52052. export interface EnvironmentTextureSpecularInfoV1 {
  52053. /**
  52054. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52055. */
  52056. specularDataPosition?: number;
  52057. /**
  52058. * This contains all the images data needed to reconstruct the cubemap.
  52059. */
  52060. mipmaps: Array<BufferImageData>;
  52061. /**
  52062. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52063. */
  52064. lodGenerationScale: number;
  52065. }
  52066. /**
  52067. * Sets of helpers addressing the serialization and deserialization of environment texture
  52068. * stored in a BabylonJS env file.
  52069. * Those files are usually stored as .env files.
  52070. */
  52071. export class EnvironmentTextureTools {
  52072. /**
  52073. * Magic number identifying the env file.
  52074. */
  52075. private static _MagicBytes;
  52076. /**
  52077. * Gets the environment info from an env file.
  52078. * @param data The array buffer containing the .env bytes.
  52079. * @returns the environment file info (the json header) if successfully parsed.
  52080. */
  52081. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52082. /**
  52083. * Creates an environment texture from a loaded cube texture.
  52084. * @param texture defines the cube texture to convert in env file
  52085. * @return a promise containing the environment data if succesfull.
  52086. */
  52087. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52088. /**
  52089. * Creates a JSON representation of the spherical data.
  52090. * @param texture defines the texture containing the polynomials
  52091. * @return the JSON representation of the spherical info
  52092. */
  52093. private static _CreateEnvTextureIrradiance;
  52094. /**
  52095. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52096. * @param data the image data
  52097. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52098. * @return the views described by info providing access to the underlying buffer
  52099. */
  52100. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52101. /**
  52102. * Uploads the texture info contained in the env file to the GPU.
  52103. * @param texture defines the internal texture to upload to
  52104. * @param data defines the data to load
  52105. * @param info defines the texture info retrieved through the GetEnvInfo method
  52106. * @returns a promise
  52107. */
  52108. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52109. private static _OnImageReadyAsync;
  52110. /**
  52111. * Uploads the levels of image data to the GPU.
  52112. * @param texture defines the internal texture to upload to
  52113. * @param imageData defines the array buffer views of image data [mipmap][face]
  52114. * @returns a promise
  52115. */
  52116. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52117. /**
  52118. * Uploads spherical polynomials information to the texture.
  52119. * @param texture defines the texture we are trying to upload the information to
  52120. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52121. */
  52122. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52123. /** @hidden */
  52124. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52125. }
  52126. }
  52127. declare module BABYLON {
  52128. /**
  52129. * Class used to inline functions in shader code
  52130. */
  52131. export class ShaderCodeInliner {
  52132. private static readonly _RegexpFindFunctionNameAndType;
  52133. private _sourceCode;
  52134. private _functionDescr;
  52135. private _numMaxIterations;
  52136. /** Gets or sets the token used to mark the functions to inline */
  52137. inlineToken: string;
  52138. /** Gets or sets the debug mode */
  52139. debug: boolean;
  52140. /** Gets the code after the inlining process */
  52141. get code(): string;
  52142. /**
  52143. * Initializes the inliner
  52144. * @param sourceCode shader code source to inline
  52145. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52146. */
  52147. constructor(sourceCode: string, numMaxIterations?: number);
  52148. /**
  52149. * Start the processing of the shader code
  52150. */
  52151. processCode(): void;
  52152. private _collectFunctions;
  52153. private _processInlining;
  52154. private _extractBetweenMarkers;
  52155. private _skipWhitespaces;
  52156. private _removeComments;
  52157. private _replaceFunctionCallsByCode;
  52158. private _findBackward;
  52159. private _escapeRegExp;
  52160. private _replaceNames;
  52161. }
  52162. }
  52163. declare module BABYLON {
  52164. /**
  52165. * Container for accessors for natively-stored mesh data buffers.
  52166. */
  52167. class NativeDataBuffer extends DataBuffer {
  52168. /**
  52169. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52170. */
  52171. nativeIndexBuffer?: any;
  52172. /**
  52173. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52174. */
  52175. nativeVertexBuffer?: any;
  52176. }
  52177. /** @hidden */
  52178. class NativeTexture extends InternalTexture {
  52179. getInternalTexture(): InternalTexture;
  52180. getViewCount(): number;
  52181. }
  52182. /** @hidden */
  52183. export class NativeEngine extends Engine {
  52184. private readonly _native;
  52185. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52186. private readonly INVALID_HANDLE;
  52187. getHardwareScalingLevel(): number;
  52188. constructor();
  52189. dispose(): void;
  52190. /**
  52191. * Can be used to override the current requestAnimationFrame requester.
  52192. * @hidden
  52193. */
  52194. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52195. /**
  52196. * Override default engine behavior.
  52197. * @param color
  52198. * @param backBuffer
  52199. * @param depth
  52200. * @param stencil
  52201. */
  52202. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52203. /**
  52204. * Gets host document
  52205. * @returns the host document object
  52206. */
  52207. getHostDocument(): Nullable<Document>;
  52208. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52209. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52210. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52211. recordVertexArrayObject(vertexBuffers: {
  52212. [key: string]: VertexBuffer;
  52213. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52214. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52215. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52216. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52217. /**
  52218. * Draw a list of indexed primitives
  52219. * @param fillMode defines the primitive to use
  52220. * @param indexStart defines the starting index
  52221. * @param indexCount defines the number of index to draw
  52222. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52223. */
  52224. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52225. /**
  52226. * Draw a list of unindexed primitives
  52227. * @param fillMode defines the primitive to use
  52228. * @param verticesStart defines the index of first vertex to draw
  52229. * @param verticesCount defines the count of vertices to draw
  52230. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52231. */
  52232. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52233. createPipelineContext(): IPipelineContext;
  52234. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52235. /** @hidden */
  52236. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52237. /** @hidden */
  52238. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52239. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52240. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52241. protected _setProgram(program: WebGLProgram): void;
  52242. _releaseEffect(effect: Effect): void;
  52243. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52244. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52245. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52246. bindSamplers(effect: Effect): void;
  52247. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52248. getRenderWidth(useScreen?: boolean): number;
  52249. getRenderHeight(useScreen?: boolean): number;
  52250. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52251. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52252. /**
  52253. * Set the z offset to apply to current rendering
  52254. * @param value defines the offset to apply
  52255. */
  52256. setZOffset(value: number): void;
  52257. /**
  52258. * Gets the current value of the zOffset
  52259. * @returns the current zOffset state
  52260. */
  52261. getZOffset(): number;
  52262. /**
  52263. * Enable or disable depth buffering
  52264. * @param enable defines the state to set
  52265. */
  52266. setDepthBuffer(enable: boolean): void;
  52267. /**
  52268. * Gets a boolean indicating if depth writing is enabled
  52269. * @returns the current depth writing state
  52270. */
  52271. getDepthWrite(): boolean;
  52272. /**
  52273. * Enable or disable depth writing
  52274. * @param enable defines the state to set
  52275. */
  52276. setDepthWrite(enable: boolean): void;
  52277. /**
  52278. * Enable or disable color writing
  52279. * @param enable defines the state to set
  52280. */
  52281. setColorWrite(enable: boolean): void;
  52282. /**
  52283. * Gets a boolean indicating if color writing is enabled
  52284. * @returns the current color writing state
  52285. */
  52286. getColorWrite(): boolean;
  52287. /**
  52288. * Sets alpha constants used by some alpha blending modes
  52289. * @param r defines the red component
  52290. * @param g defines the green component
  52291. * @param b defines the blue component
  52292. * @param a defines the alpha component
  52293. */
  52294. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52295. /**
  52296. * Sets the current alpha mode
  52297. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52298. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52299. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52300. */
  52301. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52302. /**
  52303. * Gets the current alpha mode
  52304. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52305. * @returns the current alpha mode
  52306. */
  52307. getAlphaMode(): number;
  52308. setInt(uniform: WebGLUniformLocation, int: number): void;
  52309. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52310. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52311. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52312. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52313. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52314. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52315. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52316. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52317. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52318. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52319. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52320. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52321. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52322. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52323. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52324. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52325. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52326. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52327. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52328. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52329. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52330. wipeCaches(bruteForce?: boolean): void;
  52331. _createTexture(): WebGLTexture;
  52332. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52333. /**
  52334. * Usually called from Texture.ts.
  52335. * Passed information to create a WebGLTexture
  52336. * @param url defines a value which contains one of the following:
  52337. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52338. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52339. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52340. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52341. * @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)
  52342. * @param scene needed for loading to the correct scene
  52343. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52344. * @param onLoad optional callback to be called upon successful completion
  52345. * @param onError optional callback to be called upon failure
  52346. * @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
  52347. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52348. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52349. * @param forcedExtension defines the extension to use to pick the right loader
  52350. * @param mimeType defines an optional mime type
  52351. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52352. */
  52353. 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;
  52354. /**
  52355. * Creates a cube texture
  52356. * @param rootUrl defines the url where the files to load is located
  52357. * @param scene defines the current scene
  52358. * @param files defines the list of files to load (1 per face)
  52359. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52360. * @param onLoad defines an optional callback raised when the texture is loaded
  52361. * @param onError defines an optional callback raised if there is an issue to load the texture
  52362. * @param format defines the format of the data
  52363. * @param forcedExtension defines the extension to use to pick the right loader
  52364. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52365. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52366. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52367. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52368. * @returns the cube texture as an InternalTexture
  52369. */
  52370. 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;
  52371. private _getSamplingFilter;
  52372. private static _GetNativeTextureFormat;
  52373. createRenderTargetTexture(size: number | {
  52374. width: number;
  52375. height: number;
  52376. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52377. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52378. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52379. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52380. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52381. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52382. /**
  52383. * Updates a dynamic vertex buffer.
  52384. * @param vertexBuffer the vertex buffer to update
  52385. * @param data the data used to update the vertex buffer
  52386. * @param byteOffset the byte offset of the data (optional)
  52387. * @param byteLength the byte length of the data (optional)
  52388. */
  52389. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52390. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52391. private _updateAnisotropicLevel;
  52392. private _getAddressMode;
  52393. /** @hidden */
  52394. _bindTexture(channel: number, texture: InternalTexture): void;
  52395. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52396. releaseEffects(): void;
  52397. /** @hidden */
  52398. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52399. /** @hidden */
  52400. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52401. /** @hidden */
  52402. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52403. /** @hidden */
  52404. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52405. }
  52406. }
  52407. declare module BABYLON {
  52408. /**
  52409. * Gather the list of clipboard event types as constants.
  52410. */
  52411. export class ClipboardEventTypes {
  52412. /**
  52413. * The clipboard event is fired when a copy command is active (pressed).
  52414. */
  52415. static readonly COPY: number;
  52416. /**
  52417. * The clipboard event is fired when a cut command is active (pressed).
  52418. */
  52419. static readonly CUT: number;
  52420. /**
  52421. * The clipboard event is fired when a paste command is active (pressed).
  52422. */
  52423. static readonly PASTE: number;
  52424. }
  52425. /**
  52426. * This class is used to store clipboard related info for the onClipboardObservable event.
  52427. */
  52428. export class ClipboardInfo {
  52429. /**
  52430. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52431. */
  52432. type: number;
  52433. /**
  52434. * Defines the related dom event
  52435. */
  52436. event: ClipboardEvent;
  52437. /**
  52438. *Creates an instance of ClipboardInfo.
  52439. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52440. * @param event Defines the related dom event
  52441. */
  52442. constructor(
  52443. /**
  52444. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52445. */
  52446. type: number,
  52447. /**
  52448. * Defines the related dom event
  52449. */
  52450. event: ClipboardEvent);
  52451. /**
  52452. * Get the clipboard event's type from the keycode.
  52453. * @param keyCode Defines the keyCode for the current keyboard event.
  52454. * @return {number}
  52455. */
  52456. static GetTypeFromCharacter(keyCode: number): number;
  52457. }
  52458. }
  52459. declare module BABYLON {
  52460. /**
  52461. * Google Daydream controller
  52462. */
  52463. export class DaydreamController extends WebVRController {
  52464. /**
  52465. * Base Url for the controller model.
  52466. */
  52467. static MODEL_BASE_URL: string;
  52468. /**
  52469. * File name for the controller model.
  52470. */
  52471. static MODEL_FILENAME: string;
  52472. /**
  52473. * Gamepad Id prefix used to identify Daydream Controller.
  52474. */
  52475. static readonly GAMEPAD_ID_PREFIX: string;
  52476. /**
  52477. * Creates a new DaydreamController from a gamepad
  52478. * @param vrGamepad the gamepad that the controller should be created from
  52479. */
  52480. constructor(vrGamepad: any);
  52481. /**
  52482. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52483. * @param scene scene in which to add meshes
  52484. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52485. */
  52486. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52487. /**
  52488. * Called once for each button that changed state since the last frame
  52489. * @param buttonIdx Which button index changed
  52490. * @param state New state of the button
  52491. * @param changes Which properties on the state changed since last frame
  52492. */
  52493. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52494. }
  52495. }
  52496. declare module BABYLON {
  52497. /**
  52498. * Gear VR Controller
  52499. */
  52500. export class GearVRController extends WebVRController {
  52501. /**
  52502. * Base Url for the controller model.
  52503. */
  52504. static MODEL_BASE_URL: string;
  52505. /**
  52506. * File name for the controller model.
  52507. */
  52508. static MODEL_FILENAME: string;
  52509. /**
  52510. * Gamepad Id prefix used to identify this controller.
  52511. */
  52512. static readonly GAMEPAD_ID_PREFIX: string;
  52513. private readonly _buttonIndexToObservableNameMap;
  52514. /**
  52515. * Creates a new GearVRController from a gamepad
  52516. * @param vrGamepad the gamepad that the controller should be created from
  52517. */
  52518. constructor(vrGamepad: any);
  52519. /**
  52520. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52521. * @param scene scene in which to add meshes
  52522. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52523. */
  52524. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52525. /**
  52526. * Called once for each button that changed state since the last frame
  52527. * @param buttonIdx Which button index changed
  52528. * @param state New state of the button
  52529. * @param changes Which properties on the state changed since last frame
  52530. */
  52531. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52532. }
  52533. }
  52534. declare module BABYLON {
  52535. /**
  52536. * Generic Controller
  52537. */
  52538. export class GenericController extends WebVRController {
  52539. /**
  52540. * Base Url for the controller model.
  52541. */
  52542. static readonly MODEL_BASE_URL: string;
  52543. /**
  52544. * File name for the controller model.
  52545. */
  52546. static readonly MODEL_FILENAME: string;
  52547. /**
  52548. * Creates a new GenericController from a gamepad
  52549. * @param vrGamepad the gamepad that the controller should be created from
  52550. */
  52551. constructor(vrGamepad: any);
  52552. /**
  52553. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52554. * @param scene scene in which to add meshes
  52555. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52556. */
  52557. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52558. /**
  52559. * Called once for each button that changed state since the last frame
  52560. * @param buttonIdx Which button index changed
  52561. * @param state New state of the button
  52562. * @param changes Which properties on the state changed since last frame
  52563. */
  52564. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52565. }
  52566. }
  52567. declare module BABYLON {
  52568. /**
  52569. * Oculus Touch Controller
  52570. */
  52571. export class OculusTouchController extends WebVRController {
  52572. /**
  52573. * Base Url for the controller model.
  52574. */
  52575. static MODEL_BASE_URL: string;
  52576. /**
  52577. * File name for the left controller model.
  52578. */
  52579. static MODEL_LEFT_FILENAME: string;
  52580. /**
  52581. * File name for the right controller model.
  52582. */
  52583. static MODEL_RIGHT_FILENAME: string;
  52584. /**
  52585. * Base Url for the Quest controller model.
  52586. */
  52587. static QUEST_MODEL_BASE_URL: string;
  52588. /**
  52589. * @hidden
  52590. * If the controllers are running on a device that needs the updated Quest controller models
  52591. */
  52592. static _IsQuest: boolean;
  52593. /**
  52594. * Fired when the secondary trigger on this controller is modified
  52595. */
  52596. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52597. /**
  52598. * Fired when the thumb rest on this controller is modified
  52599. */
  52600. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52601. /**
  52602. * Creates a new OculusTouchController from a gamepad
  52603. * @param vrGamepad the gamepad that the controller should be created from
  52604. */
  52605. constructor(vrGamepad: any);
  52606. /**
  52607. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52608. * @param scene scene in which to add meshes
  52609. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52610. */
  52611. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52612. /**
  52613. * Fired when the A button on this controller is modified
  52614. */
  52615. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52616. /**
  52617. * Fired when the B button on this controller is modified
  52618. */
  52619. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52620. /**
  52621. * Fired when the X button on this controller is modified
  52622. */
  52623. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52624. /**
  52625. * Fired when the Y button on this controller is modified
  52626. */
  52627. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52628. /**
  52629. * Called once for each button that changed state since the last frame
  52630. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52631. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52632. * 2) secondary trigger (same)
  52633. * 3) A (right) X (left), touch, pressed = value
  52634. * 4) B / Y
  52635. * 5) thumb rest
  52636. * @param buttonIdx Which button index changed
  52637. * @param state New state of the button
  52638. * @param changes Which properties on the state changed since last frame
  52639. */
  52640. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52641. }
  52642. }
  52643. declare module BABYLON {
  52644. /**
  52645. * Vive Controller
  52646. */
  52647. export class ViveController extends WebVRController {
  52648. /**
  52649. * Base Url for the controller model.
  52650. */
  52651. static MODEL_BASE_URL: string;
  52652. /**
  52653. * File name for the controller model.
  52654. */
  52655. static MODEL_FILENAME: string;
  52656. /**
  52657. * Creates a new ViveController from a gamepad
  52658. * @param vrGamepad the gamepad that the controller should be created from
  52659. */
  52660. constructor(vrGamepad: any);
  52661. /**
  52662. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52663. * @param scene scene in which to add meshes
  52664. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52665. */
  52666. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52667. /**
  52668. * Fired when the left button on this controller is modified
  52669. */
  52670. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52671. /**
  52672. * Fired when the right button on this controller is modified
  52673. */
  52674. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52675. /**
  52676. * Fired when the menu button on this controller is modified
  52677. */
  52678. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52679. /**
  52680. * Called once for each button that changed state since the last frame
  52681. * Vive mapping:
  52682. * 0: touchpad
  52683. * 1: trigger
  52684. * 2: left AND right buttons
  52685. * 3: menu button
  52686. * @param buttonIdx Which button index changed
  52687. * @param state New state of the button
  52688. * @param changes Which properties on the state changed since last frame
  52689. */
  52690. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52691. }
  52692. }
  52693. declare module BABYLON {
  52694. /**
  52695. * Defines the WindowsMotionController object that the state of the windows motion controller
  52696. */
  52697. export class WindowsMotionController extends WebVRController {
  52698. /**
  52699. * The base url used to load the left and right controller models
  52700. */
  52701. static MODEL_BASE_URL: string;
  52702. /**
  52703. * The name of the left controller model file
  52704. */
  52705. static MODEL_LEFT_FILENAME: string;
  52706. /**
  52707. * The name of the right controller model file
  52708. */
  52709. static MODEL_RIGHT_FILENAME: string;
  52710. /**
  52711. * The controller name prefix for this controller type
  52712. */
  52713. static readonly GAMEPAD_ID_PREFIX: string;
  52714. /**
  52715. * The controller id pattern for this controller type
  52716. */
  52717. private static readonly GAMEPAD_ID_PATTERN;
  52718. private _loadedMeshInfo;
  52719. protected readonly _mapping: {
  52720. buttons: string[];
  52721. buttonMeshNames: {
  52722. trigger: string;
  52723. menu: string;
  52724. grip: string;
  52725. thumbstick: string;
  52726. trackpad: string;
  52727. };
  52728. buttonObservableNames: {
  52729. trigger: string;
  52730. menu: string;
  52731. grip: string;
  52732. thumbstick: string;
  52733. trackpad: string;
  52734. };
  52735. axisMeshNames: string[];
  52736. pointingPoseMeshName: string;
  52737. };
  52738. /**
  52739. * Fired when the trackpad on this controller is clicked
  52740. */
  52741. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52742. /**
  52743. * Fired when the trackpad on this controller is modified
  52744. */
  52745. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52746. /**
  52747. * The current x and y values of this controller's trackpad
  52748. */
  52749. trackpad: StickValues;
  52750. /**
  52751. * Creates a new WindowsMotionController from a gamepad
  52752. * @param vrGamepad the gamepad that the controller should be created from
  52753. */
  52754. constructor(vrGamepad: any);
  52755. /**
  52756. * Fired when the trigger on this controller is modified
  52757. */
  52758. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52759. /**
  52760. * Fired when the menu button on this controller is modified
  52761. */
  52762. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52763. /**
  52764. * Fired when the grip button on this controller is modified
  52765. */
  52766. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52767. /**
  52768. * Fired when the thumbstick button on this controller is modified
  52769. */
  52770. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52771. /**
  52772. * Fired when the touchpad button on this controller is modified
  52773. */
  52774. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52775. /**
  52776. * Fired when the touchpad values on this controller are modified
  52777. */
  52778. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52779. protected _updateTrackpad(): void;
  52780. /**
  52781. * Called once per frame by the engine.
  52782. */
  52783. update(): void;
  52784. /**
  52785. * Called once for each button that changed state since the last frame
  52786. * @param buttonIdx Which button index changed
  52787. * @param state New state of the button
  52788. * @param changes Which properties on the state changed since last frame
  52789. */
  52790. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52791. /**
  52792. * Moves the buttons on the controller mesh based on their current state
  52793. * @param buttonName the name of the button to move
  52794. * @param buttonValue the value of the button which determines the buttons new position
  52795. */
  52796. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52797. /**
  52798. * Moves the axis on the controller mesh based on its current state
  52799. * @param axis the index of the axis
  52800. * @param axisValue the value of the axis which determines the meshes new position
  52801. * @hidden
  52802. */
  52803. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52804. /**
  52805. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52806. * @param scene scene in which to add meshes
  52807. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52808. */
  52809. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52810. /**
  52811. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52812. * can be transformed by button presses and axes values, based on this._mapping.
  52813. *
  52814. * @param scene scene in which the meshes exist
  52815. * @param meshes list of meshes that make up the controller model to process
  52816. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52817. */
  52818. private processModel;
  52819. private createMeshInfo;
  52820. /**
  52821. * Gets the ray of the controller in the direction the controller is pointing
  52822. * @param length the length the resulting ray should be
  52823. * @returns a ray in the direction the controller is pointing
  52824. */
  52825. getForwardRay(length?: number): Ray;
  52826. /**
  52827. * Disposes of the controller
  52828. */
  52829. dispose(): void;
  52830. }
  52831. /**
  52832. * This class represents a new windows motion controller in XR.
  52833. */
  52834. export class XRWindowsMotionController extends WindowsMotionController {
  52835. /**
  52836. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52837. */
  52838. protected readonly _mapping: {
  52839. buttons: string[];
  52840. buttonMeshNames: {
  52841. trigger: string;
  52842. menu: string;
  52843. grip: string;
  52844. thumbstick: string;
  52845. trackpad: string;
  52846. };
  52847. buttonObservableNames: {
  52848. trigger: string;
  52849. menu: string;
  52850. grip: string;
  52851. thumbstick: string;
  52852. trackpad: string;
  52853. };
  52854. axisMeshNames: string[];
  52855. pointingPoseMeshName: string;
  52856. };
  52857. /**
  52858. * Construct a new XR-Based windows motion controller
  52859. *
  52860. * @param gamepadInfo the gamepad object from the browser
  52861. */
  52862. constructor(gamepadInfo: any);
  52863. /**
  52864. * holds the thumbstick values (X,Y)
  52865. */
  52866. thumbstickValues: StickValues;
  52867. /**
  52868. * Fired when the thumbstick on this controller is clicked
  52869. */
  52870. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52871. /**
  52872. * Fired when the thumbstick on this controller is modified
  52873. */
  52874. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52875. /**
  52876. * Fired when the touchpad button on this controller is modified
  52877. */
  52878. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52879. /**
  52880. * Fired when the touchpad values on this controller are modified
  52881. */
  52882. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52883. /**
  52884. * Fired when the thumbstick button on this controller is modified
  52885. * here to prevent breaking changes
  52886. */
  52887. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52888. /**
  52889. * updating the thumbstick(!) and not the trackpad.
  52890. * This is named this way due to the difference between WebVR and XR and to avoid
  52891. * changing the parent class.
  52892. */
  52893. protected _updateTrackpad(): void;
  52894. /**
  52895. * Disposes the class with joy
  52896. */
  52897. dispose(): void;
  52898. }
  52899. }
  52900. declare module BABYLON {
  52901. /**
  52902. * Class containing static functions to help procedurally build meshes
  52903. */
  52904. export class PolyhedronBuilder {
  52905. /**
  52906. * Creates a polyhedron mesh
  52907. * * 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
  52908. * * The parameter `size` (positive float, default 1) sets the polygon size
  52909. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52910. * * 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`
  52911. * * 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
  52912. * * 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)`)
  52913. * * 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
  52914. * * 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
  52915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52916. * * 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
  52917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52918. * @param name defines the name of the mesh
  52919. * @param options defines the options used to create the mesh
  52920. * @param scene defines the hosting scene
  52921. * @returns the polyhedron mesh
  52922. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52923. */
  52924. static CreatePolyhedron(name: string, options: {
  52925. type?: number;
  52926. size?: number;
  52927. sizeX?: number;
  52928. sizeY?: number;
  52929. sizeZ?: number;
  52930. custom?: any;
  52931. faceUV?: Vector4[];
  52932. faceColors?: Color4[];
  52933. flat?: boolean;
  52934. updatable?: boolean;
  52935. sideOrientation?: number;
  52936. frontUVs?: Vector4;
  52937. backUVs?: Vector4;
  52938. }, scene?: Nullable<Scene>): Mesh;
  52939. }
  52940. }
  52941. declare module BABYLON {
  52942. /**
  52943. * Gizmo that enables scaling a mesh along 3 axis
  52944. */
  52945. export class ScaleGizmo extends Gizmo {
  52946. /**
  52947. * Internal gizmo used for interactions on the x axis
  52948. */
  52949. xGizmo: AxisScaleGizmo;
  52950. /**
  52951. * Internal gizmo used for interactions on the y axis
  52952. */
  52953. yGizmo: AxisScaleGizmo;
  52954. /**
  52955. * Internal gizmo used for interactions on the z axis
  52956. */
  52957. zGizmo: AxisScaleGizmo;
  52958. /**
  52959. * Internal gizmo used to scale all axis equally
  52960. */
  52961. uniformScaleGizmo: AxisScaleGizmo;
  52962. private _meshAttached;
  52963. private _nodeAttached;
  52964. private _updateGizmoRotationToMatchAttachedMesh;
  52965. private _snapDistance;
  52966. private _scaleRatio;
  52967. private _uniformScalingMesh;
  52968. private _octahedron;
  52969. private _sensitivity;
  52970. /** Fires an event when any of it's sub gizmos are dragged */
  52971. onDragStartObservable: Observable<unknown>;
  52972. /** Fires an event when any of it's sub gizmos are released from dragging */
  52973. onDragEndObservable: Observable<unknown>;
  52974. get attachedMesh(): Nullable<AbstractMesh>;
  52975. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52976. get attachedNode(): Nullable<Node>;
  52977. set attachedNode(node: Nullable<Node>);
  52978. /**
  52979. * Creates a ScaleGizmo
  52980. * @param gizmoLayer The utility layer the gizmo will be added to
  52981. * @param thickness display gizmo axis thickness
  52982. */
  52983. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52984. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52985. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52986. /**
  52987. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52988. */
  52989. set snapDistance(value: number);
  52990. get snapDistance(): number;
  52991. /**
  52992. * Ratio for the scale of the gizmo (Default: 1)
  52993. */
  52994. set scaleRatio(value: number);
  52995. get scaleRatio(): number;
  52996. /**
  52997. * Sensitivity factor for dragging (Default: 1)
  52998. */
  52999. set sensitivity(value: number);
  53000. get sensitivity(): number;
  53001. /**
  53002. * Disposes of the gizmo
  53003. */
  53004. dispose(): void;
  53005. }
  53006. }
  53007. declare module BABYLON {
  53008. /**
  53009. * Single axis scale gizmo
  53010. */
  53011. export class AxisScaleGizmo extends Gizmo {
  53012. /**
  53013. * Drag behavior responsible for the gizmos dragging interactions
  53014. */
  53015. dragBehavior: PointerDragBehavior;
  53016. private _pointerObserver;
  53017. /**
  53018. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53019. */
  53020. snapDistance: number;
  53021. /**
  53022. * Event that fires each time the gizmo snaps to a new location.
  53023. * * snapDistance is the the change in distance
  53024. */
  53025. onSnapObservable: Observable<{
  53026. snapDistance: number;
  53027. }>;
  53028. /**
  53029. * If the scaling operation should be done on all axis (default: false)
  53030. */
  53031. uniformScaling: boolean;
  53032. /**
  53033. * Custom sensitivity value for the drag strength
  53034. */
  53035. sensitivity: number;
  53036. private _isEnabled;
  53037. private _parent;
  53038. private _arrow;
  53039. private _coloredMaterial;
  53040. private _hoverMaterial;
  53041. /**
  53042. * Creates an AxisScaleGizmo
  53043. * @param gizmoLayer The utility layer the gizmo will be added to
  53044. * @param dragAxis The axis which the gizmo will be able to scale on
  53045. * @param color The color of the gizmo
  53046. * @param thickness display gizmo axis thickness
  53047. */
  53048. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53049. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53050. /**
  53051. * If the gizmo is enabled
  53052. */
  53053. set isEnabled(value: boolean);
  53054. get isEnabled(): boolean;
  53055. /**
  53056. * Disposes of the gizmo
  53057. */
  53058. dispose(): void;
  53059. /**
  53060. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53061. * @param mesh The mesh to replace the default mesh of the gizmo
  53062. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53063. */
  53064. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53065. }
  53066. }
  53067. declare module BABYLON {
  53068. /**
  53069. * Bounding box gizmo
  53070. */
  53071. export class BoundingBoxGizmo extends Gizmo {
  53072. private _lineBoundingBox;
  53073. private _rotateSpheresParent;
  53074. private _scaleBoxesParent;
  53075. private _boundingDimensions;
  53076. private _renderObserver;
  53077. private _pointerObserver;
  53078. private _scaleDragSpeed;
  53079. private _tmpQuaternion;
  53080. private _tmpVector;
  53081. private _tmpRotationMatrix;
  53082. /**
  53083. * 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)
  53084. */
  53085. ignoreChildren: boolean;
  53086. /**
  53087. * 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)
  53088. */
  53089. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53090. /**
  53091. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53092. */
  53093. rotationSphereSize: number;
  53094. /**
  53095. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53096. */
  53097. scaleBoxSize: number;
  53098. /**
  53099. * 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)
  53100. */
  53101. fixedDragMeshScreenSize: boolean;
  53102. /**
  53103. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53104. */
  53105. fixedDragMeshScreenSizeDistanceFactor: number;
  53106. /**
  53107. * Fired when a rotation sphere or scale box is dragged
  53108. */
  53109. onDragStartObservable: Observable<{}>;
  53110. /**
  53111. * Fired when a scale box is dragged
  53112. */
  53113. onScaleBoxDragObservable: Observable<{}>;
  53114. /**
  53115. * Fired when a scale box drag is ended
  53116. */
  53117. onScaleBoxDragEndObservable: Observable<{}>;
  53118. /**
  53119. * Fired when a rotation sphere is dragged
  53120. */
  53121. onRotationSphereDragObservable: Observable<{}>;
  53122. /**
  53123. * Fired when a rotation sphere drag is ended
  53124. */
  53125. onRotationSphereDragEndObservable: Observable<{}>;
  53126. /**
  53127. * 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)
  53128. */
  53129. scalePivot: Nullable<Vector3>;
  53130. /**
  53131. * Mesh used as a pivot to rotate the attached node
  53132. */
  53133. private _anchorMesh;
  53134. private _existingMeshScale;
  53135. private _dragMesh;
  53136. private pointerDragBehavior;
  53137. private coloredMaterial;
  53138. private hoverColoredMaterial;
  53139. /**
  53140. * Sets the color of the bounding box gizmo
  53141. * @param color the color to set
  53142. */
  53143. setColor(color: Color3): void;
  53144. /**
  53145. * Creates an BoundingBoxGizmo
  53146. * @param gizmoLayer The utility layer the gizmo will be added to
  53147. * @param color The color of the gizmo
  53148. */
  53149. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53150. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53151. private _selectNode;
  53152. /**
  53153. * Updates the bounding box information for the Gizmo
  53154. */
  53155. updateBoundingBox(): void;
  53156. private _updateRotationSpheres;
  53157. private _updateScaleBoxes;
  53158. /**
  53159. * Enables rotation on the specified axis and disables rotation on the others
  53160. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53161. */
  53162. setEnabledRotationAxis(axis: string): void;
  53163. /**
  53164. * Enables/disables scaling
  53165. * @param enable if scaling should be enabled
  53166. * @param homogeneousScaling defines if scaling should only be homogeneous
  53167. */
  53168. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53169. private _updateDummy;
  53170. /**
  53171. * Enables a pointer drag behavior on the bounding box of the gizmo
  53172. */
  53173. enableDragBehavior(): void;
  53174. /**
  53175. * Disposes of the gizmo
  53176. */
  53177. dispose(): void;
  53178. /**
  53179. * 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)
  53180. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53181. * @returns the bounding box mesh with the passed in mesh as a child
  53182. */
  53183. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53184. /**
  53185. * CustomMeshes are not supported by this gizmo
  53186. * @param mesh The mesh to replace the default mesh of the gizmo
  53187. */
  53188. setCustomMesh(mesh: Mesh): void;
  53189. }
  53190. }
  53191. declare module BABYLON {
  53192. /**
  53193. * Single plane rotation gizmo
  53194. */
  53195. export class PlaneRotationGizmo extends Gizmo {
  53196. /**
  53197. * Drag behavior responsible for the gizmos dragging interactions
  53198. */
  53199. dragBehavior: PointerDragBehavior;
  53200. private _pointerObserver;
  53201. /**
  53202. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53203. */
  53204. snapDistance: number;
  53205. /**
  53206. * Event that fires each time the gizmo snaps to a new location.
  53207. * * snapDistance is the the change in distance
  53208. */
  53209. onSnapObservable: Observable<{
  53210. snapDistance: number;
  53211. }>;
  53212. private _isEnabled;
  53213. private _parent;
  53214. /**
  53215. * Creates a PlaneRotationGizmo
  53216. * @param gizmoLayer The utility layer the gizmo will be added to
  53217. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53218. * @param color The color of the gizmo
  53219. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53220. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53221. * @param thickness display gizmo axis thickness
  53222. */
  53223. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53224. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53225. /**
  53226. * If the gizmo is enabled
  53227. */
  53228. set isEnabled(value: boolean);
  53229. get isEnabled(): boolean;
  53230. /**
  53231. * Disposes of the gizmo
  53232. */
  53233. dispose(): void;
  53234. }
  53235. }
  53236. declare module BABYLON {
  53237. /**
  53238. * Gizmo that enables rotating a mesh along 3 axis
  53239. */
  53240. export class RotationGizmo extends Gizmo {
  53241. /**
  53242. * Internal gizmo used for interactions on the x axis
  53243. */
  53244. xGizmo: PlaneRotationGizmo;
  53245. /**
  53246. * Internal gizmo used for interactions on the y axis
  53247. */
  53248. yGizmo: PlaneRotationGizmo;
  53249. /**
  53250. * Internal gizmo used for interactions on the z axis
  53251. */
  53252. zGizmo: PlaneRotationGizmo;
  53253. /** Fires an event when any of it's sub gizmos are dragged */
  53254. onDragStartObservable: Observable<unknown>;
  53255. /** Fires an event when any of it's sub gizmos are released from dragging */
  53256. onDragEndObservable: Observable<unknown>;
  53257. private _meshAttached;
  53258. private _nodeAttached;
  53259. get attachedMesh(): Nullable<AbstractMesh>;
  53260. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53261. get attachedNode(): Nullable<Node>;
  53262. set attachedNode(node: Nullable<Node>);
  53263. /**
  53264. * Creates a RotationGizmo
  53265. * @param gizmoLayer The utility layer the gizmo will be added to
  53266. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53267. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53268. * @param thickness display gizmo axis thickness
  53269. */
  53270. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53271. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53272. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53273. /**
  53274. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53275. */
  53276. set snapDistance(value: number);
  53277. get snapDistance(): number;
  53278. /**
  53279. * Ratio for the scale of the gizmo (Default: 1)
  53280. */
  53281. set scaleRatio(value: number);
  53282. get scaleRatio(): number;
  53283. /**
  53284. * Disposes of the gizmo
  53285. */
  53286. dispose(): void;
  53287. /**
  53288. * CustomMeshes are not supported by this gizmo
  53289. * @param mesh The mesh to replace the default mesh of the gizmo
  53290. */
  53291. setCustomMesh(mesh: Mesh): void;
  53292. }
  53293. }
  53294. declare module BABYLON {
  53295. /**
  53296. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  53297. */
  53298. export class GizmoManager implements IDisposable {
  53299. private scene;
  53300. /**
  53301. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53302. */
  53303. gizmos: {
  53304. positionGizmo: Nullable<PositionGizmo>;
  53305. rotationGizmo: Nullable<RotationGizmo>;
  53306. scaleGizmo: Nullable<ScaleGizmo>;
  53307. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53308. };
  53309. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53310. clearGizmoOnEmptyPointerEvent: boolean;
  53311. /** Fires an event when the manager is attached to a mesh */
  53312. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53313. private _gizmosEnabled;
  53314. private _pointerObserver;
  53315. private _attachedMesh;
  53316. private _boundingBoxColor;
  53317. private _defaultUtilityLayer;
  53318. private _defaultKeepDepthUtilityLayer;
  53319. private _thickness;
  53320. /**
  53321. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53322. */
  53323. boundingBoxDragBehavior: SixDofDragBehavior;
  53324. /**
  53325. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53326. */
  53327. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53328. /**
  53329. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  53330. */
  53331. usePointerToAttachGizmos: boolean;
  53332. /**
  53333. * Utility layer that the bounding box gizmo belongs to
  53334. */
  53335. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53336. /**
  53337. * Utility layer that all gizmos besides bounding box belong to
  53338. */
  53339. get utilityLayer(): UtilityLayerRenderer;
  53340. /**
  53341. * Instatiates a gizmo manager
  53342. * @param scene the scene to overlay the gizmos on top of
  53343. * @param thickness display gizmo axis thickness
  53344. */
  53345. constructor(scene: Scene, thickness?: number);
  53346. /**
  53347. * Attaches a set of gizmos to the specified mesh
  53348. * @param mesh The mesh the gizmo's should be attached to
  53349. */
  53350. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53351. /**
  53352. * If the position gizmo is enabled
  53353. */
  53354. set positionGizmoEnabled(value: boolean);
  53355. get positionGizmoEnabled(): boolean;
  53356. /**
  53357. * If the rotation gizmo is enabled
  53358. */
  53359. set rotationGizmoEnabled(value: boolean);
  53360. get rotationGizmoEnabled(): boolean;
  53361. /**
  53362. * If the scale gizmo is enabled
  53363. */
  53364. set scaleGizmoEnabled(value: boolean);
  53365. get scaleGizmoEnabled(): boolean;
  53366. /**
  53367. * If the boundingBox gizmo is enabled
  53368. */
  53369. set boundingBoxGizmoEnabled(value: boolean);
  53370. get boundingBoxGizmoEnabled(): boolean;
  53371. /**
  53372. * Disposes of the gizmo manager
  53373. */
  53374. dispose(): void;
  53375. }
  53376. }
  53377. declare module BABYLON {
  53378. /**
  53379. * A directional light is defined by a direction (what a surprise!).
  53380. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53381. * 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.
  53382. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53383. */
  53384. export class DirectionalLight extends ShadowLight {
  53385. private _shadowFrustumSize;
  53386. /**
  53387. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53388. */
  53389. get shadowFrustumSize(): number;
  53390. /**
  53391. * Specifies a fix frustum size for the shadow generation.
  53392. */
  53393. set shadowFrustumSize(value: number);
  53394. private _shadowOrthoScale;
  53395. /**
  53396. * Gets the shadow projection scale against the optimal computed one.
  53397. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53398. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53399. */
  53400. get shadowOrthoScale(): number;
  53401. /**
  53402. * Sets the shadow projection scale against the optimal computed one.
  53403. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53404. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53405. */
  53406. set shadowOrthoScale(value: number);
  53407. /**
  53408. * Automatically compute the projection matrix to best fit (including all the casters)
  53409. * on each frame.
  53410. */
  53411. autoUpdateExtends: boolean;
  53412. /**
  53413. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53414. * on each frame. autoUpdateExtends must be set to true for this to work
  53415. */
  53416. autoCalcShadowZBounds: boolean;
  53417. private _orthoLeft;
  53418. private _orthoRight;
  53419. private _orthoTop;
  53420. private _orthoBottom;
  53421. /**
  53422. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53423. * The directional light is emitted from everywhere in the given direction.
  53424. * It can cast shadows.
  53425. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53426. * @param name The friendly name of the light
  53427. * @param direction The direction of the light
  53428. * @param scene The scene the light belongs to
  53429. */
  53430. constructor(name: string, direction: Vector3, scene: Scene);
  53431. /**
  53432. * Returns the string "DirectionalLight".
  53433. * @return The class name
  53434. */
  53435. getClassName(): string;
  53436. /**
  53437. * Returns the integer 1.
  53438. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53439. */
  53440. getTypeID(): number;
  53441. /**
  53442. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53443. * Returns the DirectionalLight Shadow projection matrix.
  53444. */
  53445. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53446. /**
  53447. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53448. * Returns the DirectionalLight Shadow projection matrix.
  53449. */
  53450. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53451. /**
  53452. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53453. * Returns the DirectionalLight Shadow projection matrix.
  53454. */
  53455. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53456. protected _buildUniformLayout(): void;
  53457. /**
  53458. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53459. * @param effect The effect to update
  53460. * @param lightIndex The index of the light in the effect to update
  53461. * @returns The directional light
  53462. */
  53463. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53464. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53465. /**
  53466. * Gets the minZ used for shadow according to both the scene and the light.
  53467. *
  53468. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53469. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53470. * @param activeCamera The camera we are returning the min for
  53471. * @returns the depth min z
  53472. */
  53473. getDepthMinZ(activeCamera: Camera): number;
  53474. /**
  53475. * Gets the maxZ used for shadow according to both the scene and the light.
  53476. *
  53477. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53478. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53479. * @param activeCamera The camera we are returning the max for
  53480. * @returns the depth max z
  53481. */
  53482. getDepthMaxZ(activeCamera: Camera): number;
  53483. /**
  53484. * Prepares the list of defines specific to the light type.
  53485. * @param defines the list of defines
  53486. * @param lightIndex defines the index of the light for the effect
  53487. */
  53488. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53489. }
  53490. }
  53491. declare module BABYLON {
  53492. /**
  53493. * Class containing static functions to help procedurally build meshes
  53494. */
  53495. export class HemisphereBuilder {
  53496. /**
  53497. * Creates a hemisphere mesh
  53498. * @param name defines the name of the mesh
  53499. * @param options defines the options used to create the mesh
  53500. * @param scene defines the hosting scene
  53501. * @returns the hemisphere mesh
  53502. */
  53503. static CreateHemisphere(name: string, options: {
  53504. segments?: number;
  53505. diameter?: number;
  53506. sideOrientation?: number;
  53507. }, scene: any): Mesh;
  53508. }
  53509. }
  53510. declare module BABYLON {
  53511. /**
  53512. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53513. * These values define a cone of light starting from the position, emitting toward the direction.
  53514. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53515. * and the exponent defines the speed of the decay of the light with distance (reach).
  53516. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53517. */
  53518. export class SpotLight extends ShadowLight {
  53519. private _angle;
  53520. private _innerAngle;
  53521. private _cosHalfAngle;
  53522. private _lightAngleScale;
  53523. private _lightAngleOffset;
  53524. /**
  53525. * Gets the cone angle of the spot light in Radians.
  53526. */
  53527. get angle(): number;
  53528. /**
  53529. * Sets the cone angle of the spot light in Radians.
  53530. */
  53531. set angle(value: number);
  53532. /**
  53533. * Only used in gltf falloff mode, this defines the angle where
  53534. * the directional falloff will start before cutting at angle which could be seen
  53535. * as outer angle.
  53536. */
  53537. get innerAngle(): number;
  53538. /**
  53539. * Only used in gltf falloff mode, this defines the angle where
  53540. * the directional falloff will start before cutting at angle which could be seen
  53541. * as outer angle.
  53542. */
  53543. set innerAngle(value: number);
  53544. private _shadowAngleScale;
  53545. /**
  53546. * Allows scaling the angle of the light for shadow generation only.
  53547. */
  53548. get shadowAngleScale(): number;
  53549. /**
  53550. * Allows scaling the angle of the light for shadow generation only.
  53551. */
  53552. set shadowAngleScale(value: number);
  53553. /**
  53554. * The light decay speed with the distance from the emission spot.
  53555. */
  53556. exponent: number;
  53557. private _projectionTextureMatrix;
  53558. /**
  53559. * Allows reading the projecton texture
  53560. */
  53561. get projectionTextureMatrix(): Matrix;
  53562. protected _projectionTextureLightNear: number;
  53563. /**
  53564. * Gets the near clip of the Spotlight for texture projection.
  53565. */
  53566. get projectionTextureLightNear(): number;
  53567. /**
  53568. * Sets the near clip of the Spotlight for texture projection.
  53569. */
  53570. set projectionTextureLightNear(value: number);
  53571. protected _projectionTextureLightFar: number;
  53572. /**
  53573. * Gets the far clip of the Spotlight for texture projection.
  53574. */
  53575. get projectionTextureLightFar(): number;
  53576. /**
  53577. * Sets the far clip of the Spotlight for texture projection.
  53578. */
  53579. set projectionTextureLightFar(value: number);
  53580. protected _projectionTextureUpDirection: Vector3;
  53581. /**
  53582. * Gets the Up vector of the Spotlight for texture projection.
  53583. */
  53584. get projectionTextureUpDirection(): Vector3;
  53585. /**
  53586. * Sets the Up vector of the Spotlight for texture projection.
  53587. */
  53588. set projectionTextureUpDirection(value: Vector3);
  53589. private _projectionTexture;
  53590. /**
  53591. * Gets the projection texture of the light.
  53592. */
  53593. get projectionTexture(): Nullable<BaseTexture>;
  53594. /**
  53595. * Sets the projection texture of the light.
  53596. */
  53597. set projectionTexture(value: Nullable<BaseTexture>);
  53598. private _projectionTextureViewLightDirty;
  53599. private _projectionTextureProjectionLightDirty;
  53600. private _projectionTextureDirty;
  53601. private _projectionTextureViewTargetVector;
  53602. private _projectionTextureViewLightMatrix;
  53603. private _projectionTextureProjectionLightMatrix;
  53604. private _projectionTextureScalingMatrix;
  53605. /**
  53606. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53607. * It can cast shadows.
  53608. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53609. * @param name The light friendly name
  53610. * @param position The position of the spot light in the scene
  53611. * @param direction The direction of the light in the scene
  53612. * @param angle The cone angle of the light in Radians
  53613. * @param exponent The light decay speed with the distance from the emission spot
  53614. * @param scene The scene the lights belongs to
  53615. */
  53616. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53617. /**
  53618. * Returns the string "SpotLight".
  53619. * @returns the class name
  53620. */
  53621. getClassName(): string;
  53622. /**
  53623. * Returns the integer 2.
  53624. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53625. */
  53626. getTypeID(): number;
  53627. /**
  53628. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53629. */
  53630. protected _setDirection(value: Vector3): void;
  53631. /**
  53632. * Overrides the position setter to recompute the projection texture view light Matrix.
  53633. */
  53634. protected _setPosition(value: Vector3): void;
  53635. /**
  53636. * 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.
  53637. * Returns the SpotLight.
  53638. */
  53639. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53640. protected _computeProjectionTextureViewLightMatrix(): void;
  53641. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53642. /**
  53643. * Main function for light texture projection matrix computing.
  53644. */
  53645. protected _computeProjectionTextureMatrix(): void;
  53646. protected _buildUniformLayout(): void;
  53647. private _computeAngleValues;
  53648. /**
  53649. * Sets the passed Effect "effect" with the Light textures.
  53650. * @param effect The effect to update
  53651. * @param lightIndex The index of the light in the effect to update
  53652. * @returns The light
  53653. */
  53654. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53655. /**
  53656. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53657. * @param effect The effect to update
  53658. * @param lightIndex The index of the light in the effect to update
  53659. * @returns The spot light
  53660. */
  53661. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53662. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53663. /**
  53664. * Disposes the light and the associated resources.
  53665. */
  53666. dispose(): void;
  53667. /**
  53668. * Prepares the list of defines specific to the light type.
  53669. * @param defines the list of defines
  53670. * @param lightIndex defines the index of the light for the effect
  53671. */
  53672. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53673. }
  53674. }
  53675. declare module BABYLON {
  53676. /**
  53677. * Gizmo that enables viewing a light
  53678. */
  53679. export class LightGizmo extends Gizmo {
  53680. private _lightMesh;
  53681. private _material;
  53682. private _cachedPosition;
  53683. private _cachedForward;
  53684. private _attachedMeshParent;
  53685. /**
  53686. * Creates a LightGizmo
  53687. * @param gizmoLayer The utility layer the gizmo will be added to
  53688. */
  53689. constructor(gizmoLayer?: UtilityLayerRenderer);
  53690. private _light;
  53691. /**
  53692. * The light that the gizmo is attached to
  53693. */
  53694. set light(light: Nullable<Light>);
  53695. get light(): Nullable<Light>;
  53696. /**
  53697. * Gets the material used to render the light gizmo
  53698. */
  53699. get material(): StandardMaterial;
  53700. /**
  53701. * @hidden
  53702. * Updates the gizmo to match the attached mesh's position/rotation
  53703. */
  53704. protected _update(): void;
  53705. private static _Scale;
  53706. /**
  53707. * Creates the lines for a light mesh
  53708. */
  53709. private static _CreateLightLines;
  53710. /**
  53711. * Disposes of the light gizmo
  53712. */
  53713. dispose(): void;
  53714. private static _CreateHemisphericLightMesh;
  53715. private static _CreatePointLightMesh;
  53716. private static _CreateSpotLightMesh;
  53717. private static _CreateDirectionalLightMesh;
  53718. }
  53719. }
  53720. declare module BABYLON {
  53721. /** @hidden */
  53722. export var backgroundFragmentDeclaration: {
  53723. name: string;
  53724. shader: string;
  53725. };
  53726. }
  53727. declare module BABYLON {
  53728. /** @hidden */
  53729. export var backgroundUboDeclaration: {
  53730. name: string;
  53731. shader: string;
  53732. };
  53733. }
  53734. declare module BABYLON {
  53735. /** @hidden */
  53736. export var backgroundPixelShader: {
  53737. name: string;
  53738. shader: string;
  53739. };
  53740. }
  53741. declare module BABYLON {
  53742. /** @hidden */
  53743. export var backgroundVertexDeclaration: {
  53744. name: string;
  53745. shader: string;
  53746. };
  53747. }
  53748. declare module BABYLON {
  53749. /** @hidden */
  53750. export var backgroundVertexShader: {
  53751. name: string;
  53752. shader: string;
  53753. };
  53754. }
  53755. declare module BABYLON {
  53756. /**
  53757. * Background material used to create an efficient environement around your scene.
  53758. */
  53759. export class BackgroundMaterial extends PushMaterial {
  53760. /**
  53761. * Standard reflectance value at parallel view angle.
  53762. */
  53763. static StandardReflectance0: number;
  53764. /**
  53765. * Standard reflectance value at grazing angle.
  53766. */
  53767. static StandardReflectance90: number;
  53768. protected _primaryColor: Color3;
  53769. /**
  53770. * Key light Color (multiply against the environement texture)
  53771. */
  53772. primaryColor: Color3;
  53773. protected __perceptualColor: Nullable<Color3>;
  53774. /**
  53775. * Experimental Internal Use Only.
  53776. *
  53777. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53778. * This acts as a helper to set the primary color to a more "human friendly" value.
  53779. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53780. * output color as close as possible from the chosen value.
  53781. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53782. * part of lighting setup.)
  53783. */
  53784. get _perceptualColor(): Nullable<Color3>;
  53785. set _perceptualColor(value: Nullable<Color3>);
  53786. protected _primaryColorShadowLevel: float;
  53787. /**
  53788. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53789. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53790. */
  53791. get primaryColorShadowLevel(): float;
  53792. set primaryColorShadowLevel(value: float);
  53793. protected _primaryColorHighlightLevel: float;
  53794. /**
  53795. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53796. * The primary color is used at the level chosen to define what the white area would look.
  53797. */
  53798. get primaryColorHighlightLevel(): float;
  53799. set primaryColorHighlightLevel(value: float);
  53800. protected _reflectionTexture: Nullable<BaseTexture>;
  53801. /**
  53802. * Reflection Texture used in the material.
  53803. * Should be author in a specific way for the best result (refer to the documentation).
  53804. */
  53805. reflectionTexture: Nullable<BaseTexture>;
  53806. protected _reflectionBlur: float;
  53807. /**
  53808. * Reflection Texture level of blur.
  53809. *
  53810. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53811. * texture twice.
  53812. */
  53813. reflectionBlur: float;
  53814. protected _diffuseTexture: Nullable<BaseTexture>;
  53815. /**
  53816. * Diffuse Texture used in the material.
  53817. * Should be author in a specific way for the best result (refer to the documentation).
  53818. */
  53819. diffuseTexture: Nullable<BaseTexture>;
  53820. protected _shadowLights: Nullable<IShadowLight[]>;
  53821. /**
  53822. * Specify the list of lights casting shadow on the material.
  53823. * All scene shadow lights will be included if null.
  53824. */
  53825. shadowLights: Nullable<IShadowLight[]>;
  53826. protected _shadowLevel: float;
  53827. /**
  53828. * Helps adjusting the shadow to a softer level if required.
  53829. * 0 means black shadows and 1 means no shadows.
  53830. */
  53831. shadowLevel: float;
  53832. protected _sceneCenter: Vector3;
  53833. /**
  53834. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53835. * It is usually zero but might be interesting to modify according to your setup.
  53836. */
  53837. sceneCenter: Vector3;
  53838. protected _opacityFresnel: boolean;
  53839. /**
  53840. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53841. * This helps ensuring a nice transition when the camera goes under the ground.
  53842. */
  53843. opacityFresnel: boolean;
  53844. protected _reflectionFresnel: boolean;
  53845. /**
  53846. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53847. * This helps adding a mirror texture on the ground.
  53848. */
  53849. reflectionFresnel: boolean;
  53850. protected _reflectionFalloffDistance: number;
  53851. /**
  53852. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53853. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53854. */
  53855. reflectionFalloffDistance: number;
  53856. protected _reflectionAmount: number;
  53857. /**
  53858. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53859. */
  53860. reflectionAmount: number;
  53861. protected _reflectionReflectance0: number;
  53862. /**
  53863. * This specifies the weight of the reflection at grazing angle.
  53864. */
  53865. reflectionReflectance0: number;
  53866. protected _reflectionReflectance90: number;
  53867. /**
  53868. * This specifies the weight of the reflection at a perpendicular point of view.
  53869. */
  53870. reflectionReflectance90: number;
  53871. /**
  53872. * Sets the reflection reflectance fresnel values according to the default standard
  53873. * empirically know to work well :-)
  53874. */
  53875. set reflectionStandardFresnelWeight(value: number);
  53876. protected _useRGBColor: boolean;
  53877. /**
  53878. * Helps to directly use the maps channels instead of their level.
  53879. */
  53880. useRGBColor: boolean;
  53881. protected _enableNoise: boolean;
  53882. /**
  53883. * This helps reducing the banding effect that could occur on the background.
  53884. */
  53885. enableNoise: boolean;
  53886. /**
  53887. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53888. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53889. * Recommended to be keep at 1.0 except for special cases.
  53890. */
  53891. get fovMultiplier(): number;
  53892. set fovMultiplier(value: number);
  53893. private _fovMultiplier;
  53894. /**
  53895. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53896. */
  53897. useEquirectangularFOV: boolean;
  53898. private _maxSimultaneousLights;
  53899. /**
  53900. * Number of Simultaneous lights allowed on the material.
  53901. */
  53902. maxSimultaneousLights: int;
  53903. private _shadowOnly;
  53904. /**
  53905. * Make the material only render shadows
  53906. */
  53907. shadowOnly: boolean;
  53908. /**
  53909. * Default configuration related to image processing available in the Background Material.
  53910. */
  53911. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53912. /**
  53913. * Keep track of the image processing observer to allow dispose and replace.
  53914. */
  53915. private _imageProcessingObserver;
  53916. /**
  53917. * Attaches a new image processing configuration to the PBR Material.
  53918. * @param configuration (if null the scene configuration will be use)
  53919. */
  53920. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53921. /**
  53922. * Gets the image processing configuration used either in this material.
  53923. */
  53924. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53925. /**
  53926. * Sets the Default image processing configuration used either in the this material.
  53927. *
  53928. * If sets to null, the scene one is in use.
  53929. */
  53930. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53931. /**
  53932. * Gets wether the color curves effect is enabled.
  53933. */
  53934. get cameraColorCurvesEnabled(): boolean;
  53935. /**
  53936. * Sets wether the color curves effect is enabled.
  53937. */
  53938. set cameraColorCurvesEnabled(value: boolean);
  53939. /**
  53940. * Gets wether the color grading effect is enabled.
  53941. */
  53942. get cameraColorGradingEnabled(): boolean;
  53943. /**
  53944. * Gets wether the color grading effect is enabled.
  53945. */
  53946. set cameraColorGradingEnabled(value: boolean);
  53947. /**
  53948. * Gets wether tonemapping is enabled or not.
  53949. */
  53950. get cameraToneMappingEnabled(): boolean;
  53951. /**
  53952. * Sets wether tonemapping is enabled or not
  53953. */
  53954. set cameraToneMappingEnabled(value: boolean);
  53955. /**
  53956. * The camera exposure used on this material.
  53957. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53958. * This corresponds to a photographic exposure.
  53959. */
  53960. get cameraExposure(): float;
  53961. /**
  53962. * The camera exposure used on this material.
  53963. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53964. * This corresponds to a photographic exposure.
  53965. */
  53966. set cameraExposure(value: float);
  53967. /**
  53968. * Gets The camera contrast used on this material.
  53969. */
  53970. get cameraContrast(): float;
  53971. /**
  53972. * Sets The camera contrast used on this material.
  53973. */
  53974. set cameraContrast(value: float);
  53975. /**
  53976. * Gets the Color Grading 2D Lookup Texture.
  53977. */
  53978. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53979. /**
  53980. * Sets the Color Grading 2D Lookup Texture.
  53981. */
  53982. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53983. /**
  53984. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53985. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53986. * 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;
  53987. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53988. */
  53989. get cameraColorCurves(): Nullable<ColorCurves>;
  53990. /**
  53991. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53992. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53993. * 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;
  53994. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53995. */
  53996. set cameraColorCurves(value: Nullable<ColorCurves>);
  53997. /**
  53998. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53999. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54000. */
  54001. switchToBGR: boolean;
  54002. private _renderTargets;
  54003. private _reflectionControls;
  54004. private _white;
  54005. private _primaryShadowColor;
  54006. private _primaryHighlightColor;
  54007. /**
  54008. * Instantiates a Background Material in the given scene
  54009. * @param name The friendly name of the material
  54010. * @param scene The scene to add the material to
  54011. */
  54012. constructor(name: string, scene: Scene);
  54013. /**
  54014. * Gets a boolean indicating that current material needs to register RTT
  54015. */
  54016. get hasRenderTargetTextures(): boolean;
  54017. /**
  54018. * The entire material has been created in order to prevent overdraw.
  54019. * @returns false
  54020. */
  54021. needAlphaTesting(): boolean;
  54022. /**
  54023. * The entire material has been created in order to prevent overdraw.
  54024. * @returns true if blending is enable
  54025. */
  54026. needAlphaBlending(): boolean;
  54027. /**
  54028. * Checks wether the material is ready to be rendered for a given mesh.
  54029. * @param mesh The mesh to render
  54030. * @param subMesh The submesh to check against
  54031. * @param useInstances Specify wether or not the material is used with instances
  54032. * @returns true if all the dependencies are ready (Textures, Effects...)
  54033. */
  54034. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54035. /**
  54036. * Compute the primary color according to the chosen perceptual color.
  54037. */
  54038. private _computePrimaryColorFromPerceptualColor;
  54039. /**
  54040. * Compute the highlights and shadow colors according to their chosen levels.
  54041. */
  54042. private _computePrimaryColors;
  54043. /**
  54044. * Build the uniform buffer used in the material.
  54045. */
  54046. buildUniformLayout(): void;
  54047. /**
  54048. * Unbind the material.
  54049. */
  54050. unbind(): void;
  54051. /**
  54052. * Bind only the world matrix to the material.
  54053. * @param world The world matrix to bind.
  54054. */
  54055. bindOnlyWorldMatrix(world: Matrix): void;
  54056. /**
  54057. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54058. * @param world The world matrix to bind.
  54059. * @param subMesh The submesh to bind for.
  54060. */
  54061. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54062. /**
  54063. * Checks to see if a texture is used in the material.
  54064. * @param texture - Base texture to use.
  54065. * @returns - Boolean specifying if a texture is used in the material.
  54066. */
  54067. hasTexture(texture: BaseTexture): boolean;
  54068. /**
  54069. * Dispose the material.
  54070. * @param forceDisposeEffect Force disposal of the associated effect.
  54071. * @param forceDisposeTextures Force disposal of the associated textures.
  54072. */
  54073. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54074. /**
  54075. * Clones the material.
  54076. * @param name The cloned name.
  54077. * @returns The cloned material.
  54078. */
  54079. clone(name: string): BackgroundMaterial;
  54080. /**
  54081. * Serializes the current material to its JSON representation.
  54082. * @returns The JSON representation.
  54083. */
  54084. serialize(): any;
  54085. /**
  54086. * Gets the class name of the material
  54087. * @returns "BackgroundMaterial"
  54088. */
  54089. getClassName(): string;
  54090. /**
  54091. * Parse a JSON input to create back a background material.
  54092. * @param source The JSON data to parse
  54093. * @param scene The scene to create the parsed material in
  54094. * @param rootUrl The root url of the assets the material depends upon
  54095. * @returns the instantiated BackgroundMaterial.
  54096. */
  54097. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54098. }
  54099. }
  54100. declare module BABYLON {
  54101. /**
  54102. * Represents the different options available during the creation of
  54103. * a Environment helper.
  54104. *
  54105. * This can control the default ground, skybox and image processing setup of your scene.
  54106. */
  54107. export interface IEnvironmentHelperOptions {
  54108. /**
  54109. * Specifies whether or not to create a ground.
  54110. * True by default.
  54111. */
  54112. createGround: boolean;
  54113. /**
  54114. * Specifies the ground size.
  54115. * 15 by default.
  54116. */
  54117. groundSize: number;
  54118. /**
  54119. * The texture used on the ground for the main color.
  54120. * Comes from the BabylonJS CDN by default.
  54121. *
  54122. * Remarks: Can be either a texture or a url.
  54123. */
  54124. groundTexture: string | BaseTexture;
  54125. /**
  54126. * The color mixed in the ground texture by default.
  54127. * BabylonJS clearColor by default.
  54128. */
  54129. groundColor: Color3;
  54130. /**
  54131. * Specifies the ground opacity.
  54132. * 1 by default.
  54133. */
  54134. groundOpacity: number;
  54135. /**
  54136. * Enables the ground to receive shadows.
  54137. * True by default.
  54138. */
  54139. enableGroundShadow: boolean;
  54140. /**
  54141. * Helps preventing the shadow to be fully black on the ground.
  54142. * 0.5 by default.
  54143. */
  54144. groundShadowLevel: number;
  54145. /**
  54146. * Creates a mirror texture attach to the ground.
  54147. * false by default.
  54148. */
  54149. enableGroundMirror: boolean;
  54150. /**
  54151. * Specifies the ground mirror size ratio.
  54152. * 0.3 by default as the default kernel is 64.
  54153. */
  54154. groundMirrorSizeRatio: number;
  54155. /**
  54156. * Specifies the ground mirror blur kernel size.
  54157. * 64 by default.
  54158. */
  54159. groundMirrorBlurKernel: number;
  54160. /**
  54161. * Specifies the ground mirror visibility amount.
  54162. * 1 by default
  54163. */
  54164. groundMirrorAmount: number;
  54165. /**
  54166. * Specifies the ground mirror reflectance weight.
  54167. * This uses the standard weight of the background material to setup the fresnel effect
  54168. * of the mirror.
  54169. * 1 by default.
  54170. */
  54171. groundMirrorFresnelWeight: number;
  54172. /**
  54173. * Specifies the ground mirror Falloff distance.
  54174. * This can helps reducing the size of the reflection.
  54175. * 0 by Default.
  54176. */
  54177. groundMirrorFallOffDistance: number;
  54178. /**
  54179. * Specifies the ground mirror texture type.
  54180. * Unsigned Int by Default.
  54181. */
  54182. groundMirrorTextureType: number;
  54183. /**
  54184. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54185. * the shown objects.
  54186. */
  54187. groundYBias: number;
  54188. /**
  54189. * Specifies whether or not to create a skybox.
  54190. * True by default.
  54191. */
  54192. createSkybox: boolean;
  54193. /**
  54194. * Specifies the skybox size.
  54195. * 20 by default.
  54196. */
  54197. skyboxSize: number;
  54198. /**
  54199. * The texture used on the skybox for the main color.
  54200. * Comes from the BabylonJS CDN by default.
  54201. *
  54202. * Remarks: Can be either a texture or a url.
  54203. */
  54204. skyboxTexture: string | BaseTexture;
  54205. /**
  54206. * The color mixed in the skybox texture by default.
  54207. * BabylonJS clearColor by default.
  54208. */
  54209. skyboxColor: Color3;
  54210. /**
  54211. * The background rotation around the Y axis of the scene.
  54212. * This helps aligning the key lights of your scene with the background.
  54213. * 0 by default.
  54214. */
  54215. backgroundYRotation: number;
  54216. /**
  54217. * Compute automatically the size of the elements to best fit with the scene.
  54218. */
  54219. sizeAuto: boolean;
  54220. /**
  54221. * Default position of the rootMesh if autoSize is not true.
  54222. */
  54223. rootPosition: Vector3;
  54224. /**
  54225. * Sets up the image processing in the scene.
  54226. * true by default.
  54227. */
  54228. setupImageProcessing: boolean;
  54229. /**
  54230. * The texture used as your environment texture in the scene.
  54231. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54232. *
  54233. * Remarks: Can be either a texture or a url.
  54234. */
  54235. environmentTexture: string | BaseTexture;
  54236. /**
  54237. * The value of the exposure to apply to the scene.
  54238. * 0.6 by default if setupImageProcessing is true.
  54239. */
  54240. cameraExposure: number;
  54241. /**
  54242. * The value of the contrast to apply to the scene.
  54243. * 1.6 by default if setupImageProcessing is true.
  54244. */
  54245. cameraContrast: number;
  54246. /**
  54247. * Specifies whether or not tonemapping should be enabled in the scene.
  54248. * true by default if setupImageProcessing is true.
  54249. */
  54250. toneMappingEnabled: boolean;
  54251. }
  54252. /**
  54253. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54254. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54255. * It also helps with the default setup of your imageProcessing configuration.
  54256. */
  54257. export class EnvironmentHelper {
  54258. /**
  54259. * Default ground texture URL.
  54260. */
  54261. private static _groundTextureCDNUrl;
  54262. /**
  54263. * Default skybox texture URL.
  54264. */
  54265. private static _skyboxTextureCDNUrl;
  54266. /**
  54267. * Default environment texture URL.
  54268. */
  54269. private static _environmentTextureCDNUrl;
  54270. /**
  54271. * Creates the default options for the helper.
  54272. */
  54273. private static _getDefaultOptions;
  54274. private _rootMesh;
  54275. /**
  54276. * Gets the root mesh created by the helper.
  54277. */
  54278. get rootMesh(): Mesh;
  54279. private _skybox;
  54280. /**
  54281. * Gets the skybox created by the helper.
  54282. */
  54283. get skybox(): Nullable<Mesh>;
  54284. private _skyboxTexture;
  54285. /**
  54286. * Gets the skybox texture created by the helper.
  54287. */
  54288. get skyboxTexture(): Nullable<BaseTexture>;
  54289. private _skyboxMaterial;
  54290. /**
  54291. * Gets the skybox material created by the helper.
  54292. */
  54293. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54294. private _ground;
  54295. /**
  54296. * Gets the ground mesh created by the helper.
  54297. */
  54298. get ground(): Nullable<Mesh>;
  54299. private _groundTexture;
  54300. /**
  54301. * Gets the ground texture created by the helper.
  54302. */
  54303. get groundTexture(): Nullable<BaseTexture>;
  54304. private _groundMirror;
  54305. /**
  54306. * Gets the ground mirror created by the helper.
  54307. */
  54308. get groundMirror(): Nullable<MirrorTexture>;
  54309. /**
  54310. * Gets the ground mirror render list to helps pushing the meshes
  54311. * you wish in the ground reflection.
  54312. */
  54313. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54314. private _groundMaterial;
  54315. /**
  54316. * Gets the ground material created by the helper.
  54317. */
  54318. get groundMaterial(): Nullable<BackgroundMaterial>;
  54319. /**
  54320. * Stores the creation options.
  54321. */
  54322. private readonly _scene;
  54323. private _options;
  54324. /**
  54325. * This observable will be notified with any error during the creation of the environment,
  54326. * mainly texture creation errors.
  54327. */
  54328. onErrorObservable: Observable<{
  54329. message?: string;
  54330. exception?: any;
  54331. }>;
  54332. /**
  54333. * constructor
  54334. * @param options Defines the options we want to customize the helper
  54335. * @param scene The scene to add the material to
  54336. */
  54337. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54338. /**
  54339. * Updates the background according to the new options
  54340. * @param options
  54341. */
  54342. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54343. /**
  54344. * Sets the primary color of all the available elements.
  54345. * @param color the main color to affect to the ground and the background
  54346. */
  54347. setMainColor(color: Color3): void;
  54348. /**
  54349. * Setup the image processing according to the specified options.
  54350. */
  54351. private _setupImageProcessing;
  54352. /**
  54353. * Setup the environment texture according to the specified options.
  54354. */
  54355. private _setupEnvironmentTexture;
  54356. /**
  54357. * Setup the background according to the specified options.
  54358. */
  54359. private _setupBackground;
  54360. /**
  54361. * Get the scene sizes according to the setup.
  54362. */
  54363. private _getSceneSize;
  54364. /**
  54365. * Setup the ground according to the specified options.
  54366. */
  54367. private _setupGround;
  54368. /**
  54369. * Setup the ground material according to the specified options.
  54370. */
  54371. private _setupGroundMaterial;
  54372. /**
  54373. * Setup the ground diffuse texture according to the specified options.
  54374. */
  54375. private _setupGroundDiffuseTexture;
  54376. /**
  54377. * Setup the ground mirror texture according to the specified options.
  54378. */
  54379. private _setupGroundMirrorTexture;
  54380. /**
  54381. * Setup the ground to receive the mirror texture.
  54382. */
  54383. private _setupMirrorInGroundMaterial;
  54384. /**
  54385. * Setup the skybox according to the specified options.
  54386. */
  54387. private _setupSkybox;
  54388. /**
  54389. * Setup the skybox material according to the specified options.
  54390. */
  54391. private _setupSkyboxMaterial;
  54392. /**
  54393. * Setup the skybox reflection texture according to the specified options.
  54394. */
  54395. private _setupSkyboxReflectionTexture;
  54396. private _errorHandler;
  54397. /**
  54398. * Dispose all the elements created by the Helper.
  54399. */
  54400. dispose(): void;
  54401. }
  54402. }
  54403. declare module BABYLON {
  54404. /**
  54405. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54406. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54407. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54408. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54409. */
  54410. export class PhotoDome extends TransformNode {
  54411. /**
  54412. * Define the image as a Monoscopic panoramic 360 image.
  54413. */
  54414. static readonly MODE_MONOSCOPIC: number;
  54415. /**
  54416. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54417. */
  54418. static readonly MODE_TOPBOTTOM: number;
  54419. /**
  54420. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54421. */
  54422. static readonly MODE_SIDEBYSIDE: number;
  54423. private _useDirectMapping;
  54424. /**
  54425. * The texture being displayed on the sphere
  54426. */
  54427. protected _photoTexture: Texture;
  54428. /**
  54429. * Gets or sets the texture being displayed on the sphere
  54430. */
  54431. get photoTexture(): Texture;
  54432. set photoTexture(value: Texture);
  54433. /**
  54434. * Observable raised when an error occured while loading the 360 image
  54435. */
  54436. onLoadErrorObservable: Observable<string>;
  54437. /**
  54438. * The skybox material
  54439. */
  54440. protected _material: BackgroundMaterial;
  54441. /**
  54442. * The surface used for the skybox
  54443. */
  54444. protected _mesh: Mesh;
  54445. /**
  54446. * Gets the mesh used for the skybox.
  54447. */
  54448. get mesh(): Mesh;
  54449. /**
  54450. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54451. * Also see the options.resolution property.
  54452. */
  54453. get fovMultiplier(): number;
  54454. set fovMultiplier(value: number);
  54455. private _imageMode;
  54456. /**
  54457. * Gets or set the current video mode for the video. It can be:
  54458. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54459. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54460. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54461. */
  54462. get imageMode(): number;
  54463. set imageMode(value: number);
  54464. /**
  54465. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54466. * @param name Element's name, child elements will append suffixes for their own names.
  54467. * @param urlsOfPhoto defines the url of the photo to display
  54468. * @param options defines an object containing optional or exposed sub element properties
  54469. * @param onError defines a callback called when an error occured while loading the texture
  54470. */
  54471. constructor(name: string, urlOfPhoto: string, options: {
  54472. resolution?: number;
  54473. size?: number;
  54474. useDirectMapping?: boolean;
  54475. faceForward?: boolean;
  54476. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54477. private _onBeforeCameraRenderObserver;
  54478. private _changeImageMode;
  54479. /**
  54480. * Releases resources associated with this node.
  54481. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54482. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54483. */
  54484. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54485. }
  54486. }
  54487. declare module BABYLON {
  54488. /**
  54489. * Class used to host RGBD texture specific utilities
  54490. */
  54491. export class RGBDTextureTools {
  54492. /**
  54493. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54494. * @param texture the texture to expand.
  54495. */
  54496. static ExpandRGBDTexture(texture: Texture): void;
  54497. }
  54498. }
  54499. declare module BABYLON {
  54500. /**
  54501. * Class used to host texture specific utilities
  54502. */
  54503. export class BRDFTextureTools {
  54504. /**
  54505. * Prevents texture cache collision
  54506. */
  54507. private static _instanceNumber;
  54508. /**
  54509. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54510. * @param scene defines the hosting scene
  54511. * @returns the environment BRDF texture
  54512. */
  54513. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54514. private static _environmentBRDFBase64Texture;
  54515. }
  54516. }
  54517. declare module BABYLON {
  54518. /**
  54519. * @hidden
  54520. */
  54521. export interface IMaterialClearCoatDefines {
  54522. CLEARCOAT: boolean;
  54523. CLEARCOAT_DEFAULTIOR: boolean;
  54524. CLEARCOAT_TEXTURE: boolean;
  54525. CLEARCOAT_TEXTUREDIRECTUV: number;
  54526. CLEARCOAT_BUMP: boolean;
  54527. CLEARCOAT_BUMPDIRECTUV: number;
  54528. CLEARCOAT_TINT: boolean;
  54529. CLEARCOAT_TINT_TEXTURE: boolean;
  54530. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54531. /** @hidden */
  54532. _areTexturesDirty: boolean;
  54533. }
  54534. /**
  54535. * Define the code related to the clear coat parameters of the pbr material.
  54536. */
  54537. export class PBRClearCoatConfiguration {
  54538. /**
  54539. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54540. * The default fits with a polyurethane material.
  54541. */
  54542. private static readonly _DefaultIndexOfRefraction;
  54543. private _isEnabled;
  54544. /**
  54545. * Defines if the clear coat is enabled in the material.
  54546. */
  54547. isEnabled: boolean;
  54548. /**
  54549. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54550. */
  54551. intensity: number;
  54552. /**
  54553. * Defines the clear coat layer roughness.
  54554. */
  54555. roughness: number;
  54556. private _indexOfRefraction;
  54557. /**
  54558. * Defines the index of refraction of the clear coat.
  54559. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54560. * The default fits with a polyurethane material.
  54561. * Changing the default value is more performance intensive.
  54562. */
  54563. indexOfRefraction: number;
  54564. private _texture;
  54565. /**
  54566. * Stores the clear coat values in a texture.
  54567. */
  54568. texture: Nullable<BaseTexture>;
  54569. private _bumpTexture;
  54570. /**
  54571. * Define the clear coat specific bump texture.
  54572. */
  54573. bumpTexture: Nullable<BaseTexture>;
  54574. private _isTintEnabled;
  54575. /**
  54576. * Defines if the clear coat tint is enabled in the material.
  54577. */
  54578. isTintEnabled: boolean;
  54579. /**
  54580. * Defines the clear coat tint of the material.
  54581. * This is only use if tint is enabled
  54582. */
  54583. tintColor: Color3;
  54584. /**
  54585. * Defines the distance at which the tint color should be found in the
  54586. * clear coat media.
  54587. * This is only use if tint is enabled
  54588. */
  54589. tintColorAtDistance: number;
  54590. /**
  54591. * Defines the clear coat layer thickness.
  54592. * This is only use if tint is enabled
  54593. */
  54594. tintThickness: number;
  54595. private _tintTexture;
  54596. /**
  54597. * Stores the clear tint values in a texture.
  54598. * rgb is tint
  54599. * a is a thickness factor
  54600. */
  54601. tintTexture: Nullable<BaseTexture>;
  54602. /** @hidden */
  54603. private _internalMarkAllSubMeshesAsTexturesDirty;
  54604. /** @hidden */
  54605. _markAllSubMeshesAsTexturesDirty(): void;
  54606. /**
  54607. * Instantiate a new istance of clear coat configuration.
  54608. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54609. */
  54610. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54611. /**
  54612. * Gets wehter the submesh is ready to be used or not.
  54613. * @param defines the list of "defines" to update.
  54614. * @param scene defines the scene the material belongs to.
  54615. * @param engine defines the engine the material belongs to.
  54616. * @param disableBumpMap defines wether the material disables bump or not.
  54617. * @returns - boolean indicating that the submesh is ready or not.
  54618. */
  54619. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54620. /**
  54621. * Checks to see if a texture is used in the material.
  54622. * @param defines the list of "defines" to update.
  54623. * @param scene defines the scene to the material belongs to.
  54624. */
  54625. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54626. /**
  54627. * Binds the material data.
  54628. * @param uniformBuffer defines the Uniform buffer to fill in.
  54629. * @param scene defines the scene the material belongs to.
  54630. * @param engine defines the engine the material belongs to.
  54631. * @param disableBumpMap defines wether the material disables bump or not.
  54632. * @param isFrozen defines wether the material is frozen or not.
  54633. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54634. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54635. */
  54636. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54637. /**
  54638. * Checks to see if a texture is used in the material.
  54639. * @param texture - Base texture to use.
  54640. * @returns - Boolean specifying if a texture is used in the material.
  54641. */
  54642. hasTexture(texture: BaseTexture): boolean;
  54643. /**
  54644. * Returns an array of the actively used textures.
  54645. * @param activeTextures Array of BaseTextures
  54646. */
  54647. getActiveTextures(activeTextures: BaseTexture[]): void;
  54648. /**
  54649. * Returns the animatable textures.
  54650. * @param animatables Array of animatable textures.
  54651. */
  54652. getAnimatables(animatables: IAnimatable[]): void;
  54653. /**
  54654. * Disposes the resources of the material.
  54655. * @param forceDisposeTextures - Forces the disposal of all textures.
  54656. */
  54657. dispose(forceDisposeTextures?: boolean): void;
  54658. /**
  54659. * Get the current class name of the texture useful for serialization or dynamic coding.
  54660. * @returns "PBRClearCoatConfiguration"
  54661. */
  54662. getClassName(): string;
  54663. /**
  54664. * Add fallbacks to the effect fallbacks list.
  54665. * @param defines defines the Base texture to use.
  54666. * @param fallbacks defines the current fallback list.
  54667. * @param currentRank defines the current fallback rank.
  54668. * @returns the new fallback rank.
  54669. */
  54670. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54671. /**
  54672. * Add the required uniforms to the current list.
  54673. * @param uniforms defines the current uniform list.
  54674. */
  54675. static AddUniforms(uniforms: string[]): void;
  54676. /**
  54677. * Add the required samplers to the current list.
  54678. * @param samplers defines the current sampler list.
  54679. */
  54680. static AddSamplers(samplers: string[]): void;
  54681. /**
  54682. * Add the required uniforms to the current buffer.
  54683. * @param uniformBuffer defines the current uniform buffer.
  54684. */
  54685. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54686. /**
  54687. * Makes a duplicate of the current configuration into another one.
  54688. * @param clearCoatConfiguration define the config where to copy the info
  54689. */
  54690. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54691. /**
  54692. * Serializes this clear coat configuration.
  54693. * @returns - An object with the serialized config.
  54694. */
  54695. serialize(): any;
  54696. /**
  54697. * Parses a anisotropy Configuration from a serialized object.
  54698. * @param source - Serialized object.
  54699. * @param scene Defines the scene we are parsing for
  54700. * @param rootUrl Defines the rootUrl to load from
  54701. */
  54702. parse(source: any, scene: Scene, rootUrl: string): void;
  54703. }
  54704. }
  54705. declare module BABYLON {
  54706. /**
  54707. * @hidden
  54708. */
  54709. export interface IMaterialAnisotropicDefines {
  54710. ANISOTROPIC: boolean;
  54711. ANISOTROPIC_TEXTURE: boolean;
  54712. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54713. MAINUV1: boolean;
  54714. _areTexturesDirty: boolean;
  54715. _needUVs: boolean;
  54716. }
  54717. /**
  54718. * Define the code related to the anisotropic parameters of the pbr material.
  54719. */
  54720. export class PBRAnisotropicConfiguration {
  54721. private _isEnabled;
  54722. /**
  54723. * Defines if the anisotropy is enabled in the material.
  54724. */
  54725. isEnabled: boolean;
  54726. /**
  54727. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54728. */
  54729. intensity: number;
  54730. /**
  54731. * Defines if the effect is along the tangents, bitangents or in between.
  54732. * By default, the effect is "strectching" the highlights along the tangents.
  54733. */
  54734. direction: Vector2;
  54735. private _texture;
  54736. /**
  54737. * Stores the anisotropy values in a texture.
  54738. * rg is direction (like normal from -1 to 1)
  54739. * b is a intensity
  54740. */
  54741. texture: Nullable<BaseTexture>;
  54742. /** @hidden */
  54743. private _internalMarkAllSubMeshesAsTexturesDirty;
  54744. /** @hidden */
  54745. _markAllSubMeshesAsTexturesDirty(): void;
  54746. /**
  54747. * Instantiate a new istance of anisotropy configuration.
  54748. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54749. */
  54750. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54751. /**
  54752. * Specifies that the submesh is ready to be used.
  54753. * @param defines the list of "defines" to update.
  54754. * @param scene defines the scene the material belongs to.
  54755. * @returns - boolean indicating that the submesh is ready or not.
  54756. */
  54757. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54758. /**
  54759. * Checks to see if a texture is used in the material.
  54760. * @param defines the list of "defines" to update.
  54761. * @param mesh the mesh we are preparing the defines for.
  54762. * @param scene defines the scene the material belongs to.
  54763. */
  54764. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54765. /**
  54766. * Binds the material data.
  54767. * @param uniformBuffer defines the Uniform buffer to fill in.
  54768. * @param scene defines the scene the material belongs to.
  54769. * @param isFrozen defines wether the material is frozen or not.
  54770. */
  54771. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54772. /**
  54773. * Checks to see if a texture is used in the material.
  54774. * @param texture - Base texture to use.
  54775. * @returns - Boolean specifying if a texture is used in the material.
  54776. */
  54777. hasTexture(texture: BaseTexture): boolean;
  54778. /**
  54779. * Returns an array of the actively used textures.
  54780. * @param activeTextures Array of BaseTextures
  54781. */
  54782. getActiveTextures(activeTextures: BaseTexture[]): void;
  54783. /**
  54784. * Returns the animatable textures.
  54785. * @param animatables Array of animatable textures.
  54786. */
  54787. getAnimatables(animatables: IAnimatable[]): void;
  54788. /**
  54789. * Disposes the resources of the material.
  54790. * @param forceDisposeTextures - Forces the disposal of all textures.
  54791. */
  54792. dispose(forceDisposeTextures?: boolean): void;
  54793. /**
  54794. * Get the current class name of the texture useful for serialization or dynamic coding.
  54795. * @returns "PBRAnisotropicConfiguration"
  54796. */
  54797. getClassName(): string;
  54798. /**
  54799. * Add fallbacks to the effect fallbacks list.
  54800. * @param defines defines the Base texture to use.
  54801. * @param fallbacks defines the current fallback list.
  54802. * @param currentRank defines the current fallback rank.
  54803. * @returns the new fallback rank.
  54804. */
  54805. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54806. /**
  54807. * Add the required uniforms to the current list.
  54808. * @param uniforms defines the current uniform list.
  54809. */
  54810. static AddUniforms(uniforms: string[]): void;
  54811. /**
  54812. * Add the required uniforms to the current buffer.
  54813. * @param uniformBuffer defines the current uniform buffer.
  54814. */
  54815. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54816. /**
  54817. * Add the required samplers to the current list.
  54818. * @param samplers defines the current sampler list.
  54819. */
  54820. static AddSamplers(samplers: string[]): void;
  54821. /**
  54822. * Makes a duplicate of the current configuration into another one.
  54823. * @param anisotropicConfiguration define the config where to copy the info
  54824. */
  54825. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54826. /**
  54827. * Serializes this anisotropy configuration.
  54828. * @returns - An object with the serialized config.
  54829. */
  54830. serialize(): any;
  54831. /**
  54832. * Parses a anisotropy Configuration from a serialized object.
  54833. * @param source - Serialized object.
  54834. * @param scene Defines the scene we are parsing for
  54835. * @param rootUrl Defines the rootUrl to load from
  54836. */
  54837. parse(source: any, scene: Scene, rootUrl: string): void;
  54838. }
  54839. }
  54840. declare module BABYLON {
  54841. /**
  54842. * @hidden
  54843. */
  54844. export interface IMaterialBRDFDefines {
  54845. BRDF_V_HEIGHT_CORRELATED: boolean;
  54846. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54847. SPHERICAL_HARMONICS: boolean;
  54848. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54849. /** @hidden */
  54850. _areMiscDirty: boolean;
  54851. }
  54852. /**
  54853. * Define the code related to the BRDF parameters of the pbr material.
  54854. */
  54855. export class PBRBRDFConfiguration {
  54856. /**
  54857. * Default value used for the energy conservation.
  54858. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54859. */
  54860. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54861. /**
  54862. * Default value used for the Smith Visibility Height Correlated mode.
  54863. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54864. */
  54865. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54866. /**
  54867. * Default value used for the IBL diffuse part.
  54868. * This can help switching back to the polynomials mode globally which is a tiny bit
  54869. * less GPU intensive at the drawback of a lower quality.
  54870. */
  54871. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54872. /**
  54873. * Default value used for activating energy conservation for the specular workflow.
  54874. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54875. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54876. */
  54877. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54878. private _useEnergyConservation;
  54879. /**
  54880. * Defines if the material uses energy conservation.
  54881. */
  54882. useEnergyConservation: boolean;
  54883. private _useSmithVisibilityHeightCorrelated;
  54884. /**
  54885. * LEGACY Mode set to false
  54886. * Defines if the material uses height smith correlated visibility term.
  54887. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54888. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54889. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54890. * Not relying on height correlated will also disable energy conservation.
  54891. */
  54892. useSmithVisibilityHeightCorrelated: boolean;
  54893. private _useSphericalHarmonics;
  54894. /**
  54895. * LEGACY Mode set to false
  54896. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54897. * diffuse part of the IBL.
  54898. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54899. * to the ground truth.
  54900. */
  54901. useSphericalHarmonics: boolean;
  54902. private _useSpecularGlossinessInputEnergyConservation;
  54903. /**
  54904. * Defines if the material uses energy conservation, when the specular workflow is active.
  54905. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54906. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54907. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54908. */
  54909. useSpecularGlossinessInputEnergyConservation: boolean;
  54910. /** @hidden */
  54911. private _internalMarkAllSubMeshesAsMiscDirty;
  54912. /** @hidden */
  54913. _markAllSubMeshesAsMiscDirty(): void;
  54914. /**
  54915. * Instantiate a new istance of clear coat configuration.
  54916. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54917. */
  54918. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54919. /**
  54920. * Checks to see if a texture is used in the material.
  54921. * @param defines the list of "defines" to update.
  54922. */
  54923. prepareDefines(defines: IMaterialBRDFDefines): void;
  54924. /**
  54925. * Get the current class name of the texture useful for serialization or dynamic coding.
  54926. * @returns "PBRClearCoatConfiguration"
  54927. */
  54928. getClassName(): string;
  54929. /**
  54930. * Makes a duplicate of the current configuration into another one.
  54931. * @param brdfConfiguration define the config where to copy the info
  54932. */
  54933. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54934. /**
  54935. * Serializes this BRDF configuration.
  54936. * @returns - An object with the serialized config.
  54937. */
  54938. serialize(): any;
  54939. /**
  54940. * Parses a anisotropy Configuration from a serialized object.
  54941. * @param source - Serialized object.
  54942. * @param scene Defines the scene we are parsing for
  54943. * @param rootUrl Defines the rootUrl to load from
  54944. */
  54945. parse(source: any, scene: Scene, rootUrl: string): void;
  54946. }
  54947. }
  54948. declare module BABYLON {
  54949. /**
  54950. * @hidden
  54951. */
  54952. export interface IMaterialSheenDefines {
  54953. SHEEN: boolean;
  54954. SHEEN_TEXTURE: boolean;
  54955. SHEEN_TEXTUREDIRECTUV: number;
  54956. SHEEN_LINKWITHALBEDO: boolean;
  54957. SHEEN_ROUGHNESS: boolean;
  54958. SHEEN_ALBEDOSCALING: boolean;
  54959. /** @hidden */
  54960. _areTexturesDirty: boolean;
  54961. }
  54962. /**
  54963. * Define the code related to the Sheen parameters of the pbr material.
  54964. */
  54965. export class PBRSheenConfiguration {
  54966. private _isEnabled;
  54967. /**
  54968. * Defines if the material uses sheen.
  54969. */
  54970. isEnabled: boolean;
  54971. private _linkSheenWithAlbedo;
  54972. /**
  54973. * Defines if the sheen is linked to the sheen color.
  54974. */
  54975. linkSheenWithAlbedo: boolean;
  54976. /**
  54977. * Defines the sheen intensity.
  54978. */
  54979. intensity: number;
  54980. /**
  54981. * Defines the sheen color.
  54982. */
  54983. color: Color3;
  54984. private _texture;
  54985. /**
  54986. * Stores the sheen tint values in a texture.
  54987. * rgb is tint
  54988. * a is a intensity or roughness if roughness has been defined
  54989. */
  54990. texture: Nullable<BaseTexture>;
  54991. private _roughness;
  54992. /**
  54993. * Defines the sheen roughness.
  54994. * It is not taken into account if linkSheenWithAlbedo is true.
  54995. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54996. */
  54997. roughness: Nullable<number>;
  54998. private _albedoScaling;
  54999. /**
  55000. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55001. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55002. * making it easier to setup and tweak the effect
  55003. */
  55004. albedoScaling: boolean;
  55005. /** @hidden */
  55006. private _internalMarkAllSubMeshesAsTexturesDirty;
  55007. /** @hidden */
  55008. _markAllSubMeshesAsTexturesDirty(): void;
  55009. /**
  55010. * Instantiate a new istance of clear coat configuration.
  55011. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55012. */
  55013. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55014. /**
  55015. * Specifies that the submesh is ready to be used.
  55016. * @param defines the list of "defines" to update.
  55017. * @param scene defines the scene the material belongs to.
  55018. * @returns - boolean indicating that the submesh is ready or not.
  55019. */
  55020. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55021. /**
  55022. * Checks to see if a texture is used in the material.
  55023. * @param defines the list of "defines" to update.
  55024. * @param scene defines the scene the material belongs to.
  55025. */
  55026. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55027. /**
  55028. * Binds the material data.
  55029. * @param uniformBuffer defines the Uniform buffer to fill in.
  55030. * @param scene defines the scene the material belongs to.
  55031. * @param isFrozen defines wether the material is frozen or not.
  55032. */
  55033. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55034. /**
  55035. * Checks to see if a texture is used in the material.
  55036. * @param texture - Base texture to use.
  55037. * @returns - Boolean specifying if a texture is used in the material.
  55038. */
  55039. hasTexture(texture: BaseTexture): boolean;
  55040. /**
  55041. * Returns an array of the actively used textures.
  55042. * @param activeTextures Array of BaseTextures
  55043. */
  55044. getActiveTextures(activeTextures: BaseTexture[]): void;
  55045. /**
  55046. * Returns the animatable textures.
  55047. * @param animatables Array of animatable textures.
  55048. */
  55049. getAnimatables(animatables: IAnimatable[]): void;
  55050. /**
  55051. * Disposes the resources of the material.
  55052. * @param forceDisposeTextures - Forces the disposal of all textures.
  55053. */
  55054. dispose(forceDisposeTextures?: boolean): void;
  55055. /**
  55056. * Get the current class name of the texture useful for serialization or dynamic coding.
  55057. * @returns "PBRSheenConfiguration"
  55058. */
  55059. getClassName(): string;
  55060. /**
  55061. * Add fallbacks to the effect fallbacks list.
  55062. * @param defines defines the Base texture to use.
  55063. * @param fallbacks defines the current fallback list.
  55064. * @param currentRank defines the current fallback rank.
  55065. * @returns the new fallback rank.
  55066. */
  55067. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55068. /**
  55069. * Add the required uniforms to the current list.
  55070. * @param uniforms defines the current uniform list.
  55071. */
  55072. static AddUniforms(uniforms: string[]): void;
  55073. /**
  55074. * Add the required uniforms to the current buffer.
  55075. * @param uniformBuffer defines the current uniform buffer.
  55076. */
  55077. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55078. /**
  55079. * Add the required samplers to the current list.
  55080. * @param samplers defines the current sampler list.
  55081. */
  55082. static AddSamplers(samplers: string[]): void;
  55083. /**
  55084. * Makes a duplicate of the current configuration into another one.
  55085. * @param sheenConfiguration define the config where to copy the info
  55086. */
  55087. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55088. /**
  55089. * Serializes this BRDF configuration.
  55090. * @returns - An object with the serialized config.
  55091. */
  55092. serialize(): any;
  55093. /**
  55094. * Parses a anisotropy Configuration from a serialized object.
  55095. * @param source - Serialized object.
  55096. * @param scene Defines the scene we are parsing for
  55097. * @param rootUrl Defines the rootUrl to load from
  55098. */
  55099. parse(source: any, scene: Scene, rootUrl: string): void;
  55100. }
  55101. }
  55102. declare module BABYLON {
  55103. /**
  55104. * @hidden
  55105. */
  55106. export interface IMaterialSubSurfaceDefines {
  55107. SUBSURFACE: boolean;
  55108. SS_REFRACTION: boolean;
  55109. SS_TRANSLUCENCY: boolean;
  55110. SS_SCATTERING: boolean;
  55111. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55112. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55113. SS_REFRACTIONMAP_3D: boolean;
  55114. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55115. SS_LODINREFRACTIONALPHA: boolean;
  55116. SS_GAMMAREFRACTION: boolean;
  55117. SS_RGBDREFRACTION: boolean;
  55118. SS_LINEARSPECULARREFRACTION: boolean;
  55119. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55120. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55121. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55122. /** @hidden */
  55123. _areTexturesDirty: boolean;
  55124. }
  55125. /**
  55126. * Define the code related to the sub surface parameters of the pbr material.
  55127. */
  55128. export class PBRSubSurfaceConfiguration {
  55129. private _isRefractionEnabled;
  55130. /**
  55131. * Defines if the refraction is enabled in the material.
  55132. */
  55133. isRefractionEnabled: boolean;
  55134. private _isTranslucencyEnabled;
  55135. /**
  55136. * Defines if the translucency is enabled in the material.
  55137. */
  55138. isTranslucencyEnabled: boolean;
  55139. private _isScatteringEnabled;
  55140. /**
  55141. * Defines if the sub surface scattering is enabled in the material.
  55142. */
  55143. isScatteringEnabled: boolean;
  55144. private _scatteringDiffusionProfileIndex;
  55145. /**
  55146. * Diffusion profile for subsurface scattering.
  55147. * Useful for better scattering in the skins or foliages.
  55148. */
  55149. get scatteringDiffusionProfile(): Nullable<Color3>;
  55150. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55151. /**
  55152. * Defines the refraction intensity of the material.
  55153. * The refraction when enabled replaces the Diffuse part of the material.
  55154. * The intensity helps transitionning between diffuse and refraction.
  55155. */
  55156. refractionIntensity: number;
  55157. /**
  55158. * Defines the translucency intensity of the material.
  55159. * When translucency has been enabled, this defines how much of the "translucency"
  55160. * is addded to the diffuse part of the material.
  55161. */
  55162. translucencyIntensity: number;
  55163. /**
  55164. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55165. */
  55166. useAlbedoToTintRefraction: boolean;
  55167. private _thicknessTexture;
  55168. /**
  55169. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55170. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55171. * 0 would mean minimumThickness
  55172. * 1 would mean maximumThickness
  55173. * The other channels might be use as a mask to vary the different effects intensity.
  55174. */
  55175. thicknessTexture: Nullable<BaseTexture>;
  55176. private _refractionTexture;
  55177. /**
  55178. * Defines the texture to use for refraction.
  55179. */
  55180. refractionTexture: Nullable<BaseTexture>;
  55181. private _indexOfRefraction;
  55182. /**
  55183. * Index of refraction of the material base layer.
  55184. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55185. *
  55186. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55187. *
  55188. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55189. */
  55190. indexOfRefraction: number;
  55191. private _volumeIndexOfRefraction;
  55192. /**
  55193. * Index of refraction of the material's volume.
  55194. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55195. *
  55196. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55197. * the volume will use the same IOR as the surface.
  55198. */
  55199. get volumeIndexOfRefraction(): number;
  55200. set volumeIndexOfRefraction(value: number);
  55201. private _invertRefractionY;
  55202. /**
  55203. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55204. */
  55205. invertRefractionY: boolean;
  55206. private _linkRefractionWithTransparency;
  55207. /**
  55208. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55209. * Materials half opaque for instance using refraction could benefit from this control.
  55210. */
  55211. linkRefractionWithTransparency: boolean;
  55212. /**
  55213. * Defines the minimum thickness stored in the thickness map.
  55214. * If no thickness map is defined, this value will be used to simulate thickness.
  55215. */
  55216. minimumThickness: number;
  55217. /**
  55218. * Defines the maximum thickness stored in the thickness map.
  55219. */
  55220. maximumThickness: number;
  55221. /**
  55222. * Defines the volume tint of the material.
  55223. * This is used for both translucency and scattering.
  55224. */
  55225. tintColor: Color3;
  55226. /**
  55227. * Defines the distance at which the tint color should be found in the media.
  55228. * This is used for refraction only.
  55229. */
  55230. tintColorAtDistance: number;
  55231. /**
  55232. * Defines how far each channel transmit through the media.
  55233. * It is defined as a color to simplify it selection.
  55234. */
  55235. diffusionDistance: Color3;
  55236. private _useMaskFromThicknessTexture;
  55237. /**
  55238. * Stores the intensity of the different subsurface effects in the thickness texture.
  55239. * * the green channel is the translucency intensity.
  55240. * * the blue channel is the scattering intensity.
  55241. * * the alpha channel is the refraction intensity.
  55242. */
  55243. useMaskFromThicknessTexture: boolean;
  55244. private _scene;
  55245. /** @hidden */
  55246. private _internalMarkAllSubMeshesAsTexturesDirty;
  55247. private _internalMarkScenePrePassDirty;
  55248. /** @hidden */
  55249. _markAllSubMeshesAsTexturesDirty(): void;
  55250. /** @hidden */
  55251. _markScenePrePassDirty(): void;
  55252. /**
  55253. * Instantiate a new istance of sub surface configuration.
  55254. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55255. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55256. * @param scene The scene
  55257. */
  55258. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55259. /**
  55260. * Gets wehter the submesh is ready to be used or not.
  55261. * @param defines the list of "defines" to update.
  55262. * @param scene defines the scene the material belongs to.
  55263. * @returns - boolean indicating that the submesh is ready or not.
  55264. */
  55265. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55266. /**
  55267. * Checks to see if a texture is used in the material.
  55268. * @param defines the list of "defines" to update.
  55269. * @param scene defines the scene to the material belongs to.
  55270. */
  55271. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55272. /**
  55273. * Binds the material data.
  55274. * @param uniformBuffer defines the Uniform buffer to fill in.
  55275. * @param scene defines the scene the material belongs to.
  55276. * @param engine defines the engine the material belongs to.
  55277. * @param isFrozen defines whether the material is frozen or not.
  55278. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55279. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55280. */
  55281. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55282. /**
  55283. * Unbinds the material from the mesh.
  55284. * @param activeEffect defines the effect that should be unbound from.
  55285. * @returns true if unbound, otherwise false
  55286. */
  55287. unbind(activeEffect: Effect): boolean;
  55288. /**
  55289. * Returns the texture used for refraction or null if none is used.
  55290. * @param scene defines the scene the material belongs to.
  55291. * @returns - Refraction texture if present. If no refraction texture and refraction
  55292. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55293. */
  55294. private _getRefractionTexture;
  55295. /**
  55296. * Returns true if alpha blending should be disabled.
  55297. */
  55298. get disableAlphaBlending(): boolean;
  55299. /**
  55300. * Fills the list of render target textures.
  55301. * @param renderTargets the list of render targets to update
  55302. */
  55303. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55304. /**
  55305. * Checks to see if a texture is used in the material.
  55306. * @param texture - Base texture to use.
  55307. * @returns - Boolean specifying if a texture is used in the material.
  55308. */
  55309. hasTexture(texture: BaseTexture): boolean;
  55310. /**
  55311. * Gets a boolean indicating that current material needs to register RTT
  55312. * @returns true if this uses a render target otherwise false.
  55313. */
  55314. hasRenderTargetTextures(): boolean;
  55315. /**
  55316. * Returns an array of the actively used textures.
  55317. * @param activeTextures Array of BaseTextures
  55318. */
  55319. getActiveTextures(activeTextures: BaseTexture[]): void;
  55320. /**
  55321. * Returns the animatable textures.
  55322. * @param animatables Array of animatable textures.
  55323. */
  55324. getAnimatables(animatables: IAnimatable[]): void;
  55325. /**
  55326. * Disposes the resources of the material.
  55327. * @param forceDisposeTextures - Forces the disposal of all textures.
  55328. */
  55329. dispose(forceDisposeTextures?: boolean): void;
  55330. /**
  55331. * Get the current class name of the texture useful for serialization or dynamic coding.
  55332. * @returns "PBRSubSurfaceConfiguration"
  55333. */
  55334. getClassName(): string;
  55335. /**
  55336. * Add fallbacks to the effect fallbacks list.
  55337. * @param defines defines the Base texture to use.
  55338. * @param fallbacks defines the current fallback list.
  55339. * @param currentRank defines the current fallback rank.
  55340. * @returns the new fallback rank.
  55341. */
  55342. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55343. /**
  55344. * Add the required uniforms to the current list.
  55345. * @param uniforms defines the current uniform list.
  55346. */
  55347. static AddUniforms(uniforms: string[]): void;
  55348. /**
  55349. * Add the required samplers to the current list.
  55350. * @param samplers defines the current sampler list.
  55351. */
  55352. static AddSamplers(samplers: string[]): void;
  55353. /**
  55354. * Add the required uniforms to the current buffer.
  55355. * @param uniformBuffer defines the current uniform buffer.
  55356. */
  55357. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55358. /**
  55359. * Makes a duplicate of the current configuration into another one.
  55360. * @param configuration define the config where to copy the info
  55361. */
  55362. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55363. /**
  55364. * Serializes this Sub Surface configuration.
  55365. * @returns - An object with the serialized config.
  55366. */
  55367. serialize(): any;
  55368. /**
  55369. * Parses a anisotropy Configuration from a serialized object.
  55370. * @param source - Serialized object.
  55371. * @param scene Defines the scene we are parsing for
  55372. * @param rootUrl Defines the rootUrl to load from
  55373. */
  55374. parse(source: any, scene: Scene, rootUrl: string): void;
  55375. }
  55376. }
  55377. declare module BABYLON {
  55378. /** @hidden */
  55379. export var pbrFragmentDeclaration: {
  55380. name: string;
  55381. shader: string;
  55382. };
  55383. }
  55384. declare module BABYLON {
  55385. /** @hidden */
  55386. export var pbrUboDeclaration: {
  55387. name: string;
  55388. shader: string;
  55389. };
  55390. }
  55391. declare module BABYLON {
  55392. /** @hidden */
  55393. export var pbrFragmentExtraDeclaration: {
  55394. name: string;
  55395. shader: string;
  55396. };
  55397. }
  55398. declare module BABYLON {
  55399. /** @hidden */
  55400. export var pbrFragmentSamplersDeclaration: {
  55401. name: string;
  55402. shader: string;
  55403. };
  55404. }
  55405. declare module BABYLON {
  55406. /** @hidden */
  55407. export var importanceSampling: {
  55408. name: string;
  55409. shader: string;
  55410. };
  55411. }
  55412. declare module BABYLON {
  55413. /** @hidden */
  55414. export var pbrHelperFunctions: {
  55415. name: string;
  55416. shader: string;
  55417. };
  55418. }
  55419. declare module BABYLON {
  55420. /** @hidden */
  55421. export var harmonicsFunctions: {
  55422. name: string;
  55423. shader: string;
  55424. };
  55425. }
  55426. declare module BABYLON {
  55427. /** @hidden */
  55428. export var pbrDirectLightingSetupFunctions: {
  55429. name: string;
  55430. shader: string;
  55431. };
  55432. }
  55433. declare module BABYLON {
  55434. /** @hidden */
  55435. export var pbrDirectLightingFalloffFunctions: {
  55436. name: string;
  55437. shader: string;
  55438. };
  55439. }
  55440. declare module BABYLON {
  55441. /** @hidden */
  55442. export var pbrBRDFFunctions: {
  55443. name: string;
  55444. shader: string;
  55445. };
  55446. }
  55447. declare module BABYLON {
  55448. /** @hidden */
  55449. export var hdrFilteringFunctions: {
  55450. name: string;
  55451. shader: string;
  55452. };
  55453. }
  55454. declare module BABYLON {
  55455. /** @hidden */
  55456. export var pbrDirectLightingFunctions: {
  55457. name: string;
  55458. shader: string;
  55459. };
  55460. }
  55461. declare module BABYLON {
  55462. /** @hidden */
  55463. export var pbrIBLFunctions: {
  55464. name: string;
  55465. shader: string;
  55466. };
  55467. }
  55468. declare module BABYLON {
  55469. /** @hidden */
  55470. export var pbrBlockAlbedoOpacity: {
  55471. name: string;
  55472. shader: string;
  55473. };
  55474. }
  55475. declare module BABYLON {
  55476. /** @hidden */
  55477. export var pbrBlockReflectivity: {
  55478. name: string;
  55479. shader: string;
  55480. };
  55481. }
  55482. declare module BABYLON {
  55483. /** @hidden */
  55484. export var pbrBlockAmbientOcclusion: {
  55485. name: string;
  55486. shader: string;
  55487. };
  55488. }
  55489. declare module BABYLON {
  55490. /** @hidden */
  55491. export var pbrBlockAlphaFresnel: {
  55492. name: string;
  55493. shader: string;
  55494. };
  55495. }
  55496. declare module BABYLON {
  55497. /** @hidden */
  55498. export var pbrBlockAnisotropic: {
  55499. name: string;
  55500. shader: string;
  55501. };
  55502. }
  55503. declare module BABYLON {
  55504. /** @hidden */
  55505. export var pbrBlockReflection: {
  55506. name: string;
  55507. shader: string;
  55508. };
  55509. }
  55510. declare module BABYLON {
  55511. /** @hidden */
  55512. export var pbrBlockSheen: {
  55513. name: string;
  55514. shader: string;
  55515. };
  55516. }
  55517. declare module BABYLON {
  55518. /** @hidden */
  55519. export var pbrBlockClearcoat: {
  55520. name: string;
  55521. shader: string;
  55522. };
  55523. }
  55524. declare module BABYLON {
  55525. /** @hidden */
  55526. export var pbrBlockSubSurface: {
  55527. name: string;
  55528. shader: string;
  55529. };
  55530. }
  55531. declare module BABYLON {
  55532. /** @hidden */
  55533. export var pbrBlockNormalGeometric: {
  55534. name: string;
  55535. shader: string;
  55536. };
  55537. }
  55538. declare module BABYLON {
  55539. /** @hidden */
  55540. export var pbrBlockNormalFinal: {
  55541. name: string;
  55542. shader: string;
  55543. };
  55544. }
  55545. declare module BABYLON {
  55546. /** @hidden */
  55547. export var pbrBlockLightmapInit: {
  55548. name: string;
  55549. shader: string;
  55550. };
  55551. }
  55552. declare module BABYLON {
  55553. /** @hidden */
  55554. export var pbrBlockGeometryInfo: {
  55555. name: string;
  55556. shader: string;
  55557. };
  55558. }
  55559. declare module BABYLON {
  55560. /** @hidden */
  55561. export var pbrBlockReflectance0: {
  55562. name: string;
  55563. shader: string;
  55564. };
  55565. }
  55566. declare module BABYLON {
  55567. /** @hidden */
  55568. export var pbrBlockReflectance: {
  55569. name: string;
  55570. shader: string;
  55571. };
  55572. }
  55573. declare module BABYLON {
  55574. /** @hidden */
  55575. export var pbrBlockDirectLighting: {
  55576. name: string;
  55577. shader: string;
  55578. };
  55579. }
  55580. declare module BABYLON {
  55581. /** @hidden */
  55582. export var pbrBlockFinalLitComponents: {
  55583. name: string;
  55584. shader: string;
  55585. };
  55586. }
  55587. declare module BABYLON {
  55588. /** @hidden */
  55589. export var pbrBlockFinalUnlitComponents: {
  55590. name: string;
  55591. shader: string;
  55592. };
  55593. }
  55594. declare module BABYLON {
  55595. /** @hidden */
  55596. export var pbrBlockFinalColorComposition: {
  55597. name: string;
  55598. shader: string;
  55599. };
  55600. }
  55601. declare module BABYLON {
  55602. /** @hidden */
  55603. export var pbrBlockImageProcessing: {
  55604. name: string;
  55605. shader: string;
  55606. };
  55607. }
  55608. declare module BABYLON {
  55609. /** @hidden */
  55610. export var pbrDebug: {
  55611. name: string;
  55612. shader: string;
  55613. };
  55614. }
  55615. declare module BABYLON {
  55616. /** @hidden */
  55617. export var pbrPixelShader: {
  55618. name: string;
  55619. shader: string;
  55620. };
  55621. }
  55622. declare module BABYLON {
  55623. /** @hidden */
  55624. export var pbrVertexDeclaration: {
  55625. name: string;
  55626. shader: string;
  55627. };
  55628. }
  55629. declare module BABYLON {
  55630. /** @hidden */
  55631. export var pbrVertexShader: {
  55632. name: string;
  55633. shader: string;
  55634. };
  55635. }
  55636. declare module BABYLON {
  55637. /**
  55638. * Manages the defines for the PBR Material.
  55639. * @hidden
  55640. */
  55641. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55642. PBR: boolean;
  55643. NUM_SAMPLES: string;
  55644. REALTIME_FILTERING: boolean;
  55645. MAINUV1: boolean;
  55646. MAINUV2: boolean;
  55647. UV1: boolean;
  55648. UV2: boolean;
  55649. ALBEDO: boolean;
  55650. GAMMAALBEDO: boolean;
  55651. ALBEDODIRECTUV: number;
  55652. VERTEXCOLOR: boolean;
  55653. DETAIL: boolean;
  55654. DETAILDIRECTUV: number;
  55655. DETAIL_NORMALBLENDMETHOD: number;
  55656. AMBIENT: boolean;
  55657. AMBIENTDIRECTUV: number;
  55658. AMBIENTINGRAYSCALE: boolean;
  55659. OPACITY: boolean;
  55660. VERTEXALPHA: boolean;
  55661. OPACITYDIRECTUV: number;
  55662. OPACITYRGB: boolean;
  55663. ALPHATEST: boolean;
  55664. DEPTHPREPASS: boolean;
  55665. ALPHABLEND: boolean;
  55666. ALPHAFROMALBEDO: boolean;
  55667. ALPHATESTVALUE: string;
  55668. SPECULAROVERALPHA: boolean;
  55669. RADIANCEOVERALPHA: boolean;
  55670. ALPHAFRESNEL: boolean;
  55671. LINEARALPHAFRESNEL: boolean;
  55672. PREMULTIPLYALPHA: boolean;
  55673. EMISSIVE: boolean;
  55674. EMISSIVEDIRECTUV: number;
  55675. REFLECTIVITY: boolean;
  55676. REFLECTIVITYDIRECTUV: number;
  55677. SPECULARTERM: boolean;
  55678. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55679. MICROSURFACEAUTOMATIC: boolean;
  55680. LODBASEDMICROSFURACE: boolean;
  55681. MICROSURFACEMAP: boolean;
  55682. MICROSURFACEMAPDIRECTUV: number;
  55683. METALLICWORKFLOW: boolean;
  55684. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55685. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55686. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55687. AOSTOREINMETALMAPRED: boolean;
  55688. METALLIC_REFLECTANCE: boolean;
  55689. METALLIC_REFLECTANCEDIRECTUV: number;
  55690. ENVIRONMENTBRDF: boolean;
  55691. ENVIRONMENTBRDF_RGBD: boolean;
  55692. NORMAL: boolean;
  55693. TANGENT: boolean;
  55694. BUMP: boolean;
  55695. BUMPDIRECTUV: number;
  55696. OBJECTSPACE_NORMALMAP: boolean;
  55697. PARALLAX: boolean;
  55698. PARALLAXOCCLUSION: boolean;
  55699. NORMALXYSCALE: boolean;
  55700. LIGHTMAP: boolean;
  55701. LIGHTMAPDIRECTUV: number;
  55702. USELIGHTMAPASSHADOWMAP: boolean;
  55703. GAMMALIGHTMAP: boolean;
  55704. RGBDLIGHTMAP: boolean;
  55705. REFLECTION: boolean;
  55706. REFLECTIONMAP_3D: boolean;
  55707. REFLECTIONMAP_SPHERICAL: boolean;
  55708. REFLECTIONMAP_PLANAR: boolean;
  55709. REFLECTIONMAP_CUBIC: boolean;
  55710. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55711. REFLECTIONMAP_PROJECTION: boolean;
  55712. REFLECTIONMAP_SKYBOX: boolean;
  55713. REFLECTIONMAP_EXPLICIT: boolean;
  55714. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55715. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55716. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55717. INVERTCUBICMAP: boolean;
  55718. USESPHERICALFROMREFLECTIONMAP: boolean;
  55719. USEIRRADIANCEMAP: boolean;
  55720. SPHERICAL_HARMONICS: boolean;
  55721. USESPHERICALINVERTEX: boolean;
  55722. REFLECTIONMAP_OPPOSITEZ: boolean;
  55723. LODINREFLECTIONALPHA: boolean;
  55724. GAMMAREFLECTION: boolean;
  55725. RGBDREFLECTION: boolean;
  55726. LINEARSPECULARREFLECTION: boolean;
  55727. RADIANCEOCCLUSION: boolean;
  55728. HORIZONOCCLUSION: boolean;
  55729. INSTANCES: boolean;
  55730. THIN_INSTANCES: boolean;
  55731. PREPASS: boolean;
  55732. SCENE_MRT_COUNT: number;
  55733. NUM_BONE_INFLUENCERS: number;
  55734. BonesPerMesh: number;
  55735. BONETEXTURE: boolean;
  55736. NONUNIFORMSCALING: boolean;
  55737. MORPHTARGETS: boolean;
  55738. MORPHTARGETS_NORMAL: boolean;
  55739. MORPHTARGETS_TANGENT: boolean;
  55740. MORPHTARGETS_UV: boolean;
  55741. NUM_MORPH_INFLUENCERS: number;
  55742. IMAGEPROCESSING: boolean;
  55743. VIGNETTE: boolean;
  55744. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55745. VIGNETTEBLENDMODEOPAQUE: boolean;
  55746. TONEMAPPING: boolean;
  55747. TONEMAPPING_ACES: boolean;
  55748. CONTRAST: boolean;
  55749. COLORCURVES: boolean;
  55750. COLORGRADING: boolean;
  55751. COLORGRADING3D: boolean;
  55752. SAMPLER3DGREENDEPTH: boolean;
  55753. SAMPLER3DBGRMAP: boolean;
  55754. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55755. EXPOSURE: boolean;
  55756. MULTIVIEW: boolean;
  55757. USEPHYSICALLIGHTFALLOFF: boolean;
  55758. USEGLTFLIGHTFALLOFF: boolean;
  55759. TWOSIDEDLIGHTING: boolean;
  55760. SHADOWFLOAT: boolean;
  55761. CLIPPLANE: boolean;
  55762. CLIPPLANE2: boolean;
  55763. CLIPPLANE3: boolean;
  55764. CLIPPLANE4: boolean;
  55765. CLIPPLANE5: boolean;
  55766. CLIPPLANE6: boolean;
  55767. POINTSIZE: boolean;
  55768. FOG: boolean;
  55769. LOGARITHMICDEPTH: boolean;
  55770. FORCENORMALFORWARD: boolean;
  55771. SPECULARAA: boolean;
  55772. CLEARCOAT: boolean;
  55773. CLEARCOAT_DEFAULTIOR: boolean;
  55774. CLEARCOAT_TEXTURE: boolean;
  55775. CLEARCOAT_TEXTUREDIRECTUV: number;
  55776. CLEARCOAT_BUMP: boolean;
  55777. CLEARCOAT_BUMPDIRECTUV: number;
  55778. CLEARCOAT_TINT: boolean;
  55779. CLEARCOAT_TINT_TEXTURE: boolean;
  55780. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55781. ANISOTROPIC: boolean;
  55782. ANISOTROPIC_TEXTURE: boolean;
  55783. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55784. BRDF_V_HEIGHT_CORRELATED: boolean;
  55785. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55786. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55787. SHEEN: boolean;
  55788. SHEEN_TEXTURE: boolean;
  55789. SHEEN_TEXTUREDIRECTUV: number;
  55790. SHEEN_LINKWITHALBEDO: boolean;
  55791. SHEEN_ROUGHNESS: boolean;
  55792. SHEEN_ALBEDOSCALING: boolean;
  55793. SUBSURFACE: boolean;
  55794. SS_REFRACTION: boolean;
  55795. SS_TRANSLUCENCY: boolean;
  55796. SS_SCATTERING: boolean;
  55797. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55798. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55799. SS_REFRACTIONMAP_3D: boolean;
  55800. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55801. SS_LODINREFRACTIONALPHA: boolean;
  55802. SS_GAMMAREFRACTION: boolean;
  55803. SS_RGBDREFRACTION: boolean;
  55804. SS_LINEARSPECULARREFRACTION: boolean;
  55805. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55806. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55807. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55808. UNLIT: boolean;
  55809. DEBUGMODE: number;
  55810. /**
  55811. * Initializes the PBR Material defines.
  55812. */
  55813. constructor();
  55814. /**
  55815. * Resets the PBR Material defines.
  55816. */
  55817. reset(): void;
  55818. }
  55819. /**
  55820. * The Physically based material base class of BJS.
  55821. *
  55822. * This offers the main features of a standard PBR material.
  55823. * For more information, please refer to the documentation :
  55824. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55825. */
  55826. export abstract class PBRBaseMaterial extends PushMaterial {
  55827. /**
  55828. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55829. */
  55830. static readonly PBRMATERIAL_OPAQUE: number;
  55831. /**
  55832. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55833. */
  55834. static readonly PBRMATERIAL_ALPHATEST: number;
  55835. /**
  55836. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55837. */
  55838. static readonly PBRMATERIAL_ALPHABLEND: number;
  55839. /**
  55840. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55841. * They are also discarded below the alpha cutoff threshold to improve performances.
  55842. */
  55843. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55844. /**
  55845. * Defines the default value of how much AO map is occluding the analytical lights
  55846. * (point spot...).
  55847. */
  55848. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55849. /**
  55850. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55851. */
  55852. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55853. /**
  55854. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55855. * to enhance interoperability with other engines.
  55856. */
  55857. static readonly LIGHTFALLOFF_GLTF: number;
  55858. /**
  55859. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55860. * to enhance interoperability with other materials.
  55861. */
  55862. static readonly LIGHTFALLOFF_STANDARD: number;
  55863. /**
  55864. * Intensity of the direct lights e.g. the four lights available in your scene.
  55865. * This impacts both the direct diffuse and specular highlights.
  55866. */
  55867. protected _directIntensity: number;
  55868. /**
  55869. * Intensity of the emissive part of the material.
  55870. * This helps controlling the emissive effect without modifying the emissive color.
  55871. */
  55872. protected _emissiveIntensity: number;
  55873. /**
  55874. * Intensity of the environment e.g. how much the environment will light the object
  55875. * either through harmonics for rough material or through the refelction for shiny ones.
  55876. */
  55877. protected _environmentIntensity: number;
  55878. /**
  55879. * This is a special control allowing the reduction of the specular highlights coming from the
  55880. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55881. */
  55882. protected _specularIntensity: number;
  55883. /**
  55884. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55885. */
  55886. private _lightingInfos;
  55887. /**
  55888. * Debug Control allowing disabling the bump map on this material.
  55889. */
  55890. protected _disableBumpMap: boolean;
  55891. /**
  55892. * AKA Diffuse Texture in standard nomenclature.
  55893. */
  55894. protected _albedoTexture: Nullable<BaseTexture>;
  55895. /**
  55896. * AKA Occlusion Texture in other nomenclature.
  55897. */
  55898. protected _ambientTexture: Nullable<BaseTexture>;
  55899. /**
  55900. * AKA Occlusion Texture Intensity in other nomenclature.
  55901. */
  55902. protected _ambientTextureStrength: number;
  55903. /**
  55904. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55905. * 1 means it completely occludes it
  55906. * 0 mean it has no impact
  55907. */
  55908. protected _ambientTextureImpactOnAnalyticalLights: number;
  55909. /**
  55910. * Stores the alpha values in a texture.
  55911. */
  55912. protected _opacityTexture: Nullable<BaseTexture>;
  55913. /**
  55914. * Stores the reflection values in a texture.
  55915. */
  55916. protected _reflectionTexture: Nullable<BaseTexture>;
  55917. /**
  55918. * Stores the emissive values in a texture.
  55919. */
  55920. protected _emissiveTexture: Nullable<BaseTexture>;
  55921. /**
  55922. * AKA Specular texture in other nomenclature.
  55923. */
  55924. protected _reflectivityTexture: Nullable<BaseTexture>;
  55925. /**
  55926. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55927. */
  55928. protected _metallicTexture: Nullable<BaseTexture>;
  55929. /**
  55930. * Specifies the metallic scalar of the metallic/roughness workflow.
  55931. * Can also be used to scale the metalness values of the metallic texture.
  55932. */
  55933. protected _metallic: Nullable<number>;
  55934. /**
  55935. * Specifies the roughness scalar of the metallic/roughness workflow.
  55936. * Can also be used to scale the roughness values of the metallic texture.
  55937. */
  55938. protected _roughness: Nullable<number>;
  55939. /**
  55940. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55941. * By default the indexOfrefraction is used to compute F0;
  55942. *
  55943. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55944. *
  55945. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55946. * F90 = metallicReflectanceColor;
  55947. */
  55948. protected _metallicF0Factor: number;
  55949. /**
  55950. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55951. * By default the F90 is always 1;
  55952. *
  55953. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55954. *
  55955. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55956. * F90 = metallicReflectanceColor;
  55957. */
  55958. protected _metallicReflectanceColor: Color3;
  55959. /**
  55960. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55961. * This is multiply against the scalar values defined in the material.
  55962. */
  55963. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55964. /**
  55965. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55966. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55967. */
  55968. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55969. /**
  55970. * Stores surface normal data used to displace a mesh in a texture.
  55971. */
  55972. protected _bumpTexture: Nullable<BaseTexture>;
  55973. /**
  55974. * Stores the pre-calculated light information of a mesh in a texture.
  55975. */
  55976. protected _lightmapTexture: Nullable<BaseTexture>;
  55977. /**
  55978. * The color of a material in ambient lighting.
  55979. */
  55980. protected _ambientColor: Color3;
  55981. /**
  55982. * AKA Diffuse Color in other nomenclature.
  55983. */
  55984. protected _albedoColor: Color3;
  55985. /**
  55986. * AKA Specular Color in other nomenclature.
  55987. */
  55988. protected _reflectivityColor: Color3;
  55989. /**
  55990. * The color applied when light is reflected from a material.
  55991. */
  55992. protected _reflectionColor: Color3;
  55993. /**
  55994. * The color applied when light is emitted from a material.
  55995. */
  55996. protected _emissiveColor: Color3;
  55997. /**
  55998. * AKA Glossiness in other nomenclature.
  55999. */
  56000. protected _microSurface: number;
  56001. /**
  56002. * Specifies that the material will use the light map as a show map.
  56003. */
  56004. protected _useLightmapAsShadowmap: boolean;
  56005. /**
  56006. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56007. * makes the reflect vector face the model (under horizon).
  56008. */
  56009. protected _useHorizonOcclusion: boolean;
  56010. /**
  56011. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56012. * too much the area relying on ambient texture to define their ambient occlusion.
  56013. */
  56014. protected _useRadianceOcclusion: boolean;
  56015. /**
  56016. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56017. */
  56018. protected _useAlphaFromAlbedoTexture: boolean;
  56019. /**
  56020. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56021. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56022. */
  56023. protected _useSpecularOverAlpha: boolean;
  56024. /**
  56025. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56026. */
  56027. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56028. /**
  56029. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56030. */
  56031. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56032. /**
  56033. * Specifies if the metallic texture contains the roughness information in its green channel.
  56034. */
  56035. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56036. /**
  56037. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56038. */
  56039. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56040. /**
  56041. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56042. */
  56043. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56044. /**
  56045. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56046. */
  56047. protected _useAmbientInGrayScale: boolean;
  56048. /**
  56049. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56050. * The material will try to infer what glossiness each pixel should be.
  56051. */
  56052. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56053. /**
  56054. * Defines the falloff type used in this material.
  56055. * It by default is Physical.
  56056. */
  56057. protected _lightFalloff: number;
  56058. /**
  56059. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56060. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56061. */
  56062. protected _useRadianceOverAlpha: boolean;
  56063. /**
  56064. * Allows using an object space normal map (instead of tangent space).
  56065. */
  56066. protected _useObjectSpaceNormalMap: boolean;
  56067. /**
  56068. * Allows using the bump map in parallax mode.
  56069. */
  56070. protected _useParallax: boolean;
  56071. /**
  56072. * Allows using the bump map in parallax occlusion mode.
  56073. */
  56074. protected _useParallaxOcclusion: boolean;
  56075. /**
  56076. * Controls the scale bias of the parallax mode.
  56077. */
  56078. protected _parallaxScaleBias: number;
  56079. /**
  56080. * If sets to true, disables all the lights affecting the material.
  56081. */
  56082. protected _disableLighting: boolean;
  56083. /**
  56084. * Number of Simultaneous lights allowed on the material.
  56085. */
  56086. protected _maxSimultaneousLights: number;
  56087. /**
  56088. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56089. */
  56090. protected _invertNormalMapX: boolean;
  56091. /**
  56092. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56093. */
  56094. protected _invertNormalMapY: boolean;
  56095. /**
  56096. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56097. */
  56098. protected _twoSidedLighting: boolean;
  56099. /**
  56100. * Defines the alpha limits in alpha test mode.
  56101. */
  56102. protected _alphaCutOff: number;
  56103. /**
  56104. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56105. */
  56106. protected _forceAlphaTest: boolean;
  56107. /**
  56108. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56109. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56110. */
  56111. protected _useAlphaFresnel: boolean;
  56112. /**
  56113. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56114. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56115. */
  56116. protected _useLinearAlphaFresnel: boolean;
  56117. /**
  56118. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56119. * from cos thetav and roughness:
  56120. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56121. */
  56122. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56123. /**
  56124. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56125. */
  56126. protected _forceIrradianceInFragment: boolean;
  56127. private _realTimeFiltering;
  56128. /**
  56129. * Enables realtime filtering on the texture.
  56130. */
  56131. get realTimeFiltering(): boolean;
  56132. set realTimeFiltering(b: boolean);
  56133. private _realTimeFilteringQuality;
  56134. /**
  56135. * Quality switch for realtime filtering
  56136. */
  56137. get realTimeFilteringQuality(): number;
  56138. set realTimeFilteringQuality(n: number);
  56139. /**
  56140. * Can this material render to several textures at once
  56141. */
  56142. get canRenderToMRT(): boolean;
  56143. /**
  56144. * Force normal to face away from face.
  56145. */
  56146. protected _forceNormalForward: boolean;
  56147. /**
  56148. * Enables specular anti aliasing in the PBR shader.
  56149. * It will both interacts on the Geometry for analytical and IBL lighting.
  56150. * It also prefilter the roughness map based on the bump values.
  56151. */
  56152. protected _enableSpecularAntiAliasing: boolean;
  56153. /**
  56154. * Default configuration related to image processing available in the PBR Material.
  56155. */
  56156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56157. /**
  56158. * Keep track of the image processing observer to allow dispose and replace.
  56159. */
  56160. private _imageProcessingObserver;
  56161. /**
  56162. * Attaches a new image processing configuration to the PBR Material.
  56163. * @param configuration
  56164. */
  56165. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56166. /**
  56167. * Stores the available render targets.
  56168. */
  56169. private _renderTargets;
  56170. /**
  56171. * Sets the global ambient color for the material used in lighting calculations.
  56172. */
  56173. private _globalAmbientColor;
  56174. /**
  56175. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56176. */
  56177. private _useLogarithmicDepth;
  56178. /**
  56179. * If set to true, no lighting calculations will be applied.
  56180. */
  56181. private _unlit;
  56182. private _debugMode;
  56183. /**
  56184. * @hidden
  56185. * This is reserved for the inspector.
  56186. * Defines the material debug mode.
  56187. * It helps seeing only some components of the material while troubleshooting.
  56188. */
  56189. debugMode: number;
  56190. /**
  56191. * @hidden
  56192. * This is reserved for the inspector.
  56193. * Specify from where on screen the debug mode should start.
  56194. * The value goes from -1 (full screen) to 1 (not visible)
  56195. * It helps with side by side comparison against the final render
  56196. * This defaults to -1
  56197. */
  56198. private debugLimit;
  56199. /**
  56200. * @hidden
  56201. * This is reserved for the inspector.
  56202. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56203. * You can use the factor to better multiply the final value.
  56204. */
  56205. private debugFactor;
  56206. /**
  56207. * Defines the clear coat layer parameters for the material.
  56208. */
  56209. readonly clearCoat: PBRClearCoatConfiguration;
  56210. /**
  56211. * Defines the anisotropic parameters for the material.
  56212. */
  56213. readonly anisotropy: PBRAnisotropicConfiguration;
  56214. /**
  56215. * Defines the BRDF parameters for the material.
  56216. */
  56217. readonly brdf: PBRBRDFConfiguration;
  56218. /**
  56219. * Defines the Sheen parameters for the material.
  56220. */
  56221. readonly sheen: PBRSheenConfiguration;
  56222. /**
  56223. * Defines the SubSurface parameters for the material.
  56224. */
  56225. readonly subSurface: PBRSubSurfaceConfiguration;
  56226. /**
  56227. * Defines the detail map parameters for the material.
  56228. */
  56229. readonly detailMap: DetailMapConfiguration;
  56230. protected _rebuildInParallel: boolean;
  56231. /**
  56232. * Instantiates a new PBRMaterial instance.
  56233. *
  56234. * @param name The material name
  56235. * @param scene The scene the material will be use in.
  56236. */
  56237. constructor(name: string, scene: Scene);
  56238. /**
  56239. * Gets a boolean indicating that current material needs to register RTT
  56240. */
  56241. get hasRenderTargetTextures(): boolean;
  56242. /**
  56243. * Gets the name of the material class.
  56244. */
  56245. getClassName(): string;
  56246. /**
  56247. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56248. */
  56249. get useLogarithmicDepth(): boolean;
  56250. /**
  56251. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56252. */
  56253. set useLogarithmicDepth(value: boolean);
  56254. /**
  56255. * Returns true if alpha blending should be disabled.
  56256. */
  56257. protected get _disableAlphaBlending(): boolean;
  56258. /**
  56259. * Specifies whether or not this material should be rendered in alpha blend mode.
  56260. */
  56261. needAlphaBlending(): boolean;
  56262. /**
  56263. * Specifies whether or not this material should be rendered in alpha test mode.
  56264. */
  56265. needAlphaTesting(): boolean;
  56266. /**
  56267. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56268. */
  56269. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56270. /**
  56271. * Gets the texture used for the alpha test.
  56272. */
  56273. getAlphaTestTexture(): Nullable<BaseTexture>;
  56274. /**
  56275. * Specifies that the submesh is ready to be used.
  56276. * @param mesh - BJS mesh.
  56277. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56278. * @param useInstances - Specifies that instances should be used.
  56279. * @returns - boolean indicating that the submesh is ready or not.
  56280. */
  56281. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56282. /**
  56283. * Specifies if the material uses metallic roughness workflow.
  56284. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56285. */
  56286. isMetallicWorkflow(): boolean;
  56287. private _prepareEffect;
  56288. private _prepareDefines;
  56289. /**
  56290. * Force shader compilation
  56291. */
  56292. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56293. /**
  56294. * Initializes the uniform buffer layout for the shader.
  56295. */
  56296. buildUniformLayout(): void;
  56297. /**
  56298. * Unbinds the material from the mesh
  56299. */
  56300. unbind(): void;
  56301. /**
  56302. * Binds the submesh data.
  56303. * @param world - The world matrix.
  56304. * @param mesh - The BJS mesh.
  56305. * @param subMesh - A submesh of the BJS mesh.
  56306. */
  56307. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56308. /**
  56309. * Returns the animatable textures.
  56310. * @returns - Array of animatable textures.
  56311. */
  56312. getAnimatables(): IAnimatable[];
  56313. /**
  56314. * Returns the texture used for reflections.
  56315. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56316. */
  56317. private _getReflectionTexture;
  56318. /**
  56319. * Returns an array of the actively used textures.
  56320. * @returns - Array of BaseTextures
  56321. */
  56322. getActiveTextures(): BaseTexture[];
  56323. /**
  56324. * Checks to see if a texture is used in the material.
  56325. * @param texture - Base texture to use.
  56326. * @returns - Boolean specifying if a texture is used in the material.
  56327. */
  56328. hasTexture(texture: BaseTexture): boolean;
  56329. /**
  56330. * Sets the required values to the prepass renderer.
  56331. * @param prePassRenderer defines the prepass renderer to setup
  56332. */
  56333. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56334. /**
  56335. * Disposes the resources of the material.
  56336. * @param forceDisposeEffect - Forces the disposal of effects.
  56337. * @param forceDisposeTextures - Forces the disposal of all textures.
  56338. */
  56339. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56340. }
  56341. }
  56342. declare module BABYLON {
  56343. /**
  56344. * The Physically based material of BJS.
  56345. *
  56346. * This offers the main features of a standard PBR material.
  56347. * For more information, please refer to the documentation :
  56348. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56349. */
  56350. export class PBRMaterial extends PBRBaseMaterial {
  56351. /**
  56352. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56353. */
  56354. static readonly PBRMATERIAL_OPAQUE: number;
  56355. /**
  56356. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56357. */
  56358. static readonly PBRMATERIAL_ALPHATEST: number;
  56359. /**
  56360. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56361. */
  56362. static readonly PBRMATERIAL_ALPHABLEND: number;
  56363. /**
  56364. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56365. * They are also discarded below the alpha cutoff threshold to improve performances.
  56366. */
  56367. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56368. /**
  56369. * Defines the default value of how much AO map is occluding the analytical lights
  56370. * (point spot...).
  56371. */
  56372. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56373. /**
  56374. * Intensity of the direct lights e.g. the four lights available in your scene.
  56375. * This impacts both the direct diffuse and specular highlights.
  56376. */
  56377. directIntensity: number;
  56378. /**
  56379. * Intensity of the emissive part of the material.
  56380. * This helps controlling the emissive effect without modifying the emissive color.
  56381. */
  56382. emissiveIntensity: number;
  56383. /**
  56384. * Intensity of the environment e.g. how much the environment will light the object
  56385. * either through harmonics for rough material or through the refelction for shiny ones.
  56386. */
  56387. environmentIntensity: number;
  56388. /**
  56389. * This is a special control allowing the reduction of the specular highlights coming from the
  56390. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56391. */
  56392. specularIntensity: number;
  56393. /**
  56394. * Debug Control allowing disabling the bump map on this material.
  56395. */
  56396. disableBumpMap: boolean;
  56397. /**
  56398. * AKA Diffuse Texture in standard nomenclature.
  56399. */
  56400. albedoTexture: BaseTexture;
  56401. /**
  56402. * AKA Occlusion Texture in other nomenclature.
  56403. */
  56404. ambientTexture: BaseTexture;
  56405. /**
  56406. * AKA Occlusion Texture Intensity in other nomenclature.
  56407. */
  56408. ambientTextureStrength: number;
  56409. /**
  56410. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56411. * 1 means it completely occludes it
  56412. * 0 mean it has no impact
  56413. */
  56414. ambientTextureImpactOnAnalyticalLights: number;
  56415. /**
  56416. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56417. */
  56418. opacityTexture: BaseTexture;
  56419. /**
  56420. * Stores the reflection values in a texture.
  56421. */
  56422. reflectionTexture: Nullable<BaseTexture>;
  56423. /**
  56424. * Stores the emissive values in a texture.
  56425. */
  56426. emissiveTexture: BaseTexture;
  56427. /**
  56428. * AKA Specular texture in other nomenclature.
  56429. */
  56430. reflectivityTexture: BaseTexture;
  56431. /**
  56432. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56433. */
  56434. metallicTexture: BaseTexture;
  56435. /**
  56436. * Specifies the metallic scalar of the metallic/roughness workflow.
  56437. * Can also be used to scale the metalness values of the metallic texture.
  56438. */
  56439. metallic: Nullable<number>;
  56440. /**
  56441. * Specifies the roughness scalar of the metallic/roughness workflow.
  56442. * Can also be used to scale the roughness values of the metallic texture.
  56443. */
  56444. roughness: Nullable<number>;
  56445. /**
  56446. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56447. * By default the indexOfrefraction is used to compute F0;
  56448. *
  56449. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56450. *
  56451. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56452. * F90 = metallicReflectanceColor;
  56453. */
  56454. metallicF0Factor: number;
  56455. /**
  56456. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56457. * By default the F90 is always 1;
  56458. *
  56459. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56460. *
  56461. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56462. * F90 = metallicReflectanceColor;
  56463. */
  56464. metallicReflectanceColor: Color3;
  56465. /**
  56466. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56467. * This is multiply against the scalar values defined in the material.
  56468. */
  56469. metallicReflectanceTexture: Nullable<BaseTexture>;
  56470. /**
  56471. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56472. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56473. */
  56474. microSurfaceTexture: BaseTexture;
  56475. /**
  56476. * Stores surface normal data used to displace a mesh in a texture.
  56477. */
  56478. bumpTexture: BaseTexture;
  56479. /**
  56480. * Stores the pre-calculated light information of a mesh in a texture.
  56481. */
  56482. lightmapTexture: BaseTexture;
  56483. /**
  56484. * Stores the refracted light information in a texture.
  56485. */
  56486. get refractionTexture(): Nullable<BaseTexture>;
  56487. set refractionTexture(value: Nullable<BaseTexture>);
  56488. /**
  56489. * The color of a material in ambient lighting.
  56490. */
  56491. ambientColor: Color3;
  56492. /**
  56493. * AKA Diffuse Color in other nomenclature.
  56494. */
  56495. albedoColor: Color3;
  56496. /**
  56497. * AKA Specular Color in other nomenclature.
  56498. */
  56499. reflectivityColor: Color3;
  56500. /**
  56501. * The color reflected from the material.
  56502. */
  56503. reflectionColor: Color3;
  56504. /**
  56505. * The color emitted from the material.
  56506. */
  56507. emissiveColor: Color3;
  56508. /**
  56509. * AKA Glossiness in other nomenclature.
  56510. */
  56511. microSurface: number;
  56512. /**
  56513. * Index of refraction of the material base layer.
  56514. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56515. *
  56516. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56517. *
  56518. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56519. */
  56520. get indexOfRefraction(): number;
  56521. set indexOfRefraction(value: number);
  56522. /**
  56523. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56524. */
  56525. get invertRefractionY(): boolean;
  56526. set invertRefractionY(value: boolean);
  56527. /**
  56528. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56529. * Materials half opaque for instance using refraction could benefit from this control.
  56530. */
  56531. get linkRefractionWithTransparency(): boolean;
  56532. set linkRefractionWithTransparency(value: boolean);
  56533. /**
  56534. * If true, the light map contains occlusion information instead of lighting info.
  56535. */
  56536. useLightmapAsShadowmap: boolean;
  56537. /**
  56538. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56539. */
  56540. useAlphaFromAlbedoTexture: boolean;
  56541. /**
  56542. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56543. */
  56544. forceAlphaTest: boolean;
  56545. /**
  56546. * Defines the alpha limits in alpha test mode.
  56547. */
  56548. alphaCutOff: number;
  56549. /**
  56550. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56551. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56552. */
  56553. useSpecularOverAlpha: boolean;
  56554. /**
  56555. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56556. */
  56557. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56558. /**
  56559. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56560. */
  56561. useRoughnessFromMetallicTextureAlpha: boolean;
  56562. /**
  56563. * Specifies if the metallic texture contains the roughness information in its green channel.
  56564. */
  56565. useRoughnessFromMetallicTextureGreen: boolean;
  56566. /**
  56567. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56568. */
  56569. useMetallnessFromMetallicTextureBlue: boolean;
  56570. /**
  56571. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56572. */
  56573. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56574. /**
  56575. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56576. */
  56577. useAmbientInGrayScale: boolean;
  56578. /**
  56579. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56580. * The material will try to infer what glossiness each pixel should be.
  56581. */
  56582. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56583. /**
  56584. * BJS is using an harcoded light falloff based on a manually sets up range.
  56585. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56586. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56587. */
  56588. get usePhysicalLightFalloff(): boolean;
  56589. /**
  56590. * BJS is using an harcoded light falloff based on a manually sets up range.
  56591. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56592. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56593. */
  56594. set usePhysicalLightFalloff(value: boolean);
  56595. /**
  56596. * In order to support the falloff compatibility with gltf, a special mode has been added
  56597. * to reproduce the gltf light falloff.
  56598. */
  56599. get useGLTFLightFalloff(): boolean;
  56600. /**
  56601. * In order to support the falloff compatibility with gltf, a special mode has been added
  56602. * to reproduce the gltf light falloff.
  56603. */
  56604. set useGLTFLightFalloff(value: boolean);
  56605. /**
  56606. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56607. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56608. */
  56609. useRadianceOverAlpha: boolean;
  56610. /**
  56611. * Allows using an object space normal map (instead of tangent space).
  56612. */
  56613. useObjectSpaceNormalMap: boolean;
  56614. /**
  56615. * Allows using the bump map in parallax mode.
  56616. */
  56617. useParallax: boolean;
  56618. /**
  56619. * Allows using the bump map in parallax occlusion mode.
  56620. */
  56621. useParallaxOcclusion: boolean;
  56622. /**
  56623. * Controls the scale bias of the parallax mode.
  56624. */
  56625. parallaxScaleBias: number;
  56626. /**
  56627. * If sets to true, disables all the lights affecting the material.
  56628. */
  56629. disableLighting: boolean;
  56630. /**
  56631. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56632. */
  56633. forceIrradianceInFragment: boolean;
  56634. /**
  56635. * Number of Simultaneous lights allowed on the material.
  56636. */
  56637. maxSimultaneousLights: number;
  56638. /**
  56639. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56640. */
  56641. invertNormalMapX: boolean;
  56642. /**
  56643. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56644. */
  56645. invertNormalMapY: boolean;
  56646. /**
  56647. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56648. */
  56649. twoSidedLighting: boolean;
  56650. /**
  56651. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56652. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56653. */
  56654. useAlphaFresnel: boolean;
  56655. /**
  56656. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56657. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56658. */
  56659. useLinearAlphaFresnel: boolean;
  56660. /**
  56661. * Let user defines the brdf lookup texture used for IBL.
  56662. * A default 8bit version is embedded but you could point at :
  56663. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56664. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56665. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56666. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56667. */
  56668. environmentBRDFTexture: Nullable<BaseTexture>;
  56669. /**
  56670. * Force normal to face away from face.
  56671. */
  56672. forceNormalForward: boolean;
  56673. /**
  56674. * Enables specular anti aliasing in the PBR shader.
  56675. * It will both interacts on the Geometry for analytical and IBL lighting.
  56676. * It also prefilter the roughness map based on the bump values.
  56677. */
  56678. enableSpecularAntiAliasing: boolean;
  56679. /**
  56680. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56681. * makes the reflect vector face the model (under horizon).
  56682. */
  56683. useHorizonOcclusion: boolean;
  56684. /**
  56685. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56686. * too much the area relying on ambient texture to define their ambient occlusion.
  56687. */
  56688. useRadianceOcclusion: boolean;
  56689. /**
  56690. * If set to true, no lighting calculations will be applied.
  56691. */
  56692. unlit: boolean;
  56693. /**
  56694. * Gets the image processing configuration used either in this material.
  56695. */
  56696. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56697. /**
  56698. * Sets the Default image processing configuration used either in the this material.
  56699. *
  56700. * If sets to null, the scene one is in use.
  56701. */
  56702. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56703. /**
  56704. * Gets wether the color curves effect is enabled.
  56705. */
  56706. get cameraColorCurvesEnabled(): boolean;
  56707. /**
  56708. * Sets wether the color curves effect is enabled.
  56709. */
  56710. set cameraColorCurvesEnabled(value: boolean);
  56711. /**
  56712. * Gets wether the color grading effect is enabled.
  56713. */
  56714. get cameraColorGradingEnabled(): boolean;
  56715. /**
  56716. * Gets wether the color grading effect is enabled.
  56717. */
  56718. set cameraColorGradingEnabled(value: boolean);
  56719. /**
  56720. * Gets wether tonemapping is enabled or not.
  56721. */
  56722. get cameraToneMappingEnabled(): boolean;
  56723. /**
  56724. * Sets wether tonemapping is enabled or not
  56725. */
  56726. set cameraToneMappingEnabled(value: boolean);
  56727. /**
  56728. * The camera exposure used on this material.
  56729. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56730. * This corresponds to a photographic exposure.
  56731. */
  56732. get cameraExposure(): number;
  56733. /**
  56734. * The camera exposure used on this material.
  56735. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56736. * This corresponds to a photographic exposure.
  56737. */
  56738. set cameraExposure(value: number);
  56739. /**
  56740. * Gets The camera contrast used on this material.
  56741. */
  56742. get cameraContrast(): number;
  56743. /**
  56744. * Sets The camera contrast used on this material.
  56745. */
  56746. set cameraContrast(value: number);
  56747. /**
  56748. * Gets the Color Grading 2D Lookup Texture.
  56749. */
  56750. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56751. /**
  56752. * Sets the Color Grading 2D Lookup Texture.
  56753. */
  56754. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56755. /**
  56756. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56757. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56758. * 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;
  56759. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56760. */
  56761. get cameraColorCurves(): Nullable<ColorCurves>;
  56762. /**
  56763. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56764. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56765. * 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;
  56766. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56767. */
  56768. set cameraColorCurves(value: Nullable<ColorCurves>);
  56769. /**
  56770. * Instantiates a new PBRMaterial instance.
  56771. *
  56772. * @param name The material name
  56773. * @param scene The scene the material will be use in.
  56774. */
  56775. constructor(name: string, scene: Scene);
  56776. /**
  56777. * Returns the name of this material class.
  56778. */
  56779. getClassName(): string;
  56780. /**
  56781. * Makes a duplicate of the current material.
  56782. * @param name - name to use for the new material.
  56783. */
  56784. clone(name: string): PBRMaterial;
  56785. /**
  56786. * Serializes this PBR Material.
  56787. * @returns - An object with the serialized material.
  56788. */
  56789. serialize(): any;
  56790. /**
  56791. * Parses a PBR Material from a serialized object.
  56792. * @param source - Serialized object.
  56793. * @param scene - BJS scene instance.
  56794. * @param rootUrl - url for the scene object
  56795. * @returns - PBRMaterial
  56796. */
  56797. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56798. }
  56799. }
  56800. declare module BABYLON {
  56801. /**
  56802. * Direct draw surface info
  56803. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56804. */
  56805. export interface DDSInfo {
  56806. /**
  56807. * Width of the texture
  56808. */
  56809. width: number;
  56810. /**
  56811. * Width of the texture
  56812. */
  56813. height: number;
  56814. /**
  56815. * Number of Mipmaps for the texture
  56816. * @see https://en.wikipedia.org/wiki/Mipmap
  56817. */
  56818. mipmapCount: number;
  56819. /**
  56820. * If the textures format is a known fourCC format
  56821. * @see https://www.fourcc.org/
  56822. */
  56823. isFourCC: boolean;
  56824. /**
  56825. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56826. */
  56827. isRGB: boolean;
  56828. /**
  56829. * If the texture is a lumincance format
  56830. */
  56831. isLuminance: boolean;
  56832. /**
  56833. * If this is a cube texture
  56834. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56835. */
  56836. isCube: boolean;
  56837. /**
  56838. * If the texture is a compressed format eg. FOURCC_DXT1
  56839. */
  56840. isCompressed: boolean;
  56841. /**
  56842. * The dxgiFormat of the texture
  56843. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56844. */
  56845. dxgiFormat: number;
  56846. /**
  56847. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56848. */
  56849. textureType: number;
  56850. /**
  56851. * Sphericle polynomial created for the dds texture
  56852. */
  56853. sphericalPolynomial?: SphericalPolynomial;
  56854. }
  56855. /**
  56856. * Class used to provide DDS decompression tools
  56857. */
  56858. export class DDSTools {
  56859. /**
  56860. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56861. */
  56862. static StoreLODInAlphaChannel: boolean;
  56863. /**
  56864. * Gets DDS information from an array buffer
  56865. * @param data defines the array buffer view to read data from
  56866. * @returns the DDS information
  56867. */
  56868. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56869. private static _FloatView;
  56870. private static _Int32View;
  56871. private static _ToHalfFloat;
  56872. private static _FromHalfFloat;
  56873. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56874. private static _GetHalfFloatRGBAArrayBuffer;
  56875. private static _GetFloatRGBAArrayBuffer;
  56876. private static _GetFloatAsUIntRGBAArrayBuffer;
  56877. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56878. private static _GetRGBAArrayBuffer;
  56879. private static _ExtractLongWordOrder;
  56880. private static _GetRGBArrayBuffer;
  56881. private static _GetLuminanceArrayBuffer;
  56882. /**
  56883. * Uploads DDS Levels to a Babylon Texture
  56884. * @hidden
  56885. */
  56886. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56887. }
  56888. interface ThinEngine {
  56889. /**
  56890. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56891. * @param rootUrl defines the url where the file to load is located
  56892. * @param scene defines the current scene
  56893. * @param lodScale defines scale to apply to the mip map selection
  56894. * @param lodOffset defines offset to apply to the mip map selection
  56895. * @param onLoad defines an optional callback raised when the texture is loaded
  56896. * @param onError defines an optional callback raised if there is an issue to load the texture
  56897. * @param format defines the format of the data
  56898. * @param forcedExtension defines the extension to use to pick the right loader
  56899. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56900. * @returns the cube texture as an InternalTexture
  56901. */
  56902. 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;
  56903. }
  56904. }
  56905. declare module BABYLON {
  56906. /**
  56907. * Implementation of the DDS Texture Loader.
  56908. * @hidden
  56909. */
  56910. export class _DDSTextureLoader implements IInternalTextureLoader {
  56911. /**
  56912. * Defines wether the loader supports cascade loading the different faces.
  56913. */
  56914. readonly supportCascades: boolean;
  56915. /**
  56916. * This returns if the loader support the current file information.
  56917. * @param extension defines the file extension of the file being loaded
  56918. * @returns true if the loader can load the specified file
  56919. */
  56920. canLoad(extension: string): boolean;
  56921. /**
  56922. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56923. * @param data contains the texture data
  56924. * @param texture defines the BabylonJS internal texture
  56925. * @param createPolynomials will be true if polynomials have been requested
  56926. * @param onLoad defines the callback to trigger once the texture is ready
  56927. * @param onError defines the callback to trigger in case of error
  56928. */
  56929. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56930. /**
  56931. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56932. * @param data contains the texture data
  56933. * @param texture defines the BabylonJS internal texture
  56934. * @param callback defines the method to call once ready to upload
  56935. */
  56936. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56937. }
  56938. }
  56939. declare module BABYLON {
  56940. /**
  56941. * Implementation of the ENV Texture Loader.
  56942. * @hidden
  56943. */
  56944. export class _ENVTextureLoader implements IInternalTextureLoader {
  56945. /**
  56946. * Defines wether the loader supports cascade loading the different faces.
  56947. */
  56948. readonly supportCascades: boolean;
  56949. /**
  56950. * This returns if the loader support the current file information.
  56951. * @param extension defines the file extension of the file being loaded
  56952. * @returns true if the loader can load the specified file
  56953. */
  56954. canLoad(extension: string): boolean;
  56955. /**
  56956. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56957. * @param data contains the texture data
  56958. * @param texture defines the BabylonJS internal texture
  56959. * @param createPolynomials will be true if polynomials have been requested
  56960. * @param onLoad defines the callback to trigger once the texture is ready
  56961. * @param onError defines the callback to trigger in case of error
  56962. */
  56963. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56964. /**
  56965. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56966. * @param data contains the texture data
  56967. * @param texture defines the BabylonJS internal texture
  56968. * @param callback defines the method to call once ready to upload
  56969. */
  56970. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56971. }
  56972. }
  56973. declare module BABYLON {
  56974. /**
  56975. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56976. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56977. */
  56978. export class KhronosTextureContainer {
  56979. /** contents of the KTX container file */
  56980. data: ArrayBufferView;
  56981. private static HEADER_LEN;
  56982. private static COMPRESSED_2D;
  56983. private static COMPRESSED_3D;
  56984. private static TEX_2D;
  56985. private static TEX_3D;
  56986. /**
  56987. * Gets the openGL type
  56988. */
  56989. glType: number;
  56990. /**
  56991. * Gets the openGL type size
  56992. */
  56993. glTypeSize: number;
  56994. /**
  56995. * Gets the openGL format
  56996. */
  56997. glFormat: number;
  56998. /**
  56999. * Gets the openGL internal format
  57000. */
  57001. glInternalFormat: number;
  57002. /**
  57003. * Gets the base internal format
  57004. */
  57005. glBaseInternalFormat: number;
  57006. /**
  57007. * Gets image width in pixel
  57008. */
  57009. pixelWidth: number;
  57010. /**
  57011. * Gets image height in pixel
  57012. */
  57013. pixelHeight: number;
  57014. /**
  57015. * Gets image depth in pixels
  57016. */
  57017. pixelDepth: number;
  57018. /**
  57019. * Gets the number of array elements
  57020. */
  57021. numberOfArrayElements: number;
  57022. /**
  57023. * Gets the number of faces
  57024. */
  57025. numberOfFaces: number;
  57026. /**
  57027. * Gets the number of mipmap levels
  57028. */
  57029. numberOfMipmapLevels: number;
  57030. /**
  57031. * Gets the bytes of key value data
  57032. */
  57033. bytesOfKeyValueData: number;
  57034. /**
  57035. * Gets the load type
  57036. */
  57037. loadType: number;
  57038. /**
  57039. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57040. */
  57041. isInvalid: boolean;
  57042. /**
  57043. * Creates a new KhronosTextureContainer
  57044. * @param data contents of the KTX container file
  57045. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57046. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57047. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57048. */
  57049. constructor(
  57050. /** contents of the KTX container file */
  57051. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57052. /**
  57053. * Uploads KTX content to a Babylon Texture.
  57054. * It is assumed that the texture has already been created & is currently bound
  57055. * @hidden
  57056. */
  57057. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57058. private _upload2DCompressedLevels;
  57059. /**
  57060. * Checks if the given data starts with a KTX file identifier.
  57061. * @param data the data to check
  57062. * @returns true if the data is a KTX file or false otherwise
  57063. */
  57064. static IsValid(data: ArrayBufferView): boolean;
  57065. }
  57066. }
  57067. declare module BABYLON {
  57068. /**
  57069. * Class for loading KTX2 files
  57070. * !!! Experimental Extension Subject to Changes !!!
  57071. * @hidden
  57072. */
  57073. export class KhronosTextureContainer2 {
  57074. private static _ModulePromise;
  57075. private static _TranscodeFormat;
  57076. constructor(engine: ThinEngine);
  57077. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57078. private _determineTranscodeFormat;
  57079. /**
  57080. * Checks if the given data starts with a KTX2 file identifier.
  57081. * @param data the data to check
  57082. * @returns true if the data is a KTX2 file or false otherwise
  57083. */
  57084. static IsValid(data: ArrayBufferView): boolean;
  57085. }
  57086. }
  57087. declare module BABYLON {
  57088. /**
  57089. * Implementation of the KTX Texture Loader.
  57090. * @hidden
  57091. */
  57092. export class _KTXTextureLoader implements IInternalTextureLoader {
  57093. /**
  57094. * Defines wether the loader supports cascade loading the different faces.
  57095. */
  57096. readonly supportCascades: boolean;
  57097. /**
  57098. * This returns if the loader support the current file information.
  57099. * @param extension defines the file extension of the file being loaded
  57100. * @param mimeType defines the optional mime type of the file being loaded
  57101. * @returns true if the loader can load the specified file
  57102. */
  57103. canLoad(extension: string, mimeType?: string): boolean;
  57104. /**
  57105. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57106. * @param data contains the texture data
  57107. * @param texture defines the BabylonJS internal texture
  57108. * @param createPolynomials will be true if polynomials have been requested
  57109. * @param onLoad defines the callback to trigger once the texture is ready
  57110. * @param onError defines the callback to trigger in case of error
  57111. */
  57112. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57113. /**
  57114. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57115. * @param data contains the texture data
  57116. * @param texture defines the BabylonJS internal texture
  57117. * @param callback defines the method to call once ready to upload
  57118. */
  57119. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57120. }
  57121. }
  57122. declare module BABYLON {
  57123. /** @hidden */
  57124. export var _forceSceneHelpersToBundle: boolean;
  57125. interface Scene {
  57126. /**
  57127. * Creates a default light for the scene.
  57128. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57129. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57130. */
  57131. createDefaultLight(replace?: boolean): void;
  57132. /**
  57133. * Creates a default camera for the scene.
  57134. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57135. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57136. * @param replace has default false, when true replaces the active camera in the scene
  57137. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57138. */
  57139. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57140. /**
  57141. * Creates a default camera and a default light.
  57142. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57143. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57144. * @param replace has the default false, when true replaces the active camera/light in the scene
  57145. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57146. */
  57147. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57148. /**
  57149. * Creates a new sky box
  57150. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57151. * @param environmentTexture defines the texture to use as environment texture
  57152. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57153. * @param scale defines the overall scale of the skybox
  57154. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57155. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57156. * @returns a new mesh holding the sky box
  57157. */
  57158. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57159. /**
  57160. * Creates a new environment
  57161. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57162. * @param options defines the options you can use to configure the environment
  57163. * @returns the new EnvironmentHelper
  57164. */
  57165. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57166. /**
  57167. * Creates a new VREXperienceHelper
  57168. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57169. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57170. * @returns a new VREXperienceHelper
  57171. */
  57172. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57173. /**
  57174. * Creates a new WebXRDefaultExperience
  57175. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57176. * @param options experience options
  57177. * @returns a promise for a new WebXRDefaultExperience
  57178. */
  57179. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57180. }
  57181. }
  57182. declare module BABYLON {
  57183. /**
  57184. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57185. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57186. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57187. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57188. */
  57189. export class VideoDome extends TransformNode {
  57190. /**
  57191. * Define the video source as a Monoscopic panoramic 360 video.
  57192. */
  57193. static readonly MODE_MONOSCOPIC: number;
  57194. /**
  57195. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57196. */
  57197. static readonly MODE_TOPBOTTOM: number;
  57198. /**
  57199. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57200. */
  57201. static readonly MODE_SIDEBYSIDE: number;
  57202. private _halfDome;
  57203. private _useDirectMapping;
  57204. /**
  57205. * The video texture being displayed on the sphere
  57206. */
  57207. protected _videoTexture: VideoTexture;
  57208. /**
  57209. * Gets the video texture being displayed on the sphere
  57210. */
  57211. get videoTexture(): VideoTexture;
  57212. /**
  57213. * The skybox material
  57214. */
  57215. protected _material: BackgroundMaterial;
  57216. /**
  57217. * The surface used for the video dome
  57218. */
  57219. protected _mesh: Mesh;
  57220. /**
  57221. * Gets the mesh used for the video dome.
  57222. */
  57223. get mesh(): Mesh;
  57224. /**
  57225. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57226. */
  57227. private _halfDomeMask;
  57228. /**
  57229. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57230. * Also see the options.resolution property.
  57231. */
  57232. get fovMultiplier(): number;
  57233. set fovMultiplier(value: number);
  57234. private _videoMode;
  57235. /**
  57236. * Gets or set the current video mode for the video. It can be:
  57237. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57238. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57239. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57240. */
  57241. get videoMode(): number;
  57242. set videoMode(value: number);
  57243. /**
  57244. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57245. *
  57246. */
  57247. get halfDome(): boolean;
  57248. /**
  57249. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57250. */
  57251. set halfDome(enabled: boolean);
  57252. /**
  57253. * Oberserver used in Stereoscopic VR Mode.
  57254. */
  57255. private _onBeforeCameraRenderObserver;
  57256. /**
  57257. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57258. * @param name Element's name, child elements will append suffixes for their own names.
  57259. * @param urlsOrVideo defines the url(s) or the video element to use
  57260. * @param options An object containing optional or exposed sub element properties
  57261. */
  57262. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57263. resolution?: number;
  57264. clickToPlay?: boolean;
  57265. autoPlay?: boolean;
  57266. loop?: boolean;
  57267. size?: number;
  57268. poster?: string;
  57269. faceForward?: boolean;
  57270. useDirectMapping?: boolean;
  57271. halfDomeMode?: boolean;
  57272. }, scene: Scene);
  57273. private _changeVideoMode;
  57274. /**
  57275. * Releases resources associated with this node.
  57276. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57277. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57278. */
  57279. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57280. }
  57281. }
  57282. declare module BABYLON {
  57283. /**
  57284. * This class can be used to get instrumentation data from a Babylon engine
  57285. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57286. */
  57287. export class EngineInstrumentation implements IDisposable {
  57288. /**
  57289. * Define the instrumented engine.
  57290. */
  57291. engine: Engine;
  57292. private _captureGPUFrameTime;
  57293. private _gpuFrameTimeToken;
  57294. private _gpuFrameTime;
  57295. private _captureShaderCompilationTime;
  57296. private _shaderCompilationTime;
  57297. private _onBeginFrameObserver;
  57298. private _onEndFrameObserver;
  57299. private _onBeforeShaderCompilationObserver;
  57300. private _onAfterShaderCompilationObserver;
  57301. /**
  57302. * Gets the perf counter used for GPU frame time
  57303. */
  57304. get gpuFrameTimeCounter(): PerfCounter;
  57305. /**
  57306. * Gets the GPU frame time capture status
  57307. */
  57308. get captureGPUFrameTime(): boolean;
  57309. /**
  57310. * Enable or disable the GPU frame time capture
  57311. */
  57312. set captureGPUFrameTime(value: boolean);
  57313. /**
  57314. * Gets the perf counter used for shader compilation time
  57315. */
  57316. get shaderCompilationTimeCounter(): PerfCounter;
  57317. /**
  57318. * Gets the shader compilation time capture status
  57319. */
  57320. get captureShaderCompilationTime(): boolean;
  57321. /**
  57322. * Enable or disable the shader compilation time capture
  57323. */
  57324. set captureShaderCompilationTime(value: boolean);
  57325. /**
  57326. * Instantiates a new engine instrumentation.
  57327. * This class can be used to get instrumentation data from a Babylon engine
  57328. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57329. * @param engine Defines the engine to instrument
  57330. */
  57331. constructor(
  57332. /**
  57333. * Define the instrumented engine.
  57334. */
  57335. engine: Engine);
  57336. /**
  57337. * Dispose and release associated resources.
  57338. */
  57339. dispose(): void;
  57340. }
  57341. }
  57342. declare module BABYLON {
  57343. /**
  57344. * This class can be used to get instrumentation data from a Babylon engine
  57345. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57346. */
  57347. export class SceneInstrumentation implements IDisposable {
  57348. /**
  57349. * Defines the scene to instrument
  57350. */
  57351. scene: Scene;
  57352. private _captureActiveMeshesEvaluationTime;
  57353. private _activeMeshesEvaluationTime;
  57354. private _captureRenderTargetsRenderTime;
  57355. private _renderTargetsRenderTime;
  57356. private _captureFrameTime;
  57357. private _frameTime;
  57358. private _captureRenderTime;
  57359. private _renderTime;
  57360. private _captureInterFrameTime;
  57361. private _interFrameTime;
  57362. private _captureParticlesRenderTime;
  57363. private _particlesRenderTime;
  57364. private _captureSpritesRenderTime;
  57365. private _spritesRenderTime;
  57366. private _capturePhysicsTime;
  57367. private _physicsTime;
  57368. private _captureAnimationsTime;
  57369. private _animationsTime;
  57370. private _captureCameraRenderTime;
  57371. private _cameraRenderTime;
  57372. private _onBeforeActiveMeshesEvaluationObserver;
  57373. private _onAfterActiveMeshesEvaluationObserver;
  57374. private _onBeforeRenderTargetsRenderObserver;
  57375. private _onAfterRenderTargetsRenderObserver;
  57376. private _onAfterRenderObserver;
  57377. private _onBeforeDrawPhaseObserver;
  57378. private _onAfterDrawPhaseObserver;
  57379. private _onBeforeAnimationsObserver;
  57380. private _onBeforeParticlesRenderingObserver;
  57381. private _onAfterParticlesRenderingObserver;
  57382. private _onBeforeSpritesRenderingObserver;
  57383. private _onAfterSpritesRenderingObserver;
  57384. private _onBeforePhysicsObserver;
  57385. private _onAfterPhysicsObserver;
  57386. private _onAfterAnimationsObserver;
  57387. private _onBeforeCameraRenderObserver;
  57388. private _onAfterCameraRenderObserver;
  57389. /**
  57390. * Gets the perf counter used for active meshes evaluation time
  57391. */
  57392. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57393. /**
  57394. * Gets the active meshes evaluation time capture status
  57395. */
  57396. get captureActiveMeshesEvaluationTime(): boolean;
  57397. /**
  57398. * Enable or disable the active meshes evaluation time capture
  57399. */
  57400. set captureActiveMeshesEvaluationTime(value: boolean);
  57401. /**
  57402. * Gets the perf counter used for render targets render time
  57403. */
  57404. get renderTargetsRenderTimeCounter(): PerfCounter;
  57405. /**
  57406. * Gets the render targets render time capture status
  57407. */
  57408. get captureRenderTargetsRenderTime(): boolean;
  57409. /**
  57410. * Enable or disable the render targets render time capture
  57411. */
  57412. set captureRenderTargetsRenderTime(value: boolean);
  57413. /**
  57414. * Gets the perf counter used for particles render time
  57415. */
  57416. get particlesRenderTimeCounter(): PerfCounter;
  57417. /**
  57418. * Gets the particles render time capture status
  57419. */
  57420. get captureParticlesRenderTime(): boolean;
  57421. /**
  57422. * Enable or disable the particles render time capture
  57423. */
  57424. set captureParticlesRenderTime(value: boolean);
  57425. /**
  57426. * Gets the perf counter used for sprites render time
  57427. */
  57428. get spritesRenderTimeCounter(): PerfCounter;
  57429. /**
  57430. * Gets the sprites render time capture status
  57431. */
  57432. get captureSpritesRenderTime(): boolean;
  57433. /**
  57434. * Enable or disable the sprites render time capture
  57435. */
  57436. set captureSpritesRenderTime(value: boolean);
  57437. /**
  57438. * Gets the perf counter used for physics time
  57439. */
  57440. get physicsTimeCounter(): PerfCounter;
  57441. /**
  57442. * Gets the physics time capture status
  57443. */
  57444. get capturePhysicsTime(): boolean;
  57445. /**
  57446. * Enable or disable the physics time capture
  57447. */
  57448. set capturePhysicsTime(value: boolean);
  57449. /**
  57450. * Gets the perf counter used for animations time
  57451. */
  57452. get animationsTimeCounter(): PerfCounter;
  57453. /**
  57454. * Gets the animations time capture status
  57455. */
  57456. get captureAnimationsTime(): boolean;
  57457. /**
  57458. * Enable or disable the animations time capture
  57459. */
  57460. set captureAnimationsTime(value: boolean);
  57461. /**
  57462. * Gets the perf counter used for frame time capture
  57463. */
  57464. get frameTimeCounter(): PerfCounter;
  57465. /**
  57466. * Gets the frame time capture status
  57467. */
  57468. get captureFrameTime(): boolean;
  57469. /**
  57470. * Enable or disable the frame time capture
  57471. */
  57472. set captureFrameTime(value: boolean);
  57473. /**
  57474. * Gets the perf counter used for inter-frames time capture
  57475. */
  57476. get interFrameTimeCounter(): PerfCounter;
  57477. /**
  57478. * Gets the inter-frames time capture status
  57479. */
  57480. get captureInterFrameTime(): boolean;
  57481. /**
  57482. * Enable or disable the inter-frames time capture
  57483. */
  57484. set captureInterFrameTime(value: boolean);
  57485. /**
  57486. * Gets the perf counter used for render time capture
  57487. */
  57488. get renderTimeCounter(): PerfCounter;
  57489. /**
  57490. * Gets the render time capture status
  57491. */
  57492. get captureRenderTime(): boolean;
  57493. /**
  57494. * Enable or disable the render time capture
  57495. */
  57496. set captureRenderTime(value: boolean);
  57497. /**
  57498. * Gets the perf counter used for camera render time capture
  57499. */
  57500. get cameraRenderTimeCounter(): PerfCounter;
  57501. /**
  57502. * Gets the camera render time capture status
  57503. */
  57504. get captureCameraRenderTime(): boolean;
  57505. /**
  57506. * Enable or disable the camera render time capture
  57507. */
  57508. set captureCameraRenderTime(value: boolean);
  57509. /**
  57510. * Gets the perf counter used for draw calls
  57511. */
  57512. get drawCallsCounter(): PerfCounter;
  57513. /**
  57514. * Instantiates a new scene instrumentation.
  57515. * This class can be used to get instrumentation data from a Babylon engine
  57516. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57517. * @param scene Defines the scene to instrument
  57518. */
  57519. constructor(
  57520. /**
  57521. * Defines the scene to instrument
  57522. */
  57523. scene: Scene);
  57524. /**
  57525. * Dispose and release associated resources.
  57526. */
  57527. dispose(): void;
  57528. }
  57529. }
  57530. declare module BABYLON {
  57531. /** @hidden */
  57532. export var glowMapGenerationPixelShader: {
  57533. name: string;
  57534. shader: string;
  57535. };
  57536. }
  57537. declare module BABYLON {
  57538. /** @hidden */
  57539. export var glowMapGenerationVertexShader: {
  57540. name: string;
  57541. shader: string;
  57542. };
  57543. }
  57544. declare module BABYLON {
  57545. /**
  57546. * Effect layer options. This helps customizing the behaviour
  57547. * of the effect layer.
  57548. */
  57549. export interface IEffectLayerOptions {
  57550. /**
  57551. * Multiplication factor apply to the canvas size to compute the render target size
  57552. * used to generated the objects (the smaller the faster).
  57553. */
  57554. mainTextureRatio: number;
  57555. /**
  57556. * Enforces a fixed size texture to ensure effect stability across devices.
  57557. */
  57558. mainTextureFixedSize?: number;
  57559. /**
  57560. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57561. */
  57562. alphaBlendingMode: number;
  57563. /**
  57564. * The camera attached to the layer.
  57565. */
  57566. camera: Nullable<Camera>;
  57567. /**
  57568. * The rendering group to draw the layer in.
  57569. */
  57570. renderingGroupId: number;
  57571. }
  57572. /**
  57573. * The effect layer Helps adding post process effect blended with the main pass.
  57574. *
  57575. * This can be for instance use to generate glow or higlight effects on the scene.
  57576. *
  57577. * The effect layer class can not be used directly and is intented to inherited from to be
  57578. * customized per effects.
  57579. */
  57580. export abstract class EffectLayer {
  57581. private _vertexBuffers;
  57582. private _indexBuffer;
  57583. private _cachedDefines;
  57584. private _effectLayerMapGenerationEffect;
  57585. private _effectLayerOptions;
  57586. private _mergeEffect;
  57587. protected _scene: Scene;
  57588. protected _engine: Engine;
  57589. protected _maxSize: number;
  57590. protected _mainTextureDesiredSize: ISize;
  57591. protected _mainTexture: RenderTargetTexture;
  57592. protected _shouldRender: boolean;
  57593. protected _postProcesses: PostProcess[];
  57594. protected _textures: BaseTexture[];
  57595. protected _emissiveTextureAndColor: {
  57596. texture: Nullable<BaseTexture>;
  57597. color: Color4;
  57598. };
  57599. /**
  57600. * The name of the layer
  57601. */
  57602. name: string;
  57603. /**
  57604. * The clear color of the texture used to generate the glow map.
  57605. */
  57606. neutralColor: Color4;
  57607. /**
  57608. * Specifies whether the highlight layer is enabled or not.
  57609. */
  57610. isEnabled: boolean;
  57611. /**
  57612. * Gets the camera attached to the layer.
  57613. */
  57614. get camera(): Nullable<Camera>;
  57615. /**
  57616. * Gets the rendering group id the layer should render in.
  57617. */
  57618. get renderingGroupId(): number;
  57619. set renderingGroupId(renderingGroupId: number);
  57620. /**
  57621. * An event triggered when the effect layer has been disposed.
  57622. */
  57623. onDisposeObservable: Observable<EffectLayer>;
  57624. /**
  57625. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57626. */
  57627. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57628. /**
  57629. * An event triggered when the generated texture is being merged in the scene.
  57630. */
  57631. onBeforeComposeObservable: Observable<EffectLayer>;
  57632. /**
  57633. * An event triggered when the mesh is rendered into the effect render target.
  57634. */
  57635. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57636. /**
  57637. * An event triggered after the mesh has been rendered into the effect render target.
  57638. */
  57639. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57640. /**
  57641. * An event triggered when the generated texture has been merged in the scene.
  57642. */
  57643. onAfterComposeObservable: Observable<EffectLayer>;
  57644. /**
  57645. * An event triggered when the efffect layer changes its size.
  57646. */
  57647. onSizeChangedObservable: Observable<EffectLayer>;
  57648. /** @hidden */
  57649. static _SceneComponentInitialization: (scene: Scene) => void;
  57650. /**
  57651. * Instantiates a new effect Layer and references it in the scene.
  57652. * @param name The name of the layer
  57653. * @param scene The scene to use the layer in
  57654. */
  57655. constructor(
  57656. /** The Friendly of the effect in the scene */
  57657. name: string, scene: Scene);
  57658. /**
  57659. * Get the effect name of the layer.
  57660. * @return The effect name
  57661. */
  57662. abstract getEffectName(): string;
  57663. /**
  57664. * Checks for the readiness of the element composing the layer.
  57665. * @param subMesh the mesh to check for
  57666. * @param useInstances specify whether or not to use instances to render the mesh
  57667. * @return true if ready otherwise, false
  57668. */
  57669. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57670. /**
  57671. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57672. * @returns true if the effect requires stencil during the main canvas render pass.
  57673. */
  57674. abstract needStencil(): boolean;
  57675. /**
  57676. * Create the merge effect. This is the shader use to blit the information back
  57677. * to the main canvas at the end of the scene rendering.
  57678. * @returns The effect containing the shader used to merge the effect on the main canvas
  57679. */
  57680. protected abstract _createMergeEffect(): Effect;
  57681. /**
  57682. * Creates the render target textures and post processes used in the effect layer.
  57683. */
  57684. protected abstract _createTextureAndPostProcesses(): void;
  57685. /**
  57686. * Implementation specific of rendering the generating effect on the main canvas.
  57687. * @param effect The effect used to render through
  57688. */
  57689. protected abstract _internalRender(effect: Effect): void;
  57690. /**
  57691. * Sets the required values for both the emissive texture and and the main color.
  57692. */
  57693. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57694. /**
  57695. * Free any resources and references associated to a mesh.
  57696. * Internal use
  57697. * @param mesh The mesh to free.
  57698. */
  57699. abstract _disposeMesh(mesh: Mesh): void;
  57700. /**
  57701. * Serializes this layer (Glow or Highlight for example)
  57702. * @returns a serialized layer object
  57703. */
  57704. abstract serialize?(): any;
  57705. /**
  57706. * Initializes the effect layer with the required options.
  57707. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57708. */
  57709. protected _init(options: Partial<IEffectLayerOptions>): void;
  57710. /**
  57711. * Generates the index buffer of the full screen quad blending to the main canvas.
  57712. */
  57713. private _generateIndexBuffer;
  57714. /**
  57715. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57716. */
  57717. private _generateVertexBuffer;
  57718. /**
  57719. * Sets the main texture desired size which is the closest power of two
  57720. * of the engine canvas size.
  57721. */
  57722. private _setMainTextureSize;
  57723. /**
  57724. * Creates the main texture for the effect layer.
  57725. */
  57726. protected _createMainTexture(): void;
  57727. /**
  57728. * Adds specific effects defines.
  57729. * @param defines The defines to add specifics to.
  57730. */
  57731. protected _addCustomEffectDefines(defines: string[]): void;
  57732. /**
  57733. * Checks for the readiness of the element composing the layer.
  57734. * @param subMesh the mesh to check for
  57735. * @param useInstances specify whether or not to use instances to render the mesh
  57736. * @param emissiveTexture the associated emissive texture used to generate the glow
  57737. * @return true if ready otherwise, false
  57738. */
  57739. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57740. /**
  57741. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57742. */
  57743. render(): void;
  57744. /**
  57745. * Determine if a given mesh will be used in the current effect.
  57746. * @param mesh mesh to test
  57747. * @returns true if the mesh will be used
  57748. */
  57749. hasMesh(mesh: AbstractMesh): boolean;
  57750. /**
  57751. * Returns true if the layer contains information to display, otherwise false.
  57752. * @returns true if the glow layer should be rendered
  57753. */
  57754. shouldRender(): boolean;
  57755. /**
  57756. * Returns true if the mesh should render, otherwise false.
  57757. * @param mesh The mesh to render
  57758. * @returns true if it should render otherwise false
  57759. */
  57760. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57761. /**
  57762. * Returns true if the mesh can be rendered, otherwise false.
  57763. * @param mesh The mesh to render
  57764. * @param material The material used on the mesh
  57765. * @returns true if it can be rendered otherwise false
  57766. */
  57767. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57768. /**
  57769. * Returns true if the mesh should render, otherwise false.
  57770. * @param mesh The mesh to render
  57771. * @returns true if it should render otherwise false
  57772. */
  57773. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57774. /**
  57775. * Renders the submesh passed in parameter to the generation map.
  57776. */
  57777. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57778. /**
  57779. * Defines whether the current material of the mesh should be use to render the effect.
  57780. * @param mesh defines the current mesh to render
  57781. */
  57782. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57783. /**
  57784. * Rebuild the required buffers.
  57785. * @hidden Internal use only.
  57786. */
  57787. _rebuild(): void;
  57788. /**
  57789. * Dispose only the render target textures and post process.
  57790. */
  57791. private _disposeTextureAndPostProcesses;
  57792. /**
  57793. * Dispose the highlight layer and free resources.
  57794. */
  57795. dispose(): void;
  57796. /**
  57797. * Gets the class name of the effect layer
  57798. * @returns the string with the class name of the effect layer
  57799. */
  57800. getClassName(): string;
  57801. /**
  57802. * Creates an effect layer from parsed effect layer data
  57803. * @param parsedEffectLayer defines effect layer data
  57804. * @param scene defines the current scene
  57805. * @param rootUrl defines the root URL containing the effect layer information
  57806. * @returns a parsed effect Layer
  57807. */
  57808. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57809. }
  57810. }
  57811. declare module BABYLON {
  57812. interface AbstractScene {
  57813. /**
  57814. * The list of effect layers (highlights/glow) added to the scene
  57815. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57816. * @see https://doc.babylonjs.com/how_to/glow_layer
  57817. */
  57818. effectLayers: Array<EffectLayer>;
  57819. /**
  57820. * Removes the given effect layer from this scene.
  57821. * @param toRemove defines the effect layer to remove
  57822. * @returns the index of the removed effect layer
  57823. */
  57824. removeEffectLayer(toRemove: EffectLayer): number;
  57825. /**
  57826. * Adds the given effect layer to this scene
  57827. * @param newEffectLayer defines the effect layer to add
  57828. */
  57829. addEffectLayer(newEffectLayer: EffectLayer): void;
  57830. }
  57831. /**
  57832. * Defines the layer scene component responsible to manage any effect layers
  57833. * in a given scene.
  57834. */
  57835. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57836. /**
  57837. * The component name helpfull to identify the component in the list of scene components.
  57838. */
  57839. readonly name: string;
  57840. /**
  57841. * The scene the component belongs to.
  57842. */
  57843. scene: Scene;
  57844. private _engine;
  57845. private _renderEffects;
  57846. private _needStencil;
  57847. private _previousStencilState;
  57848. /**
  57849. * Creates a new instance of the component for the given scene
  57850. * @param scene Defines the scene to register the component in
  57851. */
  57852. constructor(scene: Scene);
  57853. /**
  57854. * Registers the component in a given scene
  57855. */
  57856. register(): void;
  57857. /**
  57858. * Rebuilds the elements related to this component in case of
  57859. * context lost for instance.
  57860. */
  57861. rebuild(): void;
  57862. /**
  57863. * Serializes the component data to the specified json object
  57864. * @param serializationObject The object to serialize to
  57865. */
  57866. serialize(serializationObject: any): void;
  57867. /**
  57868. * Adds all the elements from the container to the scene
  57869. * @param container the container holding the elements
  57870. */
  57871. addFromContainer(container: AbstractScene): void;
  57872. /**
  57873. * Removes all the elements in the container from the scene
  57874. * @param container contains the elements to remove
  57875. * @param dispose if the removed element should be disposed (default: false)
  57876. */
  57877. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57878. /**
  57879. * Disposes the component and the associated ressources.
  57880. */
  57881. dispose(): void;
  57882. private _isReadyForMesh;
  57883. private _renderMainTexture;
  57884. private _setStencil;
  57885. private _setStencilBack;
  57886. private _draw;
  57887. private _drawCamera;
  57888. private _drawRenderingGroup;
  57889. }
  57890. }
  57891. declare module BABYLON {
  57892. /** @hidden */
  57893. export var glowMapMergePixelShader: {
  57894. name: string;
  57895. shader: string;
  57896. };
  57897. }
  57898. declare module BABYLON {
  57899. /** @hidden */
  57900. export var glowMapMergeVertexShader: {
  57901. name: string;
  57902. shader: string;
  57903. };
  57904. }
  57905. declare module BABYLON {
  57906. interface AbstractScene {
  57907. /**
  57908. * Return a the first highlight layer of the scene with a given name.
  57909. * @param name The name of the highlight layer to look for.
  57910. * @return The highlight layer if found otherwise null.
  57911. */
  57912. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57913. }
  57914. /**
  57915. * Glow layer options. This helps customizing the behaviour
  57916. * of the glow layer.
  57917. */
  57918. export interface IGlowLayerOptions {
  57919. /**
  57920. * Multiplication factor apply to the canvas size to compute the render target size
  57921. * used to generated the glowing objects (the smaller the faster).
  57922. */
  57923. mainTextureRatio: number;
  57924. /**
  57925. * Enforces a fixed size texture to ensure resize independant blur.
  57926. */
  57927. mainTextureFixedSize?: number;
  57928. /**
  57929. * How big is the kernel of the blur texture.
  57930. */
  57931. blurKernelSize: number;
  57932. /**
  57933. * The camera attached to the layer.
  57934. */
  57935. camera: Nullable<Camera>;
  57936. /**
  57937. * Enable MSAA by chosing the number of samples.
  57938. */
  57939. mainTextureSamples?: number;
  57940. /**
  57941. * The rendering group to draw the layer in.
  57942. */
  57943. renderingGroupId: number;
  57944. }
  57945. /**
  57946. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57947. *
  57948. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57949. *
  57950. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57951. */
  57952. export class GlowLayer extends EffectLayer {
  57953. /**
  57954. * Effect Name of the layer.
  57955. */
  57956. static readonly EffectName: string;
  57957. /**
  57958. * The default blur kernel size used for the glow.
  57959. */
  57960. static DefaultBlurKernelSize: number;
  57961. /**
  57962. * The default texture size ratio used for the glow.
  57963. */
  57964. static DefaultTextureRatio: number;
  57965. /**
  57966. * Sets the kernel size of the blur.
  57967. */
  57968. set blurKernelSize(value: number);
  57969. /**
  57970. * Gets the kernel size of the blur.
  57971. */
  57972. get blurKernelSize(): number;
  57973. /**
  57974. * Sets the glow intensity.
  57975. */
  57976. set intensity(value: number);
  57977. /**
  57978. * Gets the glow intensity.
  57979. */
  57980. get intensity(): number;
  57981. private _options;
  57982. private _intensity;
  57983. private _horizontalBlurPostprocess1;
  57984. private _verticalBlurPostprocess1;
  57985. private _horizontalBlurPostprocess2;
  57986. private _verticalBlurPostprocess2;
  57987. private _blurTexture1;
  57988. private _blurTexture2;
  57989. private _postProcesses1;
  57990. private _postProcesses2;
  57991. private _includedOnlyMeshes;
  57992. private _excludedMeshes;
  57993. private _meshesUsingTheirOwnMaterials;
  57994. /**
  57995. * Callback used to let the user override the color selection on a per mesh basis
  57996. */
  57997. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57998. /**
  57999. * Callback used to let the user override the texture selection on a per mesh basis
  58000. */
  58001. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58002. /**
  58003. * Instantiates a new glow Layer and references it to the scene.
  58004. * @param name The name of the layer
  58005. * @param scene The scene to use the layer in
  58006. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58007. */
  58008. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58009. /**
  58010. * Get the effect name of the layer.
  58011. * @return The effect name
  58012. */
  58013. getEffectName(): string;
  58014. /**
  58015. * Create the merge effect. This is the shader use to blit the information back
  58016. * to the main canvas at the end of the scene rendering.
  58017. */
  58018. protected _createMergeEffect(): Effect;
  58019. /**
  58020. * Creates the render target textures and post processes used in the glow layer.
  58021. */
  58022. protected _createTextureAndPostProcesses(): void;
  58023. /**
  58024. * Checks for the readiness of the element composing the layer.
  58025. * @param subMesh the mesh to check for
  58026. * @param useInstances specify wether or not to use instances to render the mesh
  58027. * @param emissiveTexture the associated emissive texture used to generate the glow
  58028. * @return true if ready otherwise, false
  58029. */
  58030. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58031. /**
  58032. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58033. */
  58034. needStencil(): boolean;
  58035. /**
  58036. * Returns true if the mesh can be rendered, otherwise false.
  58037. * @param mesh The mesh to render
  58038. * @param material The material used on the mesh
  58039. * @returns true if it can be rendered otherwise false
  58040. */
  58041. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58042. /**
  58043. * Implementation specific of rendering the generating effect on the main canvas.
  58044. * @param effect The effect used to render through
  58045. */
  58046. protected _internalRender(effect: Effect): void;
  58047. /**
  58048. * Sets the required values for both the emissive texture and and the main color.
  58049. */
  58050. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58051. /**
  58052. * Returns true if the mesh should render, otherwise false.
  58053. * @param mesh The mesh to render
  58054. * @returns true if it should render otherwise false
  58055. */
  58056. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58057. /**
  58058. * Adds specific effects defines.
  58059. * @param defines The defines to add specifics to.
  58060. */
  58061. protected _addCustomEffectDefines(defines: string[]): void;
  58062. /**
  58063. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58064. * @param mesh The mesh to exclude from the glow layer
  58065. */
  58066. addExcludedMesh(mesh: Mesh): void;
  58067. /**
  58068. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58069. * @param mesh The mesh to remove
  58070. */
  58071. removeExcludedMesh(mesh: Mesh): void;
  58072. /**
  58073. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58074. * @param mesh The mesh to include in the glow layer
  58075. */
  58076. addIncludedOnlyMesh(mesh: Mesh): void;
  58077. /**
  58078. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58079. * @param mesh The mesh to remove
  58080. */
  58081. removeIncludedOnlyMesh(mesh: Mesh): void;
  58082. /**
  58083. * Determine if a given mesh will be used in the glow layer
  58084. * @param mesh The mesh to test
  58085. * @returns true if the mesh will be highlighted by the current glow layer
  58086. */
  58087. hasMesh(mesh: AbstractMesh): boolean;
  58088. /**
  58089. * Defines whether the current material of the mesh should be use to render the effect.
  58090. * @param mesh defines the current mesh to render
  58091. */
  58092. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58093. /**
  58094. * Add a mesh to be rendered through its own material and not with emissive only.
  58095. * @param mesh The mesh for which we need to use its material
  58096. */
  58097. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58098. /**
  58099. * Remove a mesh from being rendered through its own material and not with emissive only.
  58100. * @param mesh The mesh for which we need to not use its material
  58101. */
  58102. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58103. /**
  58104. * Free any resources and references associated to a mesh.
  58105. * Internal use
  58106. * @param mesh The mesh to free.
  58107. * @hidden
  58108. */
  58109. _disposeMesh(mesh: Mesh): void;
  58110. /**
  58111. * Gets the class name of the effect layer
  58112. * @returns the string with the class name of the effect layer
  58113. */
  58114. getClassName(): string;
  58115. /**
  58116. * Serializes this glow layer
  58117. * @returns a serialized glow layer object
  58118. */
  58119. serialize(): any;
  58120. /**
  58121. * Creates a Glow Layer from parsed glow layer data
  58122. * @param parsedGlowLayer defines glow layer data
  58123. * @param scene defines the current scene
  58124. * @param rootUrl defines the root URL containing the glow layer information
  58125. * @returns a parsed Glow Layer
  58126. */
  58127. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58128. }
  58129. }
  58130. declare module BABYLON {
  58131. /** @hidden */
  58132. export var glowBlurPostProcessPixelShader: {
  58133. name: string;
  58134. shader: string;
  58135. };
  58136. }
  58137. declare module BABYLON {
  58138. interface AbstractScene {
  58139. /**
  58140. * Return a the first highlight layer of the scene with a given name.
  58141. * @param name The name of the highlight layer to look for.
  58142. * @return The highlight layer if found otherwise null.
  58143. */
  58144. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58145. }
  58146. /**
  58147. * Highlight layer options. This helps customizing the behaviour
  58148. * of the highlight layer.
  58149. */
  58150. export interface IHighlightLayerOptions {
  58151. /**
  58152. * Multiplication factor apply to the canvas size to compute the render target size
  58153. * used to generated the glowing objects (the smaller the faster).
  58154. */
  58155. mainTextureRatio: number;
  58156. /**
  58157. * Enforces a fixed size texture to ensure resize independant blur.
  58158. */
  58159. mainTextureFixedSize?: number;
  58160. /**
  58161. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58162. * of the picture to blur (the smaller the faster).
  58163. */
  58164. blurTextureSizeRatio: number;
  58165. /**
  58166. * How big in texel of the blur texture is the vertical blur.
  58167. */
  58168. blurVerticalSize: number;
  58169. /**
  58170. * How big in texel of the blur texture is the horizontal blur.
  58171. */
  58172. blurHorizontalSize: number;
  58173. /**
  58174. * Alpha blending mode used to apply the blur. Default is combine.
  58175. */
  58176. alphaBlendingMode: number;
  58177. /**
  58178. * The camera attached to the layer.
  58179. */
  58180. camera: Nullable<Camera>;
  58181. /**
  58182. * Should we display highlight as a solid stroke?
  58183. */
  58184. isStroke?: boolean;
  58185. /**
  58186. * The rendering group to draw the layer in.
  58187. */
  58188. renderingGroupId: number;
  58189. }
  58190. /**
  58191. * The highlight layer Helps adding a glow effect around a mesh.
  58192. *
  58193. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58194. * glowy meshes to your scene.
  58195. *
  58196. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58197. */
  58198. export class HighlightLayer extends EffectLayer {
  58199. name: string;
  58200. /**
  58201. * Effect Name of the highlight layer.
  58202. */
  58203. static readonly EffectName: string;
  58204. /**
  58205. * The neutral color used during the preparation of the glow effect.
  58206. * This is black by default as the blend operation is a blend operation.
  58207. */
  58208. static NeutralColor: Color4;
  58209. /**
  58210. * Stencil value used for glowing meshes.
  58211. */
  58212. static GlowingMeshStencilReference: number;
  58213. /**
  58214. * Stencil value used for the other meshes in the scene.
  58215. */
  58216. static NormalMeshStencilReference: number;
  58217. /**
  58218. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58219. */
  58220. innerGlow: boolean;
  58221. /**
  58222. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58223. */
  58224. outerGlow: boolean;
  58225. /**
  58226. * Specifies the horizontal size of the blur.
  58227. */
  58228. set blurHorizontalSize(value: number);
  58229. /**
  58230. * Specifies the vertical size of the blur.
  58231. */
  58232. set blurVerticalSize(value: number);
  58233. /**
  58234. * Gets the horizontal size of the blur.
  58235. */
  58236. get blurHorizontalSize(): number;
  58237. /**
  58238. * Gets the vertical size of the blur.
  58239. */
  58240. get blurVerticalSize(): number;
  58241. /**
  58242. * An event triggered when the highlight layer is being blurred.
  58243. */
  58244. onBeforeBlurObservable: Observable<HighlightLayer>;
  58245. /**
  58246. * An event triggered when the highlight layer has been blurred.
  58247. */
  58248. onAfterBlurObservable: Observable<HighlightLayer>;
  58249. private _instanceGlowingMeshStencilReference;
  58250. private _options;
  58251. private _downSamplePostprocess;
  58252. private _horizontalBlurPostprocess;
  58253. private _verticalBlurPostprocess;
  58254. private _blurTexture;
  58255. private _meshes;
  58256. private _excludedMeshes;
  58257. /**
  58258. * Instantiates a new highlight Layer and references it to the scene..
  58259. * @param name The name of the layer
  58260. * @param scene The scene to use the layer in
  58261. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58262. */
  58263. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58264. /**
  58265. * Get the effect name of the layer.
  58266. * @return The effect name
  58267. */
  58268. getEffectName(): string;
  58269. /**
  58270. * Create the merge effect. This is the shader use to blit the information back
  58271. * to the main canvas at the end of the scene rendering.
  58272. */
  58273. protected _createMergeEffect(): Effect;
  58274. /**
  58275. * Creates the render target textures and post processes used in the highlight layer.
  58276. */
  58277. protected _createTextureAndPostProcesses(): void;
  58278. /**
  58279. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58280. */
  58281. needStencil(): boolean;
  58282. /**
  58283. * Checks for the readiness of the element composing the layer.
  58284. * @param subMesh the mesh to check for
  58285. * @param useInstances specify wether or not to use instances to render the mesh
  58286. * @param emissiveTexture the associated emissive texture used to generate the glow
  58287. * @return true if ready otherwise, false
  58288. */
  58289. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58290. /**
  58291. * Implementation specific of rendering the generating effect on the main canvas.
  58292. * @param effect The effect used to render through
  58293. */
  58294. protected _internalRender(effect: Effect): void;
  58295. /**
  58296. * Returns true if the layer contains information to display, otherwise false.
  58297. */
  58298. shouldRender(): boolean;
  58299. /**
  58300. * Returns true if the mesh should render, otherwise false.
  58301. * @param mesh The mesh to render
  58302. * @returns true if it should render otherwise false
  58303. */
  58304. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58305. /**
  58306. * Returns true if the mesh can be rendered, otherwise false.
  58307. * @param mesh The mesh to render
  58308. * @param material The material used on the mesh
  58309. * @returns true if it can be rendered otherwise false
  58310. */
  58311. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58312. /**
  58313. * Adds specific effects defines.
  58314. * @param defines The defines to add specifics to.
  58315. */
  58316. protected _addCustomEffectDefines(defines: string[]): void;
  58317. /**
  58318. * Sets the required values for both the emissive texture and and the main color.
  58319. */
  58320. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58321. /**
  58322. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58323. * @param mesh The mesh to exclude from the highlight layer
  58324. */
  58325. addExcludedMesh(mesh: Mesh): void;
  58326. /**
  58327. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58328. * @param mesh The mesh to highlight
  58329. */
  58330. removeExcludedMesh(mesh: Mesh): void;
  58331. /**
  58332. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58333. * @param mesh mesh to test
  58334. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58335. */
  58336. hasMesh(mesh: AbstractMesh): boolean;
  58337. /**
  58338. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58339. * @param mesh The mesh to highlight
  58340. * @param color The color of the highlight
  58341. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58342. */
  58343. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58344. /**
  58345. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58346. * @param mesh The mesh to highlight
  58347. */
  58348. removeMesh(mesh: Mesh): void;
  58349. /**
  58350. * Remove all the meshes currently referenced in the highlight layer
  58351. */
  58352. removeAllMeshes(): void;
  58353. /**
  58354. * Force the stencil to the normal expected value for none glowing parts
  58355. */
  58356. private _defaultStencilReference;
  58357. /**
  58358. * Free any resources and references associated to a mesh.
  58359. * Internal use
  58360. * @param mesh The mesh to free.
  58361. * @hidden
  58362. */
  58363. _disposeMesh(mesh: Mesh): void;
  58364. /**
  58365. * Dispose the highlight layer and free resources.
  58366. */
  58367. dispose(): void;
  58368. /**
  58369. * Gets the class name of the effect layer
  58370. * @returns the string with the class name of the effect layer
  58371. */
  58372. getClassName(): string;
  58373. /**
  58374. * Serializes this Highlight layer
  58375. * @returns a serialized Highlight layer object
  58376. */
  58377. serialize(): any;
  58378. /**
  58379. * Creates a Highlight layer from parsed Highlight layer data
  58380. * @param parsedHightlightLayer defines the Highlight layer data
  58381. * @param scene defines the current scene
  58382. * @param rootUrl defines the root URL containing the Highlight layer information
  58383. * @returns a parsed Highlight layer
  58384. */
  58385. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58386. }
  58387. }
  58388. declare module BABYLON {
  58389. interface AbstractScene {
  58390. /**
  58391. * The list of layers (background and foreground) of the scene
  58392. */
  58393. layers: Array<Layer>;
  58394. }
  58395. /**
  58396. * Defines the layer scene component responsible to manage any layers
  58397. * in a given scene.
  58398. */
  58399. export class LayerSceneComponent implements ISceneComponent {
  58400. /**
  58401. * The component name helpfull to identify the component in the list of scene components.
  58402. */
  58403. readonly name: string;
  58404. /**
  58405. * The scene the component belongs to.
  58406. */
  58407. scene: Scene;
  58408. private _engine;
  58409. /**
  58410. * Creates a new instance of the component for the given scene
  58411. * @param scene Defines the scene to register the component in
  58412. */
  58413. constructor(scene: Scene);
  58414. /**
  58415. * Registers the component in a given scene
  58416. */
  58417. register(): void;
  58418. /**
  58419. * Rebuilds the elements related to this component in case of
  58420. * context lost for instance.
  58421. */
  58422. rebuild(): void;
  58423. /**
  58424. * Disposes the component and the associated ressources.
  58425. */
  58426. dispose(): void;
  58427. private _draw;
  58428. private _drawCameraPredicate;
  58429. private _drawCameraBackground;
  58430. private _drawCameraForeground;
  58431. private _drawRenderTargetPredicate;
  58432. private _drawRenderTargetBackground;
  58433. private _drawRenderTargetForeground;
  58434. /**
  58435. * Adds all the elements from the container to the scene
  58436. * @param container the container holding the elements
  58437. */
  58438. addFromContainer(container: AbstractScene): void;
  58439. /**
  58440. * Removes all the elements in the container from the scene
  58441. * @param container contains the elements to remove
  58442. * @param dispose if the removed element should be disposed (default: false)
  58443. */
  58444. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58445. }
  58446. }
  58447. declare module BABYLON {
  58448. /** @hidden */
  58449. export var layerPixelShader: {
  58450. name: string;
  58451. shader: string;
  58452. };
  58453. }
  58454. declare module BABYLON {
  58455. /** @hidden */
  58456. export var layerVertexShader: {
  58457. name: string;
  58458. shader: string;
  58459. };
  58460. }
  58461. declare module BABYLON {
  58462. /**
  58463. * This represents a full screen 2d layer.
  58464. * This can be useful to display a picture in the background of your scene for instance.
  58465. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58466. */
  58467. export class Layer {
  58468. /**
  58469. * Define the name of the layer.
  58470. */
  58471. name: string;
  58472. /**
  58473. * Define the texture the layer should display.
  58474. */
  58475. texture: Nullable<Texture>;
  58476. /**
  58477. * Is the layer in background or foreground.
  58478. */
  58479. isBackground: boolean;
  58480. /**
  58481. * Define the color of the layer (instead of texture).
  58482. */
  58483. color: Color4;
  58484. /**
  58485. * Define the scale of the layer in order to zoom in out of the texture.
  58486. */
  58487. scale: Vector2;
  58488. /**
  58489. * Define an offset for the layer in order to shift the texture.
  58490. */
  58491. offset: Vector2;
  58492. /**
  58493. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58494. */
  58495. alphaBlendingMode: number;
  58496. /**
  58497. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58498. * Alpha test will not mix with the background color in case of transparency.
  58499. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58500. */
  58501. alphaTest: boolean;
  58502. /**
  58503. * Define a mask to restrict the layer to only some of the scene cameras.
  58504. */
  58505. layerMask: number;
  58506. /**
  58507. * Define the list of render target the layer is visible into.
  58508. */
  58509. renderTargetTextures: RenderTargetTexture[];
  58510. /**
  58511. * Define if the layer is only used in renderTarget or if it also
  58512. * renders in the main frame buffer of the canvas.
  58513. */
  58514. renderOnlyInRenderTargetTextures: boolean;
  58515. private _scene;
  58516. private _vertexBuffers;
  58517. private _indexBuffer;
  58518. private _effect;
  58519. private _previousDefines;
  58520. /**
  58521. * An event triggered when the layer is disposed.
  58522. */
  58523. onDisposeObservable: Observable<Layer>;
  58524. private _onDisposeObserver;
  58525. /**
  58526. * Back compatibility with callback before the onDisposeObservable existed.
  58527. * The set callback will be triggered when the layer has been disposed.
  58528. */
  58529. set onDispose(callback: () => void);
  58530. /**
  58531. * An event triggered before rendering the scene
  58532. */
  58533. onBeforeRenderObservable: Observable<Layer>;
  58534. private _onBeforeRenderObserver;
  58535. /**
  58536. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58537. * The set callback will be triggered just before rendering the layer.
  58538. */
  58539. set onBeforeRender(callback: () => void);
  58540. /**
  58541. * An event triggered after rendering the scene
  58542. */
  58543. onAfterRenderObservable: Observable<Layer>;
  58544. private _onAfterRenderObserver;
  58545. /**
  58546. * Back compatibility with callback before the onAfterRenderObservable existed.
  58547. * The set callback will be triggered just after rendering the layer.
  58548. */
  58549. set onAfterRender(callback: () => void);
  58550. /**
  58551. * Instantiates a new layer.
  58552. * This represents a full screen 2d layer.
  58553. * This can be useful to display a picture in the background of your scene for instance.
  58554. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58555. * @param name Define the name of the layer in the scene
  58556. * @param imgUrl Define the url of the texture to display in the layer
  58557. * @param scene Define the scene the layer belongs to
  58558. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58559. * @param color Defines a color for the layer
  58560. */
  58561. constructor(
  58562. /**
  58563. * Define the name of the layer.
  58564. */
  58565. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58566. private _createIndexBuffer;
  58567. /** @hidden */
  58568. _rebuild(): void;
  58569. /**
  58570. * Renders the layer in the scene.
  58571. */
  58572. render(): void;
  58573. /**
  58574. * Disposes and releases the associated ressources.
  58575. */
  58576. dispose(): void;
  58577. }
  58578. }
  58579. declare module BABYLON {
  58580. /** @hidden */
  58581. export var lensFlarePixelShader: {
  58582. name: string;
  58583. shader: string;
  58584. };
  58585. }
  58586. declare module BABYLON {
  58587. /** @hidden */
  58588. export var lensFlareVertexShader: {
  58589. name: string;
  58590. shader: string;
  58591. };
  58592. }
  58593. declare module BABYLON {
  58594. /**
  58595. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58596. * It is usually composed of several `lensFlare`.
  58597. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58598. */
  58599. export class LensFlareSystem {
  58600. /**
  58601. * Define the name of the lens flare system
  58602. */
  58603. name: string;
  58604. /**
  58605. * List of lens flares used in this system.
  58606. */
  58607. lensFlares: LensFlare[];
  58608. /**
  58609. * Define a limit from the border the lens flare can be visible.
  58610. */
  58611. borderLimit: number;
  58612. /**
  58613. * Define a viewport border we do not want to see the lens flare in.
  58614. */
  58615. viewportBorder: number;
  58616. /**
  58617. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58618. */
  58619. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58620. /**
  58621. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58622. */
  58623. layerMask: number;
  58624. /**
  58625. * Define the id of the lens flare system in the scene.
  58626. * (equal to name by default)
  58627. */
  58628. id: string;
  58629. private _scene;
  58630. private _emitter;
  58631. private _vertexBuffers;
  58632. private _indexBuffer;
  58633. private _effect;
  58634. private _positionX;
  58635. private _positionY;
  58636. private _isEnabled;
  58637. /** @hidden */
  58638. static _SceneComponentInitialization: (scene: Scene) => void;
  58639. /**
  58640. * Instantiates a lens flare system.
  58641. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58642. * It is usually composed of several `lensFlare`.
  58643. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58644. * @param name Define the name of the lens flare system in the scene
  58645. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58646. * @param scene Define the scene the lens flare system belongs to
  58647. */
  58648. constructor(
  58649. /**
  58650. * Define the name of the lens flare system
  58651. */
  58652. name: string, emitter: any, scene: Scene);
  58653. /**
  58654. * Define if the lens flare system is enabled.
  58655. */
  58656. get isEnabled(): boolean;
  58657. set isEnabled(value: boolean);
  58658. /**
  58659. * Get the scene the effects belongs to.
  58660. * @returns the scene holding the lens flare system
  58661. */
  58662. getScene(): Scene;
  58663. /**
  58664. * Get the emitter of the lens flare system.
  58665. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58666. * @returns the emitter of the lens flare system
  58667. */
  58668. getEmitter(): any;
  58669. /**
  58670. * Set the emitter of the lens flare system.
  58671. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58672. * @param newEmitter Define the new emitter of the system
  58673. */
  58674. setEmitter(newEmitter: any): void;
  58675. /**
  58676. * Get the lens flare system emitter position.
  58677. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58678. * @returns the position
  58679. */
  58680. getEmitterPosition(): Vector3;
  58681. /**
  58682. * @hidden
  58683. */
  58684. computeEffectivePosition(globalViewport: Viewport): boolean;
  58685. /** @hidden */
  58686. _isVisible(): boolean;
  58687. /**
  58688. * @hidden
  58689. */
  58690. render(): boolean;
  58691. /**
  58692. * Dispose and release the lens flare with its associated resources.
  58693. */
  58694. dispose(): void;
  58695. /**
  58696. * Parse a lens flare system from a JSON repressentation
  58697. * @param parsedLensFlareSystem Define the JSON to parse
  58698. * @param scene Define the scene the parsed system should be instantiated in
  58699. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58700. * @returns the parsed system
  58701. */
  58702. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58703. /**
  58704. * Serialize the current Lens Flare System into a JSON representation.
  58705. * @returns the serialized JSON
  58706. */
  58707. serialize(): any;
  58708. }
  58709. }
  58710. declare module BABYLON {
  58711. /**
  58712. * This represents one of the lens effect in a `lensFlareSystem`.
  58713. * It controls one of the indiviual texture used in the effect.
  58714. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58715. */
  58716. export class LensFlare {
  58717. /**
  58718. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58719. */
  58720. size: number;
  58721. /**
  58722. * 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.
  58723. */
  58724. position: number;
  58725. /**
  58726. * Define the lens color.
  58727. */
  58728. color: Color3;
  58729. /**
  58730. * Define the lens texture.
  58731. */
  58732. texture: Nullable<Texture>;
  58733. /**
  58734. * Define the alpha mode to render this particular lens.
  58735. */
  58736. alphaMode: number;
  58737. private _system;
  58738. /**
  58739. * Creates a new Lens Flare.
  58740. * This represents one of the lens effect in a `lensFlareSystem`.
  58741. * It controls one of the indiviual texture used in the effect.
  58742. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58743. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58744. * @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.
  58745. * @param color Define the lens color
  58746. * @param imgUrl Define the lens texture url
  58747. * @param system Define the `lensFlareSystem` this flare is part of
  58748. * @returns The newly created Lens Flare
  58749. */
  58750. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58751. /**
  58752. * Instantiates a new Lens Flare.
  58753. * This represents one of the lens effect in a `lensFlareSystem`.
  58754. * It controls one of the indiviual texture used in the effect.
  58755. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58756. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58757. * @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.
  58758. * @param color Define the lens color
  58759. * @param imgUrl Define the lens texture url
  58760. * @param system Define the `lensFlareSystem` this flare is part of
  58761. */
  58762. constructor(
  58763. /**
  58764. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58765. */
  58766. size: number,
  58767. /**
  58768. * 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.
  58769. */
  58770. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58771. /**
  58772. * Dispose and release the lens flare with its associated resources.
  58773. */
  58774. dispose(): void;
  58775. }
  58776. }
  58777. declare module BABYLON {
  58778. interface AbstractScene {
  58779. /**
  58780. * The list of lens flare system added to the scene
  58781. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58782. */
  58783. lensFlareSystems: Array<LensFlareSystem>;
  58784. /**
  58785. * Removes the given lens flare system from this scene.
  58786. * @param toRemove The lens flare system to remove
  58787. * @returns The index of the removed lens flare system
  58788. */
  58789. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58790. /**
  58791. * Adds the given lens flare system to this scene
  58792. * @param newLensFlareSystem The lens flare system to add
  58793. */
  58794. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58795. /**
  58796. * Gets a lens flare system using its name
  58797. * @param name defines the name to look for
  58798. * @returns the lens flare system or null if not found
  58799. */
  58800. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58801. /**
  58802. * Gets a lens flare system using its id
  58803. * @param id defines the id to look for
  58804. * @returns the lens flare system or null if not found
  58805. */
  58806. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58807. }
  58808. /**
  58809. * Defines the lens flare scene component responsible to manage any lens flares
  58810. * in a given scene.
  58811. */
  58812. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58813. /**
  58814. * The component name helpfull to identify the component in the list of scene components.
  58815. */
  58816. readonly name: string;
  58817. /**
  58818. * The scene the component belongs to.
  58819. */
  58820. scene: Scene;
  58821. /**
  58822. * Creates a new instance of the component for the given scene
  58823. * @param scene Defines the scene to register the component in
  58824. */
  58825. constructor(scene: Scene);
  58826. /**
  58827. * Registers the component in a given scene
  58828. */
  58829. register(): void;
  58830. /**
  58831. * Rebuilds the elements related to this component in case of
  58832. * context lost for instance.
  58833. */
  58834. rebuild(): void;
  58835. /**
  58836. * Adds all the elements from the container to the scene
  58837. * @param container the container holding the elements
  58838. */
  58839. addFromContainer(container: AbstractScene): void;
  58840. /**
  58841. * Removes all the elements in the container from the scene
  58842. * @param container contains the elements to remove
  58843. * @param dispose if the removed element should be disposed (default: false)
  58844. */
  58845. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58846. /**
  58847. * Serializes the component data to the specified json object
  58848. * @param serializationObject The object to serialize to
  58849. */
  58850. serialize(serializationObject: any): void;
  58851. /**
  58852. * Disposes the component and the associated ressources.
  58853. */
  58854. dispose(): void;
  58855. private _draw;
  58856. }
  58857. }
  58858. declare module BABYLON {
  58859. /** @hidden */
  58860. export var depthPixelShader: {
  58861. name: string;
  58862. shader: string;
  58863. };
  58864. }
  58865. declare module BABYLON {
  58866. /** @hidden */
  58867. export var depthVertexShader: {
  58868. name: string;
  58869. shader: string;
  58870. };
  58871. }
  58872. declare module BABYLON {
  58873. /**
  58874. * This represents a depth renderer in Babylon.
  58875. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58876. */
  58877. export class DepthRenderer {
  58878. private _scene;
  58879. private _depthMap;
  58880. private _effect;
  58881. private readonly _storeNonLinearDepth;
  58882. private readonly _clearColor;
  58883. /** Get if the depth renderer is using packed depth or not */
  58884. readonly isPacked: boolean;
  58885. private _cachedDefines;
  58886. private _camera;
  58887. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58888. enabled: boolean;
  58889. /**
  58890. * Specifiess that the depth renderer will only be used within
  58891. * the camera it is created for.
  58892. * This can help forcing its rendering during the camera processing.
  58893. */
  58894. useOnlyInActiveCamera: boolean;
  58895. /** @hidden */
  58896. static _SceneComponentInitialization: (scene: Scene) => void;
  58897. /**
  58898. * Instantiates a depth renderer
  58899. * @param scene The scene the renderer belongs to
  58900. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58901. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58902. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58903. */
  58904. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58905. /**
  58906. * Creates the depth rendering effect and checks if the effect is ready.
  58907. * @param subMesh The submesh to be used to render the depth map of
  58908. * @param useInstances If multiple world instances should be used
  58909. * @returns if the depth renderer is ready to render the depth map
  58910. */
  58911. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58912. /**
  58913. * Gets the texture which the depth map will be written to.
  58914. * @returns The depth map texture
  58915. */
  58916. getDepthMap(): RenderTargetTexture;
  58917. /**
  58918. * Disposes of the depth renderer.
  58919. */
  58920. dispose(): void;
  58921. }
  58922. }
  58923. declare module BABYLON {
  58924. /** @hidden */
  58925. export var minmaxReduxPixelShader: {
  58926. name: string;
  58927. shader: string;
  58928. };
  58929. }
  58930. declare module BABYLON {
  58931. /**
  58932. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58933. * and maximum values from all values of the texture.
  58934. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58935. * The source values are read from the red channel of the texture.
  58936. */
  58937. export class MinMaxReducer {
  58938. /**
  58939. * Observable triggered when the computation has been performed
  58940. */
  58941. onAfterReductionPerformed: Observable<{
  58942. min: number;
  58943. max: number;
  58944. }>;
  58945. protected _camera: Camera;
  58946. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58947. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58948. protected _postProcessManager: PostProcessManager;
  58949. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58950. protected _forceFullscreenViewport: boolean;
  58951. /**
  58952. * Creates a min/max reducer
  58953. * @param camera The camera to use for the post processes
  58954. */
  58955. constructor(camera: Camera);
  58956. /**
  58957. * Gets the texture used to read the values from.
  58958. */
  58959. get sourceTexture(): Nullable<RenderTargetTexture>;
  58960. /**
  58961. * Sets the source texture to read the values from.
  58962. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58963. * because in such textures '1' value must not be taken into account to compute the maximum
  58964. * as this value is used to clear the texture.
  58965. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58966. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58967. * @param depthRedux Indicates if the texture is a depth texture or not
  58968. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58969. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58970. */
  58971. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58972. /**
  58973. * Defines the refresh rate of the computation.
  58974. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58975. */
  58976. get refreshRate(): number;
  58977. set refreshRate(value: number);
  58978. protected _activated: boolean;
  58979. /**
  58980. * Gets the activation status of the reducer
  58981. */
  58982. get activated(): boolean;
  58983. /**
  58984. * Activates the reduction computation.
  58985. * When activated, the observers registered in onAfterReductionPerformed are
  58986. * called after the compuation is performed
  58987. */
  58988. activate(): void;
  58989. /**
  58990. * Deactivates the reduction computation.
  58991. */
  58992. deactivate(): void;
  58993. /**
  58994. * Disposes the min/max reducer
  58995. * @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.
  58996. */
  58997. dispose(disposeAll?: boolean): void;
  58998. }
  58999. }
  59000. declare module BABYLON {
  59001. /**
  59002. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59003. */
  59004. export class DepthReducer extends MinMaxReducer {
  59005. private _depthRenderer;
  59006. private _depthRendererId;
  59007. /**
  59008. * Gets the depth renderer used for the computation.
  59009. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59010. */
  59011. get depthRenderer(): Nullable<DepthRenderer>;
  59012. /**
  59013. * Creates a depth reducer
  59014. * @param camera The camera used to render the depth texture
  59015. */
  59016. constructor(camera: Camera);
  59017. /**
  59018. * Sets the depth renderer to use to generate the depth map
  59019. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59020. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59021. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59022. */
  59023. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59024. /** @hidden */
  59025. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59026. /**
  59027. * Activates the reduction computation.
  59028. * When activated, the observers registered in onAfterReductionPerformed are
  59029. * called after the compuation is performed
  59030. */
  59031. activate(): void;
  59032. /**
  59033. * Deactivates the reduction computation.
  59034. */
  59035. deactivate(): void;
  59036. /**
  59037. * Disposes the depth reducer
  59038. * @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.
  59039. */
  59040. dispose(disposeAll?: boolean): void;
  59041. }
  59042. }
  59043. declare module BABYLON {
  59044. /**
  59045. * A CSM implementation allowing casting shadows on large scenes.
  59046. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59047. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59048. */
  59049. export class CascadedShadowGenerator extends ShadowGenerator {
  59050. private static readonly frustumCornersNDCSpace;
  59051. /**
  59052. * Name of the CSM class
  59053. */
  59054. static CLASSNAME: string;
  59055. /**
  59056. * Defines the default number of cascades used by the CSM.
  59057. */
  59058. static readonly DEFAULT_CASCADES_COUNT: number;
  59059. /**
  59060. * Defines the minimum number of cascades used by the CSM.
  59061. */
  59062. static readonly MIN_CASCADES_COUNT: number;
  59063. /**
  59064. * Defines the maximum number of cascades used by the CSM.
  59065. */
  59066. static readonly MAX_CASCADES_COUNT: number;
  59067. protected _validateFilter(filter: number): number;
  59068. /**
  59069. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59070. */
  59071. penumbraDarkness: number;
  59072. private _numCascades;
  59073. /**
  59074. * Gets or set the number of cascades used by the CSM.
  59075. */
  59076. get numCascades(): number;
  59077. set numCascades(value: number);
  59078. /**
  59079. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59080. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59081. */
  59082. stabilizeCascades: boolean;
  59083. private _freezeShadowCastersBoundingInfo;
  59084. private _freezeShadowCastersBoundingInfoObservable;
  59085. /**
  59086. * Enables or disables the shadow casters bounding info computation.
  59087. * If your shadow casters don't move, you can disable this feature.
  59088. * If it is enabled, the bounding box computation is done every frame.
  59089. */
  59090. get freezeShadowCastersBoundingInfo(): boolean;
  59091. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59092. private _scbiMin;
  59093. private _scbiMax;
  59094. protected _computeShadowCastersBoundingInfo(): void;
  59095. protected _shadowCastersBoundingInfo: BoundingInfo;
  59096. /**
  59097. * Gets or sets the shadow casters bounding info.
  59098. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59099. * so that the system won't overwrite the bounds you provide
  59100. */
  59101. get shadowCastersBoundingInfo(): BoundingInfo;
  59102. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59103. protected _breaksAreDirty: boolean;
  59104. protected _minDistance: number;
  59105. protected _maxDistance: number;
  59106. /**
  59107. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59108. *
  59109. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59110. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59111. * @param min minimal distance for the breaks (default to 0.)
  59112. * @param max maximal distance for the breaks (default to 1.)
  59113. */
  59114. setMinMaxDistance(min: number, max: number): void;
  59115. /** Gets the minimal distance used in the cascade break computation */
  59116. get minDistance(): number;
  59117. /** Gets the maximal distance used in the cascade break computation */
  59118. get maxDistance(): number;
  59119. /**
  59120. * Gets the class name of that object
  59121. * @returns "CascadedShadowGenerator"
  59122. */
  59123. getClassName(): string;
  59124. private _cascadeMinExtents;
  59125. private _cascadeMaxExtents;
  59126. /**
  59127. * Gets a cascade minimum extents
  59128. * @param cascadeIndex index of the cascade
  59129. * @returns the minimum cascade extents
  59130. */
  59131. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59132. /**
  59133. * Gets a cascade maximum extents
  59134. * @param cascadeIndex index of the cascade
  59135. * @returns the maximum cascade extents
  59136. */
  59137. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59138. private _cascades;
  59139. private _currentLayer;
  59140. private _viewSpaceFrustumsZ;
  59141. private _viewMatrices;
  59142. private _projectionMatrices;
  59143. private _transformMatrices;
  59144. private _transformMatricesAsArray;
  59145. private _frustumLengths;
  59146. private _lightSizeUVCorrection;
  59147. private _depthCorrection;
  59148. private _frustumCornersWorldSpace;
  59149. private _frustumCenter;
  59150. private _shadowCameraPos;
  59151. private _shadowMaxZ;
  59152. /**
  59153. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59154. * It defaults to camera.maxZ
  59155. */
  59156. get shadowMaxZ(): number;
  59157. /**
  59158. * Sets the shadow max z distance.
  59159. */
  59160. set shadowMaxZ(value: number);
  59161. protected _debug: boolean;
  59162. /**
  59163. * Gets or sets the debug flag.
  59164. * When enabled, the cascades are materialized by different colors on the screen.
  59165. */
  59166. get debug(): boolean;
  59167. set debug(dbg: boolean);
  59168. private _depthClamp;
  59169. /**
  59170. * Gets or sets the depth clamping value.
  59171. *
  59172. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59173. * to account for the shadow casters far away.
  59174. *
  59175. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59176. */
  59177. get depthClamp(): boolean;
  59178. set depthClamp(value: boolean);
  59179. private _cascadeBlendPercentage;
  59180. /**
  59181. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59182. * It defaults to 0.1 (10% blending).
  59183. */
  59184. get cascadeBlendPercentage(): number;
  59185. set cascadeBlendPercentage(value: number);
  59186. private _lambda;
  59187. /**
  59188. * Gets or set the lambda parameter.
  59189. * This parameter is used to split the camera frustum and create the cascades.
  59190. * 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.
  59191. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59192. */
  59193. get lambda(): number;
  59194. set lambda(value: number);
  59195. /**
  59196. * Gets the view matrix corresponding to a given cascade
  59197. * @param cascadeNum cascade to retrieve the view matrix from
  59198. * @returns the cascade view matrix
  59199. */
  59200. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59201. /**
  59202. * Gets the projection matrix corresponding to a given cascade
  59203. * @param cascadeNum cascade to retrieve the projection matrix from
  59204. * @returns the cascade projection matrix
  59205. */
  59206. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59207. /**
  59208. * Gets the transformation matrix corresponding to a given cascade
  59209. * @param cascadeNum cascade to retrieve the transformation matrix from
  59210. * @returns the cascade transformation matrix
  59211. */
  59212. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59213. private _depthRenderer;
  59214. /**
  59215. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59216. *
  59217. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59218. *
  59219. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59220. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59221. * @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
  59222. */
  59223. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59224. private _depthReducer;
  59225. private _autoCalcDepthBounds;
  59226. /**
  59227. * Gets or sets the autoCalcDepthBounds property.
  59228. *
  59229. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59230. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59231. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59232. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59233. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59234. */
  59235. get autoCalcDepthBounds(): boolean;
  59236. set autoCalcDepthBounds(value: boolean);
  59237. /**
  59238. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59239. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59240. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59241. * for setting the refresh rate on the renderer yourself!
  59242. */
  59243. get autoCalcDepthBoundsRefreshRate(): number;
  59244. set autoCalcDepthBoundsRefreshRate(value: number);
  59245. /**
  59246. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59247. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59248. * you change the camera near/far planes!
  59249. */
  59250. splitFrustum(): void;
  59251. private _splitFrustum;
  59252. private _computeMatrices;
  59253. private _computeFrustumInWorldSpace;
  59254. private _computeCascadeFrustum;
  59255. /**
  59256. * Support test.
  59257. */
  59258. static get IsSupported(): boolean;
  59259. /** @hidden */
  59260. static _SceneComponentInitialization: (scene: Scene) => void;
  59261. /**
  59262. * Creates a Cascaded Shadow Generator object.
  59263. * A ShadowGenerator is the required tool to use the shadows.
  59264. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59265. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59266. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59267. * @param light The directional light object generating the shadows.
  59268. * @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.
  59269. */
  59270. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59271. protected _initializeGenerator(): void;
  59272. protected _createTargetRenderTexture(): void;
  59273. protected _initializeShadowMap(): void;
  59274. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59275. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59276. /**
  59277. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59278. * @param defines Defines of the material we want to update
  59279. * @param lightIndex Index of the light in the enabled light list of the material
  59280. */
  59281. prepareDefines(defines: any, lightIndex: number): void;
  59282. /**
  59283. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59284. * defined in the generator but impacting the effect).
  59285. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59286. * @param effect The effect we are binfing the information for
  59287. */
  59288. bindShadowLight(lightIndex: string, effect: Effect): void;
  59289. /**
  59290. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59291. * (eq to view projection * shadow projection matrices)
  59292. * @returns The transform matrix used to create the shadow map
  59293. */
  59294. getTransformMatrix(): Matrix;
  59295. /**
  59296. * Disposes the ShadowGenerator.
  59297. * Returns nothing.
  59298. */
  59299. dispose(): void;
  59300. /**
  59301. * Serializes the shadow generator setup to a json object.
  59302. * @returns The serialized JSON object
  59303. */
  59304. serialize(): any;
  59305. /**
  59306. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59307. * @param parsedShadowGenerator The JSON object to parse
  59308. * @param scene The scene to create the shadow map for
  59309. * @returns The parsed shadow generator
  59310. */
  59311. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59312. }
  59313. }
  59314. declare module BABYLON {
  59315. /**
  59316. * Defines the shadow generator component responsible to manage any shadow generators
  59317. * in a given scene.
  59318. */
  59319. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59320. /**
  59321. * The component name helpfull to identify the component in the list of scene components.
  59322. */
  59323. readonly name: string;
  59324. /**
  59325. * The scene the component belongs to.
  59326. */
  59327. scene: Scene;
  59328. /**
  59329. * Creates a new instance of the component for the given scene
  59330. * @param scene Defines the scene to register the component in
  59331. */
  59332. constructor(scene: Scene);
  59333. /**
  59334. * Registers the component in a given scene
  59335. */
  59336. register(): void;
  59337. /**
  59338. * Rebuilds the elements related to this component in case of
  59339. * context lost for instance.
  59340. */
  59341. rebuild(): void;
  59342. /**
  59343. * Serializes the component data to the specified json object
  59344. * @param serializationObject The object to serialize to
  59345. */
  59346. serialize(serializationObject: any): void;
  59347. /**
  59348. * Adds all the elements from the container to the scene
  59349. * @param container the container holding the elements
  59350. */
  59351. addFromContainer(container: AbstractScene): void;
  59352. /**
  59353. * Removes all the elements in the container from the scene
  59354. * @param container contains the elements to remove
  59355. * @param dispose if the removed element should be disposed (default: false)
  59356. */
  59357. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59358. /**
  59359. * Rebuilds the elements related to this component in case of
  59360. * context lost for instance.
  59361. */
  59362. dispose(): void;
  59363. private _gatherRenderTargets;
  59364. }
  59365. }
  59366. declare module BABYLON {
  59367. /**
  59368. * A point light is a light defined by an unique point in world space.
  59369. * The light is emitted in every direction from this point.
  59370. * A good example of a point light is a standard light bulb.
  59371. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59372. */
  59373. export class PointLight extends ShadowLight {
  59374. private _shadowAngle;
  59375. /**
  59376. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59377. * This specifies what angle the shadow will use to be created.
  59378. *
  59379. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59380. */
  59381. get shadowAngle(): number;
  59382. /**
  59383. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59384. * This specifies what angle the shadow will use to be created.
  59385. *
  59386. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59387. */
  59388. set shadowAngle(value: number);
  59389. /**
  59390. * Gets the direction if it has been set.
  59391. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59392. */
  59393. get direction(): Vector3;
  59394. /**
  59395. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59396. */
  59397. set direction(value: Vector3);
  59398. /**
  59399. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59400. * A PointLight emits the light in every direction.
  59401. * It can cast shadows.
  59402. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59403. * ```javascript
  59404. * var pointLight = new PointLight("pl", camera.position, scene);
  59405. * ```
  59406. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59407. * @param name The light friendly name
  59408. * @param position The position of the point light in the scene
  59409. * @param scene The scene the lights belongs to
  59410. */
  59411. constructor(name: string, position: Vector3, scene: Scene);
  59412. /**
  59413. * Returns the string "PointLight"
  59414. * @returns the class name
  59415. */
  59416. getClassName(): string;
  59417. /**
  59418. * Returns the integer 0.
  59419. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59420. */
  59421. getTypeID(): number;
  59422. /**
  59423. * Specifies wether or not the shadowmap should be a cube texture.
  59424. * @returns true if the shadowmap needs to be a cube texture.
  59425. */
  59426. needCube(): boolean;
  59427. /**
  59428. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59429. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59430. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59431. */
  59432. getShadowDirection(faceIndex?: number): Vector3;
  59433. /**
  59434. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59435. * - fov = PI / 2
  59436. * - aspect ratio : 1.0
  59437. * - z-near and far equal to the active camera minZ and maxZ.
  59438. * Returns the PointLight.
  59439. */
  59440. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59441. protected _buildUniformLayout(): void;
  59442. /**
  59443. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59444. * @param effect The effect to update
  59445. * @param lightIndex The index of the light in the effect to update
  59446. * @returns The point light
  59447. */
  59448. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59449. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59450. /**
  59451. * Prepares the list of defines specific to the light type.
  59452. * @param defines the list of defines
  59453. * @param lightIndex defines the index of the light for the effect
  59454. */
  59455. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59456. }
  59457. }
  59458. declare module BABYLON {
  59459. /**
  59460. * Header information of HDR texture files.
  59461. */
  59462. export interface HDRInfo {
  59463. /**
  59464. * The height of the texture in pixels.
  59465. */
  59466. height: number;
  59467. /**
  59468. * The width of the texture in pixels.
  59469. */
  59470. width: number;
  59471. /**
  59472. * The index of the beginning of the data in the binary file.
  59473. */
  59474. dataPosition: number;
  59475. }
  59476. /**
  59477. * This groups tools to convert HDR texture to native colors array.
  59478. */
  59479. export class HDRTools {
  59480. private static Ldexp;
  59481. private static Rgbe2float;
  59482. private static readStringLine;
  59483. /**
  59484. * Reads header information from an RGBE texture stored in a native array.
  59485. * More information on this format are available here:
  59486. * https://en.wikipedia.org/wiki/RGBE_image_format
  59487. *
  59488. * @param uint8array The binary file stored in native array.
  59489. * @return The header information.
  59490. */
  59491. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59492. /**
  59493. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59494. * This RGBE texture needs to store the information as a panorama.
  59495. *
  59496. * More information on this format are available here:
  59497. * https://en.wikipedia.org/wiki/RGBE_image_format
  59498. *
  59499. * @param buffer The binary file stored in an array buffer.
  59500. * @param size The expected size of the extracted cubemap.
  59501. * @return The Cube Map information.
  59502. */
  59503. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59504. /**
  59505. * Returns the pixels data extracted from an RGBE texture.
  59506. * This pixels will be stored left to right up to down in the R G B order in one array.
  59507. *
  59508. * More information on this format are available here:
  59509. * https://en.wikipedia.org/wiki/RGBE_image_format
  59510. *
  59511. * @param uint8array The binary file stored in an array buffer.
  59512. * @param hdrInfo The header information of the file.
  59513. * @return The pixels data in RGB right to left up to down order.
  59514. */
  59515. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59516. private static RGBE_ReadPixels_RLE;
  59517. private static RGBE_ReadPixels_NOT_RLE;
  59518. }
  59519. }
  59520. declare module BABYLON {
  59521. /**
  59522. * Effect Render Options
  59523. */
  59524. export interface IEffectRendererOptions {
  59525. /**
  59526. * Defines the vertices positions.
  59527. */
  59528. positions?: number[];
  59529. /**
  59530. * Defines the indices.
  59531. */
  59532. indices?: number[];
  59533. }
  59534. /**
  59535. * Helper class to render one or more effects.
  59536. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59537. */
  59538. export class EffectRenderer {
  59539. private engine;
  59540. private static _DefaultOptions;
  59541. private _vertexBuffers;
  59542. private _indexBuffer;
  59543. private _fullscreenViewport;
  59544. /**
  59545. * Creates an effect renderer
  59546. * @param engine the engine to use for rendering
  59547. * @param options defines the options of the effect renderer
  59548. */
  59549. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59550. /**
  59551. * Sets the current viewport in normalized coordinates 0-1
  59552. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59553. */
  59554. setViewport(viewport?: Viewport): void;
  59555. /**
  59556. * Binds the embedded attributes buffer to the effect.
  59557. * @param effect Defines the effect to bind the attributes for
  59558. */
  59559. bindBuffers(effect: Effect): void;
  59560. /**
  59561. * Sets the current effect wrapper to use during draw.
  59562. * The effect needs to be ready before calling this api.
  59563. * This also sets the default full screen position attribute.
  59564. * @param effectWrapper Defines the effect to draw with
  59565. */
  59566. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59567. /**
  59568. * Restores engine states
  59569. */
  59570. restoreStates(): void;
  59571. /**
  59572. * Draws a full screen quad.
  59573. */
  59574. draw(): void;
  59575. private isRenderTargetTexture;
  59576. /**
  59577. * renders one or more effects to a specified texture
  59578. * @param effectWrapper the effect to renderer
  59579. * @param outputTexture texture to draw to, if null it will render to the screen.
  59580. */
  59581. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59582. /**
  59583. * Disposes of the effect renderer
  59584. */
  59585. dispose(): void;
  59586. }
  59587. /**
  59588. * Options to create an EffectWrapper
  59589. */
  59590. interface EffectWrapperCreationOptions {
  59591. /**
  59592. * Engine to use to create the effect
  59593. */
  59594. engine: ThinEngine;
  59595. /**
  59596. * Fragment shader for the effect
  59597. */
  59598. fragmentShader: string;
  59599. /**
  59600. * Use the shader store instead of direct source code
  59601. */
  59602. useShaderStore?: boolean;
  59603. /**
  59604. * Vertex shader for the effect
  59605. */
  59606. vertexShader?: string;
  59607. /**
  59608. * Attributes to use in the shader
  59609. */
  59610. attributeNames?: Array<string>;
  59611. /**
  59612. * Uniforms to use in the shader
  59613. */
  59614. uniformNames?: Array<string>;
  59615. /**
  59616. * Texture sampler names to use in the shader
  59617. */
  59618. samplerNames?: Array<string>;
  59619. /**
  59620. * Defines to use in the shader
  59621. */
  59622. defines?: Array<string>;
  59623. /**
  59624. * Callback when effect is compiled
  59625. */
  59626. onCompiled?: Nullable<(effect: Effect) => void>;
  59627. /**
  59628. * The friendly name of the effect displayed in Spector.
  59629. */
  59630. name?: string;
  59631. }
  59632. /**
  59633. * Wraps an effect to be used for rendering
  59634. */
  59635. export class EffectWrapper {
  59636. /**
  59637. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59638. */
  59639. onApplyObservable: Observable<{}>;
  59640. /**
  59641. * The underlying effect
  59642. */
  59643. effect: Effect;
  59644. /**
  59645. * Creates an effect to be renderer
  59646. * @param creationOptions options to create the effect
  59647. */
  59648. constructor(creationOptions: EffectWrapperCreationOptions);
  59649. /**
  59650. * Disposes of the effect wrapper
  59651. */
  59652. dispose(): void;
  59653. }
  59654. }
  59655. declare module BABYLON {
  59656. /** @hidden */
  59657. export var hdrFilteringVertexShader: {
  59658. name: string;
  59659. shader: string;
  59660. };
  59661. }
  59662. declare module BABYLON {
  59663. /** @hidden */
  59664. export var hdrFilteringPixelShader: {
  59665. name: string;
  59666. shader: string;
  59667. };
  59668. }
  59669. declare module BABYLON {
  59670. /**
  59671. * Options for texture filtering
  59672. */
  59673. interface IHDRFilteringOptions {
  59674. /**
  59675. * Scales pixel intensity for the input HDR map.
  59676. */
  59677. hdrScale?: number;
  59678. /**
  59679. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59680. */
  59681. quality?: number;
  59682. }
  59683. /**
  59684. * Filters HDR maps to get correct renderings of PBR reflections
  59685. */
  59686. export class HDRFiltering {
  59687. private _engine;
  59688. private _effectRenderer;
  59689. private _effectWrapper;
  59690. private _lodGenerationOffset;
  59691. private _lodGenerationScale;
  59692. /**
  59693. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59694. * you care about baking speed.
  59695. */
  59696. quality: number;
  59697. /**
  59698. * Scales pixel intensity for the input HDR map.
  59699. */
  59700. hdrScale: number;
  59701. /**
  59702. * Instantiates HDR filter for reflection maps
  59703. *
  59704. * @param engine Thin engine
  59705. * @param options Options
  59706. */
  59707. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59708. private _createRenderTarget;
  59709. private _prefilterInternal;
  59710. private _createEffect;
  59711. /**
  59712. * Get a value indicating if the filter is ready to be used
  59713. * @param texture Texture to filter
  59714. * @returns true if the filter is ready
  59715. */
  59716. isReady(texture: BaseTexture): boolean;
  59717. /**
  59718. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59719. * Prefiltering will be invoked at the end of next rendering pass.
  59720. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59721. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59722. * @param texture Texture to filter
  59723. * @param onFinished Callback when filtering is done
  59724. * @return Promise called when prefiltering is done
  59725. */
  59726. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59727. }
  59728. }
  59729. declare module BABYLON {
  59730. /**
  59731. * This represents a texture coming from an HDR input.
  59732. *
  59733. * The only supported format is currently panorama picture stored in RGBE format.
  59734. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59735. */
  59736. export class HDRCubeTexture extends BaseTexture {
  59737. private static _facesMapping;
  59738. private _generateHarmonics;
  59739. private _noMipmap;
  59740. private _prefilterOnLoad;
  59741. private _textureMatrix;
  59742. private _size;
  59743. private _onLoad;
  59744. private _onError;
  59745. /**
  59746. * The texture URL.
  59747. */
  59748. url: string;
  59749. /**
  59750. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59751. */
  59752. coordinatesMode: number;
  59753. protected _isBlocking: boolean;
  59754. /**
  59755. * Sets wether or not the texture is blocking during loading.
  59756. */
  59757. set isBlocking(value: boolean);
  59758. /**
  59759. * Gets wether or not the texture is blocking during loading.
  59760. */
  59761. get isBlocking(): boolean;
  59762. protected _rotationY: number;
  59763. /**
  59764. * Sets texture matrix rotation angle around Y axis in radians.
  59765. */
  59766. set rotationY(value: number);
  59767. /**
  59768. * Gets texture matrix rotation angle around Y axis radians.
  59769. */
  59770. get rotationY(): number;
  59771. /**
  59772. * Gets or sets the center of the bounding box associated with the cube texture
  59773. * It must define where the camera used to render the texture was set
  59774. */
  59775. boundingBoxPosition: Vector3;
  59776. private _boundingBoxSize;
  59777. /**
  59778. * Gets or sets the size of the bounding box associated with the cube texture
  59779. * When defined, the cubemap will switch to local mode
  59780. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59781. * @example https://www.babylonjs-playground.com/#RNASML
  59782. */
  59783. set boundingBoxSize(value: Vector3);
  59784. get boundingBoxSize(): Vector3;
  59785. /**
  59786. * Instantiates an HDRTexture from the following parameters.
  59787. *
  59788. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59789. * @param sceneOrEngine The scene or engine the texture will be used in
  59790. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59791. * @param noMipmap Forces to not generate the mipmap if true
  59792. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59793. * @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)
  59794. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59795. */
  59796. 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>);
  59797. /**
  59798. * Get the current class name of the texture useful for serialization or dynamic coding.
  59799. * @returns "HDRCubeTexture"
  59800. */
  59801. getClassName(): string;
  59802. /**
  59803. * Occurs when the file is raw .hdr file.
  59804. */
  59805. private loadTexture;
  59806. clone(): HDRCubeTexture;
  59807. delayLoad(): void;
  59808. /**
  59809. * Get the texture reflection matrix used to rotate/transform the reflection.
  59810. * @returns the reflection matrix
  59811. */
  59812. getReflectionTextureMatrix(): Matrix;
  59813. /**
  59814. * Set the texture reflection matrix used to rotate/transform the reflection.
  59815. * @param value Define the reflection matrix to set
  59816. */
  59817. setReflectionTextureMatrix(value: Matrix): void;
  59818. /**
  59819. * Parses a JSON representation of an HDR Texture in order to create the texture
  59820. * @param parsedTexture Define the JSON representation
  59821. * @param scene Define the scene the texture should be created in
  59822. * @param rootUrl Define the root url in case we need to load relative dependencies
  59823. * @returns the newly created texture after parsing
  59824. */
  59825. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59826. serialize(): any;
  59827. }
  59828. }
  59829. declare module BABYLON {
  59830. /**
  59831. * Class used to control physics engine
  59832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59833. */
  59834. export class PhysicsEngine implements IPhysicsEngine {
  59835. private _physicsPlugin;
  59836. /**
  59837. * Global value used to control the smallest number supported by the simulation
  59838. */
  59839. static Epsilon: number;
  59840. private _impostors;
  59841. private _joints;
  59842. private _subTimeStep;
  59843. /**
  59844. * Gets the gravity vector used by the simulation
  59845. */
  59846. gravity: Vector3;
  59847. /**
  59848. * Factory used to create the default physics plugin.
  59849. * @returns The default physics plugin
  59850. */
  59851. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59852. /**
  59853. * Creates a new Physics Engine
  59854. * @param gravity defines the gravity vector used by the simulation
  59855. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59856. */
  59857. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59858. /**
  59859. * Sets the gravity vector used by the simulation
  59860. * @param gravity defines the gravity vector to use
  59861. */
  59862. setGravity(gravity: Vector3): void;
  59863. /**
  59864. * Set the time step of the physics engine.
  59865. * Default is 1/60.
  59866. * To slow it down, enter 1/600 for example.
  59867. * To speed it up, 1/30
  59868. * @param newTimeStep defines the new timestep to apply to this world.
  59869. */
  59870. setTimeStep(newTimeStep?: number): void;
  59871. /**
  59872. * Get the time step of the physics engine.
  59873. * @returns the current time step
  59874. */
  59875. getTimeStep(): number;
  59876. /**
  59877. * Set the sub time step of the physics engine.
  59878. * Default is 0 meaning there is no sub steps
  59879. * To increase physics resolution precision, set a small value (like 1 ms)
  59880. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59881. */
  59882. setSubTimeStep(subTimeStep?: number): void;
  59883. /**
  59884. * Get the sub time step of the physics engine.
  59885. * @returns the current sub time step
  59886. */
  59887. getSubTimeStep(): number;
  59888. /**
  59889. * Release all resources
  59890. */
  59891. dispose(): void;
  59892. /**
  59893. * Gets the name of the current physics plugin
  59894. * @returns the name of the plugin
  59895. */
  59896. getPhysicsPluginName(): string;
  59897. /**
  59898. * Adding a new impostor for the impostor tracking.
  59899. * This will be done by the impostor itself.
  59900. * @param impostor the impostor to add
  59901. */
  59902. addImpostor(impostor: PhysicsImpostor): void;
  59903. /**
  59904. * Remove an impostor from the engine.
  59905. * This impostor and its mesh will not longer be updated by the physics engine.
  59906. * @param impostor the impostor to remove
  59907. */
  59908. removeImpostor(impostor: PhysicsImpostor): void;
  59909. /**
  59910. * Add a joint to the physics engine
  59911. * @param mainImpostor defines the main impostor to which the joint is added.
  59912. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59913. * @param joint defines the joint that will connect both impostors.
  59914. */
  59915. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59916. /**
  59917. * Removes a joint from the simulation
  59918. * @param mainImpostor defines the impostor used with the joint
  59919. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59920. * @param joint defines the joint to remove
  59921. */
  59922. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59923. /**
  59924. * Called by the scene. No need to call it.
  59925. * @param delta defines the timespam between frames
  59926. */
  59927. _step(delta: number): void;
  59928. /**
  59929. * Gets the current plugin used to run the simulation
  59930. * @returns current plugin
  59931. */
  59932. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59933. /**
  59934. * Gets the list of physic impostors
  59935. * @returns an array of PhysicsImpostor
  59936. */
  59937. getImpostors(): Array<PhysicsImpostor>;
  59938. /**
  59939. * Gets the impostor for a physics enabled object
  59940. * @param object defines the object impersonated by the impostor
  59941. * @returns the PhysicsImpostor or null if not found
  59942. */
  59943. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59944. /**
  59945. * Gets the impostor for a physics body object
  59946. * @param body defines physics body used by the impostor
  59947. * @returns the PhysicsImpostor or null if not found
  59948. */
  59949. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59950. /**
  59951. * Does a raycast in the physics world
  59952. * @param from when should the ray start?
  59953. * @param to when should the ray end?
  59954. * @returns PhysicsRaycastResult
  59955. */
  59956. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59957. }
  59958. }
  59959. declare module BABYLON {
  59960. /** @hidden */
  59961. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59962. private _useDeltaForWorldStep;
  59963. world: any;
  59964. name: string;
  59965. private _physicsMaterials;
  59966. private _fixedTimeStep;
  59967. private _cannonRaycastResult;
  59968. private _raycastResult;
  59969. private _physicsBodysToRemoveAfterStep;
  59970. private _firstFrame;
  59971. BJSCANNON: any;
  59972. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59973. setGravity(gravity: Vector3): void;
  59974. setTimeStep(timeStep: number): void;
  59975. getTimeStep(): number;
  59976. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59977. private _removeMarkedPhysicsBodiesFromWorld;
  59978. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59979. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59980. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59981. private _processChildMeshes;
  59982. removePhysicsBody(impostor: PhysicsImpostor): void;
  59983. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59984. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59985. private _addMaterial;
  59986. private _checkWithEpsilon;
  59987. private _createShape;
  59988. private _createHeightmap;
  59989. private _minus90X;
  59990. private _plus90X;
  59991. private _tmpPosition;
  59992. private _tmpDeltaPosition;
  59993. private _tmpUnityRotation;
  59994. private _updatePhysicsBodyTransformation;
  59995. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59996. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59997. isSupported(): boolean;
  59998. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59999. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60000. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60001. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60002. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60003. getBodyMass(impostor: PhysicsImpostor): number;
  60004. getBodyFriction(impostor: PhysicsImpostor): number;
  60005. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60006. getBodyRestitution(impostor: PhysicsImpostor): number;
  60007. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60008. sleepBody(impostor: PhysicsImpostor): void;
  60009. wakeUpBody(impostor: PhysicsImpostor): void;
  60010. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60011. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60012. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60013. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60014. getRadius(impostor: PhysicsImpostor): number;
  60015. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60016. dispose(): void;
  60017. private _extendNamespace;
  60018. /**
  60019. * Does a raycast in the physics world
  60020. * @param from when should the ray start?
  60021. * @param to when should the ray end?
  60022. * @returns PhysicsRaycastResult
  60023. */
  60024. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60025. }
  60026. }
  60027. declare module BABYLON {
  60028. /** @hidden */
  60029. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60030. private _useDeltaForWorldStep;
  60031. world: any;
  60032. name: string;
  60033. BJSOIMO: any;
  60034. private _raycastResult;
  60035. private _fixedTimeStep;
  60036. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60037. setGravity(gravity: Vector3): void;
  60038. setTimeStep(timeStep: number): void;
  60039. getTimeStep(): number;
  60040. private _tmpImpostorsArray;
  60041. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60042. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60043. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60044. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60045. private _tmpPositionVector;
  60046. removePhysicsBody(impostor: PhysicsImpostor): void;
  60047. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60048. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60049. isSupported(): boolean;
  60050. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60051. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60052. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60053. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60054. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60055. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60056. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60057. getBodyMass(impostor: PhysicsImpostor): number;
  60058. getBodyFriction(impostor: PhysicsImpostor): number;
  60059. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60060. getBodyRestitution(impostor: PhysicsImpostor): number;
  60061. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60062. sleepBody(impostor: PhysicsImpostor): void;
  60063. wakeUpBody(impostor: PhysicsImpostor): void;
  60064. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60065. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60066. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60067. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60068. getRadius(impostor: PhysicsImpostor): number;
  60069. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60070. dispose(): void;
  60071. /**
  60072. * Does a raycast in the physics world
  60073. * @param from when should the ray start?
  60074. * @param to when should the ray end?
  60075. * @returns PhysicsRaycastResult
  60076. */
  60077. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60078. }
  60079. }
  60080. declare module BABYLON {
  60081. /**
  60082. * Class containing static functions to help procedurally build meshes
  60083. */
  60084. export class RibbonBuilder {
  60085. /**
  60086. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60087. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60088. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60089. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60090. * * 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
  60091. * * 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
  60092. * * 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
  60093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60094. * * 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
  60095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60096. * * 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
  60097. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60098. * * 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
  60099. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60101. * @param name defines the name of the mesh
  60102. * @param options defines the options used to create the mesh
  60103. * @param scene defines the hosting scene
  60104. * @returns the ribbon mesh
  60105. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60107. */
  60108. static CreateRibbon(name: string, options: {
  60109. pathArray: Vector3[][];
  60110. closeArray?: boolean;
  60111. closePath?: boolean;
  60112. offset?: number;
  60113. updatable?: boolean;
  60114. sideOrientation?: number;
  60115. frontUVs?: Vector4;
  60116. backUVs?: Vector4;
  60117. instance?: Mesh;
  60118. invertUV?: boolean;
  60119. uvs?: Vector2[];
  60120. colors?: Color4[];
  60121. }, scene?: Nullable<Scene>): Mesh;
  60122. }
  60123. }
  60124. declare module BABYLON {
  60125. /**
  60126. * Class containing static functions to help procedurally build meshes
  60127. */
  60128. export class ShapeBuilder {
  60129. /**
  60130. * 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.
  60131. * * 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.
  60132. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60133. * * 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.
  60134. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60135. * * 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
  60136. * * 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
  60137. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60139. * * 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
  60140. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60142. * @param name defines the name of the mesh
  60143. * @param options defines the options used to create the mesh
  60144. * @param scene defines the hosting scene
  60145. * @returns the extruded shape mesh
  60146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60148. */
  60149. static ExtrudeShape(name: string, options: {
  60150. shape: Vector3[];
  60151. path: Vector3[];
  60152. scale?: number;
  60153. rotation?: number;
  60154. cap?: number;
  60155. updatable?: boolean;
  60156. sideOrientation?: number;
  60157. frontUVs?: Vector4;
  60158. backUVs?: Vector4;
  60159. instance?: Mesh;
  60160. invertUV?: boolean;
  60161. }, scene?: Nullable<Scene>): Mesh;
  60162. /**
  60163. * Creates an custom extruded shape mesh.
  60164. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60165. * * 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.
  60166. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60167. * * 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
  60168. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60169. * * 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
  60170. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60171. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60172. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60173. * * 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
  60174. * * 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
  60175. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60177. * * 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
  60178. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60180. * @param name defines the name of the mesh
  60181. * @param options defines the options used to create the mesh
  60182. * @param scene defines the hosting scene
  60183. * @returns the custom extruded shape mesh
  60184. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60185. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60187. */
  60188. static ExtrudeShapeCustom(name: string, options: {
  60189. shape: Vector3[];
  60190. path: Vector3[];
  60191. scaleFunction?: any;
  60192. rotationFunction?: any;
  60193. ribbonCloseArray?: boolean;
  60194. ribbonClosePath?: boolean;
  60195. cap?: number;
  60196. updatable?: boolean;
  60197. sideOrientation?: number;
  60198. frontUVs?: Vector4;
  60199. backUVs?: Vector4;
  60200. instance?: Mesh;
  60201. invertUV?: boolean;
  60202. }, scene?: Nullable<Scene>): Mesh;
  60203. private static _ExtrudeShapeGeneric;
  60204. }
  60205. }
  60206. declare module BABYLON {
  60207. /**
  60208. * AmmoJS Physics plugin
  60209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60210. * @see https://github.com/kripken/ammo.js/
  60211. */
  60212. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60213. private _useDeltaForWorldStep;
  60214. /**
  60215. * Reference to the Ammo library
  60216. */
  60217. bjsAMMO: any;
  60218. /**
  60219. * Created ammoJS world which physics bodies are added to
  60220. */
  60221. world: any;
  60222. /**
  60223. * Name of the plugin
  60224. */
  60225. name: string;
  60226. private _timeStep;
  60227. private _fixedTimeStep;
  60228. private _maxSteps;
  60229. private _tmpQuaternion;
  60230. private _tmpAmmoTransform;
  60231. private _tmpAmmoQuaternion;
  60232. private _tmpAmmoConcreteContactResultCallback;
  60233. private _collisionConfiguration;
  60234. private _dispatcher;
  60235. private _overlappingPairCache;
  60236. private _solver;
  60237. private _softBodySolver;
  60238. private _tmpAmmoVectorA;
  60239. private _tmpAmmoVectorB;
  60240. private _tmpAmmoVectorC;
  60241. private _tmpAmmoVectorD;
  60242. private _tmpContactCallbackResult;
  60243. private _tmpAmmoVectorRCA;
  60244. private _tmpAmmoVectorRCB;
  60245. private _raycastResult;
  60246. private static readonly DISABLE_COLLISION_FLAG;
  60247. private static readonly KINEMATIC_FLAG;
  60248. private static readonly DISABLE_DEACTIVATION_FLAG;
  60249. /**
  60250. * Initializes the ammoJS plugin
  60251. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60252. * @param ammoInjection can be used to inject your own ammo reference
  60253. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60254. */
  60255. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60256. /**
  60257. * Sets the gravity of the physics world (m/(s^2))
  60258. * @param gravity Gravity to set
  60259. */
  60260. setGravity(gravity: Vector3): void;
  60261. /**
  60262. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60263. * @param timeStep timestep to use in seconds
  60264. */
  60265. setTimeStep(timeStep: number): void;
  60266. /**
  60267. * 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)
  60268. * @param fixedTimeStep fixedTimeStep to use in seconds
  60269. */
  60270. setFixedTimeStep(fixedTimeStep: number): void;
  60271. /**
  60272. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60273. * @param maxSteps the maximum number of steps by the physics engine per frame
  60274. */
  60275. setMaxSteps(maxSteps: number): void;
  60276. /**
  60277. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60278. * @returns the current timestep in seconds
  60279. */
  60280. getTimeStep(): number;
  60281. /**
  60282. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60283. */
  60284. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60285. private _isImpostorInContact;
  60286. private _isImpostorPairInContact;
  60287. private _stepSimulation;
  60288. /**
  60289. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60290. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60291. * After the step the babylon meshes are set to the position of the physics imposters
  60292. * @param delta amount of time to step forward
  60293. * @param impostors array of imposters to update before/after the step
  60294. */
  60295. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60296. /**
  60297. * Update babylon mesh to match physics world object
  60298. * @param impostor imposter to match
  60299. */
  60300. private _afterSoftStep;
  60301. /**
  60302. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60303. * @param impostor imposter to match
  60304. */
  60305. private _ropeStep;
  60306. /**
  60307. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60308. * @param impostor imposter to match
  60309. */
  60310. private _softbodyOrClothStep;
  60311. private _tmpMatrix;
  60312. /**
  60313. * Applies an impulse on the imposter
  60314. * @param impostor imposter to apply impulse to
  60315. * @param force amount of force to be applied to the imposter
  60316. * @param contactPoint the location to apply the impulse on the imposter
  60317. */
  60318. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60319. /**
  60320. * Applies a force on the imposter
  60321. * @param impostor imposter to apply force
  60322. * @param force amount of force to be applied to the imposter
  60323. * @param contactPoint the location to apply the force on the imposter
  60324. */
  60325. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60326. /**
  60327. * Creates a physics body using the plugin
  60328. * @param impostor the imposter to create the physics body on
  60329. */
  60330. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60331. /**
  60332. * Removes the physics body from the imposter and disposes of the body's memory
  60333. * @param impostor imposter to remove the physics body from
  60334. */
  60335. removePhysicsBody(impostor: PhysicsImpostor): void;
  60336. /**
  60337. * Generates a joint
  60338. * @param impostorJoint the imposter joint to create the joint with
  60339. */
  60340. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60341. /**
  60342. * Removes a joint
  60343. * @param impostorJoint the imposter joint to remove the joint from
  60344. */
  60345. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60346. private _addMeshVerts;
  60347. /**
  60348. * Initialise the soft body vertices to match its object's (mesh) vertices
  60349. * Softbody vertices (nodes) are in world space and to match this
  60350. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60351. * @param impostor to create the softbody for
  60352. */
  60353. private _softVertexData;
  60354. /**
  60355. * Create an impostor's soft body
  60356. * @param impostor to create the softbody for
  60357. */
  60358. private _createSoftbody;
  60359. /**
  60360. * Create cloth for an impostor
  60361. * @param impostor to create the softbody for
  60362. */
  60363. private _createCloth;
  60364. /**
  60365. * Create rope for an impostor
  60366. * @param impostor to create the softbody for
  60367. */
  60368. private _createRope;
  60369. /**
  60370. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60371. * @param impostor to create the custom physics shape for
  60372. */
  60373. private _createCustom;
  60374. private _addHullVerts;
  60375. private _createShape;
  60376. /**
  60377. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60378. * @param impostor imposter containing the physics body and babylon object
  60379. */
  60380. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60381. /**
  60382. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60383. * @param impostor imposter containing the physics body and babylon object
  60384. * @param newPosition new position
  60385. * @param newRotation new rotation
  60386. */
  60387. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60388. /**
  60389. * If this plugin is supported
  60390. * @returns true if its supported
  60391. */
  60392. isSupported(): boolean;
  60393. /**
  60394. * Sets the linear velocity of the physics body
  60395. * @param impostor imposter to set the velocity on
  60396. * @param velocity velocity to set
  60397. */
  60398. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60399. /**
  60400. * Sets the angular velocity of the physics body
  60401. * @param impostor imposter to set the velocity on
  60402. * @param velocity velocity to set
  60403. */
  60404. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60405. /**
  60406. * gets the linear velocity
  60407. * @param impostor imposter to get linear velocity from
  60408. * @returns linear velocity
  60409. */
  60410. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60411. /**
  60412. * gets the angular velocity
  60413. * @param impostor imposter to get angular velocity from
  60414. * @returns angular velocity
  60415. */
  60416. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60417. /**
  60418. * Sets the mass of physics body
  60419. * @param impostor imposter to set the mass on
  60420. * @param mass mass to set
  60421. */
  60422. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60423. /**
  60424. * Gets the mass of the physics body
  60425. * @param impostor imposter to get the mass from
  60426. * @returns mass
  60427. */
  60428. getBodyMass(impostor: PhysicsImpostor): number;
  60429. /**
  60430. * Gets friction of the impostor
  60431. * @param impostor impostor to get friction from
  60432. * @returns friction value
  60433. */
  60434. getBodyFriction(impostor: PhysicsImpostor): number;
  60435. /**
  60436. * Sets friction of the impostor
  60437. * @param impostor impostor to set friction on
  60438. * @param friction friction value
  60439. */
  60440. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60441. /**
  60442. * Gets restitution of the impostor
  60443. * @param impostor impostor to get restitution from
  60444. * @returns restitution value
  60445. */
  60446. getBodyRestitution(impostor: PhysicsImpostor): number;
  60447. /**
  60448. * Sets resitution of the impostor
  60449. * @param impostor impostor to set resitution on
  60450. * @param restitution resitution value
  60451. */
  60452. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60453. /**
  60454. * Gets pressure inside the impostor
  60455. * @param impostor impostor to get pressure from
  60456. * @returns pressure value
  60457. */
  60458. getBodyPressure(impostor: PhysicsImpostor): number;
  60459. /**
  60460. * Sets pressure inside a soft body impostor
  60461. * Cloth and rope must remain 0 pressure
  60462. * @param impostor impostor to set pressure on
  60463. * @param pressure pressure value
  60464. */
  60465. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60466. /**
  60467. * Gets stiffness of the impostor
  60468. * @param impostor impostor to get stiffness from
  60469. * @returns pressure value
  60470. */
  60471. getBodyStiffness(impostor: PhysicsImpostor): number;
  60472. /**
  60473. * Sets stiffness of the impostor
  60474. * @param impostor impostor to set stiffness on
  60475. * @param stiffness stiffness value from 0 to 1
  60476. */
  60477. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60478. /**
  60479. * Gets velocityIterations of the impostor
  60480. * @param impostor impostor to get velocity iterations from
  60481. * @returns velocityIterations value
  60482. */
  60483. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60484. /**
  60485. * Sets velocityIterations of the impostor
  60486. * @param impostor impostor to set velocity iterations on
  60487. * @param velocityIterations velocityIterations value
  60488. */
  60489. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60490. /**
  60491. * Gets positionIterations of the impostor
  60492. * @param impostor impostor to get position iterations from
  60493. * @returns positionIterations value
  60494. */
  60495. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60496. /**
  60497. * Sets positionIterations of the impostor
  60498. * @param impostor impostor to set position on
  60499. * @param positionIterations positionIterations value
  60500. */
  60501. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60502. /**
  60503. * Append an anchor to a cloth object
  60504. * @param impostor is the cloth impostor to add anchor to
  60505. * @param otherImpostor is the rigid impostor to anchor to
  60506. * @param width ratio across width from 0 to 1
  60507. * @param height ratio up height from 0 to 1
  60508. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60509. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60510. */
  60511. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60512. /**
  60513. * Append an hook to a rope object
  60514. * @param impostor is the rope impostor to add hook to
  60515. * @param otherImpostor is the rigid impostor to hook to
  60516. * @param length ratio along the rope from 0 to 1
  60517. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60518. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60519. */
  60520. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60521. /**
  60522. * Sleeps the physics body and stops it from being active
  60523. * @param impostor impostor to sleep
  60524. */
  60525. sleepBody(impostor: PhysicsImpostor): void;
  60526. /**
  60527. * Activates the physics body
  60528. * @param impostor impostor to activate
  60529. */
  60530. wakeUpBody(impostor: PhysicsImpostor): void;
  60531. /**
  60532. * Updates the distance parameters of the joint
  60533. * @param joint joint to update
  60534. * @param maxDistance maximum distance of the joint
  60535. * @param minDistance minimum distance of the joint
  60536. */
  60537. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60538. /**
  60539. * Sets a motor on the joint
  60540. * @param joint joint to set motor on
  60541. * @param speed speed of the motor
  60542. * @param maxForce maximum force of the motor
  60543. * @param motorIndex index of the motor
  60544. */
  60545. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60546. /**
  60547. * Sets the motors limit
  60548. * @param joint joint to set limit on
  60549. * @param upperLimit upper limit
  60550. * @param lowerLimit lower limit
  60551. */
  60552. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60553. /**
  60554. * Syncs the position and rotation of a mesh with the impostor
  60555. * @param mesh mesh to sync
  60556. * @param impostor impostor to update the mesh with
  60557. */
  60558. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60559. /**
  60560. * Gets the radius of the impostor
  60561. * @param impostor impostor to get radius from
  60562. * @returns the radius
  60563. */
  60564. getRadius(impostor: PhysicsImpostor): number;
  60565. /**
  60566. * Gets the box size of the impostor
  60567. * @param impostor impostor to get box size from
  60568. * @param result the resulting box size
  60569. */
  60570. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60571. /**
  60572. * Disposes of the impostor
  60573. */
  60574. dispose(): void;
  60575. /**
  60576. * Does a raycast in the physics world
  60577. * @param from when should the ray start?
  60578. * @param to when should the ray end?
  60579. * @returns PhysicsRaycastResult
  60580. */
  60581. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60582. }
  60583. }
  60584. declare module BABYLON {
  60585. interface AbstractScene {
  60586. /**
  60587. * The list of reflection probes added to the scene
  60588. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60589. */
  60590. reflectionProbes: Array<ReflectionProbe>;
  60591. /**
  60592. * Removes the given reflection probe from this scene.
  60593. * @param toRemove The reflection probe to remove
  60594. * @returns The index of the removed reflection probe
  60595. */
  60596. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60597. /**
  60598. * Adds the given reflection probe to this scene.
  60599. * @param newReflectionProbe The reflection probe to add
  60600. */
  60601. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60602. }
  60603. /**
  60604. * Class used to generate realtime reflection / refraction cube textures
  60605. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60606. */
  60607. export class ReflectionProbe {
  60608. /** defines the name of the probe */
  60609. name: string;
  60610. private _scene;
  60611. private _renderTargetTexture;
  60612. private _projectionMatrix;
  60613. private _viewMatrix;
  60614. private _target;
  60615. private _add;
  60616. private _attachedMesh;
  60617. private _invertYAxis;
  60618. /** Gets or sets probe position (center of the cube map) */
  60619. position: Vector3;
  60620. /**
  60621. * Creates a new reflection probe
  60622. * @param name defines the name of the probe
  60623. * @param size defines the texture resolution (for each face)
  60624. * @param scene defines the hosting scene
  60625. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60626. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60627. */
  60628. constructor(
  60629. /** defines the name of the probe */
  60630. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60631. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60632. get samples(): number;
  60633. set samples(value: number);
  60634. /** Gets or sets the refresh rate to use (on every frame by default) */
  60635. get refreshRate(): number;
  60636. set refreshRate(value: number);
  60637. /**
  60638. * Gets the hosting scene
  60639. * @returns a Scene
  60640. */
  60641. getScene(): Scene;
  60642. /** Gets the internal CubeTexture used to render to */
  60643. get cubeTexture(): RenderTargetTexture;
  60644. /** Gets the list of meshes to render */
  60645. get renderList(): Nullable<AbstractMesh[]>;
  60646. /**
  60647. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60648. * @param mesh defines the mesh to attach to
  60649. */
  60650. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60651. /**
  60652. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60653. * @param renderingGroupId The rendering group id corresponding to its index
  60654. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60655. */
  60656. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60657. /**
  60658. * Clean all associated resources
  60659. */
  60660. dispose(): void;
  60661. /**
  60662. * Converts the reflection probe information to a readable string for debug purpose.
  60663. * @param fullDetails Supports for multiple levels of logging within scene loading
  60664. * @returns the human readable reflection probe info
  60665. */
  60666. toString(fullDetails?: boolean): string;
  60667. /**
  60668. * Get the class name of the relfection probe.
  60669. * @returns "ReflectionProbe"
  60670. */
  60671. getClassName(): string;
  60672. /**
  60673. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60674. * @returns The JSON representation of the texture
  60675. */
  60676. serialize(): any;
  60677. /**
  60678. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60679. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60680. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60681. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60682. * @returns The parsed reflection probe if successful
  60683. */
  60684. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60685. }
  60686. }
  60687. declare module BABYLON {
  60688. /** @hidden */
  60689. export var _BabylonLoaderRegistered: boolean;
  60690. /**
  60691. * Helps setting up some configuration for the babylon file loader.
  60692. */
  60693. export class BabylonFileLoaderConfiguration {
  60694. /**
  60695. * The loader does not allow injecting custom physix engine into the plugins.
  60696. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60697. * So you could set this variable to your engine import to make it work.
  60698. */
  60699. static LoaderInjectedPhysicsEngine: any;
  60700. }
  60701. }
  60702. declare module BABYLON {
  60703. /**
  60704. * The Physically based simple base material of BJS.
  60705. *
  60706. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60707. * It is used as the base class for both the specGloss and metalRough conventions.
  60708. */
  60709. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60710. /**
  60711. * Number of Simultaneous lights allowed on the material.
  60712. */
  60713. maxSimultaneousLights: number;
  60714. /**
  60715. * If sets to true, disables all the lights affecting the material.
  60716. */
  60717. disableLighting: boolean;
  60718. /**
  60719. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60720. */
  60721. environmentTexture: BaseTexture;
  60722. /**
  60723. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60724. */
  60725. invertNormalMapX: boolean;
  60726. /**
  60727. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60728. */
  60729. invertNormalMapY: boolean;
  60730. /**
  60731. * Normal map used in the model.
  60732. */
  60733. normalTexture: BaseTexture;
  60734. /**
  60735. * Emissivie color used to self-illuminate the model.
  60736. */
  60737. emissiveColor: Color3;
  60738. /**
  60739. * Emissivie texture used to self-illuminate the model.
  60740. */
  60741. emissiveTexture: BaseTexture;
  60742. /**
  60743. * Occlusion Channel Strenght.
  60744. */
  60745. occlusionStrength: number;
  60746. /**
  60747. * Occlusion Texture of the material (adding extra occlusion effects).
  60748. */
  60749. occlusionTexture: BaseTexture;
  60750. /**
  60751. * Defines the alpha limits in alpha test mode.
  60752. */
  60753. alphaCutOff: number;
  60754. /**
  60755. * Gets the current double sided mode.
  60756. */
  60757. get doubleSided(): boolean;
  60758. /**
  60759. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60760. */
  60761. set doubleSided(value: boolean);
  60762. /**
  60763. * Stores the pre-calculated light information of a mesh in a texture.
  60764. */
  60765. lightmapTexture: BaseTexture;
  60766. /**
  60767. * If true, the light map contains occlusion information instead of lighting info.
  60768. */
  60769. useLightmapAsShadowmap: boolean;
  60770. /**
  60771. * Instantiates a new PBRMaterial instance.
  60772. *
  60773. * @param name The material name
  60774. * @param scene The scene the material will be use in.
  60775. */
  60776. constructor(name: string, scene: Scene);
  60777. getClassName(): string;
  60778. }
  60779. }
  60780. declare module BABYLON {
  60781. /**
  60782. * The PBR material of BJS following the metal roughness convention.
  60783. *
  60784. * This fits to the PBR convention in the GLTF definition:
  60785. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60786. */
  60787. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60788. /**
  60789. * The base color has two different interpretations depending on the value of metalness.
  60790. * When the material is a metal, the base color is the specific measured reflectance value
  60791. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60792. * of the material.
  60793. */
  60794. baseColor: Color3;
  60795. /**
  60796. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60797. * well as opacity information in the alpha channel.
  60798. */
  60799. baseTexture: BaseTexture;
  60800. /**
  60801. * Specifies the metallic scalar value of the material.
  60802. * Can also be used to scale the metalness values of the metallic texture.
  60803. */
  60804. metallic: number;
  60805. /**
  60806. * Specifies the roughness scalar value of the material.
  60807. * Can also be used to scale the roughness values of the metallic texture.
  60808. */
  60809. roughness: number;
  60810. /**
  60811. * Texture containing both the metallic value in the B channel and the
  60812. * roughness value in the G channel to keep better precision.
  60813. */
  60814. metallicRoughnessTexture: BaseTexture;
  60815. /**
  60816. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60817. *
  60818. * @param name The material name
  60819. * @param scene The scene the material will be use in.
  60820. */
  60821. constructor(name: string, scene: Scene);
  60822. /**
  60823. * Return the currrent class name of the material.
  60824. */
  60825. getClassName(): string;
  60826. /**
  60827. * Makes a duplicate of the current material.
  60828. * @param name - name to use for the new material.
  60829. */
  60830. clone(name: string): PBRMetallicRoughnessMaterial;
  60831. /**
  60832. * Serialize the material to a parsable JSON object.
  60833. */
  60834. serialize(): any;
  60835. /**
  60836. * Parses a JSON object correponding to the serialize function.
  60837. */
  60838. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60839. }
  60840. }
  60841. declare module BABYLON {
  60842. /**
  60843. * The PBR material of BJS following the specular glossiness convention.
  60844. *
  60845. * This fits to the PBR convention in the GLTF definition:
  60846. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60847. */
  60848. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60849. /**
  60850. * Specifies the diffuse color of the material.
  60851. */
  60852. diffuseColor: Color3;
  60853. /**
  60854. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60855. * channel.
  60856. */
  60857. diffuseTexture: BaseTexture;
  60858. /**
  60859. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60860. */
  60861. specularColor: Color3;
  60862. /**
  60863. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60864. */
  60865. glossiness: number;
  60866. /**
  60867. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60868. */
  60869. specularGlossinessTexture: BaseTexture;
  60870. /**
  60871. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60872. *
  60873. * @param name The material name
  60874. * @param scene The scene the material will be use in.
  60875. */
  60876. constructor(name: string, scene: Scene);
  60877. /**
  60878. * Return the currrent class name of the material.
  60879. */
  60880. getClassName(): string;
  60881. /**
  60882. * Makes a duplicate of the current material.
  60883. * @param name - name to use for the new material.
  60884. */
  60885. clone(name: string): PBRSpecularGlossinessMaterial;
  60886. /**
  60887. * Serialize the material to a parsable JSON object.
  60888. */
  60889. serialize(): any;
  60890. /**
  60891. * Parses a JSON object correponding to the serialize function.
  60892. */
  60893. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60894. }
  60895. }
  60896. declare module BABYLON {
  60897. /**
  60898. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60899. * It can help converting any input color in a desired output one. This can then be used to create effects
  60900. * from sepia, black and white to sixties or futuristic rendering...
  60901. *
  60902. * The only supported format is currently 3dl.
  60903. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60904. */
  60905. export class ColorGradingTexture extends BaseTexture {
  60906. /**
  60907. * The texture URL.
  60908. */
  60909. url: string;
  60910. /**
  60911. * Empty line regex stored for GC.
  60912. */
  60913. private static _noneEmptyLineRegex;
  60914. private _textureMatrix;
  60915. private _onLoad;
  60916. /**
  60917. * Instantiates a ColorGradingTexture from the following parameters.
  60918. *
  60919. * @param url The location of the color gradind data (currently only supporting 3dl)
  60920. * @param sceneOrEngine The scene or engine the texture will be used in
  60921. * @param onLoad defines a callback triggered when the texture has been loaded
  60922. */
  60923. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60924. /**
  60925. * Fires the onload event from the constructor if requested.
  60926. */
  60927. private _triggerOnLoad;
  60928. /**
  60929. * Returns the texture matrix used in most of the material.
  60930. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60931. */
  60932. getTextureMatrix(): Matrix;
  60933. /**
  60934. * Occurs when the file being loaded is a .3dl LUT file.
  60935. */
  60936. private load3dlTexture;
  60937. /**
  60938. * Starts the loading process of the texture.
  60939. */
  60940. private loadTexture;
  60941. /**
  60942. * Clones the color gradind texture.
  60943. */
  60944. clone(): ColorGradingTexture;
  60945. /**
  60946. * Called during delayed load for textures.
  60947. */
  60948. delayLoad(): void;
  60949. /**
  60950. * Parses a color grading texture serialized by Babylon.
  60951. * @param parsedTexture The texture information being parsedTexture
  60952. * @param scene The scene to load the texture in
  60953. * @param rootUrl The root url of the data assets to load
  60954. * @return A color gradind texture
  60955. */
  60956. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60957. /**
  60958. * Serializes the LUT texture to json format.
  60959. */
  60960. serialize(): any;
  60961. }
  60962. }
  60963. declare module BABYLON {
  60964. /**
  60965. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60966. */
  60967. export class EquiRectangularCubeTexture extends BaseTexture {
  60968. /** The six faces of the cube. */
  60969. private static _FacesMapping;
  60970. private _noMipmap;
  60971. private _onLoad;
  60972. private _onError;
  60973. /** The size of the cubemap. */
  60974. private _size;
  60975. /** The buffer of the image. */
  60976. private _buffer;
  60977. /** The width of the input image. */
  60978. private _width;
  60979. /** The height of the input image. */
  60980. private _height;
  60981. /** The URL to the image. */
  60982. url: string;
  60983. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60984. coordinatesMode: number;
  60985. /**
  60986. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60987. * @param url The location of the image
  60988. * @param scene The scene the texture will be used in
  60989. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60990. * @param noMipmap Forces to not generate the mipmap if true
  60991. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60992. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60993. * @param onLoad — defines a callback called when texture is loaded
  60994. * @param onError — defines a callback called if there is an error
  60995. */
  60996. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60997. /**
  60998. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60999. */
  61000. private loadImage;
  61001. /**
  61002. * Convert the image buffer into a cubemap and create a CubeTexture.
  61003. */
  61004. private loadTexture;
  61005. /**
  61006. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61007. * @param buffer The ArrayBuffer that should be converted.
  61008. * @returns The buffer as Float32Array.
  61009. */
  61010. private getFloat32ArrayFromArrayBuffer;
  61011. /**
  61012. * Get the current class name of the texture useful for serialization or dynamic coding.
  61013. * @returns "EquiRectangularCubeTexture"
  61014. */
  61015. getClassName(): string;
  61016. /**
  61017. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61018. * @returns A clone of the current EquiRectangularCubeTexture.
  61019. */
  61020. clone(): EquiRectangularCubeTexture;
  61021. }
  61022. }
  61023. declare module BABYLON {
  61024. /**
  61025. * Defines the options related to the creation of an HtmlElementTexture
  61026. */
  61027. export interface IHtmlElementTextureOptions {
  61028. /**
  61029. * Defines wether mip maps should be created or not.
  61030. */
  61031. generateMipMaps?: boolean;
  61032. /**
  61033. * Defines the sampling mode of the texture.
  61034. */
  61035. samplingMode?: number;
  61036. /**
  61037. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61038. */
  61039. engine: Nullable<ThinEngine>;
  61040. /**
  61041. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61042. */
  61043. scene: Nullable<Scene>;
  61044. }
  61045. /**
  61046. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61047. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61048. * is automatically managed.
  61049. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61050. * in your application.
  61051. *
  61052. * As the update is not automatic, you need to call them manually.
  61053. */
  61054. export class HtmlElementTexture extends BaseTexture {
  61055. /**
  61056. * The texture URL.
  61057. */
  61058. element: HTMLVideoElement | HTMLCanvasElement;
  61059. private static readonly DefaultOptions;
  61060. private _textureMatrix;
  61061. private _isVideo;
  61062. private _generateMipMaps;
  61063. private _samplingMode;
  61064. /**
  61065. * Instantiates a HtmlElementTexture from the following parameters.
  61066. *
  61067. * @param name Defines the name of the texture
  61068. * @param element Defines the video or canvas the texture is filled with
  61069. * @param options Defines the other none mandatory texture creation options
  61070. */
  61071. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61072. private _createInternalTexture;
  61073. /**
  61074. * Returns the texture matrix used in most of the material.
  61075. */
  61076. getTextureMatrix(): Matrix;
  61077. /**
  61078. * Updates the content of the texture.
  61079. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61080. */
  61081. update(invertY?: Nullable<boolean>): void;
  61082. }
  61083. }
  61084. declare module BABYLON {
  61085. /**
  61086. * Based on jsTGALoader - Javascript loader for TGA file
  61087. * By Vincent Thibault
  61088. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61089. */
  61090. export class TGATools {
  61091. private static _TYPE_INDEXED;
  61092. private static _TYPE_RGB;
  61093. private static _TYPE_GREY;
  61094. private static _TYPE_RLE_INDEXED;
  61095. private static _TYPE_RLE_RGB;
  61096. private static _TYPE_RLE_GREY;
  61097. private static _ORIGIN_MASK;
  61098. private static _ORIGIN_SHIFT;
  61099. private static _ORIGIN_BL;
  61100. private static _ORIGIN_BR;
  61101. private static _ORIGIN_UL;
  61102. private static _ORIGIN_UR;
  61103. /**
  61104. * Gets the header of a TGA file
  61105. * @param data defines the TGA data
  61106. * @returns the header
  61107. */
  61108. static GetTGAHeader(data: Uint8Array): any;
  61109. /**
  61110. * Uploads TGA content to a Babylon Texture
  61111. * @hidden
  61112. */
  61113. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61114. /** @hidden */
  61115. 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;
  61116. /** @hidden */
  61117. 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;
  61118. /** @hidden */
  61119. 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;
  61120. /** @hidden */
  61121. 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;
  61122. /** @hidden */
  61123. 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;
  61124. /** @hidden */
  61125. 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;
  61126. }
  61127. }
  61128. declare module BABYLON {
  61129. /**
  61130. * Implementation of the TGA Texture Loader.
  61131. * @hidden
  61132. */
  61133. export class _TGATextureLoader implements IInternalTextureLoader {
  61134. /**
  61135. * Defines wether the loader supports cascade loading the different faces.
  61136. */
  61137. readonly supportCascades: boolean;
  61138. /**
  61139. * This returns if the loader support the current file information.
  61140. * @param extension defines the file extension of the file being loaded
  61141. * @returns true if the loader can load the specified file
  61142. */
  61143. canLoad(extension: string): boolean;
  61144. /**
  61145. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61146. * @param data contains the texture data
  61147. * @param texture defines the BabylonJS internal texture
  61148. * @param createPolynomials will be true if polynomials have been requested
  61149. * @param onLoad defines the callback to trigger once the texture is ready
  61150. * @param onError defines the callback to trigger in case of error
  61151. */
  61152. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61153. /**
  61154. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61155. * @param data contains the texture data
  61156. * @param texture defines the BabylonJS internal texture
  61157. * @param callback defines the method to call once ready to upload
  61158. */
  61159. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61160. }
  61161. }
  61162. declare module BABYLON {
  61163. /**
  61164. * Info about the .basis files
  61165. */
  61166. class BasisFileInfo {
  61167. /**
  61168. * If the file has alpha
  61169. */
  61170. hasAlpha: boolean;
  61171. /**
  61172. * Info about each image of the basis file
  61173. */
  61174. images: Array<{
  61175. levels: Array<{
  61176. width: number;
  61177. height: number;
  61178. transcodedPixels: ArrayBufferView;
  61179. }>;
  61180. }>;
  61181. }
  61182. /**
  61183. * Result of transcoding a basis file
  61184. */
  61185. class TranscodeResult {
  61186. /**
  61187. * Info about the .basis file
  61188. */
  61189. fileInfo: BasisFileInfo;
  61190. /**
  61191. * Format to use when loading the file
  61192. */
  61193. format: number;
  61194. }
  61195. /**
  61196. * Configuration options for the Basis transcoder
  61197. */
  61198. export class BasisTranscodeConfiguration {
  61199. /**
  61200. * Supported compression formats used to determine the supported output format of the transcoder
  61201. */
  61202. supportedCompressionFormats?: {
  61203. /**
  61204. * etc1 compression format
  61205. */
  61206. etc1?: boolean;
  61207. /**
  61208. * s3tc compression format
  61209. */
  61210. s3tc?: boolean;
  61211. /**
  61212. * pvrtc compression format
  61213. */
  61214. pvrtc?: boolean;
  61215. /**
  61216. * etc2 compression format
  61217. */
  61218. etc2?: boolean;
  61219. };
  61220. /**
  61221. * If mipmap levels should be loaded for transcoded images (Default: true)
  61222. */
  61223. loadMipmapLevels?: boolean;
  61224. /**
  61225. * Index of a single image to load (Default: all images)
  61226. */
  61227. loadSingleImage?: number;
  61228. }
  61229. /**
  61230. * Used to load .Basis files
  61231. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61232. */
  61233. export class BasisTools {
  61234. private static _IgnoreSupportedFormats;
  61235. /**
  61236. * URL to use when loading the basis transcoder
  61237. */
  61238. static JSModuleURL: string;
  61239. /**
  61240. * URL to use when loading the wasm module for the transcoder
  61241. */
  61242. static WasmModuleURL: string;
  61243. /**
  61244. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61245. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61246. * @returns internal format corresponding to the Basis format
  61247. */
  61248. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61249. private static _WorkerPromise;
  61250. private static _Worker;
  61251. private static _actionId;
  61252. private static _CreateWorkerAsync;
  61253. /**
  61254. * Transcodes a loaded image file to compressed pixel data
  61255. * @param data image data to transcode
  61256. * @param config configuration options for the transcoding
  61257. * @returns a promise resulting in the transcoded image
  61258. */
  61259. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61260. /**
  61261. * Loads a texture from the transcode result
  61262. * @param texture texture load to
  61263. * @param transcodeResult the result of transcoding the basis file to load from
  61264. */
  61265. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61266. }
  61267. }
  61268. declare module BABYLON {
  61269. /**
  61270. * Loader for .basis file format
  61271. */
  61272. export class _BasisTextureLoader implements IInternalTextureLoader {
  61273. /**
  61274. * Defines whether the loader supports cascade loading the different faces.
  61275. */
  61276. readonly supportCascades: boolean;
  61277. /**
  61278. * This returns if the loader support the current file information.
  61279. * @param extension defines the file extension of the file being loaded
  61280. * @returns true if the loader can load the specified file
  61281. */
  61282. canLoad(extension: string): boolean;
  61283. /**
  61284. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61285. * @param data contains the texture data
  61286. * @param texture defines the BabylonJS internal texture
  61287. * @param createPolynomials will be true if polynomials have been requested
  61288. * @param onLoad defines the callback to trigger once the texture is ready
  61289. * @param onError defines the callback to trigger in case of error
  61290. */
  61291. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61292. /**
  61293. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61294. * @param data contains the texture data
  61295. * @param texture defines the BabylonJS internal texture
  61296. * @param callback defines the method to call once ready to upload
  61297. */
  61298. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61299. }
  61300. }
  61301. declare module BABYLON {
  61302. /**
  61303. * Defines the basic options interface of a TexturePacker Frame
  61304. */
  61305. export interface ITexturePackerFrame {
  61306. /**
  61307. * The frame ID
  61308. */
  61309. id: number;
  61310. /**
  61311. * The frames Scale
  61312. */
  61313. scale: Vector2;
  61314. /**
  61315. * The Frames offset
  61316. */
  61317. offset: Vector2;
  61318. }
  61319. /**
  61320. * This is a support class for frame Data on texture packer sets.
  61321. */
  61322. export class TexturePackerFrame implements ITexturePackerFrame {
  61323. /**
  61324. * The frame ID
  61325. */
  61326. id: number;
  61327. /**
  61328. * The frames Scale
  61329. */
  61330. scale: Vector2;
  61331. /**
  61332. * The Frames offset
  61333. */
  61334. offset: Vector2;
  61335. /**
  61336. * Initializes a texture package frame.
  61337. * @param id The numerical frame identifier
  61338. * @param scale Scalar Vector2 for UV frame
  61339. * @param offset Vector2 for the frame position in UV units.
  61340. * @returns TexturePackerFrame
  61341. */
  61342. constructor(id: number, scale: Vector2, offset: Vector2);
  61343. }
  61344. }
  61345. declare module BABYLON {
  61346. /**
  61347. * Defines the basic options interface of a TexturePacker
  61348. */
  61349. export interface ITexturePackerOptions {
  61350. /**
  61351. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61352. */
  61353. map?: string[];
  61354. /**
  61355. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61356. */
  61357. uvsIn?: string;
  61358. /**
  61359. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61360. */
  61361. uvsOut?: string;
  61362. /**
  61363. * number representing the layout style. Defaults to LAYOUT_STRIP
  61364. */
  61365. layout?: number;
  61366. /**
  61367. * number of columns if using custom column count layout(2). This defaults to 4.
  61368. */
  61369. colnum?: number;
  61370. /**
  61371. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61372. */
  61373. updateInputMeshes?: boolean;
  61374. /**
  61375. * boolean flag to dispose all the source textures. Defaults to true.
  61376. */
  61377. disposeSources?: boolean;
  61378. /**
  61379. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61380. */
  61381. fillBlanks?: boolean;
  61382. /**
  61383. * string value representing the context fill style color. Defaults to 'black'.
  61384. */
  61385. customFillColor?: string;
  61386. /**
  61387. * Width and Height Value of each Frame in the TexturePacker Sets
  61388. */
  61389. frameSize?: number;
  61390. /**
  61391. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61392. */
  61393. paddingRatio?: number;
  61394. /**
  61395. * Number that declares the fill method for the padding gutter.
  61396. */
  61397. paddingMode?: number;
  61398. /**
  61399. * If in SUBUV_COLOR padding mode what color to use.
  61400. */
  61401. paddingColor?: Color3 | Color4;
  61402. }
  61403. /**
  61404. * Defines the basic interface of a TexturePacker JSON File
  61405. */
  61406. export interface ITexturePackerJSON {
  61407. /**
  61408. * The frame ID
  61409. */
  61410. name: string;
  61411. /**
  61412. * The base64 channel data
  61413. */
  61414. sets: any;
  61415. /**
  61416. * The options of the Packer
  61417. */
  61418. options: ITexturePackerOptions;
  61419. /**
  61420. * The frame data of the Packer
  61421. */
  61422. frames: Array<number>;
  61423. }
  61424. /**
  61425. * This is a support class that generates a series of packed texture sets.
  61426. * @see https://doc.babylonjs.com/babylon101/materials
  61427. */
  61428. export class TexturePacker {
  61429. /** Packer Layout Constant 0 */
  61430. static readonly LAYOUT_STRIP: number;
  61431. /** Packer Layout Constant 1 */
  61432. static readonly LAYOUT_POWER2: number;
  61433. /** Packer Layout Constant 2 */
  61434. static readonly LAYOUT_COLNUM: number;
  61435. /** Packer Layout Constant 0 */
  61436. static readonly SUBUV_WRAP: number;
  61437. /** Packer Layout Constant 1 */
  61438. static readonly SUBUV_EXTEND: number;
  61439. /** Packer Layout Constant 2 */
  61440. static readonly SUBUV_COLOR: number;
  61441. /** The Name of the Texture Package */
  61442. name: string;
  61443. /** The scene scope of the TexturePacker */
  61444. scene: Scene;
  61445. /** The Meshes to target */
  61446. meshes: AbstractMesh[];
  61447. /** Arguments passed with the Constructor */
  61448. options: ITexturePackerOptions;
  61449. /** The promise that is started upon initialization */
  61450. promise: Nullable<Promise<TexturePacker | string>>;
  61451. /** The Container object for the channel sets that are generated */
  61452. sets: object;
  61453. /** The Container array for the frames that are generated */
  61454. frames: TexturePackerFrame[];
  61455. /** The expected number of textures the system is parsing. */
  61456. private _expecting;
  61457. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61458. private _paddingValue;
  61459. /**
  61460. * Initializes a texture package series from an array of meshes or a single mesh.
  61461. * @param name The name of the package
  61462. * @param meshes The target meshes to compose the package from
  61463. * @param options The arguments that texture packer should follow while building.
  61464. * @param scene The scene which the textures are scoped to.
  61465. * @returns TexturePacker
  61466. */
  61467. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61468. /**
  61469. * Starts the package process
  61470. * @param resolve The promises resolution function
  61471. * @returns TexturePacker
  61472. */
  61473. private _createFrames;
  61474. /**
  61475. * Calculates the Size of the Channel Sets
  61476. * @returns Vector2
  61477. */
  61478. private _calculateSize;
  61479. /**
  61480. * Calculates the UV data for the frames.
  61481. * @param baseSize the base frameSize
  61482. * @param padding the base frame padding
  61483. * @param dtSize size of the Dynamic Texture for that channel
  61484. * @param dtUnits is 1/dtSize
  61485. * @param update flag to update the input meshes
  61486. */
  61487. private _calculateMeshUVFrames;
  61488. /**
  61489. * Calculates the frames Offset.
  61490. * @param index of the frame
  61491. * @returns Vector2
  61492. */
  61493. private _getFrameOffset;
  61494. /**
  61495. * Updates a Mesh to the frame data
  61496. * @param mesh that is the target
  61497. * @param frameID or the frame index
  61498. */
  61499. private _updateMeshUV;
  61500. /**
  61501. * Updates a Meshes materials to use the texture packer channels
  61502. * @param m is the mesh to target
  61503. * @param force all channels on the packer to be set.
  61504. */
  61505. private _updateTextureReferences;
  61506. /**
  61507. * Public method to set a Mesh to a frame
  61508. * @param m that is the target
  61509. * @param frameID or the frame index
  61510. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61511. */
  61512. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61513. /**
  61514. * Starts the async promise to compile the texture packer.
  61515. * @returns Promise<void>
  61516. */
  61517. processAsync(): Promise<void>;
  61518. /**
  61519. * Disposes all textures associated with this packer
  61520. */
  61521. dispose(): void;
  61522. /**
  61523. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61524. * @param imageType is the image type to use.
  61525. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61526. */
  61527. download(imageType?: string, quality?: number): void;
  61528. /**
  61529. * Public method to load a texturePacker JSON file.
  61530. * @param data of the JSON file in string format.
  61531. */
  61532. updateFromJSON(data: string): void;
  61533. }
  61534. }
  61535. declare module BABYLON {
  61536. /**
  61537. * 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.
  61538. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61539. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61540. */
  61541. export class CustomProceduralTexture extends ProceduralTexture {
  61542. private _animate;
  61543. private _time;
  61544. private _config;
  61545. private _texturePath;
  61546. /**
  61547. * Instantiates a new Custom Procedural Texture.
  61548. * 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.
  61549. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61550. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61551. * @param name Define the name of the texture
  61552. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61553. * @param size Define the size of the texture to create
  61554. * @param scene Define the scene the texture belongs to
  61555. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61556. * @param generateMipMaps Define if the texture should creates mip maps or not
  61557. */
  61558. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61559. private _loadJson;
  61560. /**
  61561. * Is the texture ready to be used ? (rendered at least once)
  61562. * @returns true if ready, otherwise, false.
  61563. */
  61564. isReady(): boolean;
  61565. /**
  61566. * Render the texture to its associated render target.
  61567. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61568. */
  61569. render(useCameraPostProcess?: boolean): void;
  61570. /**
  61571. * Update the list of dependant textures samplers in the shader.
  61572. */
  61573. updateTextures(): void;
  61574. /**
  61575. * Update the uniform values of the procedural texture in the shader.
  61576. */
  61577. updateShaderUniforms(): void;
  61578. /**
  61579. * Define if the texture animates or not.
  61580. */
  61581. get animate(): boolean;
  61582. set animate(value: boolean);
  61583. }
  61584. }
  61585. declare module BABYLON {
  61586. /** @hidden */
  61587. export var noisePixelShader: {
  61588. name: string;
  61589. shader: string;
  61590. };
  61591. }
  61592. declare module BABYLON {
  61593. /**
  61594. * Class used to generate noise procedural textures
  61595. */
  61596. export class NoiseProceduralTexture extends ProceduralTexture {
  61597. private _time;
  61598. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61599. brightness: number;
  61600. /** Defines the number of octaves to process */
  61601. octaves: number;
  61602. /** Defines the level of persistence (0.8 by default) */
  61603. persistence: number;
  61604. /** Gets or sets animation speed factor (default is 1) */
  61605. animationSpeedFactor: number;
  61606. /**
  61607. * Creates a new NoiseProceduralTexture
  61608. * @param name defines the name fo the texture
  61609. * @param size defines the size of the texture (default is 256)
  61610. * @param scene defines the hosting scene
  61611. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61612. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61613. */
  61614. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61615. private _updateShaderUniforms;
  61616. protected _getDefines(): string;
  61617. /** Generate the current state of the procedural texture */
  61618. render(useCameraPostProcess?: boolean): void;
  61619. /**
  61620. * Serializes this noise procedural texture
  61621. * @returns a serialized noise procedural texture object
  61622. */
  61623. serialize(): any;
  61624. /**
  61625. * Clone the texture.
  61626. * @returns the cloned texture
  61627. */
  61628. clone(): NoiseProceduralTexture;
  61629. /**
  61630. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61631. * @param parsedTexture defines parsed texture data
  61632. * @param scene defines the current scene
  61633. * @param rootUrl defines the root URL containing noise procedural texture information
  61634. * @returns a parsed NoiseProceduralTexture
  61635. */
  61636. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61637. }
  61638. }
  61639. declare module BABYLON {
  61640. /**
  61641. * Raw cube texture where the raw buffers are passed in
  61642. */
  61643. export class RawCubeTexture extends CubeTexture {
  61644. /**
  61645. * Creates a cube texture where the raw buffers are passed in.
  61646. * @param scene defines the scene the texture is attached to
  61647. * @param data defines the array of data to use to create each face
  61648. * @param size defines the size of the textures
  61649. * @param format defines the format of the data
  61650. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61651. * @param generateMipMaps defines if the engine should generate the mip levels
  61652. * @param invertY defines if data must be stored with Y axis inverted
  61653. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61654. * @param compression defines the compression used (null by default)
  61655. */
  61656. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61657. /**
  61658. * Updates the raw cube texture.
  61659. * @param data defines the data to store
  61660. * @param format defines the data format
  61661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61662. * @param invertY defines if data must be stored with Y axis inverted
  61663. * @param compression defines the compression used (null by default)
  61664. * @param level defines which level of the texture to update
  61665. */
  61666. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61667. /**
  61668. * Updates a raw cube texture with RGBD encoded data.
  61669. * @param data defines the array of data [mipmap][face] to use to create each face
  61670. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61671. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61672. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61673. * @returns a promsie that resolves when the operation is complete
  61674. */
  61675. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61676. /**
  61677. * Clones the raw cube texture.
  61678. * @return a new cube texture
  61679. */
  61680. clone(): CubeTexture;
  61681. /** @hidden */
  61682. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61683. }
  61684. }
  61685. declare module BABYLON {
  61686. /**
  61687. * Class used to store 2D array textures containing user data
  61688. */
  61689. export class RawTexture2DArray extends Texture {
  61690. /** Gets or sets the texture format to use */
  61691. format: number;
  61692. /**
  61693. * Create a new RawTexture2DArray
  61694. * @param data defines the data of the texture
  61695. * @param width defines the width of the texture
  61696. * @param height defines the height of the texture
  61697. * @param depth defines the number of layers of the texture
  61698. * @param format defines the texture format to use
  61699. * @param scene defines the hosting scene
  61700. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61701. * @param invertY defines if texture must be stored with Y axis inverted
  61702. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61703. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61704. */
  61705. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61706. /** Gets or sets the texture format to use */
  61707. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61708. /**
  61709. * Update the texture with new data
  61710. * @param data defines the data to store in the texture
  61711. */
  61712. update(data: ArrayBufferView): void;
  61713. }
  61714. }
  61715. declare module BABYLON {
  61716. /**
  61717. * Class used to store 3D textures containing user data
  61718. */
  61719. export class RawTexture3D extends Texture {
  61720. /** Gets or sets the texture format to use */
  61721. format: number;
  61722. /**
  61723. * Create a new RawTexture3D
  61724. * @param data defines the data of the texture
  61725. * @param width defines the width of the texture
  61726. * @param height defines the height of the texture
  61727. * @param depth defines the depth of the texture
  61728. * @param format defines the texture format to use
  61729. * @param scene defines the hosting scene
  61730. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61731. * @param invertY defines if texture must be stored with Y axis inverted
  61732. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61733. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61734. */
  61735. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61736. /** Gets or sets the texture format to use */
  61737. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61738. /**
  61739. * Update the texture with new data
  61740. * @param data defines the data to store in the texture
  61741. */
  61742. update(data: ArrayBufferView): void;
  61743. }
  61744. }
  61745. declare module BABYLON {
  61746. /**
  61747. * Creates a refraction texture used by refraction channel of the standard material.
  61748. * It is like a mirror but to see through a material.
  61749. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61750. */
  61751. export class RefractionTexture extends RenderTargetTexture {
  61752. /**
  61753. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61754. * 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.
  61755. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61756. */
  61757. refractionPlane: Plane;
  61758. /**
  61759. * Define how deep under the surface we should see.
  61760. */
  61761. depth: number;
  61762. /**
  61763. * Creates a refraction texture used by refraction channel of the standard material.
  61764. * It is like a mirror but to see through a material.
  61765. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61766. * @param name Define the texture name
  61767. * @param size Define the size of the underlying texture
  61768. * @param scene Define the scene the refraction belongs to
  61769. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61770. */
  61771. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61772. /**
  61773. * Clone the refraction texture.
  61774. * @returns the cloned texture
  61775. */
  61776. clone(): RefractionTexture;
  61777. /**
  61778. * Serialize the texture to a JSON representation you could use in Parse later on
  61779. * @returns the serialized JSON representation
  61780. */
  61781. serialize(): any;
  61782. }
  61783. }
  61784. declare module BABYLON {
  61785. /**
  61786. * Block used to add support for vertex skinning (bones)
  61787. */
  61788. export class BonesBlock extends NodeMaterialBlock {
  61789. /**
  61790. * Creates a new BonesBlock
  61791. * @param name defines the block name
  61792. */
  61793. constructor(name: string);
  61794. /**
  61795. * Initialize the block and prepare the context for build
  61796. * @param state defines the state that will be used for the build
  61797. */
  61798. initialize(state: NodeMaterialBuildState): void;
  61799. /**
  61800. * Gets the current class name
  61801. * @returns the class name
  61802. */
  61803. getClassName(): string;
  61804. /**
  61805. * Gets the matrix indices input component
  61806. */
  61807. get matricesIndices(): NodeMaterialConnectionPoint;
  61808. /**
  61809. * Gets the matrix weights input component
  61810. */
  61811. get matricesWeights(): NodeMaterialConnectionPoint;
  61812. /**
  61813. * Gets the extra matrix indices input component
  61814. */
  61815. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61816. /**
  61817. * Gets the extra matrix weights input component
  61818. */
  61819. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61820. /**
  61821. * Gets the world input component
  61822. */
  61823. get world(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the output component
  61826. */
  61827. get output(): NodeMaterialConnectionPoint;
  61828. autoConfigure(material: NodeMaterial): void;
  61829. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61830. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61832. protected _buildBlock(state: NodeMaterialBuildState): this;
  61833. }
  61834. }
  61835. declare module BABYLON {
  61836. /**
  61837. * Block used to add support for instances
  61838. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61839. */
  61840. export class InstancesBlock extends NodeMaterialBlock {
  61841. /**
  61842. * Creates a new InstancesBlock
  61843. * @param name defines the block name
  61844. */
  61845. constructor(name: string);
  61846. /**
  61847. * Gets the current class name
  61848. * @returns the class name
  61849. */
  61850. getClassName(): string;
  61851. /**
  61852. * Gets the first world row input component
  61853. */
  61854. get world0(): NodeMaterialConnectionPoint;
  61855. /**
  61856. * Gets the second world row input component
  61857. */
  61858. get world1(): NodeMaterialConnectionPoint;
  61859. /**
  61860. * Gets the third world row input component
  61861. */
  61862. get world2(): NodeMaterialConnectionPoint;
  61863. /**
  61864. * Gets the forth world row input component
  61865. */
  61866. get world3(): NodeMaterialConnectionPoint;
  61867. /**
  61868. * Gets the world input component
  61869. */
  61870. get world(): NodeMaterialConnectionPoint;
  61871. /**
  61872. * Gets the output component
  61873. */
  61874. get output(): NodeMaterialConnectionPoint;
  61875. /**
  61876. * Gets the isntanceID component
  61877. */
  61878. get instanceID(): NodeMaterialConnectionPoint;
  61879. autoConfigure(material: NodeMaterial): void;
  61880. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61881. protected _buildBlock(state: NodeMaterialBuildState): this;
  61882. }
  61883. }
  61884. declare module BABYLON {
  61885. /**
  61886. * Block used to add morph targets support to vertex shader
  61887. */
  61888. export class MorphTargetsBlock extends NodeMaterialBlock {
  61889. private _repeatableContentAnchor;
  61890. /**
  61891. * Create a new MorphTargetsBlock
  61892. * @param name defines the block name
  61893. */
  61894. constructor(name: string);
  61895. /**
  61896. * Gets the current class name
  61897. * @returns the class name
  61898. */
  61899. getClassName(): string;
  61900. /**
  61901. * Gets the position input component
  61902. */
  61903. get position(): NodeMaterialConnectionPoint;
  61904. /**
  61905. * Gets the normal input component
  61906. */
  61907. get normal(): NodeMaterialConnectionPoint;
  61908. /**
  61909. * Gets the tangent input component
  61910. */
  61911. get tangent(): NodeMaterialConnectionPoint;
  61912. /**
  61913. * Gets the tangent input component
  61914. */
  61915. get uv(): NodeMaterialConnectionPoint;
  61916. /**
  61917. * Gets the position output component
  61918. */
  61919. get positionOutput(): NodeMaterialConnectionPoint;
  61920. /**
  61921. * Gets the normal output component
  61922. */
  61923. get normalOutput(): NodeMaterialConnectionPoint;
  61924. /**
  61925. * Gets the tangent output component
  61926. */
  61927. get tangentOutput(): NodeMaterialConnectionPoint;
  61928. /**
  61929. * Gets the tangent output component
  61930. */
  61931. get uvOutput(): NodeMaterialConnectionPoint;
  61932. initialize(state: NodeMaterialBuildState): void;
  61933. autoConfigure(material: NodeMaterial): void;
  61934. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61935. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61936. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61937. protected _buildBlock(state: NodeMaterialBuildState): this;
  61938. }
  61939. }
  61940. declare module BABYLON {
  61941. /**
  61942. * Block used to get data information from a light
  61943. */
  61944. export class LightInformationBlock extends NodeMaterialBlock {
  61945. private _lightDataUniformName;
  61946. private _lightColorUniformName;
  61947. private _lightTypeDefineName;
  61948. /**
  61949. * Gets or sets the light associated with this block
  61950. */
  61951. light: Nullable<Light>;
  61952. /**
  61953. * Creates a new LightInformationBlock
  61954. * @param name defines the block name
  61955. */
  61956. constructor(name: string);
  61957. /**
  61958. * Gets the current class name
  61959. * @returns the class name
  61960. */
  61961. getClassName(): string;
  61962. /**
  61963. * Gets the world position input component
  61964. */
  61965. get worldPosition(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the direction output component
  61968. */
  61969. get direction(): NodeMaterialConnectionPoint;
  61970. /**
  61971. * Gets the direction output component
  61972. */
  61973. get color(): NodeMaterialConnectionPoint;
  61974. /**
  61975. * Gets the direction output component
  61976. */
  61977. get intensity(): NodeMaterialConnectionPoint;
  61978. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61980. protected _buildBlock(state: NodeMaterialBuildState): this;
  61981. serialize(): any;
  61982. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61983. }
  61984. }
  61985. declare module BABYLON {
  61986. /**
  61987. * Block used to add image processing support to fragment shader
  61988. */
  61989. export class ImageProcessingBlock extends NodeMaterialBlock {
  61990. /**
  61991. * Create a new ImageProcessingBlock
  61992. * @param name defines the block name
  61993. */
  61994. constructor(name: string);
  61995. /**
  61996. * Gets the current class name
  61997. * @returns the class name
  61998. */
  61999. getClassName(): string;
  62000. /**
  62001. * Gets the color input component
  62002. */
  62003. get color(): NodeMaterialConnectionPoint;
  62004. /**
  62005. * Gets the output component
  62006. */
  62007. get output(): NodeMaterialConnectionPoint;
  62008. /**
  62009. * Initialize the block and prepare the context for build
  62010. * @param state defines the state that will be used for the build
  62011. */
  62012. initialize(state: NodeMaterialBuildState): void;
  62013. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62015. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62016. protected _buildBlock(state: NodeMaterialBuildState): this;
  62017. }
  62018. }
  62019. declare module BABYLON {
  62020. /**
  62021. * Block used to pertub normals based on a normal map
  62022. */
  62023. export class PerturbNormalBlock extends NodeMaterialBlock {
  62024. private _tangentSpaceParameterName;
  62025. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62026. invertX: boolean;
  62027. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62028. invertY: boolean;
  62029. /**
  62030. * Create a new PerturbNormalBlock
  62031. * @param name defines the block name
  62032. */
  62033. constructor(name: string);
  62034. /**
  62035. * Gets the current class name
  62036. * @returns the class name
  62037. */
  62038. getClassName(): string;
  62039. /**
  62040. * Gets the world position input component
  62041. */
  62042. get worldPosition(): NodeMaterialConnectionPoint;
  62043. /**
  62044. * Gets the world normal input component
  62045. */
  62046. get worldNormal(): NodeMaterialConnectionPoint;
  62047. /**
  62048. * Gets the world tangent input component
  62049. */
  62050. get worldTangent(): NodeMaterialConnectionPoint;
  62051. /**
  62052. * Gets the uv input component
  62053. */
  62054. get uv(): NodeMaterialConnectionPoint;
  62055. /**
  62056. * Gets the normal map color input component
  62057. */
  62058. get normalMapColor(): NodeMaterialConnectionPoint;
  62059. /**
  62060. * Gets the strength input component
  62061. */
  62062. get strength(): NodeMaterialConnectionPoint;
  62063. /**
  62064. * Gets the output component
  62065. */
  62066. get output(): NodeMaterialConnectionPoint;
  62067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62068. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62069. autoConfigure(material: NodeMaterial): void;
  62070. protected _buildBlock(state: NodeMaterialBuildState): this;
  62071. protected _dumpPropertiesCode(): string;
  62072. serialize(): any;
  62073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62074. }
  62075. }
  62076. declare module BABYLON {
  62077. /**
  62078. * Block used to discard a pixel if a value is smaller than a cutoff
  62079. */
  62080. export class DiscardBlock extends NodeMaterialBlock {
  62081. /**
  62082. * Create a new DiscardBlock
  62083. * @param name defines the block name
  62084. */
  62085. constructor(name: string);
  62086. /**
  62087. * Gets the current class name
  62088. * @returns the class name
  62089. */
  62090. getClassName(): string;
  62091. /**
  62092. * Gets the color input component
  62093. */
  62094. get value(): NodeMaterialConnectionPoint;
  62095. /**
  62096. * Gets the cutoff input component
  62097. */
  62098. get cutoff(): NodeMaterialConnectionPoint;
  62099. protected _buildBlock(state: NodeMaterialBuildState): this;
  62100. }
  62101. }
  62102. declare module BABYLON {
  62103. /**
  62104. * Block used to test if the fragment shader is front facing
  62105. */
  62106. export class FrontFacingBlock extends NodeMaterialBlock {
  62107. /**
  62108. * Creates a new FrontFacingBlock
  62109. * @param name defines the block name
  62110. */
  62111. constructor(name: string);
  62112. /**
  62113. * Gets the current class name
  62114. * @returns the class name
  62115. */
  62116. getClassName(): string;
  62117. /**
  62118. * Gets the output component
  62119. */
  62120. get output(): NodeMaterialConnectionPoint;
  62121. protected _buildBlock(state: NodeMaterialBuildState): this;
  62122. }
  62123. }
  62124. declare module BABYLON {
  62125. /**
  62126. * Block used to get the derivative value on x and y of a given input
  62127. */
  62128. export class DerivativeBlock extends NodeMaterialBlock {
  62129. /**
  62130. * Create a new DerivativeBlock
  62131. * @param name defines the block name
  62132. */
  62133. constructor(name: string);
  62134. /**
  62135. * Gets the current class name
  62136. * @returns the class name
  62137. */
  62138. getClassName(): string;
  62139. /**
  62140. * Gets the input component
  62141. */
  62142. get input(): NodeMaterialConnectionPoint;
  62143. /**
  62144. * Gets the derivative output on x
  62145. */
  62146. get dx(): NodeMaterialConnectionPoint;
  62147. /**
  62148. * Gets the derivative output on y
  62149. */
  62150. get dy(): NodeMaterialConnectionPoint;
  62151. protected _buildBlock(state: NodeMaterialBuildState): this;
  62152. }
  62153. }
  62154. declare module BABYLON {
  62155. /**
  62156. * Block used to make gl_FragCoord available
  62157. */
  62158. export class FragCoordBlock extends NodeMaterialBlock {
  62159. /**
  62160. * Creates a new FragCoordBlock
  62161. * @param name defines the block name
  62162. */
  62163. constructor(name: string);
  62164. /**
  62165. * Gets the current class name
  62166. * @returns the class name
  62167. */
  62168. getClassName(): string;
  62169. /**
  62170. * Gets the xy component
  62171. */
  62172. get xy(): NodeMaterialConnectionPoint;
  62173. /**
  62174. * Gets the xyz component
  62175. */
  62176. get xyz(): NodeMaterialConnectionPoint;
  62177. /**
  62178. * Gets the xyzw component
  62179. */
  62180. get xyzw(): NodeMaterialConnectionPoint;
  62181. /**
  62182. * Gets the x component
  62183. */
  62184. get x(): NodeMaterialConnectionPoint;
  62185. /**
  62186. * Gets the y component
  62187. */
  62188. get y(): NodeMaterialConnectionPoint;
  62189. /**
  62190. * Gets the z component
  62191. */
  62192. get z(): NodeMaterialConnectionPoint;
  62193. /**
  62194. * Gets the w component
  62195. */
  62196. get output(): NodeMaterialConnectionPoint;
  62197. protected writeOutputs(state: NodeMaterialBuildState): string;
  62198. protected _buildBlock(state: NodeMaterialBuildState): this;
  62199. }
  62200. }
  62201. declare module BABYLON {
  62202. /**
  62203. * Block used to get the screen sizes
  62204. */
  62205. export class ScreenSizeBlock extends NodeMaterialBlock {
  62206. private _varName;
  62207. private _scene;
  62208. /**
  62209. * Creates a new ScreenSizeBlock
  62210. * @param name defines the block name
  62211. */
  62212. constructor(name: string);
  62213. /**
  62214. * Gets the current class name
  62215. * @returns the class name
  62216. */
  62217. getClassName(): string;
  62218. /**
  62219. * Gets the xy component
  62220. */
  62221. get xy(): NodeMaterialConnectionPoint;
  62222. /**
  62223. * Gets the x component
  62224. */
  62225. get x(): NodeMaterialConnectionPoint;
  62226. /**
  62227. * Gets the y component
  62228. */
  62229. get y(): NodeMaterialConnectionPoint;
  62230. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62231. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62232. protected _buildBlock(state: NodeMaterialBuildState): this;
  62233. }
  62234. }
  62235. declare module BABYLON {
  62236. /**
  62237. * Block used to add support for scene fog
  62238. */
  62239. export class FogBlock extends NodeMaterialBlock {
  62240. private _fogDistanceName;
  62241. private _fogParameters;
  62242. /**
  62243. * Create a new FogBlock
  62244. * @param name defines the block name
  62245. */
  62246. constructor(name: string);
  62247. /**
  62248. * Gets the current class name
  62249. * @returns the class name
  62250. */
  62251. getClassName(): string;
  62252. /**
  62253. * Gets the world position input component
  62254. */
  62255. get worldPosition(): NodeMaterialConnectionPoint;
  62256. /**
  62257. * Gets the view input component
  62258. */
  62259. get view(): NodeMaterialConnectionPoint;
  62260. /**
  62261. * Gets the color input component
  62262. */
  62263. get input(): NodeMaterialConnectionPoint;
  62264. /**
  62265. * Gets the fog color input component
  62266. */
  62267. get fogColor(): NodeMaterialConnectionPoint;
  62268. /**
  62269. * Gets the output component
  62270. */
  62271. get output(): NodeMaterialConnectionPoint;
  62272. autoConfigure(material: NodeMaterial): void;
  62273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62274. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62275. protected _buildBlock(state: NodeMaterialBuildState): this;
  62276. }
  62277. }
  62278. declare module BABYLON {
  62279. /**
  62280. * Block used to add light in the fragment shader
  62281. */
  62282. export class LightBlock extends NodeMaterialBlock {
  62283. private _lightId;
  62284. /**
  62285. * Gets or sets the light associated with this block
  62286. */
  62287. light: Nullable<Light>;
  62288. /**
  62289. * Create a new LightBlock
  62290. * @param name defines the block name
  62291. */
  62292. constructor(name: string);
  62293. /**
  62294. * Gets the current class name
  62295. * @returns the class name
  62296. */
  62297. getClassName(): string;
  62298. /**
  62299. * Gets the world position input component
  62300. */
  62301. get worldPosition(): NodeMaterialConnectionPoint;
  62302. /**
  62303. * Gets the world normal input component
  62304. */
  62305. get worldNormal(): NodeMaterialConnectionPoint;
  62306. /**
  62307. * Gets the camera (or eye) position component
  62308. */
  62309. get cameraPosition(): NodeMaterialConnectionPoint;
  62310. /**
  62311. * Gets the glossiness component
  62312. */
  62313. get glossiness(): NodeMaterialConnectionPoint;
  62314. /**
  62315. * Gets the glossinness power component
  62316. */
  62317. get glossPower(): NodeMaterialConnectionPoint;
  62318. /**
  62319. * Gets the diffuse color component
  62320. */
  62321. get diffuseColor(): NodeMaterialConnectionPoint;
  62322. /**
  62323. * Gets the specular color component
  62324. */
  62325. get specularColor(): NodeMaterialConnectionPoint;
  62326. /**
  62327. * Gets the diffuse output component
  62328. */
  62329. get diffuseOutput(): NodeMaterialConnectionPoint;
  62330. /**
  62331. * Gets the specular output component
  62332. */
  62333. get specularOutput(): NodeMaterialConnectionPoint;
  62334. /**
  62335. * Gets the shadow output component
  62336. */
  62337. get shadow(): NodeMaterialConnectionPoint;
  62338. autoConfigure(material: NodeMaterial): void;
  62339. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62340. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62341. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62342. private _injectVertexCode;
  62343. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62344. serialize(): any;
  62345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62346. }
  62347. }
  62348. declare module BABYLON {
  62349. /**
  62350. * Block used to read a reflection texture from a sampler
  62351. */
  62352. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62353. /**
  62354. * Create a new ReflectionTextureBlock
  62355. * @param name defines the block name
  62356. */
  62357. constructor(name: string);
  62358. /**
  62359. * Gets the current class name
  62360. * @returns the class name
  62361. */
  62362. getClassName(): string;
  62363. /**
  62364. * Gets the world position input component
  62365. */
  62366. get position(): NodeMaterialConnectionPoint;
  62367. /**
  62368. * Gets the world position input component
  62369. */
  62370. get worldPosition(): NodeMaterialConnectionPoint;
  62371. /**
  62372. * Gets the world normal input component
  62373. */
  62374. get worldNormal(): NodeMaterialConnectionPoint;
  62375. /**
  62376. * Gets the world input component
  62377. */
  62378. get world(): NodeMaterialConnectionPoint;
  62379. /**
  62380. * Gets the camera (or eye) position component
  62381. */
  62382. get cameraPosition(): NodeMaterialConnectionPoint;
  62383. /**
  62384. * Gets the view input component
  62385. */
  62386. get view(): NodeMaterialConnectionPoint;
  62387. /**
  62388. * Gets the rgb output component
  62389. */
  62390. get rgb(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the rgba output component
  62393. */
  62394. get rgba(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the r output component
  62397. */
  62398. get r(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Gets the g output component
  62401. */
  62402. get g(): NodeMaterialConnectionPoint;
  62403. /**
  62404. * Gets the b output component
  62405. */
  62406. get b(): NodeMaterialConnectionPoint;
  62407. /**
  62408. * Gets the a output component
  62409. */
  62410. get a(): NodeMaterialConnectionPoint;
  62411. autoConfigure(material: NodeMaterial): void;
  62412. protected _buildBlock(state: NodeMaterialBuildState): this;
  62413. }
  62414. }
  62415. declare module BABYLON {
  62416. /**
  62417. * Block used to add 2 vectors
  62418. */
  62419. export class AddBlock extends NodeMaterialBlock {
  62420. /**
  62421. * Creates a new AddBlock
  62422. * @param name defines the block name
  62423. */
  62424. constructor(name: string);
  62425. /**
  62426. * Gets the current class name
  62427. * @returns the class name
  62428. */
  62429. getClassName(): string;
  62430. /**
  62431. * Gets the left operand input component
  62432. */
  62433. get left(): NodeMaterialConnectionPoint;
  62434. /**
  62435. * Gets the right operand input component
  62436. */
  62437. get right(): NodeMaterialConnectionPoint;
  62438. /**
  62439. * Gets the output component
  62440. */
  62441. get output(): NodeMaterialConnectionPoint;
  62442. protected _buildBlock(state: NodeMaterialBuildState): this;
  62443. }
  62444. }
  62445. declare module BABYLON {
  62446. /**
  62447. * Block used to scale a vector by a float
  62448. */
  62449. export class ScaleBlock extends NodeMaterialBlock {
  62450. /**
  62451. * Creates a new ScaleBlock
  62452. * @param name defines the block name
  62453. */
  62454. constructor(name: string);
  62455. /**
  62456. * Gets the current class name
  62457. * @returns the class name
  62458. */
  62459. getClassName(): string;
  62460. /**
  62461. * Gets the input component
  62462. */
  62463. get input(): NodeMaterialConnectionPoint;
  62464. /**
  62465. * Gets the factor input component
  62466. */
  62467. get factor(): NodeMaterialConnectionPoint;
  62468. /**
  62469. * Gets the output component
  62470. */
  62471. get output(): NodeMaterialConnectionPoint;
  62472. protected _buildBlock(state: NodeMaterialBuildState): this;
  62473. }
  62474. }
  62475. declare module BABYLON {
  62476. /**
  62477. * Block used to clamp a float
  62478. */
  62479. export class ClampBlock extends NodeMaterialBlock {
  62480. /** Gets or sets the minimum range */
  62481. minimum: number;
  62482. /** Gets or sets the maximum range */
  62483. maximum: number;
  62484. /**
  62485. * Creates a new ClampBlock
  62486. * @param name defines the block name
  62487. */
  62488. constructor(name: string);
  62489. /**
  62490. * Gets the current class name
  62491. * @returns the class name
  62492. */
  62493. getClassName(): string;
  62494. /**
  62495. * Gets the value input component
  62496. */
  62497. get value(): NodeMaterialConnectionPoint;
  62498. /**
  62499. * Gets the output component
  62500. */
  62501. get output(): NodeMaterialConnectionPoint;
  62502. protected _buildBlock(state: NodeMaterialBuildState): this;
  62503. protected _dumpPropertiesCode(): string;
  62504. serialize(): any;
  62505. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62506. }
  62507. }
  62508. declare module BABYLON {
  62509. /**
  62510. * Block used to apply a cross product between 2 vectors
  62511. */
  62512. export class CrossBlock extends NodeMaterialBlock {
  62513. /**
  62514. * Creates a new CrossBlock
  62515. * @param name defines the block name
  62516. */
  62517. constructor(name: string);
  62518. /**
  62519. * Gets the current class name
  62520. * @returns the class name
  62521. */
  62522. getClassName(): string;
  62523. /**
  62524. * Gets the left operand input component
  62525. */
  62526. get left(): NodeMaterialConnectionPoint;
  62527. /**
  62528. * Gets the right operand input component
  62529. */
  62530. get right(): NodeMaterialConnectionPoint;
  62531. /**
  62532. * Gets the output component
  62533. */
  62534. get output(): NodeMaterialConnectionPoint;
  62535. protected _buildBlock(state: NodeMaterialBuildState): this;
  62536. }
  62537. }
  62538. declare module BABYLON {
  62539. /**
  62540. * Block used to apply a dot product between 2 vectors
  62541. */
  62542. export class DotBlock extends NodeMaterialBlock {
  62543. /**
  62544. * Creates a new DotBlock
  62545. * @param name defines the block name
  62546. */
  62547. constructor(name: string);
  62548. /**
  62549. * Gets the current class name
  62550. * @returns the class name
  62551. */
  62552. getClassName(): string;
  62553. /**
  62554. * Gets the left operand input component
  62555. */
  62556. get left(): NodeMaterialConnectionPoint;
  62557. /**
  62558. * Gets the right operand input component
  62559. */
  62560. get right(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the output component
  62563. */
  62564. get output(): NodeMaterialConnectionPoint;
  62565. protected _buildBlock(state: NodeMaterialBuildState): this;
  62566. }
  62567. }
  62568. declare module BABYLON {
  62569. /**
  62570. * Block used to normalize a vector
  62571. */
  62572. export class NormalizeBlock extends NodeMaterialBlock {
  62573. /**
  62574. * Creates a new NormalizeBlock
  62575. * @param name defines the block name
  62576. */
  62577. constructor(name: string);
  62578. /**
  62579. * Gets the current class name
  62580. * @returns the class name
  62581. */
  62582. getClassName(): string;
  62583. /**
  62584. * Gets the input component
  62585. */
  62586. get input(): NodeMaterialConnectionPoint;
  62587. /**
  62588. * Gets the output component
  62589. */
  62590. get output(): NodeMaterialConnectionPoint;
  62591. protected _buildBlock(state: NodeMaterialBuildState): this;
  62592. }
  62593. }
  62594. declare module BABYLON {
  62595. /**
  62596. * Operations supported by the Trigonometry block
  62597. */
  62598. export enum TrigonometryBlockOperations {
  62599. /** Cos */
  62600. Cos = 0,
  62601. /** Sin */
  62602. Sin = 1,
  62603. /** Abs */
  62604. Abs = 2,
  62605. /** Exp */
  62606. Exp = 3,
  62607. /** Exp2 */
  62608. Exp2 = 4,
  62609. /** Round */
  62610. Round = 5,
  62611. /** Floor */
  62612. Floor = 6,
  62613. /** Ceiling */
  62614. Ceiling = 7,
  62615. /** Square root */
  62616. Sqrt = 8,
  62617. /** Log */
  62618. Log = 9,
  62619. /** Tangent */
  62620. Tan = 10,
  62621. /** Arc tangent */
  62622. ArcTan = 11,
  62623. /** Arc cosinus */
  62624. ArcCos = 12,
  62625. /** Arc sinus */
  62626. ArcSin = 13,
  62627. /** Fraction */
  62628. Fract = 14,
  62629. /** Sign */
  62630. Sign = 15,
  62631. /** To radians (from degrees) */
  62632. Radians = 16,
  62633. /** To degrees (from radians) */
  62634. Degrees = 17
  62635. }
  62636. /**
  62637. * Block used to apply trigonometry operation to floats
  62638. */
  62639. export class TrigonometryBlock extends NodeMaterialBlock {
  62640. /**
  62641. * Gets or sets the operation applied by the block
  62642. */
  62643. operation: TrigonometryBlockOperations;
  62644. /**
  62645. * Creates a new TrigonometryBlock
  62646. * @param name defines the block name
  62647. */
  62648. constructor(name: string);
  62649. /**
  62650. * Gets the current class name
  62651. * @returns the class name
  62652. */
  62653. getClassName(): string;
  62654. /**
  62655. * Gets the input component
  62656. */
  62657. get input(): NodeMaterialConnectionPoint;
  62658. /**
  62659. * Gets the output component
  62660. */
  62661. get output(): NodeMaterialConnectionPoint;
  62662. protected _buildBlock(state: NodeMaterialBuildState): this;
  62663. serialize(): any;
  62664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62665. protected _dumpPropertiesCode(): string;
  62666. }
  62667. }
  62668. declare module BABYLON {
  62669. /**
  62670. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62671. */
  62672. export class ColorMergerBlock extends NodeMaterialBlock {
  62673. /**
  62674. * Create a new ColorMergerBlock
  62675. * @param name defines the block name
  62676. */
  62677. constructor(name: string);
  62678. /**
  62679. * Gets the current class name
  62680. * @returns the class name
  62681. */
  62682. getClassName(): string;
  62683. /**
  62684. * Gets the rgb component (input)
  62685. */
  62686. get rgbIn(): NodeMaterialConnectionPoint;
  62687. /**
  62688. * Gets the r component (input)
  62689. */
  62690. get r(): NodeMaterialConnectionPoint;
  62691. /**
  62692. * Gets the g component (input)
  62693. */
  62694. get g(): NodeMaterialConnectionPoint;
  62695. /**
  62696. * Gets the b component (input)
  62697. */
  62698. get b(): NodeMaterialConnectionPoint;
  62699. /**
  62700. * Gets the a component (input)
  62701. */
  62702. get a(): NodeMaterialConnectionPoint;
  62703. /**
  62704. * Gets the rgba component (output)
  62705. */
  62706. get rgba(): NodeMaterialConnectionPoint;
  62707. /**
  62708. * Gets the rgb component (output)
  62709. */
  62710. get rgbOut(): NodeMaterialConnectionPoint;
  62711. /**
  62712. * Gets the rgb component (output)
  62713. * @deprecated Please use rgbOut instead.
  62714. */
  62715. get rgb(): NodeMaterialConnectionPoint;
  62716. protected _buildBlock(state: NodeMaterialBuildState): this;
  62717. }
  62718. }
  62719. declare module BABYLON {
  62720. /**
  62721. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62722. */
  62723. export class VectorSplitterBlock extends NodeMaterialBlock {
  62724. /**
  62725. * Create a new VectorSplitterBlock
  62726. * @param name defines the block name
  62727. */
  62728. constructor(name: string);
  62729. /**
  62730. * Gets the current class name
  62731. * @returns the class name
  62732. */
  62733. getClassName(): string;
  62734. /**
  62735. * Gets the xyzw component (input)
  62736. */
  62737. get xyzw(): NodeMaterialConnectionPoint;
  62738. /**
  62739. * Gets the xyz component (input)
  62740. */
  62741. get xyzIn(): NodeMaterialConnectionPoint;
  62742. /**
  62743. * Gets the xy component (input)
  62744. */
  62745. get xyIn(): NodeMaterialConnectionPoint;
  62746. /**
  62747. * Gets the xyz component (output)
  62748. */
  62749. get xyzOut(): NodeMaterialConnectionPoint;
  62750. /**
  62751. * Gets the xy component (output)
  62752. */
  62753. get xyOut(): NodeMaterialConnectionPoint;
  62754. /**
  62755. * Gets the x component (output)
  62756. */
  62757. get x(): NodeMaterialConnectionPoint;
  62758. /**
  62759. * Gets the y component (output)
  62760. */
  62761. get y(): NodeMaterialConnectionPoint;
  62762. /**
  62763. * Gets the z component (output)
  62764. */
  62765. get z(): NodeMaterialConnectionPoint;
  62766. /**
  62767. * Gets the w component (output)
  62768. */
  62769. get w(): NodeMaterialConnectionPoint;
  62770. protected _inputRename(name: string): string;
  62771. protected _outputRename(name: string): string;
  62772. protected _buildBlock(state: NodeMaterialBuildState): this;
  62773. }
  62774. }
  62775. declare module BABYLON {
  62776. /**
  62777. * Block used to lerp between 2 values
  62778. */
  62779. export class LerpBlock extends NodeMaterialBlock {
  62780. /**
  62781. * Creates a new LerpBlock
  62782. * @param name defines the block name
  62783. */
  62784. constructor(name: string);
  62785. /**
  62786. * Gets the current class name
  62787. * @returns the class name
  62788. */
  62789. getClassName(): string;
  62790. /**
  62791. * Gets the left operand input component
  62792. */
  62793. get left(): NodeMaterialConnectionPoint;
  62794. /**
  62795. * Gets the right operand input component
  62796. */
  62797. get right(): NodeMaterialConnectionPoint;
  62798. /**
  62799. * Gets the gradient operand input component
  62800. */
  62801. get gradient(): NodeMaterialConnectionPoint;
  62802. /**
  62803. * Gets the output component
  62804. */
  62805. get output(): NodeMaterialConnectionPoint;
  62806. protected _buildBlock(state: NodeMaterialBuildState): this;
  62807. }
  62808. }
  62809. declare module BABYLON {
  62810. /**
  62811. * Block used to divide 2 vectors
  62812. */
  62813. export class DivideBlock extends NodeMaterialBlock {
  62814. /**
  62815. * Creates a new DivideBlock
  62816. * @param name defines the block name
  62817. */
  62818. constructor(name: string);
  62819. /**
  62820. * Gets the current class name
  62821. * @returns the class name
  62822. */
  62823. getClassName(): string;
  62824. /**
  62825. * Gets the left operand input component
  62826. */
  62827. get left(): NodeMaterialConnectionPoint;
  62828. /**
  62829. * Gets the right operand input component
  62830. */
  62831. get right(): NodeMaterialConnectionPoint;
  62832. /**
  62833. * Gets the output component
  62834. */
  62835. get output(): NodeMaterialConnectionPoint;
  62836. protected _buildBlock(state: NodeMaterialBuildState): this;
  62837. }
  62838. }
  62839. declare module BABYLON {
  62840. /**
  62841. * Block used to subtract 2 vectors
  62842. */
  62843. export class SubtractBlock extends NodeMaterialBlock {
  62844. /**
  62845. * Creates a new SubtractBlock
  62846. * @param name defines the block name
  62847. */
  62848. constructor(name: string);
  62849. /**
  62850. * Gets the current class name
  62851. * @returns the class name
  62852. */
  62853. getClassName(): string;
  62854. /**
  62855. * Gets the left operand input component
  62856. */
  62857. get left(): NodeMaterialConnectionPoint;
  62858. /**
  62859. * Gets the right operand input component
  62860. */
  62861. get right(): NodeMaterialConnectionPoint;
  62862. /**
  62863. * Gets the output component
  62864. */
  62865. get output(): NodeMaterialConnectionPoint;
  62866. protected _buildBlock(state: NodeMaterialBuildState): this;
  62867. }
  62868. }
  62869. declare module BABYLON {
  62870. /**
  62871. * Block used to step a value
  62872. */
  62873. export class StepBlock extends NodeMaterialBlock {
  62874. /**
  62875. * Creates a new StepBlock
  62876. * @param name defines the block name
  62877. */
  62878. constructor(name: string);
  62879. /**
  62880. * Gets the current class name
  62881. * @returns the class name
  62882. */
  62883. getClassName(): string;
  62884. /**
  62885. * Gets the value operand input component
  62886. */
  62887. get value(): NodeMaterialConnectionPoint;
  62888. /**
  62889. * Gets the edge operand input component
  62890. */
  62891. get edge(): NodeMaterialConnectionPoint;
  62892. /**
  62893. * Gets the output component
  62894. */
  62895. get output(): NodeMaterialConnectionPoint;
  62896. protected _buildBlock(state: NodeMaterialBuildState): this;
  62897. }
  62898. }
  62899. declare module BABYLON {
  62900. /**
  62901. * Block used to get the opposite (1 - x) of a value
  62902. */
  62903. export class OneMinusBlock extends NodeMaterialBlock {
  62904. /**
  62905. * Creates a new OneMinusBlock
  62906. * @param name defines the block name
  62907. */
  62908. constructor(name: string);
  62909. /**
  62910. * Gets the current class name
  62911. * @returns the class name
  62912. */
  62913. getClassName(): string;
  62914. /**
  62915. * Gets the input component
  62916. */
  62917. get input(): NodeMaterialConnectionPoint;
  62918. /**
  62919. * Gets the output component
  62920. */
  62921. get output(): NodeMaterialConnectionPoint;
  62922. protected _buildBlock(state: NodeMaterialBuildState): this;
  62923. }
  62924. }
  62925. declare module BABYLON {
  62926. /**
  62927. * Block used to get the view direction
  62928. */
  62929. export class ViewDirectionBlock extends NodeMaterialBlock {
  62930. /**
  62931. * Creates a new ViewDirectionBlock
  62932. * @param name defines the block name
  62933. */
  62934. constructor(name: string);
  62935. /**
  62936. * Gets the current class name
  62937. * @returns the class name
  62938. */
  62939. getClassName(): string;
  62940. /**
  62941. * Gets the world position component
  62942. */
  62943. get worldPosition(): NodeMaterialConnectionPoint;
  62944. /**
  62945. * Gets the camera position component
  62946. */
  62947. get cameraPosition(): NodeMaterialConnectionPoint;
  62948. /**
  62949. * Gets the output component
  62950. */
  62951. get output(): NodeMaterialConnectionPoint;
  62952. autoConfigure(material: NodeMaterial): void;
  62953. protected _buildBlock(state: NodeMaterialBuildState): this;
  62954. }
  62955. }
  62956. declare module BABYLON {
  62957. /**
  62958. * Block used to compute fresnel value
  62959. */
  62960. export class FresnelBlock extends NodeMaterialBlock {
  62961. /**
  62962. * Create a new FresnelBlock
  62963. * @param name defines the block name
  62964. */
  62965. constructor(name: string);
  62966. /**
  62967. * Gets the current class name
  62968. * @returns the class name
  62969. */
  62970. getClassName(): string;
  62971. /**
  62972. * Gets the world normal input component
  62973. */
  62974. get worldNormal(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the view direction input component
  62977. */
  62978. get viewDirection(): NodeMaterialConnectionPoint;
  62979. /**
  62980. * Gets the bias input component
  62981. */
  62982. get bias(): NodeMaterialConnectionPoint;
  62983. /**
  62984. * Gets the camera (or eye) position component
  62985. */
  62986. get power(): NodeMaterialConnectionPoint;
  62987. /**
  62988. * Gets the fresnel output component
  62989. */
  62990. get fresnel(): NodeMaterialConnectionPoint;
  62991. autoConfigure(material: NodeMaterial): void;
  62992. protected _buildBlock(state: NodeMaterialBuildState): this;
  62993. }
  62994. }
  62995. declare module BABYLON {
  62996. /**
  62997. * Block used to get the max of 2 values
  62998. */
  62999. export class MaxBlock extends NodeMaterialBlock {
  63000. /**
  63001. * Creates a new MaxBlock
  63002. * @param name defines the block name
  63003. */
  63004. constructor(name: string);
  63005. /**
  63006. * Gets the current class name
  63007. * @returns the class name
  63008. */
  63009. getClassName(): string;
  63010. /**
  63011. * Gets the left operand input component
  63012. */
  63013. get left(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the right operand input component
  63016. */
  63017. get right(): NodeMaterialConnectionPoint;
  63018. /**
  63019. * Gets the output component
  63020. */
  63021. get output(): NodeMaterialConnectionPoint;
  63022. protected _buildBlock(state: NodeMaterialBuildState): this;
  63023. }
  63024. }
  63025. declare module BABYLON {
  63026. /**
  63027. * Block used to get the min of 2 values
  63028. */
  63029. export class MinBlock extends NodeMaterialBlock {
  63030. /**
  63031. * Creates a new MinBlock
  63032. * @param name defines the block name
  63033. */
  63034. constructor(name: string);
  63035. /**
  63036. * Gets the current class name
  63037. * @returns the class name
  63038. */
  63039. getClassName(): string;
  63040. /**
  63041. * Gets the left operand input component
  63042. */
  63043. get left(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the right operand input component
  63046. */
  63047. get right(): NodeMaterialConnectionPoint;
  63048. /**
  63049. * Gets the output component
  63050. */
  63051. get output(): NodeMaterialConnectionPoint;
  63052. protected _buildBlock(state: NodeMaterialBuildState): this;
  63053. }
  63054. }
  63055. declare module BABYLON {
  63056. /**
  63057. * Block used to get the distance between 2 values
  63058. */
  63059. export class DistanceBlock extends NodeMaterialBlock {
  63060. /**
  63061. * Creates a new DistanceBlock
  63062. * @param name defines the block name
  63063. */
  63064. constructor(name: string);
  63065. /**
  63066. * Gets the current class name
  63067. * @returns the class name
  63068. */
  63069. getClassName(): string;
  63070. /**
  63071. * Gets the left operand input component
  63072. */
  63073. get left(): NodeMaterialConnectionPoint;
  63074. /**
  63075. * Gets the right operand input component
  63076. */
  63077. get right(): NodeMaterialConnectionPoint;
  63078. /**
  63079. * Gets the output component
  63080. */
  63081. get output(): NodeMaterialConnectionPoint;
  63082. protected _buildBlock(state: NodeMaterialBuildState): this;
  63083. }
  63084. }
  63085. declare module BABYLON {
  63086. /**
  63087. * Block used to get the length of a vector
  63088. */
  63089. export class LengthBlock extends NodeMaterialBlock {
  63090. /**
  63091. * Creates a new LengthBlock
  63092. * @param name defines the block name
  63093. */
  63094. constructor(name: string);
  63095. /**
  63096. * Gets the current class name
  63097. * @returns the class name
  63098. */
  63099. getClassName(): string;
  63100. /**
  63101. * Gets the value input component
  63102. */
  63103. get value(): NodeMaterialConnectionPoint;
  63104. /**
  63105. * Gets the output component
  63106. */
  63107. get output(): NodeMaterialConnectionPoint;
  63108. protected _buildBlock(state: NodeMaterialBuildState): this;
  63109. }
  63110. }
  63111. declare module BABYLON {
  63112. /**
  63113. * Block used to get negative version of a value (i.e. x * -1)
  63114. */
  63115. export class NegateBlock extends NodeMaterialBlock {
  63116. /**
  63117. * Creates a new NegateBlock
  63118. * @param name defines the block name
  63119. */
  63120. constructor(name: string);
  63121. /**
  63122. * Gets the current class name
  63123. * @returns the class name
  63124. */
  63125. getClassName(): string;
  63126. /**
  63127. * Gets the value input component
  63128. */
  63129. get value(): NodeMaterialConnectionPoint;
  63130. /**
  63131. * Gets the output component
  63132. */
  63133. get output(): NodeMaterialConnectionPoint;
  63134. protected _buildBlock(state: NodeMaterialBuildState): this;
  63135. }
  63136. }
  63137. declare module BABYLON {
  63138. /**
  63139. * Block used to get the value of the first parameter raised to the power of the second
  63140. */
  63141. export class PowBlock extends NodeMaterialBlock {
  63142. /**
  63143. * Creates a new PowBlock
  63144. * @param name defines the block name
  63145. */
  63146. constructor(name: string);
  63147. /**
  63148. * Gets the current class name
  63149. * @returns the class name
  63150. */
  63151. getClassName(): string;
  63152. /**
  63153. * Gets the value operand input component
  63154. */
  63155. get value(): NodeMaterialConnectionPoint;
  63156. /**
  63157. * Gets the power operand input component
  63158. */
  63159. get power(): NodeMaterialConnectionPoint;
  63160. /**
  63161. * Gets the output component
  63162. */
  63163. get output(): NodeMaterialConnectionPoint;
  63164. protected _buildBlock(state: NodeMaterialBuildState): this;
  63165. }
  63166. }
  63167. declare module BABYLON {
  63168. /**
  63169. * Block used to get a random number
  63170. */
  63171. export class RandomNumberBlock extends NodeMaterialBlock {
  63172. /**
  63173. * Creates a new RandomNumberBlock
  63174. * @param name defines the block name
  63175. */
  63176. constructor(name: string);
  63177. /**
  63178. * Gets the current class name
  63179. * @returns the class name
  63180. */
  63181. getClassName(): string;
  63182. /**
  63183. * Gets the seed input component
  63184. */
  63185. get seed(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the output component
  63188. */
  63189. get output(): NodeMaterialConnectionPoint;
  63190. protected _buildBlock(state: NodeMaterialBuildState): this;
  63191. }
  63192. }
  63193. declare module BABYLON {
  63194. /**
  63195. * Block used to compute arc tangent of 2 values
  63196. */
  63197. export class ArcTan2Block extends NodeMaterialBlock {
  63198. /**
  63199. * Creates a new ArcTan2Block
  63200. * @param name defines the block name
  63201. */
  63202. constructor(name: string);
  63203. /**
  63204. * Gets the current class name
  63205. * @returns the class name
  63206. */
  63207. getClassName(): string;
  63208. /**
  63209. * Gets the x operand input component
  63210. */
  63211. get x(): NodeMaterialConnectionPoint;
  63212. /**
  63213. * Gets the y operand input component
  63214. */
  63215. get y(): NodeMaterialConnectionPoint;
  63216. /**
  63217. * Gets the output component
  63218. */
  63219. get output(): NodeMaterialConnectionPoint;
  63220. protected _buildBlock(state: NodeMaterialBuildState): this;
  63221. }
  63222. }
  63223. declare module BABYLON {
  63224. /**
  63225. * Block used to smooth step a value
  63226. */
  63227. export class SmoothStepBlock extends NodeMaterialBlock {
  63228. /**
  63229. * Creates a new SmoothStepBlock
  63230. * @param name defines the block name
  63231. */
  63232. constructor(name: string);
  63233. /**
  63234. * Gets the current class name
  63235. * @returns the class name
  63236. */
  63237. getClassName(): string;
  63238. /**
  63239. * Gets the value operand input component
  63240. */
  63241. get value(): NodeMaterialConnectionPoint;
  63242. /**
  63243. * Gets the first edge operand input component
  63244. */
  63245. get edge0(): NodeMaterialConnectionPoint;
  63246. /**
  63247. * Gets the second edge operand input component
  63248. */
  63249. get edge1(): NodeMaterialConnectionPoint;
  63250. /**
  63251. * Gets the output component
  63252. */
  63253. get output(): NodeMaterialConnectionPoint;
  63254. protected _buildBlock(state: NodeMaterialBuildState): this;
  63255. }
  63256. }
  63257. declare module BABYLON {
  63258. /**
  63259. * Block used to get the reciprocal (1 / x) of a value
  63260. */
  63261. export class ReciprocalBlock extends NodeMaterialBlock {
  63262. /**
  63263. * Creates a new ReciprocalBlock
  63264. * @param name defines the block name
  63265. */
  63266. constructor(name: string);
  63267. /**
  63268. * Gets the current class name
  63269. * @returns the class name
  63270. */
  63271. getClassName(): string;
  63272. /**
  63273. * Gets the input component
  63274. */
  63275. get input(): NodeMaterialConnectionPoint;
  63276. /**
  63277. * Gets the output component
  63278. */
  63279. get output(): NodeMaterialConnectionPoint;
  63280. protected _buildBlock(state: NodeMaterialBuildState): this;
  63281. }
  63282. }
  63283. declare module BABYLON {
  63284. /**
  63285. * Block used to replace a color by another one
  63286. */
  63287. export class ReplaceColorBlock extends NodeMaterialBlock {
  63288. /**
  63289. * Creates a new ReplaceColorBlock
  63290. * @param name defines the block name
  63291. */
  63292. constructor(name: string);
  63293. /**
  63294. * Gets the current class name
  63295. * @returns the class name
  63296. */
  63297. getClassName(): string;
  63298. /**
  63299. * Gets the value input component
  63300. */
  63301. get value(): NodeMaterialConnectionPoint;
  63302. /**
  63303. * Gets the reference input component
  63304. */
  63305. get reference(): NodeMaterialConnectionPoint;
  63306. /**
  63307. * Gets the distance input component
  63308. */
  63309. get distance(): NodeMaterialConnectionPoint;
  63310. /**
  63311. * Gets the replacement input component
  63312. */
  63313. get replacement(): NodeMaterialConnectionPoint;
  63314. /**
  63315. * Gets the output component
  63316. */
  63317. get output(): NodeMaterialConnectionPoint;
  63318. protected _buildBlock(state: NodeMaterialBuildState): this;
  63319. }
  63320. }
  63321. declare module BABYLON {
  63322. /**
  63323. * Block used to posterize a value
  63324. * @see https://en.wikipedia.org/wiki/Posterization
  63325. */
  63326. export class PosterizeBlock extends NodeMaterialBlock {
  63327. /**
  63328. * Creates a new PosterizeBlock
  63329. * @param name defines the block name
  63330. */
  63331. constructor(name: string);
  63332. /**
  63333. * Gets the current class name
  63334. * @returns the class name
  63335. */
  63336. getClassName(): string;
  63337. /**
  63338. * Gets the value input component
  63339. */
  63340. get value(): NodeMaterialConnectionPoint;
  63341. /**
  63342. * Gets the steps input component
  63343. */
  63344. get steps(): NodeMaterialConnectionPoint;
  63345. /**
  63346. * Gets the output component
  63347. */
  63348. get output(): NodeMaterialConnectionPoint;
  63349. protected _buildBlock(state: NodeMaterialBuildState): this;
  63350. }
  63351. }
  63352. declare module BABYLON {
  63353. /**
  63354. * Operations supported by the Wave block
  63355. */
  63356. export enum WaveBlockKind {
  63357. /** SawTooth */
  63358. SawTooth = 0,
  63359. /** Square */
  63360. Square = 1,
  63361. /** Triangle */
  63362. Triangle = 2
  63363. }
  63364. /**
  63365. * Block used to apply wave operation to floats
  63366. */
  63367. export class WaveBlock extends NodeMaterialBlock {
  63368. /**
  63369. * Gets or sets the kibnd of wave to be applied by the block
  63370. */
  63371. kind: WaveBlockKind;
  63372. /**
  63373. * Creates a new WaveBlock
  63374. * @param name defines the block name
  63375. */
  63376. constructor(name: string);
  63377. /**
  63378. * Gets the current class name
  63379. * @returns the class name
  63380. */
  63381. getClassName(): string;
  63382. /**
  63383. * Gets the input component
  63384. */
  63385. get input(): NodeMaterialConnectionPoint;
  63386. /**
  63387. * Gets the output component
  63388. */
  63389. get output(): NodeMaterialConnectionPoint;
  63390. protected _buildBlock(state: NodeMaterialBuildState): this;
  63391. serialize(): any;
  63392. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63393. }
  63394. }
  63395. declare module BABYLON {
  63396. /**
  63397. * Class used to store a color step for the GradientBlock
  63398. */
  63399. export class GradientBlockColorStep {
  63400. /**
  63401. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63402. */
  63403. step: number;
  63404. /**
  63405. * Gets or sets the color associated with this step
  63406. */
  63407. color: Color3;
  63408. /**
  63409. * Creates a new GradientBlockColorStep
  63410. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63411. * @param color defines the color associated with this step
  63412. */
  63413. constructor(
  63414. /**
  63415. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63416. */
  63417. step: number,
  63418. /**
  63419. * Gets or sets the color associated with this step
  63420. */
  63421. color: Color3);
  63422. }
  63423. /**
  63424. * Block used to return a color from a gradient based on an input value between 0 and 1
  63425. */
  63426. export class GradientBlock extends NodeMaterialBlock {
  63427. /**
  63428. * Gets or sets the list of color steps
  63429. */
  63430. colorSteps: GradientBlockColorStep[];
  63431. /**
  63432. * Creates a new GradientBlock
  63433. * @param name defines the block name
  63434. */
  63435. constructor(name: string);
  63436. /**
  63437. * Gets the current class name
  63438. * @returns the class name
  63439. */
  63440. getClassName(): string;
  63441. /**
  63442. * Gets the gradient input component
  63443. */
  63444. get gradient(): NodeMaterialConnectionPoint;
  63445. /**
  63446. * Gets the output component
  63447. */
  63448. get output(): NodeMaterialConnectionPoint;
  63449. private _writeColorConstant;
  63450. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63451. serialize(): any;
  63452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63453. protected _dumpPropertiesCode(): string;
  63454. }
  63455. }
  63456. declare module BABYLON {
  63457. /**
  63458. * Block used to normalize lerp between 2 values
  63459. */
  63460. export class NLerpBlock extends NodeMaterialBlock {
  63461. /**
  63462. * Creates a new NLerpBlock
  63463. * @param name defines the block name
  63464. */
  63465. constructor(name: string);
  63466. /**
  63467. * Gets the current class name
  63468. * @returns the class name
  63469. */
  63470. getClassName(): string;
  63471. /**
  63472. * Gets the left operand input component
  63473. */
  63474. get left(): NodeMaterialConnectionPoint;
  63475. /**
  63476. * Gets the right operand input component
  63477. */
  63478. get right(): NodeMaterialConnectionPoint;
  63479. /**
  63480. * Gets the gradient operand input component
  63481. */
  63482. get gradient(): NodeMaterialConnectionPoint;
  63483. /**
  63484. * Gets the output component
  63485. */
  63486. get output(): NodeMaterialConnectionPoint;
  63487. protected _buildBlock(state: NodeMaterialBuildState): this;
  63488. }
  63489. }
  63490. declare module BABYLON {
  63491. /**
  63492. * block used to Generate a Worley Noise 3D Noise Pattern
  63493. */
  63494. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63495. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63496. manhattanDistance: boolean;
  63497. /**
  63498. * Creates a new WorleyNoise3DBlock
  63499. * @param name defines the block name
  63500. */
  63501. constructor(name: string);
  63502. /**
  63503. * Gets the current class name
  63504. * @returns the class name
  63505. */
  63506. getClassName(): string;
  63507. /**
  63508. * Gets the seed input component
  63509. */
  63510. get seed(): NodeMaterialConnectionPoint;
  63511. /**
  63512. * Gets the jitter input component
  63513. */
  63514. get jitter(): NodeMaterialConnectionPoint;
  63515. /**
  63516. * Gets the output component
  63517. */
  63518. get output(): NodeMaterialConnectionPoint;
  63519. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63520. /**
  63521. * Exposes the properties to the UI?
  63522. */
  63523. protected _dumpPropertiesCode(): string;
  63524. /**
  63525. * Exposes the properties to the Seralize?
  63526. */
  63527. serialize(): any;
  63528. /**
  63529. * Exposes the properties to the deseralize?
  63530. */
  63531. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63532. }
  63533. }
  63534. declare module BABYLON {
  63535. /**
  63536. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63537. */
  63538. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63539. /**
  63540. * Creates a new SimplexPerlin3DBlock
  63541. * @param name defines the block name
  63542. */
  63543. constructor(name: string);
  63544. /**
  63545. * Gets the current class name
  63546. * @returns the class name
  63547. */
  63548. getClassName(): string;
  63549. /**
  63550. * Gets the seed operand input component
  63551. */
  63552. get seed(): NodeMaterialConnectionPoint;
  63553. /**
  63554. * Gets the output component
  63555. */
  63556. get output(): NodeMaterialConnectionPoint;
  63557. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63558. }
  63559. }
  63560. declare module BABYLON {
  63561. /**
  63562. * Block used to blend normals
  63563. */
  63564. export class NormalBlendBlock extends NodeMaterialBlock {
  63565. /**
  63566. * Creates a new NormalBlendBlock
  63567. * @param name defines the block name
  63568. */
  63569. constructor(name: string);
  63570. /**
  63571. * Gets the current class name
  63572. * @returns the class name
  63573. */
  63574. getClassName(): string;
  63575. /**
  63576. * Gets the first input component
  63577. */
  63578. get normalMap0(): NodeMaterialConnectionPoint;
  63579. /**
  63580. * Gets the second input component
  63581. */
  63582. get normalMap1(): NodeMaterialConnectionPoint;
  63583. /**
  63584. * Gets the output component
  63585. */
  63586. get output(): NodeMaterialConnectionPoint;
  63587. protected _buildBlock(state: NodeMaterialBuildState): this;
  63588. }
  63589. }
  63590. declare module BABYLON {
  63591. /**
  63592. * Block used to rotate a 2d vector by a given angle
  63593. */
  63594. export class Rotate2dBlock extends NodeMaterialBlock {
  63595. /**
  63596. * Creates a new Rotate2dBlock
  63597. * @param name defines the block name
  63598. */
  63599. constructor(name: string);
  63600. /**
  63601. * Gets the current class name
  63602. * @returns the class name
  63603. */
  63604. getClassName(): string;
  63605. /**
  63606. * Gets the input vector
  63607. */
  63608. get input(): NodeMaterialConnectionPoint;
  63609. /**
  63610. * Gets the input angle
  63611. */
  63612. get angle(): NodeMaterialConnectionPoint;
  63613. /**
  63614. * Gets the output component
  63615. */
  63616. get output(): NodeMaterialConnectionPoint;
  63617. autoConfigure(material: NodeMaterial): void;
  63618. protected _buildBlock(state: NodeMaterialBuildState): this;
  63619. }
  63620. }
  63621. declare module BABYLON {
  63622. /**
  63623. * Block used to get the reflected vector from a direction and a normal
  63624. */
  63625. export class ReflectBlock extends NodeMaterialBlock {
  63626. /**
  63627. * Creates a new ReflectBlock
  63628. * @param name defines the block name
  63629. */
  63630. constructor(name: string);
  63631. /**
  63632. * Gets the current class name
  63633. * @returns the class name
  63634. */
  63635. getClassName(): string;
  63636. /**
  63637. * Gets the incident component
  63638. */
  63639. get incident(): NodeMaterialConnectionPoint;
  63640. /**
  63641. * Gets the normal component
  63642. */
  63643. get normal(): NodeMaterialConnectionPoint;
  63644. /**
  63645. * Gets the output component
  63646. */
  63647. get output(): NodeMaterialConnectionPoint;
  63648. protected _buildBlock(state: NodeMaterialBuildState): this;
  63649. }
  63650. }
  63651. declare module BABYLON {
  63652. /**
  63653. * Block used to get the refracted vector from a direction and a normal
  63654. */
  63655. export class RefractBlock extends NodeMaterialBlock {
  63656. /**
  63657. * Creates a new RefractBlock
  63658. * @param name defines the block name
  63659. */
  63660. constructor(name: string);
  63661. /**
  63662. * Gets the current class name
  63663. * @returns the class name
  63664. */
  63665. getClassName(): string;
  63666. /**
  63667. * Gets the incident component
  63668. */
  63669. get incident(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the normal component
  63672. */
  63673. get normal(): NodeMaterialConnectionPoint;
  63674. /**
  63675. * Gets the index of refraction component
  63676. */
  63677. get ior(): NodeMaterialConnectionPoint;
  63678. /**
  63679. * Gets the output component
  63680. */
  63681. get output(): NodeMaterialConnectionPoint;
  63682. protected _buildBlock(state: NodeMaterialBuildState): this;
  63683. }
  63684. }
  63685. declare module BABYLON {
  63686. /**
  63687. * Block used to desaturate a color
  63688. */
  63689. export class DesaturateBlock extends NodeMaterialBlock {
  63690. /**
  63691. * Creates a new DesaturateBlock
  63692. * @param name defines the block name
  63693. */
  63694. constructor(name: string);
  63695. /**
  63696. * Gets the current class name
  63697. * @returns the class name
  63698. */
  63699. getClassName(): string;
  63700. /**
  63701. * Gets the color operand input component
  63702. */
  63703. get color(): NodeMaterialConnectionPoint;
  63704. /**
  63705. * Gets the level operand input component
  63706. */
  63707. get level(): NodeMaterialConnectionPoint;
  63708. /**
  63709. * Gets the output component
  63710. */
  63711. get output(): NodeMaterialConnectionPoint;
  63712. protected _buildBlock(state: NodeMaterialBuildState): this;
  63713. }
  63714. }
  63715. declare module BABYLON {
  63716. /**
  63717. * Block used to implement the ambient occlusion module of the PBR material
  63718. */
  63719. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63720. /**
  63721. * Create a new AmbientOcclusionBlock
  63722. * @param name defines the block name
  63723. */
  63724. constructor(name: string);
  63725. /**
  63726. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63727. */
  63728. useAmbientInGrayScale: boolean;
  63729. /**
  63730. * Initialize the block and prepare the context for build
  63731. * @param state defines the state that will be used for the build
  63732. */
  63733. initialize(state: NodeMaterialBuildState): void;
  63734. /**
  63735. * Gets the current class name
  63736. * @returns the class name
  63737. */
  63738. getClassName(): string;
  63739. /**
  63740. * Gets the texture input component
  63741. */
  63742. get texture(): NodeMaterialConnectionPoint;
  63743. /**
  63744. * Gets the texture intensity component
  63745. */
  63746. get intensity(): NodeMaterialConnectionPoint;
  63747. /**
  63748. * Gets the direct light intensity input component
  63749. */
  63750. get directLightIntensity(): NodeMaterialConnectionPoint;
  63751. /**
  63752. * Gets the ambient occlusion object output component
  63753. */
  63754. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63755. /**
  63756. * Gets the main code of the block (fragment side)
  63757. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63758. * @returns the shader code
  63759. */
  63760. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63762. protected _buildBlock(state: NodeMaterialBuildState): this;
  63763. protected _dumpPropertiesCode(): string;
  63764. serialize(): any;
  63765. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63766. }
  63767. }
  63768. declare module BABYLON {
  63769. /**
  63770. * Block used to implement the reflection module of the PBR material
  63771. */
  63772. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63773. /** @hidden */
  63774. _defineLODReflectionAlpha: string;
  63775. /** @hidden */
  63776. _defineLinearSpecularReflection: string;
  63777. private _vEnvironmentIrradianceName;
  63778. /** @hidden */
  63779. _vReflectionMicrosurfaceInfosName: string;
  63780. /** @hidden */
  63781. _vReflectionInfosName: string;
  63782. /** @hidden */
  63783. _vReflectionFilteringInfoName: string;
  63784. private _scene;
  63785. /**
  63786. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63787. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63788. * It's less burden on the user side in the editor part.
  63789. */
  63790. /** @hidden */
  63791. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63792. /** @hidden */
  63793. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63794. /** @hidden */
  63795. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63796. /**
  63797. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63798. * diffuse part of the IBL.
  63799. */
  63800. useSphericalHarmonics: boolean;
  63801. /**
  63802. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63803. */
  63804. forceIrradianceInFragment: boolean;
  63805. /**
  63806. * Create a new ReflectionBlock
  63807. * @param name defines the block name
  63808. */
  63809. constructor(name: string);
  63810. /**
  63811. * Gets the current class name
  63812. * @returns the class name
  63813. */
  63814. getClassName(): string;
  63815. /**
  63816. * Gets the position input component
  63817. */
  63818. get position(): NodeMaterialConnectionPoint;
  63819. /**
  63820. * Gets the world position input component
  63821. */
  63822. get worldPosition(): NodeMaterialConnectionPoint;
  63823. /**
  63824. * Gets the world normal input component
  63825. */
  63826. get worldNormal(): NodeMaterialConnectionPoint;
  63827. /**
  63828. * Gets the world input component
  63829. */
  63830. get world(): NodeMaterialConnectionPoint;
  63831. /**
  63832. * Gets the camera (or eye) position component
  63833. */
  63834. get cameraPosition(): NodeMaterialConnectionPoint;
  63835. /**
  63836. * Gets the view input component
  63837. */
  63838. get view(): NodeMaterialConnectionPoint;
  63839. /**
  63840. * Gets the color input component
  63841. */
  63842. get color(): NodeMaterialConnectionPoint;
  63843. /**
  63844. * Gets the reflection object output component
  63845. */
  63846. get reflection(): NodeMaterialConnectionPoint;
  63847. /**
  63848. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63849. */
  63850. get hasTexture(): boolean;
  63851. /**
  63852. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63853. */
  63854. get reflectionColor(): string;
  63855. protected _getTexture(): Nullable<BaseTexture>;
  63856. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63857. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63858. /**
  63859. * Gets the code to inject in the vertex shader
  63860. * @param state current state of the node material building
  63861. * @returns the shader code
  63862. */
  63863. handleVertexSide(state: NodeMaterialBuildState): string;
  63864. /**
  63865. * Gets the main code of the block (fragment side)
  63866. * @param state current state of the node material building
  63867. * @param normalVarName name of the existing variable corresponding to the normal
  63868. * @returns the shader code
  63869. */
  63870. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63871. protected _buildBlock(state: NodeMaterialBuildState): this;
  63872. protected _dumpPropertiesCode(): string;
  63873. serialize(): any;
  63874. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63875. }
  63876. }
  63877. declare module BABYLON {
  63878. /**
  63879. * Block used to implement the sheen module of the PBR material
  63880. */
  63881. export class SheenBlock extends NodeMaterialBlock {
  63882. /**
  63883. * Create a new SheenBlock
  63884. * @param name defines the block name
  63885. */
  63886. constructor(name: string);
  63887. /**
  63888. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63889. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63890. * making it easier to setup and tweak the effect
  63891. */
  63892. albedoScaling: boolean;
  63893. /**
  63894. * Defines if the sheen is linked to the sheen color.
  63895. */
  63896. linkSheenWithAlbedo: boolean;
  63897. /**
  63898. * Initialize the block and prepare the context for build
  63899. * @param state defines the state that will be used for the build
  63900. */
  63901. initialize(state: NodeMaterialBuildState): void;
  63902. /**
  63903. * Gets the current class name
  63904. * @returns the class name
  63905. */
  63906. getClassName(): string;
  63907. /**
  63908. * Gets the intensity input component
  63909. */
  63910. get intensity(): NodeMaterialConnectionPoint;
  63911. /**
  63912. * Gets the color input component
  63913. */
  63914. get color(): NodeMaterialConnectionPoint;
  63915. /**
  63916. * Gets the roughness input component
  63917. */
  63918. get roughness(): NodeMaterialConnectionPoint;
  63919. /**
  63920. * Gets the sheen object output component
  63921. */
  63922. get sheen(): NodeMaterialConnectionPoint;
  63923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63924. /**
  63925. * Gets the main code of the block (fragment side)
  63926. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63927. * @returns the shader code
  63928. */
  63929. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63930. protected _buildBlock(state: NodeMaterialBuildState): this;
  63931. protected _dumpPropertiesCode(): string;
  63932. serialize(): any;
  63933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63934. }
  63935. }
  63936. declare module BABYLON {
  63937. /**
  63938. * Block used to implement the reflectivity module of the PBR material
  63939. */
  63940. export class ReflectivityBlock extends NodeMaterialBlock {
  63941. private _metallicReflectanceColor;
  63942. private _metallicF0Factor;
  63943. /** @hidden */
  63944. _vMetallicReflectanceFactorsName: string;
  63945. /**
  63946. * The property below is set by the main PBR block prior to calling methods of this class.
  63947. */
  63948. /** @hidden */
  63949. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63950. /**
  63951. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63952. */
  63953. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63954. /**
  63955. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63956. */
  63957. useMetallnessFromMetallicTextureBlue: boolean;
  63958. /**
  63959. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63960. */
  63961. useRoughnessFromMetallicTextureAlpha: boolean;
  63962. /**
  63963. * Specifies if the metallic texture contains the roughness information in its green channel.
  63964. */
  63965. useRoughnessFromMetallicTextureGreen: boolean;
  63966. /**
  63967. * Create a new ReflectivityBlock
  63968. * @param name defines the block name
  63969. */
  63970. constructor(name: string);
  63971. /**
  63972. * Initialize the block and prepare the context for build
  63973. * @param state defines the state that will be used for the build
  63974. */
  63975. initialize(state: NodeMaterialBuildState): void;
  63976. /**
  63977. * Gets the current class name
  63978. * @returns the class name
  63979. */
  63980. getClassName(): string;
  63981. /**
  63982. * Gets the metallic input component
  63983. */
  63984. get metallic(): NodeMaterialConnectionPoint;
  63985. /**
  63986. * Gets the roughness input component
  63987. */
  63988. get roughness(): NodeMaterialConnectionPoint;
  63989. /**
  63990. * Gets the texture input component
  63991. */
  63992. get texture(): NodeMaterialConnectionPoint;
  63993. /**
  63994. * Gets the reflectivity object output component
  63995. */
  63996. get reflectivity(): NodeMaterialConnectionPoint;
  63997. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63998. /**
  63999. * Gets the main code of the block (fragment side)
  64000. * @param state current state of the node material building
  64001. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64002. * @returns the shader code
  64003. */
  64004. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64005. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64006. protected _buildBlock(state: NodeMaterialBuildState): this;
  64007. protected _dumpPropertiesCode(): string;
  64008. serialize(): any;
  64009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64010. }
  64011. }
  64012. declare module BABYLON {
  64013. /**
  64014. * Block used to implement the anisotropy module of the PBR material
  64015. */
  64016. export class AnisotropyBlock extends NodeMaterialBlock {
  64017. /**
  64018. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64019. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64020. * It's less burden on the user side in the editor part.
  64021. */
  64022. /** @hidden */
  64023. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64024. /** @hidden */
  64025. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64026. /**
  64027. * Create a new AnisotropyBlock
  64028. * @param name defines the block name
  64029. */
  64030. constructor(name: string);
  64031. /**
  64032. * Initialize the block and prepare the context for build
  64033. * @param state defines the state that will be used for the build
  64034. */
  64035. initialize(state: NodeMaterialBuildState): void;
  64036. /**
  64037. * Gets the current class name
  64038. * @returns the class name
  64039. */
  64040. getClassName(): string;
  64041. /**
  64042. * Gets the intensity input component
  64043. */
  64044. get intensity(): NodeMaterialConnectionPoint;
  64045. /**
  64046. * Gets the direction input component
  64047. */
  64048. get direction(): NodeMaterialConnectionPoint;
  64049. /**
  64050. * Gets the texture input component
  64051. */
  64052. get texture(): NodeMaterialConnectionPoint;
  64053. /**
  64054. * Gets the uv input component
  64055. */
  64056. get uv(): NodeMaterialConnectionPoint;
  64057. /**
  64058. * Gets the worldTangent input component
  64059. */
  64060. get worldTangent(): NodeMaterialConnectionPoint;
  64061. /**
  64062. * Gets the anisotropy object output component
  64063. */
  64064. get anisotropy(): NodeMaterialConnectionPoint;
  64065. private _generateTBNSpace;
  64066. /**
  64067. * Gets the main code of the block (fragment side)
  64068. * @param state current state of the node material building
  64069. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64070. * @returns the shader code
  64071. */
  64072. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64073. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64074. protected _buildBlock(state: NodeMaterialBuildState): this;
  64075. }
  64076. }
  64077. declare module BABYLON {
  64078. /**
  64079. * Block used to implement the clear coat module of the PBR material
  64080. */
  64081. export class ClearCoatBlock extends NodeMaterialBlock {
  64082. private _scene;
  64083. /**
  64084. * Create a new ClearCoatBlock
  64085. * @param name defines the block name
  64086. */
  64087. constructor(name: string);
  64088. /**
  64089. * Initialize the block and prepare the context for build
  64090. * @param state defines the state that will be used for the build
  64091. */
  64092. initialize(state: NodeMaterialBuildState): void;
  64093. /**
  64094. * Gets the current class name
  64095. * @returns the class name
  64096. */
  64097. getClassName(): string;
  64098. /**
  64099. * Gets the intensity input component
  64100. */
  64101. get intensity(): NodeMaterialConnectionPoint;
  64102. /**
  64103. * Gets the roughness input component
  64104. */
  64105. get roughness(): NodeMaterialConnectionPoint;
  64106. /**
  64107. * Gets the ior input component
  64108. */
  64109. get ior(): NodeMaterialConnectionPoint;
  64110. /**
  64111. * Gets the texture input component
  64112. */
  64113. get texture(): NodeMaterialConnectionPoint;
  64114. /**
  64115. * Gets the bump texture input component
  64116. */
  64117. get bumpTexture(): NodeMaterialConnectionPoint;
  64118. /**
  64119. * Gets the uv input component
  64120. */
  64121. get uv(): NodeMaterialConnectionPoint;
  64122. /**
  64123. * Gets the tint color input component
  64124. */
  64125. get tintColor(): NodeMaterialConnectionPoint;
  64126. /**
  64127. * Gets the tint "at distance" input component
  64128. */
  64129. get tintAtDistance(): NodeMaterialConnectionPoint;
  64130. /**
  64131. * Gets the tint thickness input component
  64132. */
  64133. get tintThickness(): NodeMaterialConnectionPoint;
  64134. /**
  64135. * Gets the world tangent input component
  64136. */
  64137. get worldTangent(): NodeMaterialConnectionPoint;
  64138. /**
  64139. * Gets the clear coat object output component
  64140. */
  64141. get clearcoat(): NodeMaterialConnectionPoint;
  64142. autoConfigure(material: NodeMaterial): void;
  64143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64145. private _generateTBNSpace;
  64146. /**
  64147. * Gets the main code of the block (fragment side)
  64148. * @param state current state of the node material building
  64149. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64150. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64151. * @param worldPosVarName name of the variable holding the world position
  64152. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64153. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64154. * @param worldNormalVarName name of the variable holding the world normal
  64155. * @returns the shader code
  64156. */
  64157. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64158. protected _buildBlock(state: NodeMaterialBuildState): this;
  64159. }
  64160. }
  64161. declare module BABYLON {
  64162. /**
  64163. * Block used to implement the sub surface module of the PBR material
  64164. */
  64165. export class SubSurfaceBlock extends NodeMaterialBlock {
  64166. /**
  64167. * Create a new SubSurfaceBlock
  64168. * @param name defines the block name
  64169. */
  64170. constructor(name: string);
  64171. /**
  64172. * Stores the intensity of the different subsurface effects in the thickness texture.
  64173. * * the green channel is the translucency intensity.
  64174. * * the blue channel is the scattering intensity.
  64175. * * the alpha channel is the refraction intensity.
  64176. */
  64177. useMaskFromThicknessTexture: boolean;
  64178. /**
  64179. * Initialize the block and prepare the context for build
  64180. * @param state defines the state that will be used for the build
  64181. */
  64182. initialize(state: NodeMaterialBuildState): void;
  64183. /**
  64184. * Gets the current class name
  64185. * @returns the class name
  64186. */
  64187. getClassName(): string;
  64188. /**
  64189. * Gets the min thickness input component
  64190. */
  64191. get minThickness(): NodeMaterialConnectionPoint;
  64192. /**
  64193. * Gets the max thickness input component
  64194. */
  64195. get maxThickness(): NodeMaterialConnectionPoint;
  64196. /**
  64197. * Gets the thickness texture component
  64198. */
  64199. get thicknessTexture(): NodeMaterialConnectionPoint;
  64200. /**
  64201. * Gets the tint color input component
  64202. */
  64203. get tintColor(): NodeMaterialConnectionPoint;
  64204. /**
  64205. * Gets the translucency intensity input component
  64206. */
  64207. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64208. /**
  64209. * Gets the translucency diffusion distance input component
  64210. */
  64211. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64212. /**
  64213. * Gets the refraction object parameters
  64214. */
  64215. get refraction(): NodeMaterialConnectionPoint;
  64216. /**
  64217. * Gets the sub surface object output component
  64218. */
  64219. get subsurface(): NodeMaterialConnectionPoint;
  64220. autoConfigure(material: NodeMaterial): void;
  64221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64222. /**
  64223. * Gets the main code of the block (fragment side)
  64224. * @param state current state of the node material building
  64225. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64226. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64227. * @param worldPosVarName name of the variable holding the world position
  64228. * @returns the shader code
  64229. */
  64230. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64231. protected _buildBlock(state: NodeMaterialBuildState): this;
  64232. }
  64233. }
  64234. declare module BABYLON {
  64235. /**
  64236. * Block used to implement the PBR metallic/roughness model
  64237. */
  64238. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64239. /**
  64240. * Gets or sets the light associated with this block
  64241. */
  64242. light: Nullable<Light>;
  64243. private _lightId;
  64244. private _scene;
  64245. private _environmentBRDFTexture;
  64246. private _environmentBrdfSamplerName;
  64247. private _vNormalWName;
  64248. private _invertNormalName;
  64249. /**
  64250. * Create a new ReflectionBlock
  64251. * @param name defines the block name
  64252. */
  64253. constructor(name: string);
  64254. /**
  64255. * Intensity of the direct lights e.g. the four lights available in your scene.
  64256. * This impacts both the direct diffuse and specular highlights.
  64257. */
  64258. directIntensity: number;
  64259. /**
  64260. * Intensity of the environment e.g. how much the environment will light the object
  64261. * either through harmonics for rough material or through the refelction for shiny ones.
  64262. */
  64263. environmentIntensity: number;
  64264. /**
  64265. * This is a special control allowing the reduction of the specular highlights coming from the
  64266. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64267. */
  64268. specularIntensity: number;
  64269. /**
  64270. * Defines the falloff type used in this material.
  64271. * It by default is Physical.
  64272. */
  64273. lightFalloff: number;
  64274. /**
  64275. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64276. */
  64277. useAlphaFromAlbedoTexture: boolean;
  64278. /**
  64279. * Specifies that alpha test should be used
  64280. */
  64281. useAlphaTest: boolean;
  64282. /**
  64283. * Defines the alpha limits in alpha test mode.
  64284. */
  64285. alphaTestCutoff: number;
  64286. /**
  64287. * Specifies that alpha blending should be used
  64288. */
  64289. useAlphaBlending: boolean;
  64290. /**
  64291. * Defines if the alpha value should be determined via the rgb values.
  64292. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64293. */
  64294. opacityRGB: boolean;
  64295. /**
  64296. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64297. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64298. */
  64299. useRadianceOverAlpha: boolean;
  64300. /**
  64301. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64302. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64303. */
  64304. useSpecularOverAlpha: boolean;
  64305. /**
  64306. * Enables specular anti aliasing in the PBR shader.
  64307. * It will both interacts on the Geometry for analytical and IBL lighting.
  64308. * It also prefilter the roughness map based on the bump values.
  64309. */
  64310. enableSpecularAntiAliasing: boolean;
  64311. /**
  64312. * Enables realtime filtering on the texture.
  64313. */
  64314. realTimeFiltering: boolean;
  64315. /**
  64316. * Quality switch for realtime filtering
  64317. */
  64318. realTimeFilteringQuality: number;
  64319. /**
  64320. * Defines if the material uses energy conservation.
  64321. */
  64322. useEnergyConservation: boolean;
  64323. /**
  64324. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64325. * too much the area relying on ambient texture to define their ambient occlusion.
  64326. */
  64327. useRadianceOcclusion: boolean;
  64328. /**
  64329. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64330. * makes the reflect vector face the model (under horizon).
  64331. */
  64332. useHorizonOcclusion: boolean;
  64333. /**
  64334. * If set to true, no lighting calculations will be applied.
  64335. */
  64336. unlit: boolean;
  64337. /**
  64338. * Force normal to face away from face.
  64339. */
  64340. forceNormalForward: boolean;
  64341. /**
  64342. * Defines the material debug mode.
  64343. * It helps seeing only some components of the material while troubleshooting.
  64344. */
  64345. debugMode: number;
  64346. /**
  64347. * Specify from where on screen the debug mode should start.
  64348. * The value goes from -1 (full screen) to 1 (not visible)
  64349. * It helps with side by side comparison against the final render
  64350. * This defaults to 0
  64351. */
  64352. debugLimit: number;
  64353. /**
  64354. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64355. * You can use the factor to better multiply the final value.
  64356. */
  64357. debugFactor: number;
  64358. /**
  64359. * Initialize the block and prepare the context for build
  64360. * @param state defines the state that will be used for the build
  64361. */
  64362. initialize(state: NodeMaterialBuildState): void;
  64363. /**
  64364. * Gets the current class name
  64365. * @returns the class name
  64366. */
  64367. getClassName(): string;
  64368. /**
  64369. * Gets the world position input component
  64370. */
  64371. get worldPosition(): NodeMaterialConnectionPoint;
  64372. /**
  64373. * Gets the world normal input component
  64374. */
  64375. get worldNormal(): NodeMaterialConnectionPoint;
  64376. /**
  64377. * Gets the perturbed normal input component
  64378. */
  64379. get perturbedNormal(): NodeMaterialConnectionPoint;
  64380. /**
  64381. * Gets the camera position input component
  64382. */
  64383. get cameraPosition(): NodeMaterialConnectionPoint;
  64384. /**
  64385. * Gets the base color input component
  64386. */
  64387. get baseColor(): NodeMaterialConnectionPoint;
  64388. /**
  64389. * Gets the opacity texture input component
  64390. */
  64391. get opacityTexture(): NodeMaterialConnectionPoint;
  64392. /**
  64393. * Gets the ambient color input component
  64394. */
  64395. get ambientColor(): NodeMaterialConnectionPoint;
  64396. /**
  64397. * Gets the reflectivity object parameters
  64398. */
  64399. get reflectivity(): NodeMaterialConnectionPoint;
  64400. /**
  64401. * Gets the ambient occlusion object parameters
  64402. */
  64403. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64404. /**
  64405. * Gets the reflection object parameters
  64406. */
  64407. get reflection(): NodeMaterialConnectionPoint;
  64408. /**
  64409. * Gets the sheen object parameters
  64410. */
  64411. get sheen(): NodeMaterialConnectionPoint;
  64412. /**
  64413. * Gets the clear coat object parameters
  64414. */
  64415. get clearcoat(): NodeMaterialConnectionPoint;
  64416. /**
  64417. * Gets the sub surface object parameters
  64418. */
  64419. get subsurface(): NodeMaterialConnectionPoint;
  64420. /**
  64421. * Gets the anisotropy object parameters
  64422. */
  64423. get anisotropy(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the ambient output component
  64426. */
  64427. get ambient(): NodeMaterialConnectionPoint;
  64428. /**
  64429. * Gets the diffuse output component
  64430. */
  64431. get diffuse(): NodeMaterialConnectionPoint;
  64432. /**
  64433. * Gets the specular output component
  64434. */
  64435. get specular(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Gets the sheen output component
  64438. */
  64439. get sheenDir(): NodeMaterialConnectionPoint;
  64440. /**
  64441. * Gets the clear coat output component
  64442. */
  64443. get clearcoatDir(): NodeMaterialConnectionPoint;
  64444. /**
  64445. * Gets the indirect diffuse output component
  64446. */
  64447. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64448. /**
  64449. * Gets the indirect specular output component
  64450. */
  64451. get specularIndirect(): NodeMaterialConnectionPoint;
  64452. /**
  64453. * Gets the indirect sheen output component
  64454. */
  64455. get sheenIndirect(): NodeMaterialConnectionPoint;
  64456. /**
  64457. * Gets the indirect clear coat output component
  64458. */
  64459. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64460. /**
  64461. * Gets the refraction output component
  64462. */
  64463. get refraction(): NodeMaterialConnectionPoint;
  64464. /**
  64465. * Gets the global lighting output component
  64466. */
  64467. get lighting(): NodeMaterialConnectionPoint;
  64468. /**
  64469. * Gets the shadow output component
  64470. */
  64471. get shadow(): NodeMaterialConnectionPoint;
  64472. /**
  64473. * Gets the alpha output component
  64474. */
  64475. get alpha(): NodeMaterialConnectionPoint;
  64476. autoConfigure(material: NodeMaterial): void;
  64477. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64478. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64479. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64480. private _injectVertexCode;
  64481. /**
  64482. * Gets the code corresponding to the albedo/opacity module
  64483. * @returns the shader code
  64484. */
  64485. getAlbedoOpacityCode(): string;
  64486. protected _buildBlock(state: NodeMaterialBuildState): this;
  64487. protected _dumpPropertiesCode(): string;
  64488. serialize(): any;
  64489. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64490. }
  64491. }
  64492. declare module BABYLON {
  64493. /**
  64494. * Block used to compute value of one parameter modulo another
  64495. */
  64496. export class ModBlock extends NodeMaterialBlock {
  64497. /**
  64498. * Creates a new ModBlock
  64499. * @param name defines the block name
  64500. */
  64501. constructor(name: string);
  64502. /**
  64503. * Gets the current class name
  64504. * @returns the class name
  64505. */
  64506. getClassName(): string;
  64507. /**
  64508. * Gets the left operand input component
  64509. */
  64510. get left(): NodeMaterialConnectionPoint;
  64511. /**
  64512. * Gets the right operand input component
  64513. */
  64514. get right(): NodeMaterialConnectionPoint;
  64515. /**
  64516. * Gets the output component
  64517. */
  64518. get output(): NodeMaterialConnectionPoint;
  64519. protected _buildBlock(state: NodeMaterialBuildState): this;
  64520. }
  64521. }
  64522. declare module BABYLON {
  64523. /**
  64524. * Helper class to push actions to a pool of workers.
  64525. */
  64526. export class WorkerPool implements IDisposable {
  64527. private _workerInfos;
  64528. private _pendingActions;
  64529. /**
  64530. * Constructor
  64531. * @param workers Array of workers to use for actions
  64532. */
  64533. constructor(workers: Array<Worker>);
  64534. /**
  64535. * Terminates all workers and clears any pending actions.
  64536. */
  64537. dispose(): void;
  64538. /**
  64539. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64540. * pended until a worker has completed its action.
  64541. * @param action The action to perform. Call onComplete when the action is complete.
  64542. */
  64543. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64544. private _execute;
  64545. }
  64546. }
  64547. declare module BABYLON {
  64548. /**
  64549. * Configuration for Draco compression
  64550. */
  64551. export interface IDracoCompressionConfiguration {
  64552. /**
  64553. * Configuration for the decoder.
  64554. */
  64555. decoder: {
  64556. /**
  64557. * The url to the WebAssembly module.
  64558. */
  64559. wasmUrl?: string;
  64560. /**
  64561. * The url to the WebAssembly binary.
  64562. */
  64563. wasmBinaryUrl?: string;
  64564. /**
  64565. * The url to the fallback JavaScript module.
  64566. */
  64567. fallbackUrl?: string;
  64568. };
  64569. }
  64570. /**
  64571. * Draco compression (https://google.github.io/draco/)
  64572. *
  64573. * This class wraps the Draco module.
  64574. *
  64575. * **Encoder**
  64576. *
  64577. * The encoder is not currently implemented.
  64578. *
  64579. * **Decoder**
  64580. *
  64581. * 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.
  64582. *
  64583. * To update the configuration, use the following code:
  64584. * ```javascript
  64585. * DracoCompression.Configuration = {
  64586. * decoder: {
  64587. * wasmUrl: "<url to the WebAssembly library>",
  64588. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64589. * fallbackUrl: "<url to the fallback JavaScript library>",
  64590. * }
  64591. * };
  64592. * ```
  64593. *
  64594. * 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.
  64595. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64596. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64597. *
  64598. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64599. * ```javascript
  64600. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64601. * ```
  64602. *
  64603. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64604. */
  64605. export class DracoCompression implements IDisposable {
  64606. private _workerPoolPromise?;
  64607. private _decoderModulePromise?;
  64608. /**
  64609. * The configuration. Defaults to the following urls:
  64610. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64611. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64612. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64613. */
  64614. static Configuration: IDracoCompressionConfiguration;
  64615. /**
  64616. * Returns true if the decoder configuration is available.
  64617. */
  64618. static get DecoderAvailable(): boolean;
  64619. /**
  64620. * Default number of workers to create when creating the draco compression object.
  64621. */
  64622. static DefaultNumWorkers: number;
  64623. private static GetDefaultNumWorkers;
  64624. private static _Default;
  64625. /**
  64626. * Default instance for the draco compression object.
  64627. */
  64628. static get Default(): DracoCompression;
  64629. /**
  64630. * Constructor
  64631. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64632. */
  64633. constructor(numWorkers?: number);
  64634. /**
  64635. * Stop all async operations and release resources.
  64636. */
  64637. dispose(): void;
  64638. /**
  64639. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64640. * @returns a promise that resolves when ready
  64641. */
  64642. whenReadyAsync(): Promise<void>;
  64643. /**
  64644. * Decode Draco compressed mesh data to vertex data.
  64645. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64646. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64647. * @returns A promise that resolves with the decoded vertex data
  64648. */
  64649. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64650. [kind: string]: number;
  64651. }): Promise<VertexData>;
  64652. }
  64653. }
  64654. declare module BABYLON {
  64655. /**
  64656. * Class for building Constructive Solid Geometry
  64657. */
  64658. export class CSG {
  64659. private polygons;
  64660. /**
  64661. * The world matrix
  64662. */
  64663. matrix: Matrix;
  64664. /**
  64665. * Stores the position
  64666. */
  64667. position: Vector3;
  64668. /**
  64669. * Stores the rotation
  64670. */
  64671. rotation: Vector3;
  64672. /**
  64673. * Stores the rotation quaternion
  64674. */
  64675. rotationQuaternion: Nullable<Quaternion>;
  64676. /**
  64677. * Stores the scaling vector
  64678. */
  64679. scaling: Vector3;
  64680. /**
  64681. * Convert the Mesh to CSG
  64682. * @param mesh The Mesh to convert to CSG
  64683. * @returns A new CSG from the Mesh
  64684. */
  64685. static FromMesh(mesh: Mesh): CSG;
  64686. /**
  64687. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64688. * @param polygons Polygons used to construct a CSG solid
  64689. */
  64690. private static FromPolygons;
  64691. /**
  64692. * Clones, or makes a deep copy, of the CSG
  64693. * @returns A new CSG
  64694. */
  64695. clone(): CSG;
  64696. /**
  64697. * Unions this CSG with another CSG
  64698. * @param csg The CSG to union against this CSG
  64699. * @returns The unioned CSG
  64700. */
  64701. union(csg: CSG): CSG;
  64702. /**
  64703. * Unions this CSG with another CSG in place
  64704. * @param csg The CSG to union against this CSG
  64705. */
  64706. unionInPlace(csg: CSG): void;
  64707. /**
  64708. * Subtracts this CSG with another CSG
  64709. * @param csg The CSG to subtract against this CSG
  64710. * @returns A new CSG
  64711. */
  64712. subtract(csg: CSG): CSG;
  64713. /**
  64714. * Subtracts this CSG with another CSG in place
  64715. * @param csg The CSG to subtact against this CSG
  64716. */
  64717. subtractInPlace(csg: CSG): void;
  64718. /**
  64719. * Intersect this CSG with another CSG
  64720. * @param csg The CSG to intersect against this CSG
  64721. * @returns A new CSG
  64722. */
  64723. intersect(csg: CSG): CSG;
  64724. /**
  64725. * Intersects this CSG with another CSG in place
  64726. * @param csg The CSG to intersect against this CSG
  64727. */
  64728. intersectInPlace(csg: CSG): void;
  64729. /**
  64730. * Return a new CSG solid with solid and empty space switched. This solid is
  64731. * not modified.
  64732. * @returns A new CSG solid with solid and empty space switched
  64733. */
  64734. inverse(): CSG;
  64735. /**
  64736. * Inverses the CSG in place
  64737. */
  64738. inverseInPlace(): void;
  64739. /**
  64740. * This is used to keep meshes transformations so they can be restored
  64741. * when we build back a Babylon Mesh
  64742. * NB : All CSG operations are performed in world coordinates
  64743. * @param csg The CSG to copy the transform attributes from
  64744. * @returns This CSG
  64745. */
  64746. copyTransformAttributes(csg: CSG): CSG;
  64747. /**
  64748. * Build Raw mesh from CSG
  64749. * Coordinates here are in world space
  64750. * @param name The name of the mesh geometry
  64751. * @param scene The Scene
  64752. * @param keepSubMeshes Specifies if the submeshes should be kept
  64753. * @returns A new Mesh
  64754. */
  64755. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64756. /**
  64757. * Build Mesh from CSG taking material and transforms into account
  64758. * @param name The name of the Mesh
  64759. * @param material The material of the Mesh
  64760. * @param scene The Scene
  64761. * @param keepSubMeshes Specifies if submeshes should be kept
  64762. * @returns The new Mesh
  64763. */
  64764. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64765. }
  64766. }
  64767. declare module BABYLON {
  64768. /**
  64769. * Class used to create a trail following a mesh
  64770. */
  64771. export class TrailMesh extends Mesh {
  64772. private _generator;
  64773. private _autoStart;
  64774. private _running;
  64775. private _diameter;
  64776. private _length;
  64777. private _sectionPolygonPointsCount;
  64778. private _sectionVectors;
  64779. private _sectionNormalVectors;
  64780. private _beforeRenderObserver;
  64781. /**
  64782. * @constructor
  64783. * @param name The value used by scene.getMeshByName() to do a lookup.
  64784. * @param generator The mesh or transform node to generate a trail.
  64785. * @param scene The scene to add this mesh to.
  64786. * @param diameter Diameter of trailing mesh. Default is 1.
  64787. * @param length Length of trailing mesh. Default is 60.
  64788. * @param autoStart Automatically start trailing mesh. Default true.
  64789. */
  64790. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64791. /**
  64792. * "TrailMesh"
  64793. * @returns "TrailMesh"
  64794. */
  64795. getClassName(): string;
  64796. private _createMesh;
  64797. /**
  64798. * Start trailing mesh.
  64799. */
  64800. start(): void;
  64801. /**
  64802. * Stop trailing mesh.
  64803. */
  64804. stop(): void;
  64805. /**
  64806. * Update trailing mesh geometry.
  64807. */
  64808. update(): void;
  64809. /**
  64810. * Returns a new TrailMesh object.
  64811. * @param name is a string, the name given to the new mesh
  64812. * @param newGenerator use new generator object for cloned trail mesh
  64813. * @returns a new mesh
  64814. */
  64815. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64816. /**
  64817. * Serializes this trail mesh
  64818. * @param serializationObject object to write serialization to
  64819. */
  64820. serialize(serializationObject: any): void;
  64821. /**
  64822. * Parses a serialized trail mesh
  64823. * @param parsedMesh the serialized mesh
  64824. * @param scene the scene to create the trail mesh in
  64825. * @returns the created trail mesh
  64826. */
  64827. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64828. }
  64829. }
  64830. declare module BABYLON {
  64831. /**
  64832. * Class containing static functions to help procedurally build meshes
  64833. */
  64834. export class TiledBoxBuilder {
  64835. /**
  64836. * Creates a box mesh
  64837. * 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)
  64838. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64840. * * 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
  64841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64842. * @param name defines the name of the mesh
  64843. * @param options defines the options used to create the mesh
  64844. * @param scene defines the hosting scene
  64845. * @returns the box mesh
  64846. */
  64847. static CreateTiledBox(name: string, options: {
  64848. pattern?: number;
  64849. width?: number;
  64850. height?: number;
  64851. depth?: number;
  64852. tileSize?: number;
  64853. tileWidth?: number;
  64854. tileHeight?: number;
  64855. alignHorizontal?: number;
  64856. alignVertical?: number;
  64857. faceUV?: Vector4[];
  64858. faceColors?: Color4[];
  64859. sideOrientation?: number;
  64860. updatable?: boolean;
  64861. }, scene?: Nullable<Scene>): Mesh;
  64862. }
  64863. }
  64864. declare module BABYLON {
  64865. /**
  64866. * Class containing static functions to help procedurally build meshes
  64867. */
  64868. export class TorusKnotBuilder {
  64869. /**
  64870. * Creates a torus knot mesh
  64871. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64872. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64873. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64874. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64876. * * 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
  64877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64878. * @param name defines the name of the mesh
  64879. * @param options defines the options used to create the mesh
  64880. * @param scene defines the hosting scene
  64881. * @returns the torus knot mesh
  64882. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64883. */
  64884. static CreateTorusKnot(name: string, options: {
  64885. radius?: number;
  64886. tube?: number;
  64887. radialSegments?: number;
  64888. tubularSegments?: number;
  64889. p?: number;
  64890. q?: number;
  64891. updatable?: boolean;
  64892. sideOrientation?: number;
  64893. frontUVs?: Vector4;
  64894. backUVs?: Vector4;
  64895. }, scene: any): Mesh;
  64896. }
  64897. }
  64898. declare module BABYLON {
  64899. /**
  64900. * Polygon
  64901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64902. */
  64903. export class Polygon {
  64904. /**
  64905. * Creates a rectangle
  64906. * @param xmin bottom X coord
  64907. * @param ymin bottom Y coord
  64908. * @param xmax top X coord
  64909. * @param ymax top Y coord
  64910. * @returns points that make the resulting rectation
  64911. */
  64912. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64913. /**
  64914. * Creates a circle
  64915. * @param radius radius of circle
  64916. * @param cx scale in x
  64917. * @param cy scale in y
  64918. * @param numberOfSides number of sides that make up the circle
  64919. * @returns points that make the resulting circle
  64920. */
  64921. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64922. /**
  64923. * Creates a polygon from input string
  64924. * @param input Input polygon data
  64925. * @returns the parsed points
  64926. */
  64927. static Parse(input: string): Vector2[];
  64928. /**
  64929. * Starts building a polygon from x and y coordinates
  64930. * @param x x coordinate
  64931. * @param y y coordinate
  64932. * @returns the started path2
  64933. */
  64934. static StartingAt(x: number, y: number): Path2;
  64935. }
  64936. /**
  64937. * Builds a polygon
  64938. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64939. */
  64940. export class PolygonMeshBuilder {
  64941. private _points;
  64942. private _outlinepoints;
  64943. private _holes;
  64944. private _name;
  64945. private _scene;
  64946. private _epoints;
  64947. private _eholes;
  64948. private _addToepoint;
  64949. /**
  64950. * Babylon reference to the earcut plugin.
  64951. */
  64952. bjsEarcut: any;
  64953. /**
  64954. * Creates a PolygonMeshBuilder
  64955. * @param name name of the builder
  64956. * @param contours Path of the polygon
  64957. * @param scene scene to add to when creating the mesh
  64958. * @param earcutInjection can be used to inject your own earcut reference
  64959. */
  64960. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64961. /**
  64962. * Adds a whole within the polygon
  64963. * @param hole Array of points defining the hole
  64964. * @returns this
  64965. */
  64966. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64967. /**
  64968. * Creates the polygon
  64969. * @param updatable If the mesh should be updatable
  64970. * @param depth The depth of the mesh created
  64971. * @returns the created mesh
  64972. */
  64973. build(updatable?: boolean, depth?: number): Mesh;
  64974. /**
  64975. * Creates the polygon
  64976. * @param depth The depth of the mesh created
  64977. * @returns the created VertexData
  64978. */
  64979. buildVertexData(depth?: number): VertexData;
  64980. /**
  64981. * Adds a side to the polygon
  64982. * @param positions points that make the polygon
  64983. * @param normals normals of the polygon
  64984. * @param uvs uvs of the polygon
  64985. * @param indices indices of the polygon
  64986. * @param bounds bounds of the polygon
  64987. * @param points points of the polygon
  64988. * @param depth depth of the polygon
  64989. * @param flip flip of the polygon
  64990. */
  64991. private addSide;
  64992. }
  64993. }
  64994. declare module BABYLON {
  64995. /**
  64996. * Class containing static functions to help procedurally build meshes
  64997. */
  64998. export class PolygonBuilder {
  64999. /**
  65000. * Creates a polygon mesh
  65001. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65002. * * 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
  65003. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65005. * * 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)
  65006. * * Remember you can only change the shape positions, not their number when updating a polygon
  65007. * @param name defines the name of the mesh
  65008. * @param options defines the options used to create the mesh
  65009. * @param scene defines the hosting scene
  65010. * @param earcutInjection can be used to inject your own earcut reference
  65011. * @returns the polygon mesh
  65012. */
  65013. static CreatePolygon(name: string, options: {
  65014. shape: Vector3[];
  65015. holes?: Vector3[][];
  65016. depth?: number;
  65017. faceUV?: Vector4[];
  65018. faceColors?: Color4[];
  65019. updatable?: boolean;
  65020. sideOrientation?: number;
  65021. frontUVs?: Vector4;
  65022. backUVs?: Vector4;
  65023. wrap?: boolean;
  65024. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65025. /**
  65026. * Creates an extruded polygon mesh, with depth in the Y direction.
  65027. * * 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)
  65028. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65029. * @param name defines the name of the mesh
  65030. * @param options defines the options used to create the mesh
  65031. * @param scene defines the hosting scene
  65032. * @param earcutInjection can be used to inject your own earcut reference
  65033. * @returns the polygon mesh
  65034. */
  65035. static ExtrudePolygon(name: string, options: {
  65036. shape: Vector3[];
  65037. holes?: Vector3[][];
  65038. depth?: number;
  65039. faceUV?: Vector4[];
  65040. faceColors?: Color4[];
  65041. updatable?: boolean;
  65042. sideOrientation?: number;
  65043. frontUVs?: Vector4;
  65044. backUVs?: Vector4;
  65045. wrap?: boolean;
  65046. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65047. }
  65048. }
  65049. declare module BABYLON {
  65050. /**
  65051. * Class containing static functions to help procedurally build meshes
  65052. */
  65053. export class LatheBuilder {
  65054. /**
  65055. * Creates lathe mesh.
  65056. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65057. * * 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
  65058. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65059. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65060. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65061. * * 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
  65062. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65063. * * 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
  65064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65065. * * 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
  65066. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65068. * @param name defines the name of the mesh
  65069. * @param options defines the options used to create the mesh
  65070. * @param scene defines the hosting scene
  65071. * @returns the lathe mesh
  65072. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65073. */
  65074. static CreateLathe(name: string, options: {
  65075. shape: Vector3[];
  65076. radius?: number;
  65077. tessellation?: number;
  65078. clip?: number;
  65079. arc?: number;
  65080. closed?: boolean;
  65081. updatable?: boolean;
  65082. sideOrientation?: number;
  65083. frontUVs?: Vector4;
  65084. backUVs?: Vector4;
  65085. cap?: number;
  65086. invertUV?: boolean;
  65087. }, scene?: Nullable<Scene>): Mesh;
  65088. }
  65089. }
  65090. declare module BABYLON {
  65091. /**
  65092. * Class containing static functions to help procedurally build meshes
  65093. */
  65094. export class TiledPlaneBuilder {
  65095. /**
  65096. * Creates a tiled plane mesh
  65097. * * The parameter `pattern` will, depending on value, do nothing or
  65098. * * * flip (reflect about central vertical) alternate tiles across and up
  65099. * * * flip every tile on alternate rows
  65100. * * * rotate (180 degs) alternate tiles across and up
  65101. * * * rotate every tile on alternate rows
  65102. * * * flip and rotate alternate tiles across and up
  65103. * * * flip and rotate every tile on alternate rows
  65104. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65105. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65106. * * 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
  65107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65108. * * 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)
  65109. * * 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)
  65110. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65111. * @param name defines the name of the mesh
  65112. * @param options defines the options used to create the mesh
  65113. * @param scene defines the hosting scene
  65114. * @returns the box mesh
  65115. */
  65116. static CreateTiledPlane(name: string, options: {
  65117. pattern?: number;
  65118. tileSize?: number;
  65119. tileWidth?: number;
  65120. tileHeight?: number;
  65121. size?: number;
  65122. width?: number;
  65123. height?: number;
  65124. alignHorizontal?: number;
  65125. alignVertical?: number;
  65126. sideOrientation?: number;
  65127. frontUVs?: Vector4;
  65128. backUVs?: Vector4;
  65129. updatable?: boolean;
  65130. }, scene?: Nullable<Scene>): Mesh;
  65131. }
  65132. }
  65133. declare module BABYLON {
  65134. /**
  65135. * Class containing static functions to help procedurally build meshes
  65136. */
  65137. export class TubeBuilder {
  65138. /**
  65139. * Creates a tube mesh.
  65140. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65141. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65142. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65143. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65144. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65145. * * 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)
  65146. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65147. * * 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
  65148. * * 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
  65149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65150. * * 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
  65151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65153. * @param name defines the name of the mesh
  65154. * @param options defines the options used to create the mesh
  65155. * @param scene defines the hosting scene
  65156. * @returns the tube mesh
  65157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65158. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65159. */
  65160. static CreateTube(name: string, options: {
  65161. path: Vector3[];
  65162. radius?: number;
  65163. tessellation?: number;
  65164. radiusFunction?: {
  65165. (i: number, distance: number): number;
  65166. };
  65167. cap?: number;
  65168. arc?: number;
  65169. updatable?: boolean;
  65170. sideOrientation?: number;
  65171. frontUVs?: Vector4;
  65172. backUVs?: Vector4;
  65173. instance?: Mesh;
  65174. invertUV?: boolean;
  65175. }, scene?: Nullable<Scene>): Mesh;
  65176. }
  65177. }
  65178. declare module BABYLON {
  65179. /**
  65180. * Class containing static functions to help procedurally build meshes
  65181. */
  65182. export class IcoSphereBuilder {
  65183. /**
  65184. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65185. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65186. * * 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`)
  65187. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65188. * * 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
  65189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65190. * * 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
  65191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65192. * @param name defines the name of the mesh
  65193. * @param options defines the options used to create the mesh
  65194. * @param scene defines the hosting scene
  65195. * @returns the icosahedron mesh
  65196. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65197. */
  65198. static CreateIcoSphere(name: string, options: {
  65199. radius?: number;
  65200. radiusX?: number;
  65201. radiusY?: number;
  65202. radiusZ?: number;
  65203. flat?: boolean;
  65204. subdivisions?: number;
  65205. sideOrientation?: number;
  65206. frontUVs?: Vector4;
  65207. backUVs?: Vector4;
  65208. updatable?: boolean;
  65209. }, scene?: Nullable<Scene>): Mesh;
  65210. }
  65211. }
  65212. declare module BABYLON {
  65213. /**
  65214. * Class containing static functions to help procedurally build meshes
  65215. */
  65216. export class DecalBuilder {
  65217. /**
  65218. * Creates a decal mesh.
  65219. * 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
  65220. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65221. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65222. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65223. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65224. * @param name defines the name of the mesh
  65225. * @param sourceMesh defines the mesh where the decal must be applied
  65226. * @param options defines the options used to create the mesh
  65227. * @param scene defines the hosting scene
  65228. * @returns the decal mesh
  65229. * @see https://doc.babylonjs.com/how_to/decals
  65230. */
  65231. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65232. position?: Vector3;
  65233. normal?: Vector3;
  65234. size?: Vector3;
  65235. angle?: number;
  65236. }): Mesh;
  65237. }
  65238. }
  65239. declare module BABYLON {
  65240. /**
  65241. * Class containing static functions to help procedurally build meshes
  65242. */
  65243. export class MeshBuilder {
  65244. /**
  65245. * Creates a box mesh
  65246. * * The parameter `size` sets the size (float) of each box side (default 1)
  65247. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65248. * * 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)
  65249. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65251. * * 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
  65252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65253. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65254. * @param name defines the name of the mesh
  65255. * @param options defines the options used to create the mesh
  65256. * @param scene defines the hosting scene
  65257. * @returns the box mesh
  65258. */
  65259. static CreateBox(name: string, options: {
  65260. size?: number;
  65261. width?: number;
  65262. height?: number;
  65263. depth?: number;
  65264. faceUV?: Vector4[];
  65265. faceColors?: Color4[];
  65266. sideOrientation?: number;
  65267. frontUVs?: Vector4;
  65268. backUVs?: Vector4;
  65269. wrap?: boolean;
  65270. topBaseAt?: number;
  65271. bottomBaseAt?: number;
  65272. updatable?: boolean;
  65273. }, scene?: Nullable<Scene>): Mesh;
  65274. /**
  65275. * Creates a tiled box mesh
  65276. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65278. * @param name defines the name of the mesh
  65279. * @param options defines the options used to create the mesh
  65280. * @param scene defines the hosting scene
  65281. * @returns the tiled box mesh
  65282. */
  65283. static CreateTiledBox(name: string, options: {
  65284. pattern?: number;
  65285. size?: number;
  65286. width?: number;
  65287. height?: number;
  65288. depth: number;
  65289. tileSize?: number;
  65290. tileWidth?: number;
  65291. tileHeight?: number;
  65292. faceUV?: Vector4[];
  65293. faceColors?: Color4[];
  65294. alignHorizontal?: number;
  65295. alignVertical?: number;
  65296. sideOrientation?: number;
  65297. updatable?: boolean;
  65298. }, scene?: Nullable<Scene>): Mesh;
  65299. /**
  65300. * Creates a sphere mesh
  65301. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65302. * * 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`)
  65303. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65304. * * 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
  65305. * * 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)
  65306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65307. * * 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
  65308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65309. * @param name defines the name of the mesh
  65310. * @param options defines the options used to create the mesh
  65311. * @param scene defines the hosting scene
  65312. * @returns the sphere mesh
  65313. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65314. */
  65315. static CreateSphere(name: string, options: {
  65316. segments?: number;
  65317. diameter?: number;
  65318. diameterX?: number;
  65319. diameterY?: number;
  65320. diameterZ?: number;
  65321. arc?: number;
  65322. slice?: number;
  65323. sideOrientation?: number;
  65324. frontUVs?: Vector4;
  65325. backUVs?: Vector4;
  65326. updatable?: boolean;
  65327. }, scene?: Nullable<Scene>): Mesh;
  65328. /**
  65329. * Creates a plane polygonal mesh. By default, this is a disc
  65330. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65331. * * 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
  65332. * * 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
  65333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65334. * * 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
  65335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65336. * @param name defines the name of the mesh
  65337. * @param options defines the options used to create the mesh
  65338. * @param scene defines the hosting scene
  65339. * @returns the plane polygonal mesh
  65340. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65341. */
  65342. static CreateDisc(name: string, options: {
  65343. radius?: number;
  65344. tessellation?: number;
  65345. arc?: number;
  65346. updatable?: boolean;
  65347. sideOrientation?: number;
  65348. frontUVs?: Vector4;
  65349. backUVs?: Vector4;
  65350. }, scene?: Nullable<Scene>): Mesh;
  65351. /**
  65352. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65353. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65354. * * 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`)
  65355. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65356. * * 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
  65357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65358. * * 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
  65359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65360. * @param name defines the name of the mesh
  65361. * @param options defines the options used to create the mesh
  65362. * @param scene defines the hosting scene
  65363. * @returns the icosahedron mesh
  65364. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65365. */
  65366. static CreateIcoSphere(name: string, options: {
  65367. radius?: number;
  65368. radiusX?: number;
  65369. radiusY?: number;
  65370. radiusZ?: number;
  65371. flat?: boolean;
  65372. subdivisions?: number;
  65373. sideOrientation?: number;
  65374. frontUVs?: Vector4;
  65375. backUVs?: Vector4;
  65376. updatable?: boolean;
  65377. }, scene?: Nullable<Scene>): Mesh;
  65378. /**
  65379. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65380. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65381. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65382. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65383. * * 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
  65384. * * 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
  65385. * * 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
  65386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65387. * * 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
  65388. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65389. * * 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
  65390. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65391. * * 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
  65392. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65394. * @param name defines the name of the mesh
  65395. * @param options defines the options used to create the mesh
  65396. * @param scene defines the hosting scene
  65397. * @returns the ribbon mesh
  65398. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65399. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65400. */
  65401. static CreateRibbon(name: string, options: {
  65402. pathArray: Vector3[][];
  65403. closeArray?: boolean;
  65404. closePath?: boolean;
  65405. offset?: number;
  65406. updatable?: boolean;
  65407. sideOrientation?: number;
  65408. frontUVs?: Vector4;
  65409. backUVs?: Vector4;
  65410. instance?: Mesh;
  65411. invertUV?: boolean;
  65412. uvs?: Vector2[];
  65413. colors?: Color4[];
  65414. }, scene?: Nullable<Scene>): Mesh;
  65415. /**
  65416. * Creates a cylinder or a cone mesh
  65417. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65418. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65419. * * 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.
  65420. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65421. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65422. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65423. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65424. * * 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).
  65425. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65426. * * 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).
  65427. * * 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
  65428. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65429. * * 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
  65430. * * 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.
  65431. * * If `enclose` is false, a ring surface is one element.
  65432. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65433. * * 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
  65434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65435. * * 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
  65436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65437. * @param name defines the name of the mesh
  65438. * @param options defines the options used to create the mesh
  65439. * @param scene defines the hosting scene
  65440. * @returns the cylinder mesh
  65441. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65442. */
  65443. static CreateCylinder(name: string, options: {
  65444. height?: number;
  65445. diameterTop?: number;
  65446. diameterBottom?: number;
  65447. diameter?: number;
  65448. tessellation?: number;
  65449. subdivisions?: number;
  65450. arc?: number;
  65451. faceColors?: Color4[];
  65452. faceUV?: Vector4[];
  65453. updatable?: boolean;
  65454. hasRings?: boolean;
  65455. enclose?: boolean;
  65456. cap?: number;
  65457. sideOrientation?: number;
  65458. frontUVs?: Vector4;
  65459. backUVs?: Vector4;
  65460. }, scene?: Nullable<Scene>): Mesh;
  65461. /**
  65462. * Creates a torus mesh
  65463. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65464. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65465. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65467. * * 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
  65468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65469. * @param name defines the name of the mesh
  65470. * @param options defines the options used to create the mesh
  65471. * @param scene defines the hosting scene
  65472. * @returns the torus mesh
  65473. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65474. */
  65475. static CreateTorus(name: string, options: {
  65476. diameter?: number;
  65477. thickness?: number;
  65478. tessellation?: number;
  65479. updatable?: boolean;
  65480. sideOrientation?: number;
  65481. frontUVs?: Vector4;
  65482. backUVs?: Vector4;
  65483. }, scene?: Nullable<Scene>): Mesh;
  65484. /**
  65485. * Creates a torus knot mesh
  65486. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65487. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65488. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65489. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65491. * * 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
  65492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65493. * @param name defines the name of the mesh
  65494. * @param options defines the options used to create the mesh
  65495. * @param scene defines the hosting scene
  65496. * @returns the torus knot mesh
  65497. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65498. */
  65499. static CreateTorusKnot(name: string, options: {
  65500. radius?: number;
  65501. tube?: number;
  65502. radialSegments?: number;
  65503. tubularSegments?: number;
  65504. p?: number;
  65505. q?: number;
  65506. updatable?: boolean;
  65507. sideOrientation?: number;
  65508. frontUVs?: Vector4;
  65509. backUVs?: Vector4;
  65510. }, scene?: Nullable<Scene>): Mesh;
  65511. /**
  65512. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65513. * * 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
  65514. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65515. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65516. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65517. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65518. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65519. * * 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
  65520. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65523. * @param name defines the name of the new line system
  65524. * @param options defines the options used to create the line system
  65525. * @param scene defines the hosting scene
  65526. * @returns a new line system mesh
  65527. */
  65528. static CreateLineSystem(name: string, options: {
  65529. lines: Vector3[][];
  65530. updatable?: boolean;
  65531. instance?: Nullable<LinesMesh>;
  65532. colors?: Nullable<Color4[][]>;
  65533. useVertexAlpha?: boolean;
  65534. }, scene: Nullable<Scene>): LinesMesh;
  65535. /**
  65536. * Creates a line mesh
  65537. * 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
  65538. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65539. * * The parameter `points` is an array successive Vector3
  65540. * * 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
  65541. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65542. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65543. * * When updating an instance, remember that only point positions can change, not the number of points
  65544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65546. * @param name defines the name of the new line system
  65547. * @param options defines the options used to create the line system
  65548. * @param scene defines the hosting scene
  65549. * @returns a new line mesh
  65550. */
  65551. static CreateLines(name: string, options: {
  65552. points: Vector3[];
  65553. updatable?: boolean;
  65554. instance?: Nullable<LinesMesh>;
  65555. colors?: Color4[];
  65556. useVertexAlpha?: boolean;
  65557. }, scene?: Nullable<Scene>): LinesMesh;
  65558. /**
  65559. * Creates a dashed line mesh
  65560. * * 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
  65561. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65562. * * The parameter `points` is an array successive Vector3
  65563. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65564. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65565. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65566. * * 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
  65567. * * When updating an instance, remember that only point positions can change, not the number of points
  65568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65569. * @param name defines the name of the mesh
  65570. * @param options defines the options used to create the mesh
  65571. * @param scene defines the hosting scene
  65572. * @returns the dashed line mesh
  65573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65574. */
  65575. static CreateDashedLines(name: string, options: {
  65576. points: Vector3[];
  65577. dashSize?: number;
  65578. gapSize?: number;
  65579. dashNb?: number;
  65580. updatable?: boolean;
  65581. instance?: LinesMesh;
  65582. }, scene?: Nullable<Scene>): LinesMesh;
  65583. /**
  65584. * 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.
  65585. * * 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.
  65586. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65587. * * 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.
  65588. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65589. * * 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
  65590. * * 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
  65591. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65593. * * 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
  65594. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65596. * @param name defines the name of the mesh
  65597. * @param options defines the options used to create the mesh
  65598. * @param scene defines the hosting scene
  65599. * @returns the extruded shape mesh
  65600. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65602. */
  65603. static ExtrudeShape(name: string, options: {
  65604. shape: Vector3[];
  65605. path: Vector3[];
  65606. scale?: number;
  65607. rotation?: number;
  65608. cap?: number;
  65609. updatable?: boolean;
  65610. sideOrientation?: number;
  65611. frontUVs?: Vector4;
  65612. backUVs?: Vector4;
  65613. instance?: Mesh;
  65614. invertUV?: boolean;
  65615. }, scene?: Nullable<Scene>): Mesh;
  65616. /**
  65617. * Creates an custom extruded shape mesh.
  65618. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65619. * * 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.
  65620. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65621. * * 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
  65622. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65623. * * 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
  65624. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65625. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65626. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65627. * * 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
  65628. * * 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
  65629. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65631. * * 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
  65632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65634. * @param name defines the name of the mesh
  65635. * @param options defines the options used to create the mesh
  65636. * @param scene defines the hosting scene
  65637. * @returns the custom extruded shape mesh
  65638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65641. */
  65642. static ExtrudeShapeCustom(name: string, options: {
  65643. shape: Vector3[];
  65644. path: Vector3[];
  65645. scaleFunction?: any;
  65646. rotationFunction?: any;
  65647. ribbonCloseArray?: boolean;
  65648. ribbonClosePath?: boolean;
  65649. cap?: number;
  65650. updatable?: boolean;
  65651. sideOrientation?: number;
  65652. frontUVs?: Vector4;
  65653. backUVs?: Vector4;
  65654. instance?: Mesh;
  65655. invertUV?: boolean;
  65656. }, scene?: Nullable<Scene>): Mesh;
  65657. /**
  65658. * Creates lathe mesh.
  65659. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65660. * * 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
  65661. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65662. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65663. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65664. * * 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
  65665. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65666. * * 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
  65667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65668. * * 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
  65669. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65671. * @param name defines the name of the mesh
  65672. * @param options defines the options used to create the mesh
  65673. * @param scene defines the hosting scene
  65674. * @returns the lathe mesh
  65675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65676. */
  65677. static CreateLathe(name: string, options: {
  65678. shape: Vector3[];
  65679. radius?: number;
  65680. tessellation?: number;
  65681. clip?: number;
  65682. arc?: number;
  65683. closed?: boolean;
  65684. updatable?: boolean;
  65685. sideOrientation?: number;
  65686. frontUVs?: Vector4;
  65687. backUVs?: Vector4;
  65688. cap?: number;
  65689. invertUV?: boolean;
  65690. }, scene?: Nullable<Scene>): Mesh;
  65691. /**
  65692. * Creates a tiled plane mesh
  65693. * * You can set a limited pattern arrangement with the tiles
  65694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65695. * * 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
  65696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65697. * @param name defines the name of the mesh
  65698. * @param options defines the options used to create the mesh
  65699. * @param scene defines the hosting scene
  65700. * @returns the plane mesh
  65701. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65702. */
  65703. static CreateTiledPlane(name: string, options: {
  65704. pattern?: number;
  65705. tileSize?: number;
  65706. tileWidth?: number;
  65707. tileHeight?: number;
  65708. size?: number;
  65709. width?: number;
  65710. height?: number;
  65711. alignHorizontal?: number;
  65712. alignVertical?: number;
  65713. sideOrientation?: number;
  65714. frontUVs?: Vector4;
  65715. backUVs?: Vector4;
  65716. updatable?: boolean;
  65717. }, scene?: Nullable<Scene>): Mesh;
  65718. /**
  65719. * Creates a plane mesh
  65720. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65721. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65722. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65724. * * 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
  65725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65726. * @param name defines the name of the mesh
  65727. * @param options defines the options used to create the mesh
  65728. * @param scene defines the hosting scene
  65729. * @returns the plane mesh
  65730. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65731. */
  65732. static CreatePlane(name: string, options: {
  65733. size?: number;
  65734. width?: number;
  65735. height?: number;
  65736. sideOrientation?: number;
  65737. frontUVs?: Vector4;
  65738. backUVs?: Vector4;
  65739. updatable?: boolean;
  65740. sourcePlane?: Plane;
  65741. }, scene?: Nullable<Scene>): Mesh;
  65742. /**
  65743. * Creates a ground mesh
  65744. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65745. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65747. * @param name defines the name of the mesh
  65748. * @param options defines the options used to create the mesh
  65749. * @param scene defines the hosting scene
  65750. * @returns the ground mesh
  65751. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65752. */
  65753. static CreateGround(name: string, options: {
  65754. width?: number;
  65755. height?: number;
  65756. subdivisions?: number;
  65757. subdivisionsX?: number;
  65758. subdivisionsY?: number;
  65759. updatable?: boolean;
  65760. }, scene?: Nullable<Scene>): Mesh;
  65761. /**
  65762. * Creates a tiled ground mesh
  65763. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65764. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65765. * * 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
  65766. * * 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
  65767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65768. * @param name defines the name of the mesh
  65769. * @param options defines the options used to create the mesh
  65770. * @param scene defines the hosting scene
  65771. * @returns the tiled ground mesh
  65772. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65773. */
  65774. static CreateTiledGround(name: string, options: {
  65775. xmin: number;
  65776. zmin: number;
  65777. xmax: number;
  65778. zmax: number;
  65779. subdivisions?: {
  65780. w: number;
  65781. h: number;
  65782. };
  65783. precision?: {
  65784. w: number;
  65785. h: number;
  65786. };
  65787. updatable?: boolean;
  65788. }, scene?: Nullable<Scene>): Mesh;
  65789. /**
  65790. * Creates a ground mesh from a height map
  65791. * * The parameter `url` sets the URL of the height map image resource.
  65792. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65793. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65794. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65795. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65796. * * 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.
  65797. * * 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).
  65798. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65800. * @param name defines the name of the mesh
  65801. * @param url defines the url to the height map
  65802. * @param options defines the options used to create the mesh
  65803. * @param scene defines the hosting scene
  65804. * @returns the ground mesh
  65805. * @see https://doc.babylonjs.com/babylon101/height_map
  65806. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65807. */
  65808. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65809. width?: number;
  65810. height?: number;
  65811. subdivisions?: number;
  65812. minHeight?: number;
  65813. maxHeight?: number;
  65814. colorFilter?: Color3;
  65815. alphaFilter?: number;
  65816. updatable?: boolean;
  65817. onReady?: (mesh: GroundMesh) => void;
  65818. }, scene?: Nullable<Scene>): GroundMesh;
  65819. /**
  65820. * Creates a polygon mesh
  65821. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65822. * * 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
  65823. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65825. * * 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)
  65826. * * Remember you can only change the shape positions, not their number when updating a polygon
  65827. * @param name defines the name of the mesh
  65828. * @param options defines the options used to create the mesh
  65829. * @param scene defines the hosting scene
  65830. * @param earcutInjection can be used to inject your own earcut reference
  65831. * @returns the polygon mesh
  65832. */
  65833. static CreatePolygon(name: string, options: {
  65834. shape: Vector3[];
  65835. holes?: Vector3[][];
  65836. depth?: number;
  65837. faceUV?: Vector4[];
  65838. faceColors?: Color4[];
  65839. updatable?: boolean;
  65840. sideOrientation?: number;
  65841. frontUVs?: Vector4;
  65842. backUVs?: Vector4;
  65843. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65844. /**
  65845. * Creates an extruded polygon mesh, with depth in the Y direction.
  65846. * * 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)
  65847. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65848. * @param name defines the name of the mesh
  65849. * @param options defines the options used to create the mesh
  65850. * @param scene defines the hosting scene
  65851. * @param earcutInjection can be used to inject your own earcut reference
  65852. * @returns the polygon mesh
  65853. */
  65854. static ExtrudePolygon(name: string, options: {
  65855. shape: Vector3[];
  65856. holes?: Vector3[][];
  65857. depth?: number;
  65858. faceUV?: Vector4[];
  65859. faceColors?: Color4[];
  65860. updatable?: boolean;
  65861. sideOrientation?: number;
  65862. frontUVs?: Vector4;
  65863. backUVs?: Vector4;
  65864. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65865. /**
  65866. * Creates a tube mesh.
  65867. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65868. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65869. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65870. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65871. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65872. * * 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)
  65873. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65874. * * 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
  65875. * * 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
  65876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65877. * * 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
  65878. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65880. * @param name defines the name of the mesh
  65881. * @param options defines the options used to create the mesh
  65882. * @param scene defines the hosting scene
  65883. * @returns the tube mesh
  65884. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65885. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65886. */
  65887. static CreateTube(name: string, options: {
  65888. path: Vector3[];
  65889. radius?: number;
  65890. tessellation?: number;
  65891. radiusFunction?: {
  65892. (i: number, distance: number): number;
  65893. };
  65894. cap?: number;
  65895. arc?: number;
  65896. updatable?: boolean;
  65897. sideOrientation?: number;
  65898. frontUVs?: Vector4;
  65899. backUVs?: Vector4;
  65900. instance?: Mesh;
  65901. invertUV?: boolean;
  65902. }, scene?: Nullable<Scene>): Mesh;
  65903. /**
  65904. * Creates a polyhedron mesh
  65905. * * 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
  65906. * * The parameter `size` (positive float, default 1) sets the polygon size
  65907. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65908. * * 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`
  65909. * * 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
  65910. * * 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)`)
  65911. * * 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
  65912. * * 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
  65913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65914. * * 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
  65915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65916. * @param name defines the name of the mesh
  65917. * @param options defines the options used to create the mesh
  65918. * @param scene defines the hosting scene
  65919. * @returns the polyhedron mesh
  65920. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65921. */
  65922. static CreatePolyhedron(name: string, options: {
  65923. type?: number;
  65924. size?: number;
  65925. sizeX?: number;
  65926. sizeY?: number;
  65927. sizeZ?: number;
  65928. custom?: any;
  65929. faceUV?: Vector4[];
  65930. faceColors?: Color4[];
  65931. flat?: boolean;
  65932. updatable?: boolean;
  65933. sideOrientation?: number;
  65934. frontUVs?: Vector4;
  65935. backUVs?: Vector4;
  65936. }, scene?: Nullable<Scene>): Mesh;
  65937. /**
  65938. * Creates a decal mesh.
  65939. * 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
  65940. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65941. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65942. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65943. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65944. * @param name defines the name of the mesh
  65945. * @param sourceMesh defines the mesh where the decal must be applied
  65946. * @param options defines the options used to create the mesh
  65947. * @param scene defines the hosting scene
  65948. * @returns the decal mesh
  65949. * @see https://doc.babylonjs.com/how_to/decals
  65950. */
  65951. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65952. position?: Vector3;
  65953. normal?: Vector3;
  65954. size?: Vector3;
  65955. angle?: number;
  65956. }): Mesh;
  65957. }
  65958. }
  65959. declare module BABYLON {
  65960. /**
  65961. * A simplifier interface for future simplification implementations
  65962. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65963. */
  65964. export interface ISimplifier {
  65965. /**
  65966. * Simplification of a given mesh according to the given settings.
  65967. * Since this requires computation, it is assumed that the function runs async.
  65968. * @param settings The settings of the simplification, including quality and distance
  65969. * @param successCallback A callback that will be called after the mesh was simplified.
  65970. * @param errorCallback in case of an error, this callback will be called. optional.
  65971. */
  65972. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65973. }
  65974. /**
  65975. * Expected simplification settings.
  65976. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65977. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65978. */
  65979. export interface ISimplificationSettings {
  65980. /**
  65981. * Gets or sets the expected quality
  65982. */
  65983. quality: number;
  65984. /**
  65985. * Gets or sets the distance when this optimized version should be used
  65986. */
  65987. distance: number;
  65988. /**
  65989. * Gets an already optimized mesh
  65990. */
  65991. optimizeMesh?: boolean;
  65992. }
  65993. /**
  65994. * Class used to specify simplification options
  65995. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65996. */
  65997. export class SimplificationSettings implements ISimplificationSettings {
  65998. /** expected quality */
  65999. quality: number;
  66000. /** distance when this optimized version should be used */
  66001. distance: number;
  66002. /** already optimized mesh */
  66003. optimizeMesh?: boolean | undefined;
  66004. /**
  66005. * Creates a SimplificationSettings
  66006. * @param quality expected quality
  66007. * @param distance distance when this optimized version should be used
  66008. * @param optimizeMesh already optimized mesh
  66009. */
  66010. constructor(
  66011. /** expected quality */
  66012. quality: number,
  66013. /** distance when this optimized version should be used */
  66014. distance: number,
  66015. /** already optimized mesh */
  66016. optimizeMesh?: boolean | undefined);
  66017. }
  66018. /**
  66019. * Interface used to define a simplification task
  66020. */
  66021. export interface ISimplificationTask {
  66022. /**
  66023. * Array of settings
  66024. */
  66025. settings: Array<ISimplificationSettings>;
  66026. /**
  66027. * Simplification type
  66028. */
  66029. simplificationType: SimplificationType;
  66030. /**
  66031. * Mesh to simplify
  66032. */
  66033. mesh: Mesh;
  66034. /**
  66035. * Callback called on success
  66036. */
  66037. successCallback?: () => void;
  66038. /**
  66039. * Defines if parallel processing can be used
  66040. */
  66041. parallelProcessing: boolean;
  66042. }
  66043. /**
  66044. * Queue used to order the simplification tasks
  66045. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66046. */
  66047. export class SimplificationQueue {
  66048. private _simplificationArray;
  66049. /**
  66050. * Gets a boolean indicating that the process is still running
  66051. */
  66052. running: boolean;
  66053. /**
  66054. * Creates a new queue
  66055. */
  66056. constructor();
  66057. /**
  66058. * Adds a new simplification task
  66059. * @param task defines a task to add
  66060. */
  66061. addTask(task: ISimplificationTask): void;
  66062. /**
  66063. * Execute next task
  66064. */
  66065. executeNext(): void;
  66066. /**
  66067. * Execute a simplification task
  66068. * @param task defines the task to run
  66069. */
  66070. runSimplification(task: ISimplificationTask): void;
  66071. private getSimplifier;
  66072. }
  66073. /**
  66074. * The implemented types of simplification
  66075. * At the moment only Quadratic Error Decimation is implemented
  66076. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66077. */
  66078. export enum SimplificationType {
  66079. /** Quadratic error decimation */
  66080. QUADRATIC = 0
  66081. }
  66082. /**
  66083. * An implementation of the Quadratic Error simplification algorithm.
  66084. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66085. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66086. * @author RaananW
  66087. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66088. */
  66089. export class QuadraticErrorSimplification implements ISimplifier {
  66090. private _mesh;
  66091. private triangles;
  66092. private vertices;
  66093. private references;
  66094. private _reconstructedMesh;
  66095. /** Gets or sets the number pf sync interations */
  66096. syncIterations: number;
  66097. /** Gets or sets the aggressiveness of the simplifier */
  66098. aggressiveness: number;
  66099. /** Gets or sets the number of allowed iterations for decimation */
  66100. decimationIterations: number;
  66101. /** Gets or sets the espilon to use for bounding box computation */
  66102. boundingBoxEpsilon: number;
  66103. /**
  66104. * Creates a new QuadraticErrorSimplification
  66105. * @param _mesh defines the target mesh
  66106. */
  66107. constructor(_mesh: Mesh);
  66108. /**
  66109. * Simplification of a given mesh according to the given settings.
  66110. * Since this requires computation, it is assumed that the function runs async.
  66111. * @param settings The settings of the simplification, including quality and distance
  66112. * @param successCallback A callback that will be called after the mesh was simplified.
  66113. */
  66114. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66115. private runDecimation;
  66116. private initWithMesh;
  66117. private init;
  66118. private reconstructMesh;
  66119. private initDecimatedMesh;
  66120. private isFlipped;
  66121. private updateTriangles;
  66122. private identifyBorder;
  66123. private updateMesh;
  66124. private vertexError;
  66125. private calculateError;
  66126. }
  66127. }
  66128. declare module BABYLON {
  66129. interface Scene {
  66130. /** @hidden (Backing field) */
  66131. _simplificationQueue: SimplificationQueue;
  66132. /**
  66133. * Gets or sets the simplification queue attached to the scene
  66134. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66135. */
  66136. simplificationQueue: SimplificationQueue;
  66137. }
  66138. interface Mesh {
  66139. /**
  66140. * Simplify the mesh according to the given array of settings.
  66141. * Function will return immediately and will simplify async
  66142. * @param settings a collection of simplification settings
  66143. * @param parallelProcessing should all levels calculate parallel or one after the other
  66144. * @param simplificationType the type of simplification to run
  66145. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66146. * @returns the current mesh
  66147. */
  66148. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66149. }
  66150. /**
  66151. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66152. * created in a scene
  66153. */
  66154. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66155. /**
  66156. * The component name helpfull to identify the component in the list of scene components.
  66157. */
  66158. readonly name: string;
  66159. /**
  66160. * The scene the component belongs to.
  66161. */
  66162. scene: Scene;
  66163. /**
  66164. * Creates a new instance of the component for the given scene
  66165. * @param scene Defines the scene to register the component in
  66166. */
  66167. constructor(scene: Scene);
  66168. /**
  66169. * Registers the component in a given scene
  66170. */
  66171. register(): void;
  66172. /**
  66173. * Rebuilds the elements related to this component in case of
  66174. * context lost for instance.
  66175. */
  66176. rebuild(): void;
  66177. /**
  66178. * Disposes the component and the associated ressources
  66179. */
  66180. dispose(): void;
  66181. private _beforeCameraUpdate;
  66182. }
  66183. }
  66184. declare module BABYLON {
  66185. interface Mesh {
  66186. /**
  66187. * Creates a new thin instance
  66188. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66189. * @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
  66190. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66191. */
  66192. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66193. /**
  66194. * Adds the transformation (matrix) of the current mesh as a thin instance
  66195. * @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
  66196. * @returns the thin instance index number
  66197. */
  66198. thinInstanceAddSelf(refresh: boolean): number;
  66199. /**
  66200. * Registers a custom attribute to be used with thin instances
  66201. * @param kind name of the attribute
  66202. * @param stride size in floats of the attribute
  66203. */
  66204. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66205. /**
  66206. * Sets the matrix of a thin instance
  66207. * @param index index of the thin instance
  66208. * @param matrix matrix to set
  66209. * @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
  66210. */
  66211. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66212. /**
  66213. * Sets the value of a custom attribute for a thin instance
  66214. * @param kind name of the attribute
  66215. * @param index index of the thin instance
  66216. * @param value value to set
  66217. * @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
  66218. */
  66219. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66220. /**
  66221. * 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.
  66222. */
  66223. thinInstanceCount: number;
  66224. /**
  66225. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66226. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66227. * @param buffer buffer to set
  66228. * @param stride size in floats of each value of the buffer
  66229. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66230. */
  66231. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66232. /**
  66233. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66234. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66235. */
  66236. thinInstanceBufferUpdated(kind: string): void;
  66237. /**
  66238. * Refreshes the bounding info, taking into account all the thin instances defined
  66239. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66240. */
  66241. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66242. /** @hidden */
  66243. _thinInstanceInitializeUserStorage(): void;
  66244. /** @hidden */
  66245. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66246. /** @hidden */
  66247. _userThinInstanceBuffersStorage: {
  66248. data: {
  66249. [key: string]: Float32Array;
  66250. };
  66251. sizes: {
  66252. [key: string]: number;
  66253. };
  66254. vertexBuffers: {
  66255. [key: string]: Nullable<VertexBuffer>;
  66256. };
  66257. strides: {
  66258. [key: string]: number;
  66259. };
  66260. };
  66261. }
  66262. }
  66263. declare module BABYLON {
  66264. /**
  66265. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66266. */
  66267. export interface INavigationEnginePlugin {
  66268. /**
  66269. * plugin name
  66270. */
  66271. name: string;
  66272. /**
  66273. * Creates a navigation mesh
  66274. * @param meshes array of all the geometry used to compute the navigatio mesh
  66275. * @param parameters bunch of parameters used to filter geometry
  66276. */
  66277. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66278. /**
  66279. * Create a navigation mesh debug mesh
  66280. * @param scene is where the mesh will be added
  66281. * @returns debug display mesh
  66282. */
  66283. createDebugNavMesh(scene: Scene): Mesh;
  66284. /**
  66285. * Get a navigation mesh constrained position, closest to the parameter position
  66286. * @param position world position
  66287. * @returns the closest point to position constrained by the navigation mesh
  66288. */
  66289. getClosestPoint(position: Vector3): Vector3;
  66290. /**
  66291. * Get a navigation mesh constrained position, closest to the parameter position
  66292. * @param position world position
  66293. * @param result output the closest point to position constrained by the navigation mesh
  66294. */
  66295. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66296. /**
  66297. * Get a navigation mesh constrained position, within a particular radius
  66298. * @param position world position
  66299. * @param maxRadius the maximum distance to the constrained world position
  66300. * @returns the closest point to position constrained by the navigation mesh
  66301. */
  66302. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66303. /**
  66304. * Get a navigation mesh constrained position, within a particular radius
  66305. * @param position world position
  66306. * @param maxRadius the maximum distance to the constrained world position
  66307. * @param result output the closest point to position constrained by the navigation mesh
  66308. */
  66309. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66310. /**
  66311. * Compute the final position from a segment made of destination-position
  66312. * @param position world position
  66313. * @param destination world position
  66314. * @returns the resulting point along the navmesh
  66315. */
  66316. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66317. /**
  66318. * Compute the final position from a segment made of destination-position
  66319. * @param position world position
  66320. * @param destination world position
  66321. * @param result output the resulting point along the navmesh
  66322. */
  66323. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66324. /**
  66325. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66326. * @param start world position
  66327. * @param end world position
  66328. * @returns array containing world position composing the path
  66329. */
  66330. computePath(start: Vector3, end: Vector3): Vector3[];
  66331. /**
  66332. * If this plugin is supported
  66333. * @returns true if plugin is supported
  66334. */
  66335. isSupported(): boolean;
  66336. /**
  66337. * Create a new Crowd so you can add agents
  66338. * @param maxAgents the maximum agent count in the crowd
  66339. * @param maxAgentRadius the maximum radius an agent can have
  66340. * @param scene to attach the crowd to
  66341. * @returns the crowd you can add agents to
  66342. */
  66343. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66344. /**
  66345. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66346. * The queries will try to find a solution within those bounds
  66347. * default is (1,1,1)
  66348. * @param extent x,y,z value that define the extent around the queries point of reference
  66349. */
  66350. setDefaultQueryExtent(extent: Vector3): void;
  66351. /**
  66352. * Get the Bounding box extent specified by setDefaultQueryExtent
  66353. * @returns the box extent values
  66354. */
  66355. getDefaultQueryExtent(): Vector3;
  66356. /**
  66357. * build the navmesh from a previously saved state using getNavmeshData
  66358. * @param data the Uint8Array returned by getNavmeshData
  66359. */
  66360. buildFromNavmeshData(data: Uint8Array): void;
  66361. /**
  66362. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66363. * @returns data the Uint8Array that can be saved and reused
  66364. */
  66365. getNavmeshData(): Uint8Array;
  66366. /**
  66367. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66368. * @param result output the box extent values
  66369. */
  66370. getDefaultQueryExtentToRef(result: Vector3): void;
  66371. /**
  66372. * Release all resources
  66373. */
  66374. dispose(): void;
  66375. }
  66376. /**
  66377. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66378. */
  66379. export interface ICrowd {
  66380. /**
  66381. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66382. * You can attach anything to that node. The node position is updated in the scene update tick.
  66383. * @param pos world position that will be constrained by the navigation mesh
  66384. * @param parameters agent parameters
  66385. * @param transform hooked to the agent that will be update by the scene
  66386. * @returns agent index
  66387. */
  66388. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66389. /**
  66390. * Returns the agent position in world space
  66391. * @param index agent index returned by addAgent
  66392. * @returns world space position
  66393. */
  66394. getAgentPosition(index: number): Vector3;
  66395. /**
  66396. * Gets the agent position result in world space
  66397. * @param index agent index returned by addAgent
  66398. * @param result output world space position
  66399. */
  66400. getAgentPositionToRef(index: number, result: Vector3): void;
  66401. /**
  66402. * Gets the agent velocity in world space
  66403. * @param index agent index returned by addAgent
  66404. * @returns world space velocity
  66405. */
  66406. getAgentVelocity(index: number): Vector3;
  66407. /**
  66408. * Gets the agent velocity result in world space
  66409. * @param index agent index returned by addAgent
  66410. * @param result output world space velocity
  66411. */
  66412. getAgentVelocityToRef(index: number, result: Vector3): void;
  66413. /**
  66414. * remove a particular agent previously created
  66415. * @param index agent index returned by addAgent
  66416. */
  66417. removeAgent(index: number): void;
  66418. /**
  66419. * get the list of all agents attached to this crowd
  66420. * @returns list of agent indices
  66421. */
  66422. getAgents(): number[];
  66423. /**
  66424. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66425. * @param deltaTime in seconds
  66426. */
  66427. update(deltaTime: number): void;
  66428. /**
  66429. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66430. * @param index agent index returned by addAgent
  66431. * @param destination targeted world position
  66432. */
  66433. agentGoto(index: number, destination: Vector3): void;
  66434. /**
  66435. * Teleport the agent to a new position
  66436. * @param index agent index returned by addAgent
  66437. * @param destination targeted world position
  66438. */
  66439. agentTeleport(index: number, destination: Vector3): void;
  66440. /**
  66441. * Update agent parameters
  66442. * @param index agent index returned by addAgent
  66443. * @param parameters agent parameters
  66444. */
  66445. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66446. /**
  66447. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66448. * The queries will try to find a solution within those bounds
  66449. * default is (1,1,1)
  66450. * @param extent x,y,z value that define the extent around the queries point of reference
  66451. */
  66452. setDefaultQueryExtent(extent: Vector3): void;
  66453. /**
  66454. * Get the Bounding box extent specified by setDefaultQueryExtent
  66455. * @returns the box extent values
  66456. */
  66457. getDefaultQueryExtent(): Vector3;
  66458. /**
  66459. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66460. * @param result output the box extent values
  66461. */
  66462. getDefaultQueryExtentToRef(result: Vector3): void;
  66463. /**
  66464. * Release all resources
  66465. */
  66466. dispose(): void;
  66467. }
  66468. /**
  66469. * Configures an agent
  66470. */
  66471. export interface IAgentParameters {
  66472. /**
  66473. * Agent radius. [Limit: >= 0]
  66474. */
  66475. radius: number;
  66476. /**
  66477. * Agent height. [Limit: > 0]
  66478. */
  66479. height: number;
  66480. /**
  66481. * Maximum allowed acceleration. [Limit: >= 0]
  66482. */
  66483. maxAcceleration: number;
  66484. /**
  66485. * Maximum allowed speed. [Limit: >= 0]
  66486. */
  66487. maxSpeed: number;
  66488. /**
  66489. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66490. */
  66491. collisionQueryRange: number;
  66492. /**
  66493. * The path visibility optimization range. [Limit: > 0]
  66494. */
  66495. pathOptimizationRange: number;
  66496. /**
  66497. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66498. */
  66499. separationWeight: number;
  66500. }
  66501. /**
  66502. * Configures the navigation mesh creation
  66503. */
  66504. export interface INavMeshParameters {
  66505. /**
  66506. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66507. */
  66508. cs: number;
  66509. /**
  66510. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66511. */
  66512. ch: number;
  66513. /**
  66514. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66515. */
  66516. walkableSlopeAngle: number;
  66517. /**
  66518. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66519. * be considered walkable. [Limit: >= 3] [Units: vx]
  66520. */
  66521. walkableHeight: number;
  66522. /**
  66523. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66524. */
  66525. walkableClimb: number;
  66526. /**
  66527. * The distance to erode/shrink the walkable area of the heightfield away from
  66528. * obstructions. [Limit: >=0] [Units: vx]
  66529. */
  66530. walkableRadius: number;
  66531. /**
  66532. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66533. */
  66534. maxEdgeLen: number;
  66535. /**
  66536. * The maximum distance a simplfied contour's border edges should deviate
  66537. * the original raw contour. [Limit: >=0] [Units: vx]
  66538. */
  66539. maxSimplificationError: number;
  66540. /**
  66541. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66542. */
  66543. minRegionArea: number;
  66544. /**
  66545. * Any regions with a span count smaller than this value will, if possible,
  66546. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66547. */
  66548. mergeRegionArea: number;
  66549. /**
  66550. * The maximum number of vertices allowed for polygons generated during the
  66551. * contour to polygon conversion process. [Limit: >= 3]
  66552. */
  66553. maxVertsPerPoly: number;
  66554. /**
  66555. * Sets the sampling distance to use when generating the detail mesh.
  66556. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66557. */
  66558. detailSampleDist: number;
  66559. /**
  66560. * The maximum distance the detail mesh surface should deviate from heightfield
  66561. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66562. */
  66563. detailSampleMaxError: number;
  66564. }
  66565. }
  66566. declare module BABYLON {
  66567. /**
  66568. * RecastJS navigation plugin
  66569. */
  66570. export class RecastJSPlugin implements INavigationEnginePlugin {
  66571. /**
  66572. * Reference to the Recast library
  66573. */
  66574. bjsRECAST: any;
  66575. /**
  66576. * plugin name
  66577. */
  66578. name: string;
  66579. /**
  66580. * the first navmesh created. We might extend this to support multiple navmeshes
  66581. */
  66582. navMesh: any;
  66583. /**
  66584. * Initializes the recastJS plugin
  66585. * @param recastInjection can be used to inject your own recast reference
  66586. */
  66587. constructor(recastInjection?: any);
  66588. /**
  66589. * Creates a navigation mesh
  66590. * @param meshes array of all the geometry used to compute the navigatio mesh
  66591. * @param parameters bunch of parameters used to filter geometry
  66592. */
  66593. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66594. /**
  66595. * Create a navigation mesh debug mesh
  66596. * @param scene is where the mesh will be added
  66597. * @returns debug display mesh
  66598. */
  66599. createDebugNavMesh(scene: Scene): Mesh;
  66600. /**
  66601. * Get a navigation mesh constrained position, closest to the parameter position
  66602. * @param position world position
  66603. * @returns the closest point to position constrained by the navigation mesh
  66604. */
  66605. getClosestPoint(position: Vector3): Vector3;
  66606. /**
  66607. * Get a navigation mesh constrained position, closest to the parameter position
  66608. * @param position world position
  66609. * @param result output the closest point to position constrained by the navigation mesh
  66610. */
  66611. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66612. /**
  66613. * Get a navigation mesh constrained position, within a particular radius
  66614. * @param position world position
  66615. * @param maxRadius the maximum distance to the constrained world position
  66616. * @returns the closest point to position constrained by the navigation mesh
  66617. */
  66618. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66619. /**
  66620. * Get a navigation mesh constrained position, within a particular radius
  66621. * @param position world position
  66622. * @param maxRadius the maximum distance to the constrained world position
  66623. * @param result output the closest point to position constrained by the navigation mesh
  66624. */
  66625. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66626. /**
  66627. * Compute the final position from a segment made of destination-position
  66628. * @param position world position
  66629. * @param destination world position
  66630. * @returns the resulting point along the navmesh
  66631. */
  66632. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66633. /**
  66634. * Compute the final position from a segment made of destination-position
  66635. * @param position world position
  66636. * @param destination world position
  66637. * @param result output the resulting point along the navmesh
  66638. */
  66639. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66640. /**
  66641. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66642. * @param start world position
  66643. * @param end world position
  66644. * @returns array containing world position composing the path
  66645. */
  66646. computePath(start: Vector3, end: Vector3): Vector3[];
  66647. /**
  66648. * Create a new Crowd so you can add agents
  66649. * @param maxAgents the maximum agent count in the crowd
  66650. * @param maxAgentRadius the maximum radius an agent can have
  66651. * @param scene to attach the crowd to
  66652. * @returns the crowd you can add agents to
  66653. */
  66654. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66655. /**
  66656. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66657. * The queries will try to find a solution within those bounds
  66658. * default is (1,1,1)
  66659. * @param extent x,y,z value that define the extent around the queries point of reference
  66660. */
  66661. setDefaultQueryExtent(extent: Vector3): void;
  66662. /**
  66663. * Get the Bounding box extent specified by setDefaultQueryExtent
  66664. * @returns the box extent values
  66665. */
  66666. getDefaultQueryExtent(): Vector3;
  66667. /**
  66668. * build the navmesh from a previously saved state using getNavmeshData
  66669. * @param data the Uint8Array returned by getNavmeshData
  66670. */
  66671. buildFromNavmeshData(data: Uint8Array): void;
  66672. /**
  66673. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66674. * @returns data the Uint8Array that can be saved and reused
  66675. */
  66676. getNavmeshData(): Uint8Array;
  66677. /**
  66678. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66679. * @param result output the box extent values
  66680. */
  66681. getDefaultQueryExtentToRef(result: Vector3): void;
  66682. /**
  66683. * Disposes
  66684. */
  66685. dispose(): void;
  66686. /**
  66687. * If this plugin is supported
  66688. * @returns true if plugin is supported
  66689. */
  66690. isSupported(): boolean;
  66691. }
  66692. /**
  66693. * Recast detour crowd implementation
  66694. */
  66695. export class RecastJSCrowd implements ICrowd {
  66696. /**
  66697. * Recast/detour plugin
  66698. */
  66699. bjsRECASTPlugin: RecastJSPlugin;
  66700. /**
  66701. * Link to the detour crowd
  66702. */
  66703. recastCrowd: any;
  66704. /**
  66705. * One transform per agent
  66706. */
  66707. transforms: TransformNode[];
  66708. /**
  66709. * All agents created
  66710. */
  66711. agents: number[];
  66712. /**
  66713. * Link to the scene is kept to unregister the crowd from the scene
  66714. */
  66715. private _scene;
  66716. /**
  66717. * Observer for crowd updates
  66718. */
  66719. private _onBeforeAnimationsObserver;
  66720. /**
  66721. * Constructor
  66722. * @param plugin recastJS plugin
  66723. * @param maxAgents the maximum agent count in the crowd
  66724. * @param maxAgentRadius the maximum radius an agent can have
  66725. * @param scene to attach the crowd to
  66726. * @returns the crowd you can add agents to
  66727. */
  66728. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66729. /**
  66730. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66731. * You can attach anything to that node. The node position is updated in the scene update tick.
  66732. * @param pos world position that will be constrained by the navigation mesh
  66733. * @param parameters agent parameters
  66734. * @param transform hooked to the agent that will be update by the scene
  66735. * @returns agent index
  66736. */
  66737. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66738. /**
  66739. * Returns the agent position in world space
  66740. * @param index agent index returned by addAgent
  66741. * @returns world space position
  66742. */
  66743. getAgentPosition(index: number): Vector3;
  66744. /**
  66745. * Returns the agent position result in world space
  66746. * @param index agent index returned by addAgent
  66747. * @param result output world space position
  66748. */
  66749. getAgentPositionToRef(index: number, result: Vector3): void;
  66750. /**
  66751. * Returns the agent velocity in world space
  66752. * @param index agent index returned by addAgent
  66753. * @returns world space velocity
  66754. */
  66755. getAgentVelocity(index: number): Vector3;
  66756. /**
  66757. * Returns the agent velocity result in world space
  66758. * @param index agent index returned by addAgent
  66759. * @param result output world space velocity
  66760. */
  66761. getAgentVelocityToRef(index: number, result: Vector3): void;
  66762. /**
  66763. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66764. * @param index agent index returned by addAgent
  66765. * @param destination targeted world position
  66766. */
  66767. agentGoto(index: number, destination: Vector3): void;
  66768. /**
  66769. * Teleport the agent to a new position
  66770. * @param index agent index returned by addAgent
  66771. * @param destination targeted world position
  66772. */
  66773. agentTeleport(index: number, destination: Vector3): void;
  66774. /**
  66775. * Update agent parameters
  66776. * @param index agent index returned by addAgent
  66777. * @param parameters agent parameters
  66778. */
  66779. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66780. /**
  66781. * remove a particular agent previously created
  66782. * @param index agent index returned by addAgent
  66783. */
  66784. removeAgent(index: number): void;
  66785. /**
  66786. * get the list of all agents attached to this crowd
  66787. * @returns list of agent indices
  66788. */
  66789. getAgents(): number[];
  66790. /**
  66791. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66792. * @param deltaTime in seconds
  66793. */
  66794. update(deltaTime: number): void;
  66795. /**
  66796. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66797. * The queries will try to find a solution within those bounds
  66798. * default is (1,1,1)
  66799. * @param extent x,y,z value that define the extent around the queries point of reference
  66800. */
  66801. setDefaultQueryExtent(extent: Vector3): void;
  66802. /**
  66803. * Get the Bounding box extent specified by setDefaultQueryExtent
  66804. * @returns the box extent values
  66805. */
  66806. getDefaultQueryExtent(): Vector3;
  66807. /**
  66808. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66809. * @param result output the box extent values
  66810. */
  66811. getDefaultQueryExtentToRef(result: Vector3): void;
  66812. /**
  66813. * Release all resources
  66814. */
  66815. dispose(): void;
  66816. }
  66817. }
  66818. declare module BABYLON {
  66819. /**
  66820. * Class used to enable access to IndexedDB
  66821. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66822. */
  66823. export class Database implements IOfflineProvider {
  66824. private _callbackManifestChecked;
  66825. private _currentSceneUrl;
  66826. private _db;
  66827. private _enableSceneOffline;
  66828. private _enableTexturesOffline;
  66829. private _manifestVersionFound;
  66830. private _mustUpdateRessources;
  66831. private _hasReachedQuota;
  66832. private _isSupported;
  66833. private _idbFactory;
  66834. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66835. private static IsUASupportingBlobStorage;
  66836. /**
  66837. * Gets a boolean indicating if Database storate is enabled (off by default)
  66838. */
  66839. static IDBStorageEnabled: boolean;
  66840. /**
  66841. * Gets a boolean indicating if scene must be saved in the database
  66842. */
  66843. get enableSceneOffline(): boolean;
  66844. /**
  66845. * Gets a boolean indicating if textures must be saved in the database
  66846. */
  66847. get enableTexturesOffline(): boolean;
  66848. /**
  66849. * Creates a new Database
  66850. * @param urlToScene defines the url to load the scene
  66851. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66852. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66853. */
  66854. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66855. private static _ParseURL;
  66856. private static _ReturnFullUrlLocation;
  66857. private _checkManifestFile;
  66858. /**
  66859. * Open the database and make it available
  66860. * @param successCallback defines the callback to call on success
  66861. * @param errorCallback defines the callback to call on error
  66862. */
  66863. open(successCallback: () => void, errorCallback: () => void): void;
  66864. /**
  66865. * Loads an image from the database
  66866. * @param url defines the url to load from
  66867. * @param image defines the target DOM image
  66868. */
  66869. loadImage(url: string, image: HTMLImageElement): void;
  66870. private _loadImageFromDBAsync;
  66871. private _saveImageIntoDBAsync;
  66872. private _checkVersionFromDB;
  66873. private _loadVersionFromDBAsync;
  66874. private _saveVersionIntoDBAsync;
  66875. /**
  66876. * Loads a file from database
  66877. * @param url defines the URL to load from
  66878. * @param sceneLoaded defines a callback to call on success
  66879. * @param progressCallBack defines a callback to call when progress changed
  66880. * @param errorCallback defines a callback to call on error
  66881. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66882. */
  66883. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66884. private _loadFileAsync;
  66885. private _saveFileAsync;
  66886. /**
  66887. * Validates if xhr data is correct
  66888. * @param xhr defines the request to validate
  66889. * @param dataType defines the expected data type
  66890. * @returns true if data is correct
  66891. */
  66892. private static _ValidateXHRData;
  66893. }
  66894. }
  66895. declare module BABYLON {
  66896. /** @hidden */
  66897. export var gpuUpdateParticlesPixelShader: {
  66898. name: string;
  66899. shader: string;
  66900. };
  66901. }
  66902. declare module BABYLON {
  66903. /** @hidden */
  66904. export var gpuUpdateParticlesVertexShader: {
  66905. name: string;
  66906. shader: string;
  66907. };
  66908. }
  66909. declare module BABYLON {
  66910. /** @hidden */
  66911. export var clipPlaneFragmentDeclaration2: {
  66912. name: string;
  66913. shader: string;
  66914. };
  66915. }
  66916. declare module BABYLON {
  66917. /** @hidden */
  66918. export var gpuRenderParticlesPixelShader: {
  66919. name: string;
  66920. shader: string;
  66921. };
  66922. }
  66923. declare module BABYLON {
  66924. /** @hidden */
  66925. export var clipPlaneVertexDeclaration2: {
  66926. name: string;
  66927. shader: string;
  66928. };
  66929. }
  66930. declare module BABYLON {
  66931. /** @hidden */
  66932. export var gpuRenderParticlesVertexShader: {
  66933. name: string;
  66934. shader: string;
  66935. };
  66936. }
  66937. declare module BABYLON {
  66938. /**
  66939. * This represents a GPU particle system in Babylon
  66940. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66941. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66942. */
  66943. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66944. /**
  66945. * The layer mask we are rendering the particles through.
  66946. */
  66947. layerMask: number;
  66948. private _capacity;
  66949. private _activeCount;
  66950. private _currentActiveCount;
  66951. private _accumulatedCount;
  66952. private _renderEffect;
  66953. private _updateEffect;
  66954. private _buffer0;
  66955. private _buffer1;
  66956. private _spriteBuffer;
  66957. private _updateVAO;
  66958. private _renderVAO;
  66959. private _targetIndex;
  66960. private _sourceBuffer;
  66961. private _targetBuffer;
  66962. private _engine;
  66963. private _currentRenderId;
  66964. private _started;
  66965. private _stopped;
  66966. private _timeDelta;
  66967. private _randomTexture;
  66968. private _randomTexture2;
  66969. private _attributesStrideSize;
  66970. private _updateEffectOptions;
  66971. private _randomTextureSize;
  66972. private _actualFrame;
  66973. private _customEffect;
  66974. private readonly _rawTextureWidth;
  66975. /**
  66976. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66977. */
  66978. static get IsSupported(): boolean;
  66979. /**
  66980. * An event triggered when the system is disposed.
  66981. */
  66982. onDisposeObservable: Observable<IParticleSystem>;
  66983. /**
  66984. * Gets the maximum number of particles active at the same time.
  66985. * @returns The max number of active particles.
  66986. */
  66987. getCapacity(): number;
  66988. /**
  66989. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66990. * to override the particles.
  66991. */
  66992. forceDepthWrite: boolean;
  66993. /**
  66994. * Gets or set the number of active particles
  66995. */
  66996. get activeParticleCount(): number;
  66997. set activeParticleCount(value: number);
  66998. private _preWarmDone;
  66999. /**
  67000. * Specifies if the particles are updated in emitter local space or world space.
  67001. */
  67002. isLocal: boolean;
  67003. /**
  67004. * Is this system ready to be used/rendered
  67005. * @return true if the system is ready
  67006. */
  67007. isReady(): boolean;
  67008. /**
  67009. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67010. * @returns True if it has been started, otherwise false.
  67011. */
  67012. isStarted(): boolean;
  67013. /**
  67014. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67015. * @returns True if it has been stopped, otherwise false.
  67016. */
  67017. isStopped(): boolean;
  67018. /**
  67019. * Gets a boolean indicating that the system is stopping
  67020. * @returns true if the system is currently stopping
  67021. */
  67022. isStopping(): boolean;
  67023. /**
  67024. * Gets the number of particles active at the same time.
  67025. * @returns The number of active particles.
  67026. */
  67027. getActiveCount(): number;
  67028. /**
  67029. * Starts the particle system and begins to emit
  67030. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67031. */
  67032. start(delay?: number): void;
  67033. /**
  67034. * Stops the particle system.
  67035. */
  67036. stop(): void;
  67037. /**
  67038. * Remove all active particles
  67039. */
  67040. reset(): void;
  67041. /**
  67042. * Returns the string "GPUParticleSystem"
  67043. * @returns a string containing the class name
  67044. */
  67045. getClassName(): string;
  67046. /**
  67047. * Gets the custom effect used to render the particles
  67048. * @param blendMode Blend mode for which the effect should be retrieved
  67049. * @returns The effect
  67050. */
  67051. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67052. /**
  67053. * Sets the custom effect used to render the particles
  67054. * @param effect The effect to set
  67055. * @param blendMode Blend mode for which the effect should be set
  67056. */
  67057. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67058. /** @hidden */
  67059. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67060. /**
  67061. * Observable that will be called just before the particles are drawn
  67062. */
  67063. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67064. /**
  67065. * Gets the name of the particle vertex shader
  67066. */
  67067. get vertexShaderName(): string;
  67068. private _colorGradientsTexture;
  67069. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67070. /**
  67071. * Adds a new color gradient
  67072. * @param gradient defines the gradient to use (between 0 and 1)
  67073. * @param color1 defines the color to affect to the specified gradient
  67074. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67075. * @returns the current particle system
  67076. */
  67077. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67078. private _refreshColorGradient;
  67079. /** Force the system to rebuild all gradients that need to be resync */
  67080. forceRefreshGradients(): void;
  67081. /**
  67082. * Remove a specific color gradient
  67083. * @param gradient defines the gradient to remove
  67084. * @returns the current particle system
  67085. */
  67086. removeColorGradient(gradient: number): GPUParticleSystem;
  67087. private _angularSpeedGradientsTexture;
  67088. private _sizeGradientsTexture;
  67089. private _velocityGradientsTexture;
  67090. private _limitVelocityGradientsTexture;
  67091. private _dragGradientsTexture;
  67092. private _addFactorGradient;
  67093. /**
  67094. * Adds a new size gradient
  67095. * @param gradient defines the gradient to use (between 0 and 1)
  67096. * @param factor defines the size factor to affect to the specified gradient
  67097. * @returns the current particle system
  67098. */
  67099. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67100. /**
  67101. * Remove a specific size gradient
  67102. * @param gradient defines the gradient to remove
  67103. * @returns the current particle system
  67104. */
  67105. removeSizeGradient(gradient: number): GPUParticleSystem;
  67106. private _refreshFactorGradient;
  67107. /**
  67108. * Adds a new angular speed gradient
  67109. * @param gradient defines the gradient to use (between 0 and 1)
  67110. * @param factor defines the angular speed to affect to the specified gradient
  67111. * @returns the current particle system
  67112. */
  67113. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67114. /**
  67115. * Remove a specific angular speed gradient
  67116. * @param gradient defines the gradient to remove
  67117. * @returns the current particle system
  67118. */
  67119. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67120. /**
  67121. * Adds a new velocity gradient
  67122. * @param gradient defines the gradient to use (between 0 and 1)
  67123. * @param factor defines the velocity to affect to the specified gradient
  67124. * @returns the current particle system
  67125. */
  67126. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67127. /**
  67128. * Remove a specific velocity gradient
  67129. * @param gradient defines the gradient to remove
  67130. * @returns the current particle system
  67131. */
  67132. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67133. /**
  67134. * Adds a new limit velocity gradient
  67135. * @param gradient defines the gradient to use (between 0 and 1)
  67136. * @param factor defines the limit velocity value to affect to the specified gradient
  67137. * @returns the current particle system
  67138. */
  67139. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67140. /**
  67141. * Remove a specific limit velocity gradient
  67142. * @param gradient defines the gradient to remove
  67143. * @returns the current particle system
  67144. */
  67145. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67146. /**
  67147. * Adds a new drag gradient
  67148. * @param gradient defines the gradient to use (between 0 and 1)
  67149. * @param factor defines the drag value to affect to the specified gradient
  67150. * @returns the current particle system
  67151. */
  67152. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67153. /**
  67154. * Remove a specific drag gradient
  67155. * @param gradient defines the gradient to remove
  67156. * @returns the current particle system
  67157. */
  67158. removeDragGradient(gradient: number): GPUParticleSystem;
  67159. /**
  67160. * Not supported by GPUParticleSystem
  67161. * @param gradient defines the gradient to use (between 0 and 1)
  67162. * @param factor defines the emit rate value to affect to the specified gradient
  67163. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67164. * @returns the current particle system
  67165. */
  67166. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67167. /**
  67168. * Not supported by GPUParticleSystem
  67169. * @param gradient defines the gradient to remove
  67170. * @returns the current particle system
  67171. */
  67172. removeEmitRateGradient(gradient: number): IParticleSystem;
  67173. /**
  67174. * Not supported by GPUParticleSystem
  67175. * @param gradient defines the gradient to use (between 0 and 1)
  67176. * @param factor defines the start size value to affect to the specified gradient
  67177. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67178. * @returns the current particle system
  67179. */
  67180. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67181. /**
  67182. * Not supported by GPUParticleSystem
  67183. * @param gradient defines the gradient to remove
  67184. * @returns the current particle system
  67185. */
  67186. removeStartSizeGradient(gradient: number): IParticleSystem;
  67187. /**
  67188. * Not supported by GPUParticleSystem
  67189. * @param gradient defines the gradient to use (between 0 and 1)
  67190. * @param min defines the color remap minimal range
  67191. * @param max defines the color remap maximal range
  67192. * @returns the current particle system
  67193. */
  67194. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67195. /**
  67196. * Not supported by GPUParticleSystem
  67197. * @param gradient defines the gradient to remove
  67198. * @returns the current particle system
  67199. */
  67200. removeColorRemapGradient(): IParticleSystem;
  67201. /**
  67202. * Not supported by GPUParticleSystem
  67203. * @param gradient defines the gradient to use (between 0 and 1)
  67204. * @param min defines the alpha remap minimal range
  67205. * @param max defines the alpha remap maximal range
  67206. * @returns the current particle system
  67207. */
  67208. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67209. /**
  67210. * Not supported by GPUParticleSystem
  67211. * @param gradient defines the gradient to remove
  67212. * @returns the current particle system
  67213. */
  67214. removeAlphaRemapGradient(): IParticleSystem;
  67215. /**
  67216. * Not supported by GPUParticleSystem
  67217. * @param gradient defines the gradient to use (between 0 and 1)
  67218. * @param color defines the color to affect to the specified gradient
  67219. * @returns the current particle system
  67220. */
  67221. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67222. /**
  67223. * Not supported by GPUParticleSystem
  67224. * @param gradient defines the gradient to remove
  67225. * @returns the current particle system
  67226. */
  67227. removeRampGradient(): IParticleSystem;
  67228. /**
  67229. * Not supported by GPUParticleSystem
  67230. * @returns the list of ramp gradients
  67231. */
  67232. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67233. /**
  67234. * Not supported by GPUParticleSystem
  67235. * Gets or sets a boolean indicating that ramp gradients must be used
  67236. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67237. */
  67238. get useRampGradients(): boolean;
  67239. set useRampGradients(value: boolean);
  67240. /**
  67241. * Not supported by GPUParticleSystem
  67242. * @param gradient defines the gradient to use (between 0 and 1)
  67243. * @param factor defines the life time factor to affect to the specified gradient
  67244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67245. * @returns the current particle system
  67246. */
  67247. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67248. /**
  67249. * Not supported by GPUParticleSystem
  67250. * @param gradient defines the gradient to remove
  67251. * @returns the current particle system
  67252. */
  67253. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67254. /**
  67255. * Instantiates a GPU particle system.
  67256. * 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.
  67257. * @param name The name of the particle system
  67258. * @param options The options used to create the system
  67259. * @param scene The scene the particle system belongs to
  67260. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67261. * @param customEffect a custom effect used to change the way particles are rendered by default
  67262. */
  67263. constructor(name: string, options: Partial<{
  67264. capacity: number;
  67265. randomTextureSize: number;
  67266. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67267. protected _reset(): void;
  67268. private _createUpdateVAO;
  67269. private _createRenderVAO;
  67270. private _initialize;
  67271. /** @hidden */
  67272. _recreateUpdateEffect(): void;
  67273. private _getEffect;
  67274. /**
  67275. * Fill the defines array according to the current settings of the particle system
  67276. * @param defines Array to be updated
  67277. * @param blendMode blend mode to take into account when updating the array
  67278. */
  67279. fillDefines(defines: Array<string>, blendMode?: number): void;
  67280. /**
  67281. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67282. * @param uniforms Uniforms array to fill
  67283. * @param attributes Attributes array to fill
  67284. * @param samplers Samplers array to fill
  67285. */
  67286. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67287. /** @hidden */
  67288. _recreateRenderEffect(): Effect;
  67289. /**
  67290. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67291. * @param preWarm defines if we are in the pre-warmimg phase
  67292. */
  67293. animate(preWarm?: boolean): void;
  67294. private _createFactorGradientTexture;
  67295. private _createSizeGradientTexture;
  67296. private _createAngularSpeedGradientTexture;
  67297. private _createVelocityGradientTexture;
  67298. private _createLimitVelocityGradientTexture;
  67299. private _createDragGradientTexture;
  67300. private _createColorGradientTexture;
  67301. /**
  67302. * Renders the particle system in its current state
  67303. * @param preWarm defines if the system should only update the particles but not render them
  67304. * @returns the current number of particles
  67305. */
  67306. render(preWarm?: boolean): number;
  67307. /**
  67308. * Rebuilds the particle system
  67309. */
  67310. rebuild(): void;
  67311. private _releaseBuffers;
  67312. private _releaseVAOs;
  67313. /**
  67314. * Disposes the particle system and free the associated resources
  67315. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67316. */
  67317. dispose(disposeTexture?: boolean): void;
  67318. /**
  67319. * Clones the particle system.
  67320. * @param name The name of the cloned object
  67321. * @param newEmitter The new emitter to use
  67322. * @returns the cloned particle system
  67323. */
  67324. clone(name: string, newEmitter: any): GPUParticleSystem;
  67325. /**
  67326. * Serializes the particle system to a JSON object
  67327. * @param serializeTexture defines if the texture must be serialized as well
  67328. * @returns the JSON object
  67329. */
  67330. serialize(serializeTexture?: boolean): any;
  67331. /**
  67332. * Parses a JSON object to create a GPU particle system.
  67333. * @param parsedParticleSystem The JSON object to parse
  67334. * @param scene The scene to create the particle system in
  67335. * @param rootUrl The root url to use to load external dependencies like texture
  67336. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67337. * @returns the parsed GPU particle system
  67338. */
  67339. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67340. }
  67341. }
  67342. declare module BABYLON {
  67343. /**
  67344. * Represents a set of particle systems working together to create a specific effect
  67345. */
  67346. export class ParticleSystemSet implements IDisposable {
  67347. /**
  67348. * Gets or sets base Assets URL
  67349. */
  67350. static BaseAssetsUrl: string;
  67351. private _emitterCreationOptions;
  67352. private _emitterNode;
  67353. /**
  67354. * Gets the particle system list
  67355. */
  67356. systems: IParticleSystem[];
  67357. /**
  67358. * Gets the emitter node used with this set
  67359. */
  67360. get emitterNode(): Nullable<TransformNode>;
  67361. /**
  67362. * Creates a new emitter mesh as a sphere
  67363. * @param options defines the options used to create the sphere
  67364. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67365. * @param scene defines the hosting scene
  67366. */
  67367. setEmitterAsSphere(options: {
  67368. diameter: number;
  67369. segments: number;
  67370. color: Color3;
  67371. }, renderingGroupId: number, scene: Scene): void;
  67372. /**
  67373. * Starts all particle systems of the set
  67374. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67375. */
  67376. start(emitter?: AbstractMesh): void;
  67377. /**
  67378. * Release all associated resources
  67379. */
  67380. dispose(): void;
  67381. /**
  67382. * Serialize the set into a JSON compatible object
  67383. * @param serializeTexture defines if the texture must be serialized as well
  67384. * @returns a JSON compatible representation of the set
  67385. */
  67386. serialize(serializeTexture?: boolean): any;
  67387. /**
  67388. * Parse a new ParticleSystemSet from a serialized source
  67389. * @param data defines a JSON compatible representation of the set
  67390. * @param scene defines the hosting scene
  67391. * @param gpu defines if we want GPU particles or CPU particles
  67392. * @returns a new ParticleSystemSet
  67393. */
  67394. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67395. }
  67396. }
  67397. declare module BABYLON {
  67398. /**
  67399. * This class is made for on one-liner static method to help creating particle system set.
  67400. */
  67401. export class ParticleHelper {
  67402. /**
  67403. * Gets or sets base Assets URL
  67404. */
  67405. static BaseAssetsUrl: string;
  67406. /** Define the Url to load snippets */
  67407. static SnippetUrl: string;
  67408. /**
  67409. * Create a default particle system that you can tweak
  67410. * @param emitter defines the emitter to use
  67411. * @param capacity defines the system capacity (default is 500 particles)
  67412. * @param scene defines the hosting scene
  67413. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67414. * @returns the new Particle system
  67415. */
  67416. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67417. /**
  67418. * This is the main static method (one-liner) of this helper to create different particle systems
  67419. * @param type This string represents the type to the particle system to create
  67420. * @param scene The scene where the particle system should live
  67421. * @param gpu If the system will use gpu
  67422. * @returns the ParticleSystemSet created
  67423. */
  67424. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67425. /**
  67426. * Static function used to export a particle system to a ParticleSystemSet variable.
  67427. * Please note that the emitter shape is not exported
  67428. * @param systems defines the particle systems to export
  67429. * @returns the created particle system set
  67430. */
  67431. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67432. /**
  67433. * Creates a particle system from a snippet saved in a remote file
  67434. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67435. * @param url defines the url to load from
  67436. * @param scene defines the hosting scene
  67437. * @param gpu If the system will use gpu
  67438. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67439. * @returns a promise that will resolve to the new particle system
  67440. */
  67441. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67442. /**
  67443. * Creates a particle system from a snippet saved by the particle system editor
  67444. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67445. * @param scene defines the hosting scene
  67446. * @param gpu If the system will use gpu
  67447. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67448. * @returns a promise that will resolve to the new particle system
  67449. */
  67450. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67451. }
  67452. }
  67453. declare module BABYLON {
  67454. interface Engine {
  67455. /**
  67456. * Create an effect to use with particle systems.
  67457. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67458. * the particle system for which you want to create a custom effect in the last parameter
  67459. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67460. * @param uniformsNames defines a list of attribute names
  67461. * @param samplers defines an array of string used to represent textures
  67462. * @param defines defines the string containing the defines to use to compile the shaders
  67463. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67464. * @param onCompiled defines a function to call when the effect creation is successful
  67465. * @param onError defines a function to call when the effect creation has failed
  67466. * @param particleSystem the particle system you want to create the effect for
  67467. * @returns the new Effect
  67468. */
  67469. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67470. }
  67471. interface Mesh {
  67472. /**
  67473. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67474. * @returns an array of IParticleSystem
  67475. */
  67476. getEmittedParticleSystems(): IParticleSystem[];
  67477. /**
  67478. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67479. * @returns an array of IParticleSystem
  67480. */
  67481. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67482. }
  67483. }
  67484. declare module BABYLON {
  67485. /** Defines the 4 color options */
  67486. export enum PointColor {
  67487. /** color value */
  67488. Color = 2,
  67489. /** uv value */
  67490. UV = 1,
  67491. /** random value */
  67492. Random = 0,
  67493. /** stated value */
  67494. Stated = 3
  67495. }
  67496. /**
  67497. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67498. * 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.
  67499. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67500. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67501. *
  67502. * Full documentation here : TO BE ENTERED
  67503. */
  67504. export class PointsCloudSystem implements IDisposable {
  67505. /**
  67506. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67507. * Example : var p = SPS.particles[i];
  67508. */
  67509. particles: CloudPoint[];
  67510. /**
  67511. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67512. */
  67513. nbParticles: number;
  67514. /**
  67515. * This a counter for your own usage. It's not set by any SPS functions.
  67516. */
  67517. counter: number;
  67518. /**
  67519. * The PCS name. This name is also given to the underlying mesh.
  67520. */
  67521. name: string;
  67522. /**
  67523. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67524. */
  67525. mesh: Mesh;
  67526. /**
  67527. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67528. * Please read :
  67529. */
  67530. vars: any;
  67531. /**
  67532. * @hidden
  67533. */
  67534. _size: number;
  67535. private _scene;
  67536. private _promises;
  67537. private _positions;
  67538. private _indices;
  67539. private _normals;
  67540. private _colors;
  67541. private _uvs;
  67542. private _indices32;
  67543. private _positions32;
  67544. private _colors32;
  67545. private _uvs32;
  67546. private _updatable;
  67547. private _isVisibilityBoxLocked;
  67548. private _alwaysVisible;
  67549. private _groups;
  67550. private _groupCounter;
  67551. private _computeParticleColor;
  67552. private _computeParticleTexture;
  67553. private _computeParticleRotation;
  67554. private _computeBoundingBox;
  67555. private _isReady;
  67556. /**
  67557. * Creates a PCS (Points Cloud System) object
  67558. * @param name (String) is the PCS name, this will be the underlying mesh name
  67559. * @param pointSize (number) is the size for each point
  67560. * @param scene (Scene) is the scene in which the PCS is added
  67561. * @param options defines the options of the PCS e.g.
  67562. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67563. */
  67564. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67565. updatable?: boolean;
  67566. });
  67567. /**
  67568. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67569. * If no points were added to the PCS, the returned mesh is just a single point.
  67570. * @returns a promise for the created mesh
  67571. */
  67572. buildMeshAsync(): Promise<Mesh>;
  67573. /**
  67574. * @hidden
  67575. */
  67576. private _buildMesh;
  67577. private _addParticle;
  67578. private _randomUnitVector;
  67579. private _getColorIndicesForCoord;
  67580. private _setPointsColorOrUV;
  67581. private _colorFromTexture;
  67582. private _calculateDensity;
  67583. /**
  67584. * Adds points to the PCS in random positions within a unit sphere
  67585. * @param nb (positive integer) the number of particles to be created from this model
  67586. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67587. * @returns the number of groups in the system
  67588. */
  67589. addPoints(nb: number, pointFunction?: any): number;
  67590. /**
  67591. * Adds points to the PCS from the surface of the model shape
  67592. * @param mesh is any Mesh object that will be used as a surface model for the points
  67593. * @param nb (positive integer) the number of particles to be created from this model
  67594. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67595. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67596. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67597. * @returns the number of groups in the system
  67598. */
  67599. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67600. /**
  67601. * Adds points to the PCS inside the model shape
  67602. * @param mesh is any Mesh object that will be used as a surface model for the points
  67603. * @param nb (positive integer) the number of particles to be created from this model
  67604. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67605. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67606. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67607. * @returns the number of groups in the system
  67608. */
  67609. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67610. /**
  67611. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67612. * This method calls `updateParticle()` for each particle of the SPS.
  67613. * For an animated SPS, it is usually called within the render loop.
  67614. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67615. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67616. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67617. * @returns the PCS.
  67618. */
  67619. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67620. /**
  67621. * Disposes the PCS.
  67622. */
  67623. dispose(): void;
  67624. /**
  67625. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67626. * doc :
  67627. * @returns the PCS.
  67628. */
  67629. refreshVisibleSize(): PointsCloudSystem;
  67630. /**
  67631. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67632. * @param size the size (float) of the visibility box
  67633. * note : this doesn't lock the PCS mesh bounding box.
  67634. * doc :
  67635. */
  67636. setVisibilityBox(size: number): void;
  67637. /**
  67638. * Gets whether the PCS is always visible or not
  67639. * doc :
  67640. */
  67641. get isAlwaysVisible(): boolean;
  67642. /**
  67643. * Sets the PCS as always visible or not
  67644. * doc :
  67645. */
  67646. set isAlwaysVisible(val: boolean);
  67647. /**
  67648. * Tells to `setParticles()` to compute the particle rotations or not
  67649. * Default value : false. The PCS is faster when it's set to false
  67650. * Note : particle rotations are only applied to parent particles
  67651. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67652. */
  67653. set computeParticleRotation(val: boolean);
  67654. /**
  67655. * Tells to `setParticles()` to compute the particle colors or not.
  67656. * Default value : true. The PCS is faster when it's set to false.
  67657. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67658. */
  67659. set computeParticleColor(val: boolean);
  67660. set computeParticleTexture(val: boolean);
  67661. /**
  67662. * Gets if `setParticles()` computes the particle colors or not.
  67663. * Default value : false. The PCS is faster when it's set to false.
  67664. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67665. */
  67666. get computeParticleColor(): boolean;
  67667. /**
  67668. * Gets if `setParticles()` computes the particle textures or not.
  67669. * Default value : false. The PCS is faster when it's set to false.
  67670. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67671. */
  67672. get computeParticleTexture(): boolean;
  67673. /**
  67674. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67675. */
  67676. set computeBoundingBox(val: boolean);
  67677. /**
  67678. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67679. */
  67680. get computeBoundingBox(): boolean;
  67681. /**
  67682. * This function does nothing. It may be overwritten to set all the particle first values.
  67683. * The PCS doesn't call this function, you may have to call it by your own.
  67684. * doc :
  67685. */
  67686. initParticles(): void;
  67687. /**
  67688. * This function does nothing. It may be overwritten to recycle a particle
  67689. * The PCS doesn't call this function, you can to call it
  67690. * doc :
  67691. * @param particle The particle to recycle
  67692. * @returns the recycled particle
  67693. */
  67694. recycleParticle(particle: CloudPoint): CloudPoint;
  67695. /**
  67696. * Updates a particle : this function should be overwritten by the user.
  67697. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67698. * doc :
  67699. * @example : just set a particle position or velocity and recycle conditions
  67700. * @param particle The particle to update
  67701. * @returns the updated particle
  67702. */
  67703. updateParticle(particle: CloudPoint): CloudPoint;
  67704. /**
  67705. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67706. * This does nothing and may be overwritten by the user.
  67707. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67708. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67709. * @param update the boolean update value actually passed to setParticles()
  67710. */
  67711. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67712. /**
  67713. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67714. * This will be passed three parameters.
  67715. * This does nothing and may be overwritten by the user.
  67716. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67717. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67718. * @param update the boolean update value actually passed to setParticles()
  67719. */
  67720. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67721. }
  67722. }
  67723. declare module BABYLON {
  67724. /**
  67725. * Represents one particle of a points cloud system.
  67726. */
  67727. export class CloudPoint {
  67728. /**
  67729. * particle global index
  67730. */
  67731. idx: number;
  67732. /**
  67733. * The color of the particle
  67734. */
  67735. color: Nullable<Color4>;
  67736. /**
  67737. * The world space position of the particle.
  67738. */
  67739. position: Vector3;
  67740. /**
  67741. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67742. */
  67743. rotation: Vector3;
  67744. /**
  67745. * The world space rotation quaternion of the particle.
  67746. */
  67747. rotationQuaternion: Nullable<Quaternion>;
  67748. /**
  67749. * The uv of the particle.
  67750. */
  67751. uv: Nullable<Vector2>;
  67752. /**
  67753. * The current speed of the particle.
  67754. */
  67755. velocity: Vector3;
  67756. /**
  67757. * The pivot point in the particle local space.
  67758. */
  67759. pivot: Vector3;
  67760. /**
  67761. * Must the particle be translated from its pivot point in its local space ?
  67762. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67763. * Default : false
  67764. */
  67765. translateFromPivot: boolean;
  67766. /**
  67767. * Index of this particle in the global "positions" array (Internal use)
  67768. * @hidden
  67769. */
  67770. _pos: number;
  67771. /**
  67772. * @hidden Index of this particle in the global "indices" array (Internal use)
  67773. */
  67774. _ind: number;
  67775. /**
  67776. * Group this particle belongs to
  67777. */
  67778. _group: PointsGroup;
  67779. /**
  67780. * Group id of this particle
  67781. */
  67782. groupId: number;
  67783. /**
  67784. * Index of the particle in its group id (Internal use)
  67785. */
  67786. idxInGroup: number;
  67787. /**
  67788. * @hidden Particle BoundingInfo object (Internal use)
  67789. */
  67790. _boundingInfo: BoundingInfo;
  67791. /**
  67792. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67793. */
  67794. _pcs: PointsCloudSystem;
  67795. /**
  67796. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67797. */
  67798. _stillInvisible: boolean;
  67799. /**
  67800. * @hidden Last computed particle rotation matrix
  67801. */
  67802. _rotationMatrix: number[];
  67803. /**
  67804. * Parent particle Id, if any.
  67805. * Default null.
  67806. */
  67807. parentId: Nullable<number>;
  67808. /**
  67809. * @hidden Internal global position in the PCS.
  67810. */
  67811. _globalPosition: Vector3;
  67812. /**
  67813. * Creates a Point Cloud object.
  67814. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67815. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67816. * @param group (PointsGroup) is the group the particle belongs to
  67817. * @param groupId (integer) is the group identifier in the PCS.
  67818. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67819. * @param pcs defines the PCS it is associated to
  67820. */
  67821. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67822. /**
  67823. * get point size
  67824. */
  67825. get size(): Vector3;
  67826. /**
  67827. * Set point size
  67828. */
  67829. set size(scale: Vector3);
  67830. /**
  67831. * Legacy support, changed quaternion to rotationQuaternion
  67832. */
  67833. get quaternion(): Nullable<Quaternion>;
  67834. /**
  67835. * Legacy support, changed quaternion to rotationQuaternion
  67836. */
  67837. set quaternion(q: Nullable<Quaternion>);
  67838. /**
  67839. * Returns a boolean. True if the particle intersects a mesh, else false
  67840. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67841. * @param target is the object (point or mesh) what the intersection is computed against
  67842. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67843. * @returns true if it intersects
  67844. */
  67845. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67846. /**
  67847. * get the rotation matrix of the particle
  67848. * @hidden
  67849. */
  67850. getRotationMatrix(m: Matrix): void;
  67851. }
  67852. /**
  67853. * Represents a group of points in a points cloud system
  67854. * * PCS internal tool, don't use it manually.
  67855. */
  67856. export class PointsGroup {
  67857. /**
  67858. * The group id
  67859. * @hidden
  67860. */
  67861. groupID: number;
  67862. /**
  67863. * image data for group (internal use)
  67864. * @hidden
  67865. */
  67866. _groupImageData: Nullable<ArrayBufferView>;
  67867. /**
  67868. * Image Width (internal use)
  67869. * @hidden
  67870. */
  67871. _groupImgWidth: number;
  67872. /**
  67873. * Image Height (internal use)
  67874. * @hidden
  67875. */
  67876. _groupImgHeight: number;
  67877. /**
  67878. * Custom position function (internal use)
  67879. * @hidden
  67880. */
  67881. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67882. /**
  67883. * density per facet for surface points
  67884. * @hidden
  67885. */
  67886. _groupDensity: number[];
  67887. /**
  67888. * Only when points are colored by texture carries pointer to texture list array
  67889. * @hidden
  67890. */
  67891. _textureNb: number;
  67892. /**
  67893. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67894. * PCS internal tool, don't use it manually.
  67895. * @hidden
  67896. */
  67897. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67898. }
  67899. }
  67900. declare module BABYLON {
  67901. interface Scene {
  67902. /** @hidden (Backing field) */
  67903. _physicsEngine: Nullable<IPhysicsEngine>;
  67904. /** @hidden */
  67905. _physicsTimeAccumulator: number;
  67906. /**
  67907. * Gets the current physics engine
  67908. * @returns a IPhysicsEngine or null if none attached
  67909. */
  67910. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67911. /**
  67912. * Enables physics to the current scene
  67913. * @param gravity defines the scene's gravity for the physics engine
  67914. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67915. * @return a boolean indicating if the physics engine was initialized
  67916. */
  67917. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67918. /**
  67919. * Disables and disposes the physics engine associated with the scene
  67920. */
  67921. disablePhysicsEngine(): void;
  67922. /**
  67923. * Gets a boolean indicating if there is an active physics engine
  67924. * @returns a boolean indicating if there is an active physics engine
  67925. */
  67926. isPhysicsEnabled(): boolean;
  67927. /**
  67928. * Deletes a physics compound impostor
  67929. * @param compound defines the compound to delete
  67930. */
  67931. deleteCompoundImpostor(compound: any): void;
  67932. /**
  67933. * An event triggered when physic simulation is about to be run
  67934. */
  67935. onBeforePhysicsObservable: Observable<Scene>;
  67936. /**
  67937. * An event triggered when physic simulation has been done
  67938. */
  67939. onAfterPhysicsObservable: Observable<Scene>;
  67940. }
  67941. interface AbstractMesh {
  67942. /** @hidden */
  67943. _physicsImpostor: Nullable<PhysicsImpostor>;
  67944. /**
  67945. * Gets or sets impostor used for physic simulation
  67946. * @see https://doc.babylonjs.com/features/physics_engine
  67947. */
  67948. physicsImpostor: Nullable<PhysicsImpostor>;
  67949. /**
  67950. * Gets the current physics impostor
  67951. * @see https://doc.babylonjs.com/features/physics_engine
  67952. * @returns a physics impostor or null
  67953. */
  67954. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67955. /** Apply a physic impulse to the mesh
  67956. * @param force defines the force to apply
  67957. * @param contactPoint defines where to apply the force
  67958. * @returns the current mesh
  67959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67960. */
  67961. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67962. /**
  67963. * Creates a physic joint between two meshes
  67964. * @param otherMesh defines the other mesh to use
  67965. * @param pivot1 defines the pivot to use on this mesh
  67966. * @param pivot2 defines the pivot to use on the other mesh
  67967. * @param options defines additional options (can be plugin dependent)
  67968. * @returns the current mesh
  67969. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67970. */
  67971. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67972. /** @hidden */
  67973. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67974. }
  67975. /**
  67976. * Defines the physics engine scene component responsible to manage a physics engine
  67977. */
  67978. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67979. /**
  67980. * The component name helpful to identify the component in the list of scene components.
  67981. */
  67982. readonly name: string;
  67983. /**
  67984. * The scene the component belongs to.
  67985. */
  67986. scene: Scene;
  67987. /**
  67988. * Creates a new instance of the component for the given scene
  67989. * @param scene Defines the scene to register the component in
  67990. */
  67991. constructor(scene: Scene);
  67992. /**
  67993. * Registers the component in a given scene
  67994. */
  67995. register(): void;
  67996. /**
  67997. * Rebuilds the elements related to this component in case of
  67998. * context lost for instance.
  67999. */
  68000. rebuild(): void;
  68001. /**
  68002. * Disposes the component and the associated ressources
  68003. */
  68004. dispose(): void;
  68005. }
  68006. }
  68007. declare module BABYLON {
  68008. /**
  68009. * A helper for physics simulations
  68010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68011. */
  68012. export class PhysicsHelper {
  68013. private _scene;
  68014. private _physicsEngine;
  68015. /**
  68016. * Initializes the Physics helper
  68017. * @param scene Babylon.js scene
  68018. */
  68019. constructor(scene: Scene);
  68020. /**
  68021. * Applies a radial explosion impulse
  68022. * @param origin the origin of the explosion
  68023. * @param radiusOrEventOptions the radius or the options of radial explosion
  68024. * @param strength the explosion strength
  68025. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68026. * @returns A physics radial explosion event, or null
  68027. */
  68028. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68029. /**
  68030. * Applies a radial explosion force
  68031. * @param origin the origin of the explosion
  68032. * @param radiusOrEventOptions the radius or the options of radial explosion
  68033. * @param strength the explosion strength
  68034. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68035. * @returns A physics radial explosion event, or null
  68036. */
  68037. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68038. /**
  68039. * Creates a gravitational field
  68040. * @param origin the origin of the explosion
  68041. * @param radiusOrEventOptions the radius or the options of radial explosion
  68042. * @param strength the explosion strength
  68043. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68044. * @returns A physics gravitational field event, or null
  68045. */
  68046. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68047. /**
  68048. * Creates a physics updraft event
  68049. * @param origin the origin of the updraft
  68050. * @param radiusOrEventOptions the radius or the options of the updraft
  68051. * @param strength the strength of the updraft
  68052. * @param height the height of the updraft
  68053. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68054. * @returns A physics updraft event, or null
  68055. */
  68056. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68057. /**
  68058. * Creates a physics vortex event
  68059. * @param origin the of the vortex
  68060. * @param radiusOrEventOptions the radius or the options of the vortex
  68061. * @param strength the strength of the vortex
  68062. * @param height the height of the vortex
  68063. * @returns a Physics vortex event, or null
  68064. * A physics vortex event or null
  68065. */
  68066. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68067. }
  68068. /**
  68069. * Represents a physics radial explosion event
  68070. */
  68071. class PhysicsRadialExplosionEvent {
  68072. private _scene;
  68073. private _options;
  68074. private _sphere;
  68075. private _dataFetched;
  68076. /**
  68077. * Initializes a radial explosioin event
  68078. * @param _scene BabylonJS scene
  68079. * @param _options The options for the vortex event
  68080. */
  68081. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68082. /**
  68083. * Returns the data related to the radial explosion event (sphere).
  68084. * @returns The radial explosion event data
  68085. */
  68086. getData(): PhysicsRadialExplosionEventData;
  68087. /**
  68088. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68089. * @param impostor A physics imposter
  68090. * @param origin the origin of the explosion
  68091. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68092. */
  68093. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68094. /**
  68095. * Triggers affecterd impostors callbacks
  68096. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68097. */
  68098. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68099. /**
  68100. * Disposes the sphere.
  68101. * @param force Specifies if the sphere should be disposed by force
  68102. */
  68103. dispose(force?: boolean): void;
  68104. /*** Helpers ***/
  68105. private _prepareSphere;
  68106. private _intersectsWithSphere;
  68107. }
  68108. /**
  68109. * Represents a gravitational field event
  68110. */
  68111. class PhysicsGravitationalFieldEvent {
  68112. private _physicsHelper;
  68113. private _scene;
  68114. private _origin;
  68115. private _options;
  68116. private _tickCallback;
  68117. private _sphere;
  68118. private _dataFetched;
  68119. /**
  68120. * Initializes the physics gravitational field event
  68121. * @param _physicsHelper A physics helper
  68122. * @param _scene BabylonJS scene
  68123. * @param _origin The origin position of the gravitational field event
  68124. * @param _options The options for the vortex event
  68125. */
  68126. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68127. /**
  68128. * Returns the data related to the gravitational field event (sphere).
  68129. * @returns A gravitational field event
  68130. */
  68131. getData(): PhysicsGravitationalFieldEventData;
  68132. /**
  68133. * Enables the gravitational field.
  68134. */
  68135. enable(): void;
  68136. /**
  68137. * Disables the gravitational field.
  68138. */
  68139. disable(): void;
  68140. /**
  68141. * Disposes the sphere.
  68142. * @param force The force to dispose from the gravitational field event
  68143. */
  68144. dispose(force?: boolean): void;
  68145. private _tick;
  68146. }
  68147. /**
  68148. * Represents a physics updraft event
  68149. */
  68150. class PhysicsUpdraftEvent {
  68151. private _scene;
  68152. private _origin;
  68153. private _options;
  68154. private _physicsEngine;
  68155. private _originTop;
  68156. private _originDirection;
  68157. private _tickCallback;
  68158. private _cylinder;
  68159. private _cylinderPosition;
  68160. private _dataFetched;
  68161. /**
  68162. * Initializes the physics updraft event
  68163. * @param _scene BabylonJS scene
  68164. * @param _origin The origin position of the updraft
  68165. * @param _options The options for the updraft event
  68166. */
  68167. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68168. /**
  68169. * Returns the data related to the updraft event (cylinder).
  68170. * @returns A physics updraft event
  68171. */
  68172. getData(): PhysicsUpdraftEventData;
  68173. /**
  68174. * Enables the updraft.
  68175. */
  68176. enable(): void;
  68177. /**
  68178. * Disables the updraft.
  68179. */
  68180. disable(): void;
  68181. /**
  68182. * Disposes the cylinder.
  68183. * @param force Specifies if the updraft should be disposed by force
  68184. */
  68185. dispose(force?: boolean): void;
  68186. private getImpostorHitData;
  68187. private _tick;
  68188. /*** Helpers ***/
  68189. private _prepareCylinder;
  68190. private _intersectsWithCylinder;
  68191. }
  68192. /**
  68193. * Represents a physics vortex event
  68194. */
  68195. class PhysicsVortexEvent {
  68196. private _scene;
  68197. private _origin;
  68198. private _options;
  68199. private _physicsEngine;
  68200. private _originTop;
  68201. private _tickCallback;
  68202. private _cylinder;
  68203. private _cylinderPosition;
  68204. private _dataFetched;
  68205. /**
  68206. * Initializes the physics vortex event
  68207. * @param _scene The BabylonJS scene
  68208. * @param _origin The origin position of the vortex
  68209. * @param _options The options for the vortex event
  68210. */
  68211. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68212. /**
  68213. * Returns the data related to the vortex event (cylinder).
  68214. * @returns The physics vortex event data
  68215. */
  68216. getData(): PhysicsVortexEventData;
  68217. /**
  68218. * Enables the vortex.
  68219. */
  68220. enable(): void;
  68221. /**
  68222. * Disables the cortex.
  68223. */
  68224. disable(): void;
  68225. /**
  68226. * Disposes the sphere.
  68227. * @param force
  68228. */
  68229. dispose(force?: boolean): void;
  68230. private getImpostorHitData;
  68231. private _tick;
  68232. /*** Helpers ***/
  68233. private _prepareCylinder;
  68234. private _intersectsWithCylinder;
  68235. }
  68236. /**
  68237. * Options fot the radial explosion event
  68238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68239. */
  68240. export class PhysicsRadialExplosionEventOptions {
  68241. /**
  68242. * The radius of the sphere for the radial explosion.
  68243. */
  68244. radius: number;
  68245. /**
  68246. * The strenth of the explosion.
  68247. */
  68248. strength: number;
  68249. /**
  68250. * The strenght of the force in correspondence to the distance of the affected object
  68251. */
  68252. falloff: PhysicsRadialImpulseFalloff;
  68253. /**
  68254. * Sphere options for the radial explosion.
  68255. */
  68256. sphere: {
  68257. segments: number;
  68258. diameter: number;
  68259. };
  68260. /**
  68261. * Sphere options for the radial explosion.
  68262. */
  68263. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68264. }
  68265. /**
  68266. * Options fot the updraft event
  68267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68268. */
  68269. export class PhysicsUpdraftEventOptions {
  68270. /**
  68271. * The radius of the cylinder for the vortex
  68272. */
  68273. radius: number;
  68274. /**
  68275. * The strenth of the updraft.
  68276. */
  68277. strength: number;
  68278. /**
  68279. * The height of the cylinder for the updraft.
  68280. */
  68281. height: number;
  68282. /**
  68283. * The mode for the the updraft.
  68284. */
  68285. updraftMode: PhysicsUpdraftMode;
  68286. }
  68287. /**
  68288. * Options fot the vortex event
  68289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68290. */
  68291. export class PhysicsVortexEventOptions {
  68292. /**
  68293. * The radius of the cylinder for the vortex
  68294. */
  68295. radius: number;
  68296. /**
  68297. * The strenth of the vortex.
  68298. */
  68299. strength: number;
  68300. /**
  68301. * The height of the cylinder for the vortex.
  68302. */
  68303. height: number;
  68304. /**
  68305. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68306. */
  68307. centripetalForceThreshold: number;
  68308. /**
  68309. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68310. */
  68311. centripetalForceMultiplier: number;
  68312. /**
  68313. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68314. */
  68315. centrifugalForceMultiplier: number;
  68316. /**
  68317. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68318. */
  68319. updraftForceMultiplier: number;
  68320. }
  68321. /**
  68322. * The strenght of the force in correspondence to the distance of the affected object
  68323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68324. */
  68325. export enum PhysicsRadialImpulseFalloff {
  68326. /** Defines that impulse is constant in strength across it's whole radius */
  68327. Constant = 0,
  68328. /** Defines that impulse gets weaker if it's further from the origin */
  68329. Linear = 1
  68330. }
  68331. /**
  68332. * The strength of the force in correspondence to the distance of the affected object
  68333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68334. */
  68335. export enum PhysicsUpdraftMode {
  68336. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68337. Center = 0,
  68338. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68339. Perpendicular = 1
  68340. }
  68341. /**
  68342. * Interface for a physics hit data
  68343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68344. */
  68345. export interface PhysicsHitData {
  68346. /**
  68347. * The force applied at the contact point
  68348. */
  68349. force: Vector3;
  68350. /**
  68351. * The contact point
  68352. */
  68353. contactPoint: Vector3;
  68354. /**
  68355. * The distance from the origin to the contact point
  68356. */
  68357. distanceFromOrigin: number;
  68358. }
  68359. /**
  68360. * Interface for radial explosion event data
  68361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68362. */
  68363. export interface PhysicsRadialExplosionEventData {
  68364. /**
  68365. * A sphere used for the radial explosion event
  68366. */
  68367. sphere: Mesh;
  68368. }
  68369. /**
  68370. * Interface for gravitational field event data
  68371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68372. */
  68373. export interface PhysicsGravitationalFieldEventData {
  68374. /**
  68375. * A sphere mesh used for the gravitational field event
  68376. */
  68377. sphere: Mesh;
  68378. }
  68379. /**
  68380. * Interface for updraft event data
  68381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68382. */
  68383. export interface PhysicsUpdraftEventData {
  68384. /**
  68385. * A cylinder used for the updraft event
  68386. */
  68387. cylinder: Mesh;
  68388. }
  68389. /**
  68390. * Interface for vortex event data
  68391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68392. */
  68393. export interface PhysicsVortexEventData {
  68394. /**
  68395. * A cylinder used for the vortex event
  68396. */
  68397. cylinder: Mesh;
  68398. }
  68399. /**
  68400. * Interface for an affected physics impostor
  68401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68402. */
  68403. export interface PhysicsAffectedImpostorWithData {
  68404. /**
  68405. * The impostor affected by the effect
  68406. */
  68407. impostor: PhysicsImpostor;
  68408. /**
  68409. * The data about the hit/horce from the explosion
  68410. */
  68411. hitData: PhysicsHitData;
  68412. }
  68413. }
  68414. declare module BABYLON {
  68415. /** @hidden */
  68416. export var blackAndWhitePixelShader: {
  68417. name: string;
  68418. shader: string;
  68419. };
  68420. }
  68421. declare module BABYLON {
  68422. /**
  68423. * Post process used to render in black and white
  68424. */
  68425. export class BlackAndWhitePostProcess extends PostProcess {
  68426. /**
  68427. * Linear about to convert he result to black and white (default: 1)
  68428. */
  68429. degree: number;
  68430. /**
  68431. * Creates a black and white post process
  68432. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68433. * @param name The name of the effect.
  68434. * @param options The required width/height ratio to downsize to before computing the render pass.
  68435. * @param camera The camera to apply the render pass to.
  68436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68437. * @param engine The engine which the post process will be applied. (default: current engine)
  68438. * @param reusable If the post process can be reused on the same frame. (default: false)
  68439. */
  68440. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68441. }
  68442. }
  68443. declare module BABYLON {
  68444. /**
  68445. * This represents a set of one or more post processes in Babylon.
  68446. * A post process can be used to apply a shader to a texture after it is rendered.
  68447. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68448. */
  68449. export class PostProcessRenderEffect {
  68450. private _postProcesses;
  68451. private _getPostProcesses;
  68452. private _singleInstance;
  68453. private _cameras;
  68454. private _indicesForCamera;
  68455. /**
  68456. * Name of the effect
  68457. * @hidden
  68458. */
  68459. _name: string;
  68460. /**
  68461. * Instantiates a post process render effect.
  68462. * A post process can be used to apply a shader to a texture after it is rendered.
  68463. * @param engine The engine the effect is tied to
  68464. * @param name The name of the effect
  68465. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68466. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68467. */
  68468. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68469. /**
  68470. * Checks if all the post processes in the effect are supported.
  68471. */
  68472. get isSupported(): boolean;
  68473. /**
  68474. * Updates the current state of the effect
  68475. * @hidden
  68476. */
  68477. _update(): void;
  68478. /**
  68479. * Attaches the effect on cameras
  68480. * @param cameras The camera to attach to.
  68481. * @hidden
  68482. */
  68483. _attachCameras(cameras: Camera): void;
  68484. /**
  68485. * Attaches the effect on cameras
  68486. * @param cameras The camera to attach to.
  68487. * @hidden
  68488. */
  68489. _attachCameras(cameras: Camera[]): void;
  68490. /**
  68491. * Detaches the effect on cameras
  68492. * @param cameras The camera to detatch from.
  68493. * @hidden
  68494. */
  68495. _detachCameras(cameras: Camera): void;
  68496. /**
  68497. * Detatches the effect on cameras
  68498. * @param cameras The camera to detatch from.
  68499. * @hidden
  68500. */
  68501. _detachCameras(cameras: Camera[]): void;
  68502. /**
  68503. * Enables the effect on given cameras
  68504. * @param cameras The camera to enable.
  68505. * @hidden
  68506. */
  68507. _enable(cameras: Camera): void;
  68508. /**
  68509. * Enables the effect on given cameras
  68510. * @param cameras The camera to enable.
  68511. * @hidden
  68512. */
  68513. _enable(cameras: Nullable<Camera[]>): void;
  68514. /**
  68515. * Disables the effect on the given cameras
  68516. * @param cameras The camera to disable.
  68517. * @hidden
  68518. */
  68519. _disable(cameras: Camera): void;
  68520. /**
  68521. * Disables the effect on the given cameras
  68522. * @param cameras The camera to disable.
  68523. * @hidden
  68524. */
  68525. _disable(cameras: Nullable<Camera[]>): void;
  68526. /**
  68527. * Gets a list of the post processes contained in the effect.
  68528. * @param camera The camera to get the post processes on.
  68529. * @returns The list of the post processes in the effect.
  68530. */
  68531. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68532. }
  68533. }
  68534. declare module BABYLON {
  68535. /** @hidden */
  68536. export var extractHighlightsPixelShader: {
  68537. name: string;
  68538. shader: string;
  68539. };
  68540. }
  68541. declare module BABYLON {
  68542. /**
  68543. * 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.
  68544. */
  68545. export class ExtractHighlightsPostProcess extends PostProcess {
  68546. /**
  68547. * The luminance threshold, pixels below this value will be set to black.
  68548. */
  68549. threshold: number;
  68550. /** @hidden */
  68551. _exposure: number;
  68552. /**
  68553. * Post process which has the input texture to be used when performing highlight extraction
  68554. * @hidden
  68555. */
  68556. _inputPostProcess: Nullable<PostProcess>;
  68557. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68558. }
  68559. }
  68560. declare module BABYLON {
  68561. /** @hidden */
  68562. export var bloomMergePixelShader: {
  68563. name: string;
  68564. shader: string;
  68565. };
  68566. }
  68567. declare module BABYLON {
  68568. /**
  68569. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68570. */
  68571. export class BloomMergePostProcess extends PostProcess {
  68572. /** Weight of the bloom to be added to the original input. */
  68573. weight: number;
  68574. /**
  68575. * Creates a new instance of @see BloomMergePostProcess
  68576. * @param name The name of the effect.
  68577. * @param originalFromInput Post process which's input will be used for the merge.
  68578. * @param blurred Blurred highlights post process which's output will be used.
  68579. * @param weight Weight of the bloom to be added to the original input.
  68580. * @param options The required width/height ratio to downsize to before computing the render pass.
  68581. * @param camera The camera to apply the render pass to.
  68582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68583. * @param engine The engine which the post process will be applied. (default: current engine)
  68584. * @param reusable If the post process can be reused on the same frame. (default: false)
  68585. * @param textureType Type of textures used when performing the post process. (default: 0)
  68586. * @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)
  68587. */
  68588. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68589. /** Weight of the bloom to be added to the original input. */
  68590. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68591. }
  68592. }
  68593. declare module BABYLON {
  68594. /**
  68595. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68596. */
  68597. export class BloomEffect extends PostProcessRenderEffect {
  68598. private bloomScale;
  68599. /**
  68600. * @hidden Internal
  68601. */
  68602. _effects: Array<PostProcess>;
  68603. /**
  68604. * @hidden Internal
  68605. */
  68606. _downscale: ExtractHighlightsPostProcess;
  68607. private _blurX;
  68608. private _blurY;
  68609. private _merge;
  68610. /**
  68611. * The luminance threshold to find bright areas of the image to bloom.
  68612. */
  68613. get threshold(): number;
  68614. set threshold(value: number);
  68615. /**
  68616. * The strength of the bloom.
  68617. */
  68618. get weight(): number;
  68619. set weight(value: number);
  68620. /**
  68621. * Specifies the size of the bloom blur kernel, relative to the final output size
  68622. */
  68623. get kernel(): number;
  68624. set kernel(value: number);
  68625. /**
  68626. * Creates a new instance of @see BloomEffect
  68627. * @param scene The scene the effect belongs to.
  68628. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68629. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68630. * @param bloomWeight The the strength of bloom.
  68631. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68632. * @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)
  68633. */
  68634. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68635. /**
  68636. * Disposes each of the internal effects for a given camera.
  68637. * @param camera The camera to dispose the effect on.
  68638. */
  68639. disposeEffects(camera: Camera): void;
  68640. /**
  68641. * @hidden Internal
  68642. */
  68643. _updateEffects(): void;
  68644. /**
  68645. * Internal
  68646. * @returns if all the contained post processes are ready.
  68647. * @hidden
  68648. */
  68649. _isReady(): boolean;
  68650. }
  68651. }
  68652. declare module BABYLON {
  68653. /** @hidden */
  68654. export var chromaticAberrationPixelShader: {
  68655. name: string;
  68656. shader: string;
  68657. };
  68658. }
  68659. declare module BABYLON {
  68660. /**
  68661. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68662. */
  68663. export class ChromaticAberrationPostProcess extends PostProcess {
  68664. /**
  68665. * The amount of seperation of rgb channels (default: 30)
  68666. */
  68667. aberrationAmount: number;
  68668. /**
  68669. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68670. */
  68671. radialIntensity: number;
  68672. /**
  68673. * 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))
  68674. */
  68675. direction: Vector2;
  68676. /**
  68677. * 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))
  68678. */
  68679. centerPosition: Vector2;
  68680. /**
  68681. * Creates a new instance ChromaticAberrationPostProcess
  68682. * @param name The name of the effect.
  68683. * @param screenWidth The width of the screen to apply the effect on.
  68684. * @param screenHeight The height of the screen to apply the effect on.
  68685. * @param options The required width/height ratio to downsize to before computing the render pass.
  68686. * @param camera The camera to apply the render pass to.
  68687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68688. * @param engine The engine which the post process will be applied. (default: current engine)
  68689. * @param reusable If the post process can be reused on the same frame. (default: false)
  68690. * @param textureType Type of textures used when performing the post process. (default: 0)
  68691. * @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)
  68692. */
  68693. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68694. }
  68695. }
  68696. declare module BABYLON {
  68697. /** @hidden */
  68698. export var circleOfConfusionPixelShader: {
  68699. name: string;
  68700. shader: string;
  68701. };
  68702. }
  68703. declare module BABYLON {
  68704. /**
  68705. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68706. */
  68707. export class CircleOfConfusionPostProcess extends PostProcess {
  68708. /**
  68709. * 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.
  68710. */
  68711. lensSize: number;
  68712. /**
  68713. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68714. */
  68715. fStop: number;
  68716. /**
  68717. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68718. */
  68719. focusDistance: number;
  68720. /**
  68721. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68722. */
  68723. focalLength: number;
  68724. private _depthTexture;
  68725. /**
  68726. * Creates a new instance CircleOfConfusionPostProcess
  68727. * @param name The name of the effect.
  68728. * @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.
  68729. * @param options The required width/height ratio to downsize to before computing the render pass.
  68730. * @param camera The camera to apply the render pass to.
  68731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68732. * @param engine The engine which the post process will be applied. (default: current engine)
  68733. * @param reusable If the post process can be reused on the same frame. (default: false)
  68734. * @param textureType Type of textures used when performing the post process. (default: 0)
  68735. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  68736. */
  68737. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68738. /**
  68739. * 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.
  68740. */
  68741. set depthTexture(value: RenderTargetTexture);
  68742. }
  68743. }
  68744. declare module BABYLON {
  68745. /** @hidden */
  68746. export var colorCorrectionPixelShader: {
  68747. name: string;
  68748. shader: string;
  68749. };
  68750. }
  68751. declare module BABYLON {
  68752. /**
  68753. *
  68754. * This post-process allows the modification of rendered colors by using
  68755. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68756. *
  68757. * The object needs to be provided an url to a texture containing the color
  68758. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68759. * Use an image editing software to tweak the LUT to match your needs.
  68760. *
  68761. * For an example of a color LUT, see here:
  68762. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68763. * For explanations on color grading, see here:
  68764. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68765. *
  68766. */
  68767. export class ColorCorrectionPostProcess extends PostProcess {
  68768. private _colorTableTexture;
  68769. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68770. }
  68771. }
  68772. declare module BABYLON {
  68773. /** @hidden */
  68774. export var convolutionPixelShader: {
  68775. name: string;
  68776. shader: string;
  68777. };
  68778. }
  68779. declare module BABYLON {
  68780. /**
  68781. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68782. * input texture to perform effects such as edge detection or sharpening
  68783. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68784. */
  68785. export class ConvolutionPostProcess extends PostProcess {
  68786. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68787. kernel: number[];
  68788. /**
  68789. * Creates a new instance ConvolutionPostProcess
  68790. * @param name The name of the effect.
  68791. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68792. * @param options The required width/height ratio to downsize to before computing the render pass.
  68793. * @param camera The camera to apply the render pass to.
  68794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68795. * @param engine The engine which the post process will be applied. (default: current engine)
  68796. * @param reusable If the post process can be reused on the same frame. (default: false)
  68797. * @param textureType Type of textures used when performing the post process. (default: 0)
  68798. */
  68799. constructor(name: string,
  68800. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68801. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68802. /**
  68803. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68804. */
  68805. static EdgeDetect0Kernel: number[];
  68806. /**
  68807. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68808. */
  68809. static EdgeDetect1Kernel: number[];
  68810. /**
  68811. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68812. */
  68813. static EdgeDetect2Kernel: number[];
  68814. /**
  68815. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68816. */
  68817. static SharpenKernel: number[];
  68818. /**
  68819. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68820. */
  68821. static EmbossKernel: number[];
  68822. /**
  68823. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68824. */
  68825. static GaussianKernel: number[];
  68826. }
  68827. }
  68828. declare module BABYLON {
  68829. /**
  68830. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68831. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68832. * based on samples that have a large difference in distance than the center pixel.
  68833. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68834. */
  68835. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68836. direction: Vector2;
  68837. /**
  68838. * Creates a new instance CircleOfConfusionPostProcess
  68839. * @param name The name of the effect.
  68840. * @param scene The scene the effect belongs to.
  68841. * @param direction The direction the blur should be applied.
  68842. * @param kernel The size of the kernel used to blur.
  68843. * @param options The required width/height ratio to downsize to before computing the render pass.
  68844. * @param camera The camera to apply the render pass to.
  68845. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68846. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68848. * @param engine The engine which the post process will be applied. (default: current engine)
  68849. * @param reusable If the post process can be reused on the same frame. (default: false)
  68850. * @param textureType Type of textures used when performing the post process. (default: 0)
  68851. * @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)
  68852. */
  68853. 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);
  68854. }
  68855. }
  68856. declare module BABYLON {
  68857. /** @hidden */
  68858. export var depthOfFieldMergePixelShader: {
  68859. name: string;
  68860. shader: string;
  68861. };
  68862. }
  68863. declare module BABYLON {
  68864. /**
  68865. * Options to be set when merging outputs from the default pipeline.
  68866. */
  68867. export class DepthOfFieldMergePostProcessOptions {
  68868. /**
  68869. * The original image to merge on top of
  68870. */
  68871. originalFromInput: PostProcess;
  68872. /**
  68873. * Parameters to perform the merge of the depth of field effect
  68874. */
  68875. depthOfField?: {
  68876. circleOfConfusion: PostProcess;
  68877. blurSteps: Array<PostProcess>;
  68878. };
  68879. /**
  68880. * Parameters to perform the merge of bloom effect
  68881. */
  68882. bloom?: {
  68883. blurred: PostProcess;
  68884. weight: number;
  68885. };
  68886. }
  68887. /**
  68888. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68889. */
  68890. export class DepthOfFieldMergePostProcess extends PostProcess {
  68891. private blurSteps;
  68892. /**
  68893. * Creates a new instance of DepthOfFieldMergePostProcess
  68894. * @param name The name of the effect.
  68895. * @param originalFromInput Post process which's input will be used for the merge.
  68896. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68897. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68898. * @param options The required width/height ratio to downsize to before computing the render pass.
  68899. * @param camera The camera to apply the render pass to.
  68900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68901. * @param engine The engine which the post process will be applied. (default: current engine)
  68902. * @param reusable If the post process can be reused on the same frame. (default: false)
  68903. * @param textureType Type of textures used when performing the post process. (default: 0)
  68904. * @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)
  68905. */
  68906. 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);
  68907. /**
  68908. * Updates the effect with the current post process compile time values and recompiles the shader.
  68909. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68910. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68911. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68912. * @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
  68913. * @param onCompiled Called when the shader has been compiled.
  68914. * @param onError Called if there is an error when compiling a shader.
  68915. */
  68916. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68917. }
  68918. }
  68919. declare module BABYLON {
  68920. /**
  68921. * Specifies the level of max blur that should be applied when using the depth of field effect
  68922. */
  68923. export enum DepthOfFieldEffectBlurLevel {
  68924. /**
  68925. * Subtle blur
  68926. */
  68927. Low = 0,
  68928. /**
  68929. * Medium blur
  68930. */
  68931. Medium = 1,
  68932. /**
  68933. * Large blur
  68934. */
  68935. High = 2
  68936. }
  68937. /**
  68938. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68939. */
  68940. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68941. private _circleOfConfusion;
  68942. /**
  68943. * @hidden Internal, blurs from high to low
  68944. */
  68945. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68946. private _depthOfFieldBlurY;
  68947. private _dofMerge;
  68948. /**
  68949. * @hidden Internal post processes in depth of field effect
  68950. */
  68951. _effects: Array<PostProcess>;
  68952. /**
  68953. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68954. */
  68955. set focalLength(value: number);
  68956. get focalLength(): number;
  68957. /**
  68958. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68959. */
  68960. set fStop(value: number);
  68961. get fStop(): number;
  68962. /**
  68963. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68964. */
  68965. set focusDistance(value: number);
  68966. get focusDistance(): number;
  68967. /**
  68968. * 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.
  68969. */
  68970. set lensSize(value: number);
  68971. get lensSize(): number;
  68972. /**
  68973. * Creates a new instance DepthOfFieldEffect
  68974. * @param scene The scene the effect belongs to.
  68975. * @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.
  68976. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68977. * @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)
  68978. */
  68979. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68980. /**
  68981. * Get the current class name of the current effet
  68982. * @returns "DepthOfFieldEffect"
  68983. */
  68984. getClassName(): string;
  68985. /**
  68986. * 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.
  68987. */
  68988. set depthTexture(value: RenderTargetTexture);
  68989. /**
  68990. * Disposes each of the internal effects for a given camera.
  68991. * @param camera The camera to dispose the effect on.
  68992. */
  68993. disposeEffects(camera: Camera): void;
  68994. /**
  68995. * @hidden Internal
  68996. */
  68997. _updateEffects(): void;
  68998. /**
  68999. * Internal
  69000. * @returns if all the contained post processes are ready.
  69001. * @hidden
  69002. */
  69003. _isReady(): boolean;
  69004. }
  69005. }
  69006. declare module BABYLON {
  69007. /** @hidden */
  69008. export var displayPassPixelShader: {
  69009. name: string;
  69010. shader: string;
  69011. };
  69012. }
  69013. declare module BABYLON {
  69014. /**
  69015. * DisplayPassPostProcess which produces an output the same as it's input
  69016. */
  69017. export class DisplayPassPostProcess extends PostProcess {
  69018. /**
  69019. * Creates the DisplayPassPostProcess
  69020. * @param name The name of the effect.
  69021. * @param options The required width/height ratio to downsize to before computing the render pass.
  69022. * @param camera The camera to apply the render pass to.
  69023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69024. * @param engine The engine which the post process will be applied. (default: current engine)
  69025. * @param reusable If the post process can be reused on the same frame. (default: false)
  69026. */
  69027. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69028. }
  69029. }
  69030. declare module BABYLON {
  69031. /** @hidden */
  69032. export var filterPixelShader: {
  69033. name: string;
  69034. shader: string;
  69035. };
  69036. }
  69037. declare module BABYLON {
  69038. /**
  69039. * Applies a kernel filter to the image
  69040. */
  69041. export class FilterPostProcess extends PostProcess {
  69042. /** The matrix to be applied to the image */
  69043. kernelMatrix: Matrix;
  69044. /**
  69045. *
  69046. * @param name The name of the effect.
  69047. * @param kernelMatrix The matrix to be applied to the image
  69048. * @param options The required width/height ratio to downsize to before computing the render pass.
  69049. * @param camera The camera to apply the render pass to.
  69050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69051. * @param engine The engine which the post process will be applied. (default: current engine)
  69052. * @param reusable If the post process can be reused on the same frame. (default: false)
  69053. */
  69054. constructor(name: string,
  69055. /** The matrix to be applied to the image */
  69056. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69057. }
  69058. }
  69059. declare module BABYLON {
  69060. /** @hidden */
  69061. export var fxaaPixelShader: {
  69062. name: string;
  69063. shader: string;
  69064. };
  69065. }
  69066. declare module BABYLON {
  69067. /** @hidden */
  69068. export var fxaaVertexShader: {
  69069. name: string;
  69070. shader: string;
  69071. };
  69072. }
  69073. declare module BABYLON {
  69074. /**
  69075. * Fxaa post process
  69076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69077. */
  69078. export class FxaaPostProcess extends PostProcess {
  69079. /** @hidden */
  69080. texelWidth: number;
  69081. /** @hidden */
  69082. texelHeight: number;
  69083. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69084. private _getDefines;
  69085. }
  69086. }
  69087. declare module BABYLON {
  69088. /** @hidden */
  69089. export var grainPixelShader: {
  69090. name: string;
  69091. shader: string;
  69092. };
  69093. }
  69094. declare module BABYLON {
  69095. /**
  69096. * The GrainPostProcess adds noise to the image at mid luminance levels
  69097. */
  69098. export class GrainPostProcess extends PostProcess {
  69099. /**
  69100. * The intensity of the grain added (default: 30)
  69101. */
  69102. intensity: number;
  69103. /**
  69104. * If the grain should be randomized on every frame
  69105. */
  69106. animated: boolean;
  69107. /**
  69108. * Creates a new instance of @see GrainPostProcess
  69109. * @param name The name of the effect.
  69110. * @param options The required width/height ratio to downsize to before computing the render pass.
  69111. * @param camera The camera to apply the render pass to.
  69112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69113. * @param engine The engine which the post process will be applied. (default: current engine)
  69114. * @param reusable If the post process can be reused on the same frame. (default: false)
  69115. * @param textureType Type of textures used when performing the post process. (default: 0)
  69116. * @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)
  69117. */
  69118. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69119. }
  69120. }
  69121. declare module BABYLON {
  69122. /** @hidden */
  69123. export var highlightsPixelShader: {
  69124. name: string;
  69125. shader: string;
  69126. };
  69127. }
  69128. declare module BABYLON {
  69129. /**
  69130. * Extracts highlights from the image
  69131. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69132. */
  69133. export class HighlightsPostProcess extends PostProcess {
  69134. /**
  69135. * Extracts highlights from the image
  69136. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69137. * @param name The name of the effect.
  69138. * @param options The required width/height ratio to downsize to before computing the render pass.
  69139. * @param camera The camera to apply the render pass to.
  69140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69141. * @param engine The engine which the post process will be applied. (default: current engine)
  69142. * @param reusable If the post process can be reused on the same frame. (default: false)
  69143. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69144. */
  69145. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69146. }
  69147. }
  69148. declare module BABYLON {
  69149. /** @hidden */
  69150. export var mrtFragmentDeclaration: {
  69151. name: string;
  69152. shader: string;
  69153. };
  69154. }
  69155. declare module BABYLON {
  69156. /** @hidden */
  69157. export var geometryPixelShader: {
  69158. name: string;
  69159. shader: string;
  69160. };
  69161. }
  69162. declare module BABYLON {
  69163. /** @hidden */
  69164. export var geometryVertexShader: {
  69165. name: string;
  69166. shader: string;
  69167. };
  69168. }
  69169. declare module BABYLON {
  69170. /** @hidden */
  69171. interface ISavedTransformationMatrix {
  69172. world: Matrix;
  69173. viewProjection: Matrix;
  69174. }
  69175. /**
  69176. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69177. */
  69178. export class GeometryBufferRenderer {
  69179. /**
  69180. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69181. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69182. */
  69183. static readonly POSITION_TEXTURE_TYPE: number;
  69184. /**
  69185. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69186. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69187. */
  69188. static readonly VELOCITY_TEXTURE_TYPE: number;
  69189. /**
  69190. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69191. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69192. */
  69193. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69194. /**
  69195. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69196. * in order to compute objects velocities when enableVelocity is set to "true"
  69197. * @hidden
  69198. */
  69199. _previousTransformationMatrices: {
  69200. [index: number]: ISavedTransformationMatrix;
  69201. };
  69202. /**
  69203. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69204. * in order to compute objects velocities when enableVelocity is set to "true"
  69205. * @hidden
  69206. */
  69207. _previousBonesTransformationMatrices: {
  69208. [index: number]: Float32Array;
  69209. };
  69210. /**
  69211. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69212. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69213. */
  69214. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69215. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69216. renderTransparentMeshes: boolean;
  69217. private _scene;
  69218. private _resizeObserver;
  69219. private _multiRenderTarget;
  69220. private _ratio;
  69221. private _enablePosition;
  69222. private _enableVelocity;
  69223. private _enableReflectivity;
  69224. private _positionIndex;
  69225. private _velocityIndex;
  69226. private _reflectivityIndex;
  69227. protected _effect: Effect;
  69228. protected _cachedDefines: string;
  69229. /**
  69230. * Set the render list (meshes to be rendered) used in the G buffer.
  69231. */
  69232. set renderList(meshes: Mesh[]);
  69233. /**
  69234. * Gets wether or not G buffer are supported by the running hardware.
  69235. * This requires draw buffer supports
  69236. */
  69237. get isSupported(): boolean;
  69238. /**
  69239. * Returns the index of the given texture type in the G-Buffer textures array
  69240. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69241. * @returns the index of the given texture type in the G-Buffer textures array
  69242. */
  69243. getTextureIndex(textureType: number): number;
  69244. /**
  69245. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69246. */
  69247. get enablePosition(): boolean;
  69248. /**
  69249. * Sets whether or not objects positions are enabled for the G buffer.
  69250. */
  69251. set enablePosition(enable: boolean);
  69252. /**
  69253. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69254. */
  69255. get enableVelocity(): boolean;
  69256. /**
  69257. * Sets wether or not objects velocities are enabled for the G buffer.
  69258. */
  69259. set enableVelocity(enable: boolean);
  69260. /**
  69261. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69262. */
  69263. get enableReflectivity(): boolean;
  69264. /**
  69265. * Sets wether or not objects roughness are enabled for the G buffer.
  69266. */
  69267. set enableReflectivity(enable: boolean);
  69268. /**
  69269. * Gets the scene associated with the buffer.
  69270. */
  69271. get scene(): Scene;
  69272. /**
  69273. * Gets the ratio used by the buffer during its creation.
  69274. * How big is the buffer related to the main canvas.
  69275. */
  69276. get ratio(): number;
  69277. /** @hidden */
  69278. static _SceneComponentInitialization: (scene: Scene) => void;
  69279. /**
  69280. * Creates a new G Buffer for the scene
  69281. * @param scene The scene the buffer belongs to
  69282. * @param ratio How big is the buffer related to the main canvas.
  69283. */
  69284. constructor(scene: Scene, ratio?: number);
  69285. /**
  69286. * Checks wether everything is ready to render a submesh to the G buffer.
  69287. * @param subMesh the submesh to check readiness for
  69288. * @param useInstances is the mesh drawn using instance or not
  69289. * @returns true if ready otherwise false
  69290. */
  69291. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69292. /**
  69293. * Gets the current underlying G Buffer.
  69294. * @returns the buffer
  69295. */
  69296. getGBuffer(): MultiRenderTarget;
  69297. /**
  69298. * Gets the number of samples used to render the buffer (anti aliasing).
  69299. */
  69300. get samples(): number;
  69301. /**
  69302. * Sets the number of samples used to render the buffer (anti aliasing).
  69303. */
  69304. set samples(value: number);
  69305. /**
  69306. * Disposes the renderer and frees up associated resources.
  69307. */
  69308. dispose(): void;
  69309. protected _createRenderTargets(): void;
  69310. private _copyBonesTransformationMatrices;
  69311. }
  69312. }
  69313. declare module BABYLON {
  69314. interface Scene {
  69315. /** @hidden (Backing field) */
  69316. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69317. /**
  69318. * Gets or Sets the current geometry buffer associated to the scene.
  69319. */
  69320. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69321. /**
  69322. * Enables a GeometryBufferRender and associates it with the scene
  69323. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69324. * @returns the GeometryBufferRenderer
  69325. */
  69326. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69327. /**
  69328. * Disables the GeometryBufferRender associated with the scene
  69329. */
  69330. disableGeometryBufferRenderer(): void;
  69331. }
  69332. /**
  69333. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69334. * in several rendering techniques.
  69335. */
  69336. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69337. /**
  69338. * The component name helpful to identify the component in the list of scene components.
  69339. */
  69340. readonly name: string;
  69341. /**
  69342. * The scene the component belongs to.
  69343. */
  69344. scene: Scene;
  69345. /**
  69346. * Creates a new instance of the component for the given scene
  69347. * @param scene Defines the scene to register the component in
  69348. */
  69349. constructor(scene: Scene);
  69350. /**
  69351. * Registers the component in a given scene
  69352. */
  69353. register(): void;
  69354. /**
  69355. * Rebuilds the elements related to this component in case of
  69356. * context lost for instance.
  69357. */
  69358. rebuild(): void;
  69359. /**
  69360. * Disposes the component and the associated ressources
  69361. */
  69362. dispose(): void;
  69363. private _gatherRenderTargets;
  69364. }
  69365. }
  69366. declare module BABYLON {
  69367. /** @hidden */
  69368. export var motionBlurPixelShader: {
  69369. name: string;
  69370. shader: string;
  69371. };
  69372. }
  69373. declare module BABYLON {
  69374. /**
  69375. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69376. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69377. * As an example, all you have to do is to create the post-process:
  69378. * var mb = new BABYLON.MotionBlurPostProcess(
  69379. * 'mb', // The name of the effect.
  69380. * scene, // The scene containing the objects to blur according to their velocity.
  69381. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69382. * camera // The camera to apply the render pass to.
  69383. * );
  69384. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69385. */
  69386. export class MotionBlurPostProcess extends PostProcess {
  69387. /**
  69388. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69389. */
  69390. motionStrength: number;
  69391. /**
  69392. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69393. */
  69394. get motionBlurSamples(): number;
  69395. /**
  69396. * Sets the number of iterations to be used for motion blur quality
  69397. */
  69398. set motionBlurSamples(samples: number);
  69399. private _motionBlurSamples;
  69400. private _geometryBufferRenderer;
  69401. /**
  69402. * Creates a new instance MotionBlurPostProcess
  69403. * @param name The name of the effect.
  69404. * @param scene The scene containing the objects to blur according to their velocity.
  69405. * @param options The required width/height ratio to downsize to before computing the render pass.
  69406. * @param camera The camera to apply the render pass to.
  69407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69408. * @param engine The engine which the post process will be applied. (default: current engine)
  69409. * @param reusable If the post process can be reused on the same frame. (default: false)
  69410. * @param textureType Type of textures used when performing the post process. (default: 0)
  69411. * @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)
  69412. */
  69413. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69414. /**
  69415. * Excludes the given skinned mesh from computing bones velocities.
  69416. * 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.
  69417. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69418. */
  69419. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69420. /**
  69421. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69422. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69423. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69424. */
  69425. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69426. /**
  69427. * Disposes the post process.
  69428. * @param camera The camera to dispose the post process on.
  69429. */
  69430. dispose(camera?: Camera): void;
  69431. }
  69432. }
  69433. declare module BABYLON {
  69434. /** @hidden */
  69435. export var refractionPixelShader: {
  69436. name: string;
  69437. shader: string;
  69438. };
  69439. }
  69440. declare module BABYLON {
  69441. /**
  69442. * Post process which applies a refractin texture
  69443. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69444. */
  69445. export class RefractionPostProcess extends PostProcess {
  69446. /** the base color of the refraction (used to taint the rendering) */
  69447. color: Color3;
  69448. /** simulated refraction depth */
  69449. depth: number;
  69450. /** the coefficient of the base color (0 to remove base color tainting) */
  69451. colorLevel: number;
  69452. private _refTexture;
  69453. private _ownRefractionTexture;
  69454. /**
  69455. * Gets or sets the refraction texture
  69456. * Please note that you are responsible for disposing the texture if you set it manually
  69457. */
  69458. get refractionTexture(): Texture;
  69459. set refractionTexture(value: Texture);
  69460. /**
  69461. * Initializes the RefractionPostProcess
  69462. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69463. * @param name The name of the effect.
  69464. * @param refractionTextureUrl Url of the refraction texture to use
  69465. * @param color the base color of the refraction (used to taint the rendering)
  69466. * @param depth simulated refraction depth
  69467. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69468. * @param camera The camera to apply the render pass to.
  69469. * @param options The required width/height ratio to downsize to before computing the render pass.
  69470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69471. * @param engine The engine which the post process will be applied. (default: current engine)
  69472. * @param reusable If the post process can be reused on the same frame. (default: false)
  69473. */
  69474. constructor(name: string, refractionTextureUrl: string,
  69475. /** the base color of the refraction (used to taint the rendering) */
  69476. color: Color3,
  69477. /** simulated refraction depth */
  69478. depth: number,
  69479. /** the coefficient of the base color (0 to remove base color tainting) */
  69480. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69481. /**
  69482. * Disposes of the post process
  69483. * @param camera Camera to dispose post process on
  69484. */
  69485. dispose(camera: Camera): void;
  69486. }
  69487. }
  69488. declare module BABYLON {
  69489. /** @hidden */
  69490. export var sharpenPixelShader: {
  69491. name: string;
  69492. shader: string;
  69493. };
  69494. }
  69495. declare module BABYLON {
  69496. /**
  69497. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69498. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69499. */
  69500. export class SharpenPostProcess extends PostProcess {
  69501. /**
  69502. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69503. */
  69504. colorAmount: number;
  69505. /**
  69506. * How much sharpness should be applied (default: 0.3)
  69507. */
  69508. edgeAmount: number;
  69509. /**
  69510. * Creates a new instance ConvolutionPostProcess
  69511. * @param name The name of the effect.
  69512. * @param options The required width/height ratio to downsize to before computing the render pass.
  69513. * @param camera The camera to apply the render pass to.
  69514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69515. * @param engine The engine which the post process will be applied. (default: current engine)
  69516. * @param reusable If the post process can be reused on the same frame. (default: false)
  69517. * @param textureType Type of textures used when performing the post process. (default: 0)
  69518. * @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)
  69519. */
  69520. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69521. }
  69522. }
  69523. declare module BABYLON {
  69524. /**
  69525. * PostProcessRenderPipeline
  69526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69527. */
  69528. export class PostProcessRenderPipeline {
  69529. private engine;
  69530. private _renderEffects;
  69531. private _renderEffectsForIsolatedPass;
  69532. /**
  69533. * List of inspectable custom properties (used by the Inspector)
  69534. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69535. */
  69536. inspectableCustomProperties: IInspectable[];
  69537. /**
  69538. * @hidden
  69539. */
  69540. protected _cameras: Camera[];
  69541. /** @hidden */
  69542. _name: string;
  69543. /**
  69544. * Gets pipeline name
  69545. */
  69546. get name(): string;
  69547. /** Gets the list of attached cameras */
  69548. get cameras(): Camera[];
  69549. /**
  69550. * Initializes a PostProcessRenderPipeline
  69551. * @param engine engine to add the pipeline to
  69552. * @param name name of the pipeline
  69553. */
  69554. constructor(engine: Engine, name: string);
  69555. /**
  69556. * Gets the class name
  69557. * @returns "PostProcessRenderPipeline"
  69558. */
  69559. getClassName(): string;
  69560. /**
  69561. * If all the render effects in the pipeline are supported
  69562. */
  69563. get isSupported(): boolean;
  69564. /**
  69565. * Adds an effect to the pipeline
  69566. * @param renderEffect the effect to add
  69567. */
  69568. addEffect(renderEffect: PostProcessRenderEffect): void;
  69569. /** @hidden */
  69570. _rebuild(): void;
  69571. /** @hidden */
  69572. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69573. /** @hidden */
  69574. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69575. /** @hidden */
  69576. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69577. /** @hidden */
  69578. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69579. /** @hidden */
  69580. _attachCameras(cameras: Camera, unique: boolean): void;
  69581. /** @hidden */
  69582. _attachCameras(cameras: Camera[], unique: boolean): void;
  69583. /** @hidden */
  69584. _detachCameras(cameras: Camera): void;
  69585. /** @hidden */
  69586. _detachCameras(cameras: Nullable<Camera[]>): void;
  69587. /** @hidden */
  69588. _update(): void;
  69589. /** @hidden */
  69590. _reset(): void;
  69591. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69592. /**
  69593. * Sets the required values to the prepass renderer.
  69594. * @param prePassRenderer defines the prepass renderer to setup.
  69595. * @returns true if the pre pass is needed.
  69596. */
  69597. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  69598. /**
  69599. * Disposes of the pipeline
  69600. */
  69601. dispose(): void;
  69602. }
  69603. }
  69604. declare module BABYLON {
  69605. /**
  69606. * PostProcessRenderPipelineManager class
  69607. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69608. */
  69609. export class PostProcessRenderPipelineManager {
  69610. private _renderPipelines;
  69611. /**
  69612. * Initializes a PostProcessRenderPipelineManager
  69613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69614. */
  69615. constructor();
  69616. /**
  69617. * Gets the list of supported render pipelines
  69618. */
  69619. get supportedPipelines(): PostProcessRenderPipeline[];
  69620. /**
  69621. * Adds a pipeline to the manager
  69622. * @param renderPipeline The pipeline to add
  69623. */
  69624. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69625. /**
  69626. * Attaches a camera to the pipeline
  69627. * @param renderPipelineName The name of the pipeline to attach to
  69628. * @param cameras the camera to attach
  69629. * @param unique if the camera can be attached multiple times to the pipeline
  69630. */
  69631. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69632. /**
  69633. * Detaches a camera from the pipeline
  69634. * @param renderPipelineName The name of the pipeline to detach from
  69635. * @param cameras the camera to detach
  69636. */
  69637. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69638. /**
  69639. * Enables an effect by name on a pipeline
  69640. * @param renderPipelineName the name of the pipeline to enable the effect in
  69641. * @param renderEffectName the name of the effect to enable
  69642. * @param cameras the cameras that the effect should be enabled on
  69643. */
  69644. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69645. /**
  69646. * Disables an effect by name on a pipeline
  69647. * @param renderPipelineName the name of the pipeline to disable the effect in
  69648. * @param renderEffectName the name of the effect to disable
  69649. * @param cameras the cameras that the effect should be disabled on
  69650. */
  69651. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69652. /**
  69653. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69654. */
  69655. update(): void;
  69656. /** @hidden */
  69657. _rebuild(): void;
  69658. /**
  69659. * Disposes of the manager and pipelines
  69660. */
  69661. dispose(): void;
  69662. }
  69663. }
  69664. declare module BABYLON {
  69665. interface Scene {
  69666. /** @hidden (Backing field) */
  69667. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69668. /**
  69669. * Gets the postprocess render pipeline manager
  69670. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69671. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69672. */
  69673. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69674. }
  69675. /**
  69676. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69677. */
  69678. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69679. /**
  69680. * The component name helpfull to identify the component in the list of scene components.
  69681. */
  69682. readonly name: string;
  69683. /**
  69684. * The scene the component belongs to.
  69685. */
  69686. scene: Scene;
  69687. /**
  69688. * Creates a new instance of the component for the given scene
  69689. * @param scene Defines the scene to register the component in
  69690. */
  69691. constructor(scene: Scene);
  69692. /**
  69693. * Registers the component in a given scene
  69694. */
  69695. register(): void;
  69696. /**
  69697. * Rebuilds the elements related to this component in case of
  69698. * context lost for instance.
  69699. */
  69700. rebuild(): void;
  69701. /**
  69702. * Disposes the component and the associated ressources
  69703. */
  69704. dispose(): void;
  69705. private _gatherRenderTargets;
  69706. }
  69707. }
  69708. declare module BABYLON {
  69709. /**
  69710. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69711. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69712. */
  69713. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69714. private _scene;
  69715. private _camerasToBeAttached;
  69716. /**
  69717. * ID of the sharpen post process,
  69718. */
  69719. private readonly SharpenPostProcessId;
  69720. /**
  69721. * @ignore
  69722. * ID of the image processing post process;
  69723. */
  69724. readonly ImageProcessingPostProcessId: string;
  69725. /**
  69726. * @ignore
  69727. * ID of the Fast Approximate Anti-Aliasing post process;
  69728. */
  69729. readonly FxaaPostProcessId: string;
  69730. /**
  69731. * ID of the chromatic aberration post process,
  69732. */
  69733. private readonly ChromaticAberrationPostProcessId;
  69734. /**
  69735. * ID of the grain post process
  69736. */
  69737. private readonly GrainPostProcessId;
  69738. /**
  69739. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69740. */
  69741. sharpen: SharpenPostProcess;
  69742. private _sharpenEffect;
  69743. private bloom;
  69744. /**
  69745. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69746. */
  69747. depthOfField: DepthOfFieldEffect;
  69748. /**
  69749. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69750. */
  69751. fxaa: FxaaPostProcess;
  69752. /**
  69753. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69754. */
  69755. imageProcessing: ImageProcessingPostProcess;
  69756. /**
  69757. * Chromatic aberration post process which will shift rgb colors in the image
  69758. */
  69759. chromaticAberration: ChromaticAberrationPostProcess;
  69760. private _chromaticAberrationEffect;
  69761. /**
  69762. * Grain post process which add noise to the image
  69763. */
  69764. grain: GrainPostProcess;
  69765. private _grainEffect;
  69766. /**
  69767. * Glow post process which adds a glow to emissive areas of the image
  69768. */
  69769. private _glowLayer;
  69770. /**
  69771. * Animations which can be used to tweak settings over a period of time
  69772. */
  69773. animations: Animation[];
  69774. private _imageProcessingConfigurationObserver;
  69775. private _sharpenEnabled;
  69776. private _bloomEnabled;
  69777. private _depthOfFieldEnabled;
  69778. private _depthOfFieldBlurLevel;
  69779. private _fxaaEnabled;
  69780. private _imageProcessingEnabled;
  69781. private _defaultPipelineTextureType;
  69782. private _bloomScale;
  69783. private _chromaticAberrationEnabled;
  69784. private _grainEnabled;
  69785. private _buildAllowed;
  69786. /**
  69787. * Gets active scene
  69788. */
  69789. get scene(): Scene;
  69790. /**
  69791. * Enable or disable the sharpen process from the pipeline
  69792. */
  69793. set sharpenEnabled(enabled: boolean);
  69794. get sharpenEnabled(): boolean;
  69795. private _resizeObserver;
  69796. private _hardwareScaleLevel;
  69797. private _bloomKernel;
  69798. /**
  69799. * Specifies the size of the bloom blur kernel, relative to the final output size
  69800. */
  69801. get bloomKernel(): number;
  69802. set bloomKernel(value: number);
  69803. /**
  69804. * Specifies the weight of the bloom in the final rendering
  69805. */
  69806. private _bloomWeight;
  69807. /**
  69808. * Specifies the luma threshold for the area that will be blurred by the bloom
  69809. */
  69810. private _bloomThreshold;
  69811. private _hdr;
  69812. /**
  69813. * The strength of the bloom.
  69814. */
  69815. set bloomWeight(value: number);
  69816. get bloomWeight(): number;
  69817. /**
  69818. * The strength of the bloom.
  69819. */
  69820. set bloomThreshold(value: number);
  69821. get bloomThreshold(): number;
  69822. /**
  69823. * The scale of the bloom, lower value will provide better performance.
  69824. */
  69825. set bloomScale(value: number);
  69826. get bloomScale(): number;
  69827. /**
  69828. * Enable or disable the bloom from the pipeline
  69829. */
  69830. set bloomEnabled(enabled: boolean);
  69831. get bloomEnabled(): boolean;
  69832. private _rebuildBloom;
  69833. /**
  69834. * If the depth of field is enabled.
  69835. */
  69836. get depthOfFieldEnabled(): boolean;
  69837. set depthOfFieldEnabled(enabled: boolean);
  69838. /**
  69839. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69840. */
  69841. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69842. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69843. /**
  69844. * If the anti aliasing is enabled.
  69845. */
  69846. set fxaaEnabled(enabled: boolean);
  69847. get fxaaEnabled(): boolean;
  69848. private _samples;
  69849. /**
  69850. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69851. */
  69852. set samples(sampleCount: number);
  69853. get samples(): number;
  69854. /**
  69855. * If image processing is enabled.
  69856. */
  69857. set imageProcessingEnabled(enabled: boolean);
  69858. get imageProcessingEnabled(): boolean;
  69859. /**
  69860. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69861. */
  69862. set glowLayerEnabled(enabled: boolean);
  69863. get glowLayerEnabled(): boolean;
  69864. /**
  69865. * Gets the glow layer (or null if not defined)
  69866. */
  69867. get glowLayer(): Nullable<GlowLayer>;
  69868. /**
  69869. * Enable or disable the chromaticAberration process from the pipeline
  69870. */
  69871. set chromaticAberrationEnabled(enabled: boolean);
  69872. get chromaticAberrationEnabled(): boolean;
  69873. /**
  69874. * Enable or disable the grain process from the pipeline
  69875. */
  69876. set grainEnabled(enabled: boolean);
  69877. get grainEnabled(): boolean;
  69878. /**
  69879. * @constructor
  69880. * @param name - The rendering pipeline name (default: "")
  69881. * @param hdr - If high dynamic range textures should be used (default: true)
  69882. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69883. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69884. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69885. */
  69886. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69887. /**
  69888. * Get the class name
  69889. * @returns "DefaultRenderingPipeline"
  69890. */
  69891. getClassName(): string;
  69892. /**
  69893. * Force the compilation of the entire pipeline.
  69894. */
  69895. prepare(): void;
  69896. private _hasCleared;
  69897. private _prevPostProcess;
  69898. private _prevPrevPostProcess;
  69899. private _setAutoClearAndTextureSharing;
  69900. private _depthOfFieldSceneObserver;
  69901. private _buildPipeline;
  69902. private _disposePostProcesses;
  69903. /**
  69904. * Adds a camera to the pipeline
  69905. * @param camera the camera to be added
  69906. */
  69907. addCamera(camera: Camera): void;
  69908. /**
  69909. * Removes a camera from the pipeline
  69910. * @param camera the camera to remove
  69911. */
  69912. removeCamera(camera: Camera): void;
  69913. /**
  69914. * Dispose of the pipeline and stop all post processes
  69915. */
  69916. dispose(): void;
  69917. /**
  69918. * Serialize the rendering pipeline (Used when exporting)
  69919. * @returns the serialized object
  69920. */
  69921. serialize(): any;
  69922. /**
  69923. * Parse the serialized pipeline
  69924. * @param source Source pipeline.
  69925. * @param scene The scene to load the pipeline to.
  69926. * @param rootUrl The URL of the serialized pipeline.
  69927. * @returns An instantiated pipeline from the serialized object.
  69928. */
  69929. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69930. }
  69931. }
  69932. declare module BABYLON {
  69933. /** @hidden */
  69934. export var lensHighlightsPixelShader: {
  69935. name: string;
  69936. shader: string;
  69937. };
  69938. }
  69939. declare module BABYLON {
  69940. /** @hidden */
  69941. export var depthOfFieldPixelShader: {
  69942. name: string;
  69943. shader: string;
  69944. };
  69945. }
  69946. declare module BABYLON {
  69947. /**
  69948. * BABYLON.JS Chromatic Aberration GLSL Shader
  69949. * Author: Olivier Guyot
  69950. * Separates very slightly R, G and B colors on the edges of the screen
  69951. * Inspired by Francois Tarlier & Martins Upitis
  69952. */
  69953. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69954. /**
  69955. * @ignore
  69956. * The chromatic aberration PostProcess id in the pipeline
  69957. */
  69958. LensChromaticAberrationEffect: string;
  69959. /**
  69960. * @ignore
  69961. * The highlights enhancing PostProcess id in the pipeline
  69962. */
  69963. HighlightsEnhancingEffect: string;
  69964. /**
  69965. * @ignore
  69966. * The depth-of-field PostProcess id in the pipeline
  69967. */
  69968. LensDepthOfFieldEffect: string;
  69969. private _scene;
  69970. private _depthTexture;
  69971. private _grainTexture;
  69972. private _chromaticAberrationPostProcess;
  69973. private _highlightsPostProcess;
  69974. private _depthOfFieldPostProcess;
  69975. private _edgeBlur;
  69976. private _grainAmount;
  69977. private _chromaticAberration;
  69978. private _distortion;
  69979. private _highlightsGain;
  69980. private _highlightsThreshold;
  69981. private _dofDistance;
  69982. private _dofAperture;
  69983. private _dofDarken;
  69984. private _dofPentagon;
  69985. private _blurNoise;
  69986. /**
  69987. * @constructor
  69988. *
  69989. * Effect parameters are as follow:
  69990. * {
  69991. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69992. * edge_blur: number; // from 0 to x (1 for realism)
  69993. * distortion: number; // from 0 to x (1 for realism)
  69994. * grain_amount: number; // from 0 to 1
  69995. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69996. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69997. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69998. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69999. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70000. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70001. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70002. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70003. * }
  70004. * Note: if an effect parameter is unset, effect is disabled
  70005. *
  70006. * @param name The rendering pipeline name
  70007. * @param parameters - An object containing all parameters (see above)
  70008. * @param scene The scene linked to this pipeline
  70009. * @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)
  70010. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70011. */
  70012. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70013. /**
  70014. * Get the class name
  70015. * @returns "LensRenderingPipeline"
  70016. */
  70017. getClassName(): string;
  70018. /**
  70019. * Gets associated scene
  70020. */
  70021. get scene(): Scene;
  70022. /**
  70023. * Gets or sets the edge blur
  70024. */
  70025. get edgeBlur(): number;
  70026. set edgeBlur(value: number);
  70027. /**
  70028. * Gets or sets the grain amount
  70029. */
  70030. get grainAmount(): number;
  70031. set grainAmount(value: number);
  70032. /**
  70033. * Gets or sets the chromatic aberration amount
  70034. */
  70035. get chromaticAberration(): number;
  70036. set chromaticAberration(value: number);
  70037. /**
  70038. * Gets or sets the depth of field aperture
  70039. */
  70040. get dofAperture(): number;
  70041. set dofAperture(value: number);
  70042. /**
  70043. * Gets or sets the edge distortion
  70044. */
  70045. get edgeDistortion(): number;
  70046. set edgeDistortion(value: number);
  70047. /**
  70048. * Gets or sets the depth of field distortion
  70049. */
  70050. get dofDistortion(): number;
  70051. set dofDistortion(value: number);
  70052. /**
  70053. * Gets or sets the darken out of focus amount
  70054. */
  70055. get darkenOutOfFocus(): number;
  70056. set darkenOutOfFocus(value: number);
  70057. /**
  70058. * Gets or sets a boolean indicating if blur noise is enabled
  70059. */
  70060. get blurNoise(): boolean;
  70061. set blurNoise(value: boolean);
  70062. /**
  70063. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70064. */
  70065. get pentagonBokeh(): boolean;
  70066. set pentagonBokeh(value: boolean);
  70067. /**
  70068. * Gets or sets the highlight grain amount
  70069. */
  70070. get highlightsGain(): number;
  70071. set highlightsGain(value: number);
  70072. /**
  70073. * Gets or sets the highlight threshold
  70074. */
  70075. get highlightsThreshold(): number;
  70076. set highlightsThreshold(value: number);
  70077. /**
  70078. * Sets the amount of blur at the edges
  70079. * @param amount blur amount
  70080. */
  70081. setEdgeBlur(amount: number): void;
  70082. /**
  70083. * Sets edge blur to 0
  70084. */
  70085. disableEdgeBlur(): void;
  70086. /**
  70087. * Sets the amout of grain
  70088. * @param amount Amount of grain
  70089. */
  70090. setGrainAmount(amount: number): void;
  70091. /**
  70092. * Set grain amount to 0
  70093. */
  70094. disableGrain(): void;
  70095. /**
  70096. * Sets the chromatic aberration amount
  70097. * @param amount amount of chromatic aberration
  70098. */
  70099. setChromaticAberration(amount: number): void;
  70100. /**
  70101. * Sets chromatic aberration amount to 0
  70102. */
  70103. disableChromaticAberration(): void;
  70104. /**
  70105. * Sets the EdgeDistortion amount
  70106. * @param amount amount of EdgeDistortion
  70107. */
  70108. setEdgeDistortion(amount: number): void;
  70109. /**
  70110. * Sets edge distortion to 0
  70111. */
  70112. disableEdgeDistortion(): void;
  70113. /**
  70114. * Sets the FocusDistance amount
  70115. * @param amount amount of FocusDistance
  70116. */
  70117. setFocusDistance(amount: number): void;
  70118. /**
  70119. * Disables depth of field
  70120. */
  70121. disableDepthOfField(): void;
  70122. /**
  70123. * Sets the Aperture amount
  70124. * @param amount amount of Aperture
  70125. */
  70126. setAperture(amount: number): void;
  70127. /**
  70128. * Sets the DarkenOutOfFocus amount
  70129. * @param amount amount of DarkenOutOfFocus
  70130. */
  70131. setDarkenOutOfFocus(amount: number): void;
  70132. private _pentagonBokehIsEnabled;
  70133. /**
  70134. * Creates a pentagon bokeh effect
  70135. */
  70136. enablePentagonBokeh(): void;
  70137. /**
  70138. * Disables the pentagon bokeh effect
  70139. */
  70140. disablePentagonBokeh(): void;
  70141. /**
  70142. * Enables noise blur
  70143. */
  70144. enableNoiseBlur(): void;
  70145. /**
  70146. * Disables noise blur
  70147. */
  70148. disableNoiseBlur(): void;
  70149. /**
  70150. * Sets the HighlightsGain amount
  70151. * @param amount amount of HighlightsGain
  70152. */
  70153. setHighlightsGain(amount: number): void;
  70154. /**
  70155. * Sets the HighlightsThreshold amount
  70156. * @param amount amount of HighlightsThreshold
  70157. */
  70158. setHighlightsThreshold(amount: number): void;
  70159. /**
  70160. * Disables highlights
  70161. */
  70162. disableHighlights(): void;
  70163. /**
  70164. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70165. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70166. */
  70167. dispose(disableDepthRender?: boolean): void;
  70168. private _createChromaticAberrationPostProcess;
  70169. private _createHighlightsPostProcess;
  70170. private _createDepthOfFieldPostProcess;
  70171. private _createGrainTexture;
  70172. }
  70173. }
  70174. declare module BABYLON {
  70175. /** @hidden */
  70176. export var ssao2PixelShader: {
  70177. name: string;
  70178. shader: string;
  70179. };
  70180. }
  70181. declare module BABYLON {
  70182. /** @hidden */
  70183. export var ssaoCombinePixelShader: {
  70184. name: string;
  70185. shader: string;
  70186. };
  70187. }
  70188. declare module BABYLON {
  70189. /**
  70190. * Render pipeline to produce ssao effect
  70191. */
  70192. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70193. /**
  70194. * @ignore
  70195. * The PassPostProcess id in the pipeline that contains the original scene color
  70196. */
  70197. SSAOOriginalSceneColorEffect: string;
  70198. /**
  70199. * @ignore
  70200. * The SSAO PostProcess id in the pipeline
  70201. */
  70202. SSAORenderEffect: string;
  70203. /**
  70204. * @ignore
  70205. * The horizontal blur PostProcess id in the pipeline
  70206. */
  70207. SSAOBlurHRenderEffect: string;
  70208. /**
  70209. * @ignore
  70210. * The vertical blur PostProcess id in the pipeline
  70211. */
  70212. SSAOBlurVRenderEffect: string;
  70213. /**
  70214. * @ignore
  70215. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70216. */
  70217. SSAOCombineRenderEffect: string;
  70218. /**
  70219. * The output strength of the SSAO post-process. Default value is 1.0.
  70220. */
  70221. totalStrength: number;
  70222. /**
  70223. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70224. */
  70225. maxZ: number;
  70226. /**
  70227. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70228. */
  70229. minZAspect: number;
  70230. private _samples;
  70231. /**
  70232. * Number of samples used for the SSAO calculations. Default value is 8
  70233. */
  70234. set samples(n: number);
  70235. get samples(): number;
  70236. private _textureSamples;
  70237. /**
  70238. * Number of samples to use for antialiasing
  70239. */
  70240. set textureSamples(n: number);
  70241. get textureSamples(): number;
  70242. /**
  70243. * Force rendering the geometry through geometry buffer
  70244. */
  70245. private _forceGeometryBuffer;
  70246. /**
  70247. * Ratio object used for SSAO ratio and blur ratio
  70248. */
  70249. private _ratio;
  70250. /**
  70251. * Dynamically generated sphere sampler.
  70252. */
  70253. private _sampleSphere;
  70254. /**
  70255. * Blur filter offsets
  70256. */
  70257. private _samplerOffsets;
  70258. private _expensiveBlur;
  70259. /**
  70260. * If bilateral blur should be used
  70261. */
  70262. set expensiveBlur(b: boolean);
  70263. get expensiveBlur(): boolean;
  70264. /**
  70265. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70266. */
  70267. radius: number;
  70268. /**
  70269. * The base color of the SSAO post-process
  70270. * The final result is "base + ssao" between [0, 1]
  70271. */
  70272. base: number;
  70273. /**
  70274. * Support test.
  70275. */
  70276. static get IsSupported(): boolean;
  70277. private _scene;
  70278. private _randomTexture;
  70279. private _originalColorPostProcess;
  70280. private _ssaoPostProcess;
  70281. private _blurHPostProcess;
  70282. private _blurVPostProcess;
  70283. private _ssaoCombinePostProcess;
  70284. private _prePassRenderer;
  70285. /**
  70286. * Gets active scene
  70287. */
  70288. get scene(): Scene;
  70289. /**
  70290. * @constructor
  70291. * @param name The rendering pipeline name
  70292. * @param scene The scene linked to this pipeline
  70293. * @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 }
  70294. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70295. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70296. */
  70297. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70298. /**
  70299. * Get the class name
  70300. * @returns "SSAO2RenderingPipeline"
  70301. */
  70302. getClassName(): string;
  70303. /**
  70304. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70305. */
  70306. dispose(disableGeometryBufferRenderer?: boolean): void;
  70307. private _createBlurPostProcess;
  70308. /** @hidden */
  70309. _rebuild(): void;
  70310. private _bits;
  70311. private _radicalInverse_VdC;
  70312. private _hammersley;
  70313. private _hemisphereSample_uniform;
  70314. private _generateHemisphere;
  70315. private _getDefinesForSSAO;
  70316. private _createSSAOPostProcess;
  70317. private _createSSAOCombinePostProcess;
  70318. private _createRandomTexture;
  70319. /**
  70320. * Serialize the rendering pipeline (Used when exporting)
  70321. * @returns the serialized object
  70322. */
  70323. serialize(): any;
  70324. /**
  70325. * Parse the serialized pipeline
  70326. * @param source Source pipeline.
  70327. * @param scene The scene to load the pipeline to.
  70328. * @param rootUrl The URL of the serialized pipeline.
  70329. * @returns An instantiated pipeline from the serialized object.
  70330. */
  70331. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70332. /**
  70333. * Sets the required values to the prepass renderer.
  70334. * @param prePassRenderer defines the prepass renderer to setup
  70335. * @returns true if the pre pass is needed.
  70336. */
  70337. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70338. }
  70339. }
  70340. declare module BABYLON {
  70341. /** @hidden */
  70342. export var ssaoPixelShader: {
  70343. name: string;
  70344. shader: string;
  70345. };
  70346. }
  70347. declare module BABYLON {
  70348. /**
  70349. * Render pipeline to produce ssao effect
  70350. */
  70351. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70352. /**
  70353. * @ignore
  70354. * The PassPostProcess id in the pipeline that contains the original scene color
  70355. */
  70356. SSAOOriginalSceneColorEffect: string;
  70357. /**
  70358. * @ignore
  70359. * The SSAO PostProcess id in the pipeline
  70360. */
  70361. SSAORenderEffect: string;
  70362. /**
  70363. * @ignore
  70364. * The horizontal blur PostProcess id in the pipeline
  70365. */
  70366. SSAOBlurHRenderEffect: string;
  70367. /**
  70368. * @ignore
  70369. * The vertical blur PostProcess id in the pipeline
  70370. */
  70371. SSAOBlurVRenderEffect: string;
  70372. /**
  70373. * @ignore
  70374. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70375. */
  70376. SSAOCombineRenderEffect: string;
  70377. /**
  70378. * The output strength of the SSAO post-process. Default value is 1.0.
  70379. */
  70380. totalStrength: number;
  70381. /**
  70382. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70383. */
  70384. radius: number;
  70385. /**
  70386. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70387. * Must not be equal to fallOff and superior to fallOff.
  70388. * Default value is 0.0075
  70389. */
  70390. area: number;
  70391. /**
  70392. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70393. * Must not be equal to area and inferior to area.
  70394. * Default value is 0.000001
  70395. */
  70396. fallOff: number;
  70397. /**
  70398. * The base color of the SSAO post-process
  70399. * The final result is "base + ssao" between [0, 1]
  70400. */
  70401. base: number;
  70402. private _scene;
  70403. private _depthTexture;
  70404. private _randomTexture;
  70405. private _originalColorPostProcess;
  70406. private _ssaoPostProcess;
  70407. private _blurHPostProcess;
  70408. private _blurVPostProcess;
  70409. private _ssaoCombinePostProcess;
  70410. private _firstUpdate;
  70411. /**
  70412. * Gets active scene
  70413. */
  70414. get scene(): Scene;
  70415. /**
  70416. * @constructor
  70417. * @param name - The rendering pipeline name
  70418. * @param scene - The scene linked to this pipeline
  70419. * @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 }
  70420. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70421. */
  70422. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70423. /**
  70424. * Get the class name
  70425. * @returns "SSAORenderingPipeline"
  70426. */
  70427. getClassName(): string;
  70428. /**
  70429. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70430. */
  70431. dispose(disableDepthRender?: boolean): void;
  70432. private _createBlurPostProcess;
  70433. /** @hidden */
  70434. _rebuild(): void;
  70435. private _createSSAOPostProcess;
  70436. private _createSSAOCombinePostProcess;
  70437. private _createRandomTexture;
  70438. }
  70439. }
  70440. declare module BABYLON {
  70441. /** @hidden */
  70442. export var screenSpaceReflectionPixelShader: {
  70443. name: string;
  70444. shader: string;
  70445. };
  70446. }
  70447. declare module BABYLON {
  70448. /**
  70449. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70450. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70451. */
  70452. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70453. /**
  70454. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70455. */
  70456. threshold: number;
  70457. /**
  70458. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70459. */
  70460. strength: number;
  70461. /**
  70462. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70463. */
  70464. reflectionSpecularFalloffExponent: number;
  70465. /**
  70466. * 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]
  70467. */
  70468. step: number;
  70469. /**
  70470. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70471. */
  70472. roughnessFactor: number;
  70473. private _geometryBufferRenderer;
  70474. private _enableSmoothReflections;
  70475. private _reflectionSamples;
  70476. private _smoothSteps;
  70477. /**
  70478. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70479. * @param name The name of the effect.
  70480. * @param scene The scene containing the objects to calculate reflections.
  70481. * @param options The required width/height ratio to downsize to before computing the render pass.
  70482. * @param camera The camera to apply the render pass to.
  70483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70484. * @param engine The engine which the post process will be applied. (default: current engine)
  70485. * @param reusable If the post process can be reused on the same frame. (default: false)
  70486. * @param textureType Type of textures used when performing the post process. (default: 0)
  70487. * @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)
  70488. */
  70489. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70490. /**
  70491. * Gets wether or not smoothing reflections is enabled.
  70492. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70493. */
  70494. get enableSmoothReflections(): boolean;
  70495. /**
  70496. * Sets wether or not smoothing reflections is enabled.
  70497. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70498. */
  70499. set enableSmoothReflections(enabled: boolean);
  70500. /**
  70501. * Gets the number of samples taken while computing reflections. More samples count is high,
  70502. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70503. */
  70504. get reflectionSamples(): number;
  70505. /**
  70506. * Sets the number of samples taken while computing reflections. More samples count is high,
  70507. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70508. */
  70509. set reflectionSamples(samples: number);
  70510. /**
  70511. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70512. * more the post-process will require GPU power and can generate a drop in FPS.
  70513. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70514. */
  70515. get smoothSteps(): number;
  70516. set smoothSteps(steps: number);
  70517. private _updateEffectDefines;
  70518. }
  70519. }
  70520. declare module BABYLON {
  70521. /** @hidden */
  70522. export var standardPixelShader: {
  70523. name: string;
  70524. shader: string;
  70525. };
  70526. }
  70527. declare module BABYLON {
  70528. /**
  70529. * Standard rendering pipeline
  70530. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70531. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70532. */
  70533. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70534. /**
  70535. * Public members
  70536. */
  70537. /**
  70538. * Post-process which contains the original scene color before the pipeline applies all the effects
  70539. */
  70540. originalPostProcess: Nullable<PostProcess>;
  70541. /**
  70542. * Post-process used to down scale an image x4
  70543. */
  70544. downSampleX4PostProcess: Nullable<PostProcess>;
  70545. /**
  70546. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70547. */
  70548. brightPassPostProcess: Nullable<PostProcess>;
  70549. /**
  70550. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70551. */
  70552. blurHPostProcesses: PostProcess[];
  70553. /**
  70554. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70555. */
  70556. blurVPostProcesses: PostProcess[];
  70557. /**
  70558. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70559. */
  70560. textureAdderPostProcess: Nullable<PostProcess>;
  70561. /**
  70562. * Post-process used to create volumetric lighting effect
  70563. */
  70564. volumetricLightPostProcess: Nullable<PostProcess>;
  70565. /**
  70566. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70567. */
  70568. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70569. /**
  70570. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70571. */
  70572. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70573. /**
  70574. * Post-process used to merge the volumetric light effect and the real scene color
  70575. */
  70576. volumetricLightMergePostProces: Nullable<PostProcess>;
  70577. /**
  70578. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70579. */
  70580. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70581. /**
  70582. * Base post-process used to calculate the average luminance of the final image for HDR
  70583. */
  70584. luminancePostProcess: Nullable<PostProcess>;
  70585. /**
  70586. * Post-processes used to create down sample post-processes in order to get
  70587. * the average luminance of the final image for HDR
  70588. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70589. */
  70590. luminanceDownSamplePostProcesses: PostProcess[];
  70591. /**
  70592. * Post-process used to create a HDR effect (light adaptation)
  70593. */
  70594. hdrPostProcess: Nullable<PostProcess>;
  70595. /**
  70596. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70597. */
  70598. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70599. /**
  70600. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70601. */
  70602. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70603. /**
  70604. * Post-process used to merge the final HDR post-process and the real scene color
  70605. */
  70606. hdrFinalPostProcess: Nullable<PostProcess>;
  70607. /**
  70608. * Post-process used to create a lens flare effect
  70609. */
  70610. lensFlarePostProcess: Nullable<PostProcess>;
  70611. /**
  70612. * Post-process that merges the result of the lens flare post-process and the real scene color
  70613. */
  70614. lensFlareComposePostProcess: Nullable<PostProcess>;
  70615. /**
  70616. * Post-process used to create a motion blur effect
  70617. */
  70618. motionBlurPostProcess: Nullable<PostProcess>;
  70619. /**
  70620. * Post-process used to create a depth of field effect
  70621. */
  70622. depthOfFieldPostProcess: Nullable<PostProcess>;
  70623. /**
  70624. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70625. */
  70626. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70627. /**
  70628. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70629. */
  70630. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70631. /**
  70632. * Represents the brightness threshold in order to configure the illuminated surfaces
  70633. */
  70634. brightThreshold: number;
  70635. /**
  70636. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70637. */
  70638. blurWidth: number;
  70639. /**
  70640. * Sets if the blur for highlighted surfaces must be only horizontal
  70641. */
  70642. horizontalBlur: boolean;
  70643. /**
  70644. * Gets the overall exposure used by the pipeline
  70645. */
  70646. get exposure(): number;
  70647. /**
  70648. * Sets the overall exposure used by the pipeline
  70649. */
  70650. set exposure(value: number);
  70651. /**
  70652. * Texture used typically to simulate "dirty" on camera lens
  70653. */
  70654. lensTexture: Nullable<Texture>;
  70655. /**
  70656. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70657. */
  70658. volumetricLightCoefficient: number;
  70659. /**
  70660. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70661. */
  70662. volumetricLightPower: number;
  70663. /**
  70664. * Used the set the blur intensity to smooth the volumetric lights
  70665. */
  70666. volumetricLightBlurScale: number;
  70667. /**
  70668. * Light (spot or directional) used to generate the volumetric lights rays
  70669. * The source light must have a shadow generate so the pipeline can get its
  70670. * depth map
  70671. */
  70672. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70673. /**
  70674. * For eye adaptation, represents the minimum luminance the eye can see
  70675. */
  70676. hdrMinimumLuminance: number;
  70677. /**
  70678. * For eye adaptation, represents the decrease luminance speed
  70679. */
  70680. hdrDecreaseRate: number;
  70681. /**
  70682. * For eye adaptation, represents the increase luminance speed
  70683. */
  70684. hdrIncreaseRate: number;
  70685. /**
  70686. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70687. */
  70688. get hdrAutoExposure(): boolean;
  70689. /**
  70690. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70691. */
  70692. set hdrAutoExposure(value: boolean);
  70693. /**
  70694. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70695. */
  70696. lensColorTexture: Nullable<Texture>;
  70697. /**
  70698. * The overall strengh for the lens flare effect
  70699. */
  70700. lensFlareStrength: number;
  70701. /**
  70702. * Dispersion coefficient for lens flare ghosts
  70703. */
  70704. lensFlareGhostDispersal: number;
  70705. /**
  70706. * Main lens flare halo width
  70707. */
  70708. lensFlareHaloWidth: number;
  70709. /**
  70710. * Based on the lens distortion effect, defines how much the lens flare result
  70711. * is distorted
  70712. */
  70713. lensFlareDistortionStrength: number;
  70714. /**
  70715. * Configures the blur intensity used for for lens flare (halo)
  70716. */
  70717. lensFlareBlurWidth: number;
  70718. /**
  70719. * Lens star texture must be used to simulate rays on the flares and is available
  70720. * in the documentation
  70721. */
  70722. lensStarTexture: Nullable<Texture>;
  70723. /**
  70724. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70725. * flare effect by taking account of the dirt texture
  70726. */
  70727. lensFlareDirtTexture: Nullable<Texture>;
  70728. /**
  70729. * Represents the focal length for the depth of field effect
  70730. */
  70731. depthOfFieldDistance: number;
  70732. /**
  70733. * Represents the blur intensity for the blurred part of the depth of field effect
  70734. */
  70735. depthOfFieldBlurWidth: number;
  70736. /**
  70737. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70738. */
  70739. get motionStrength(): number;
  70740. /**
  70741. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70742. */
  70743. set motionStrength(strength: number);
  70744. /**
  70745. * Gets wether or not the motion blur post-process is object based or screen based.
  70746. */
  70747. get objectBasedMotionBlur(): boolean;
  70748. /**
  70749. * Sets wether or not the motion blur post-process should be object based or screen based
  70750. */
  70751. set objectBasedMotionBlur(value: boolean);
  70752. /**
  70753. * List of animations for the pipeline (IAnimatable implementation)
  70754. */
  70755. animations: Animation[];
  70756. /**
  70757. * Private members
  70758. */
  70759. private _scene;
  70760. private _currentDepthOfFieldSource;
  70761. private _basePostProcess;
  70762. private _fixedExposure;
  70763. private _currentExposure;
  70764. private _hdrAutoExposure;
  70765. private _hdrCurrentLuminance;
  70766. private _motionStrength;
  70767. private _isObjectBasedMotionBlur;
  70768. private _floatTextureType;
  70769. private _camerasToBeAttached;
  70770. private _ratio;
  70771. private _bloomEnabled;
  70772. private _depthOfFieldEnabled;
  70773. private _vlsEnabled;
  70774. private _lensFlareEnabled;
  70775. private _hdrEnabled;
  70776. private _motionBlurEnabled;
  70777. private _fxaaEnabled;
  70778. private _screenSpaceReflectionsEnabled;
  70779. private _motionBlurSamples;
  70780. private _volumetricLightStepsCount;
  70781. private _samples;
  70782. /**
  70783. * @ignore
  70784. * Specifies if the bloom pipeline is enabled
  70785. */
  70786. get BloomEnabled(): boolean;
  70787. set BloomEnabled(enabled: boolean);
  70788. /**
  70789. * @ignore
  70790. * Specifies if the depth of field pipeline is enabed
  70791. */
  70792. get DepthOfFieldEnabled(): boolean;
  70793. set DepthOfFieldEnabled(enabled: boolean);
  70794. /**
  70795. * @ignore
  70796. * Specifies if the lens flare pipeline is enabed
  70797. */
  70798. get LensFlareEnabled(): boolean;
  70799. set LensFlareEnabled(enabled: boolean);
  70800. /**
  70801. * @ignore
  70802. * Specifies if the HDR pipeline is enabled
  70803. */
  70804. get HDREnabled(): boolean;
  70805. set HDREnabled(enabled: boolean);
  70806. /**
  70807. * @ignore
  70808. * Specifies if the volumetric lights scattering effect is enabled
  70809. */
  70810. get VLSEnabled(): boolean;
  70811. set VLSEnabled(enabled: boolean);
  70812. /**
  70813. * @ignore
  70814. * Specifies if the motion blur effect is enabled
  70815. */
  70816. get MotionBlurEnabled(): boolean;
  70817. set MotionBlurEnabled(enabled: boolean);
  70818. /**
  70819. * Specifies if anti-aliasing is enabled
  70820. */
  70821. get fxaaEnabled(): boolean;
  70822. set fxaaEnabled(enabled: boolean);
  70823. /**
  70824. * Specifies if screen space reflections are enabled.
  70825. */
  70826. get screenSpaceReflectionsEnabled(): boolean;
  70827. set screenSpaceReflectionsEnabled(enabled: boolean);
  70828. /**
  70829. * Specifies the number of steps used to calculate the volumetric lights
  70830. * Typically in interval [50, 200]
  70831. */
  70832. get volumetricLightStepsCount(): number;
  70833. set volumetricLightStepsCount(count: number);
  70834. /**
  70835. * Specifies the number of samples used for the motion blur effect
  70836. * Typically in interval [16, 64]
  70837. */
  70838. get motionBlurSamples(): number;
  70839. set motionBlurSamples(samples: number);
  70840. /**
  70841. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70842. */
  70843. get samples(): number;
  70844. set samples(sampleCount: number);
  70845. /**
  70846. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70847. * @constructor
  70848. * @param name The rendering pipeline name
  70849. * @param scene The scene linked to this pipeline
  70850. * @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)
  70851. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70852. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70853. */
  70854. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70855. private _buildPipeline;
  70856. private _createDownSampleX4PostProcess;
  70857. private _createBrightPassPostProcess;
  70858. private _createBlurPostProcesses;
  70859. private _createTextureAdderPostProcess;
  70860. private _createVolumetricLightPostProcess;
  70861. private _createLuminancePostProcesses;
  70862. private _createHdrPostProcess;
  70863. private _createLensFlarePostProcess;
  70864. private _createDepthOfFieldPostProcess;
  70865. private _createMotionBlurPostProcess;
  70866. private _getDepthTexture;
  70867. private _disposePostProcesses;
  70868. /**
  70869. * Dispose of the pipeline and stop all post processes
  70870. */
  70871. dispose(): void;
  70872. /**
  70873. * Serialize the rendering pipeline (Used when exporting)
  70874. * @returns the serialized object
  70875. */
  70876. serialize(): any;
  70877. /**
  70878. * Parse the serialized pipeline
  70879. * @param source Source pipeline.
  70880. * @param scene The scene to load the pipeline to.
  70881. * @param rootUrl The URL of the serialized pipeline.
  70882. * @returns An instantiated pipeline from the serialized object.
  70883. */
  70884. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70885. /**
  70886. * Luminance steps
  70887. */
  70888. static LuminanceSteps: number;
  70889. }
  70890. }
  70891. declare module BABYLON {
  70892. /** @hidden */
  70893. export var stereoscopicInterlacePixelShader: {
  70894. name: string;
  70895. shader: string;
  70896. };
  70897. }
  70898. declare module BABYLON {
  70899. /**
  70900. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70901. */
  70902. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70903. private _stepSize;
  70904. private _passedProcess;
  70905. /**
  70906. * Initializes a StereoscopicInterlacePostProcessI
  70907. * @param name The name of the effect.
  70908. * @param rigCameras The rig cameras to be appled to the post process
  70909. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70910. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70912. * @param engine The engine which the post process will be applied. (default: current engine)
  70913. * @param reusable If the post process can be reused on the same frame. (default: false)
  70914. */
  70915. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70916. }
  70917. /**
  70918. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70919. */
  70920. export class StereoscopicInterlacePostProcess extends PostProcess {
  70921. private _stepSize;
  70922. private _passedProcess;
  70923. /**
  70924. * Initializes a StereoscopicInterlacePostProcess
  70925. * @param name The name of the effect.
  70926. * @param rigCameras The rig cameras to be appled to the post process
  70927. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70929. * @param engine The engine which the post process will be applied. (default: current engine)
  70930. * @param reusable If the post process can be reused on the same frame. (default: false)
  70931. */
  70932. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70933. }
  70934. }
  70935. declare module BABYLON {
  70936. /** @hidden */
  70937. export var tonemapPixelShader: {
  70938. name: string;
  70939. shader: string;
  70940. };
  70941. }
  70942. declare module BABYLON {
  70943. /** Defines operator used for tonemapping */
  70944. export enum TonemappingOperator {
  70945. /** Hable */
  70946. Hable = 0,
  70947. /** Reinhard */
  70948. Reinhard = 1,
  70949. /** HejiDawson */
  70950. HejiDawson = 2,
  70951. /** Photographic */
  70952. Photographic = 3
  70953. }
  70954. /**
  70955. * Defines a post process to apply tone mapping
  70956. */
  70957. export class TonemapPostProcess extends PostProcess {
  70958. private _operator;
  70959. /** Defines the required exposure adjustement */
  70960. exposureAdjustment: number;
  70961. /**
  70962. * Creates a new TonemapPostProcess
  70963. * @param name defines the name of the postprocess
  70964. * @param _operator defines the operator to use
  70965. * @param exposureAdjustment defines the required exposure adjustement
  70966. * @param camera defines the camera to use (can be null)
  70967. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70968. * @param engine defines the hosting engine (can be ignore if camera is set)
  70969. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70970. */
  70971. constructor(name: string, _operator: TonemappingOperator,
  70972. /** Defines the required exposure adjustement */
  70973. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70974. }
  70975. }
  70976. declare module BABYLON {
  70977. /** @hidden */
  70978. export var volumetricLightScatteringPixelShader: {
  70979. name: string;
  70980. shader: string;
  70981. };
  70982. }
  70983. declare module BABYLON {
  70984. /** @hidden */
  70985. export var volumetricLightScatteringPassVertexShader: {
  70986. name: string;
  70987. shader: string;
  70988. };
  70989. }
  70990. declare module BABYLON {
  70991. /** @hidden */
  70992. export var volumetricLightScatteringPassPixelShader: {
  70993. name: string;
  70994. shader: string;
  70995. };
  70996. }
  70997. declare module BABYLON {
  70998. /**
  70999. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71000. */
  71001. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71002. private _volumetricLightScatteringPass;
  71003. private _volumetricLightScatteringRTT;
  71004. private _viewPort;
  71005. private _screenCoordinates;
  71006. private _cachedDefines;
  71007. /**
  71008. * If not undefined, the mesh position is computed from the attached node position
  71009. */
  71010. attachedNode: {
  71011. position: Vector3;
  71012. };
  71013. /**
  71014. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71015. */
  71016. customMeshPosition: Vector3;
  71017. /**
  71018. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71019. */
  71020. useCustomMeshPosition: boolean;
  71021. /**
  71022. * If the post-process should inverse the light scattering direction
  71023. */
  71024. invert: boolean;
  71025. /**
  71026. * The internal mesh used by the post-process
  71027. */
  71028. mesh: Mesh;
  71029. /**
  71030. * @hidden
  71031. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71032. */
  71033. get useDiffuseColor(): boolean;
  71034. set useDiffuseColor(useDiffuseColor: boolean);
  71035. /**
  71036. * Array containing the excluded meshes not rendered in the internal pass
  71037. */
  71038. excludedMeshes: AbstractMesh[];
  71039. /**
  71040. * Controls the overall intensity of the post-process
  71041. */
  71042. exposure: number;
  71043. /**
  71044. * Dissipates each sample's contribution in range [0, 1]
  71045. */
  71046. decay: number;
  71047. /**
  71048. * Controls the overall intensity of each sample
  71049. */
  71050. weight: number;
  71051. /**
  71052. * Controls the density of each sample
  71053. */
  71054. density: number;
  71055. /**
  71056. * @constructor
  71057. * @param name The post-process name
  71058. * @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)
  71059. * @param camera The camera that the post-process will be attached to
  71060. * @param mesh The mesh used to create the light scattering
  71061. * @param samples The post-process quality, default 100
  71062. * @param samplingModeThe post-process filtering mode
  71063. * @param engine The babylon engine
  71064. * @param reusable If the post-process is reusable
  71065. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71066. */
  71067. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71068. /**
  71069. * Returns the string "VolumetricLightScatteringPostProcess"
  71070. * @returns "VolumetricLightScatteringPostProcess"
  71071. */
  71072. getClassName(): string;
  71073. private _isReady;
  71074. /**
  71075. * Sets the new light position for light scattering effect
  71076. * @param position The new custom light position
  71077. */
  71078. setCustomMeshPosition(position: Vector3): void;
  71079. /**
  71080. * Returns the light position for light scattering effect
  71081. * @return Vector3 The custom light position
  71082. */
  71083. getCustomMeshPosition(): Vector3;
  71084. /**
  71085. * Disposes the internal assets and detaches the post-process from the camera
  71086. */
  71087. dispose(camera: Camera): void;
  71088. /**
  71089. * Returns the render target texture used by the post-process
  71090. * @return the render target texture used by the post-process
  71091. */
  71092. getPass(): RenderTargetTexture;
  71093. private _meshExcluded;
  71094. private _createPass;
  71095. private _updateMeshScreenCoordinates;
  71096. /**
  71097. * Creates a default mesh for the Volumeric Light Scattering post-process
  71098. * @param name The mesh name
  71099. * @param scene The scene where to create the mesh
  71100. * @return the default mesh
  71101. */
  71102. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71103. }
  71104. }
  71105. declare module BABYLON {
  71106. /** @hidden */
  71107. export var screenSpaceCurvaturePixelShader: {
  71108. name: string;
  71109. shader: string;
  71110. };
  71111. }
  71112. declare module BABYLON {
  71113. /**
  71114. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71115. */
  71116. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71117. /**
  71118. * Defines how much ridge the curvature effect displays.
  71119. */
  71120. ridge: number;
  71121. /**
  71122. * Defines how much valley the curvature effect displays.
  71123. */
  71124. valley: number;
  71125. private _geometryBufferRenderer;
  71126. /**
  71127. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71128. * @param name The name of the effect.
  71129. * @param scene The scene containing the objects to blur according to their velocity.
  71130. * @param options The required width/height ratio to downsize to before computing the render pass.
  71131. * @param camera The camera to apply the render pass to.
  71132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71133. * @param engine The engine which the post process will be applied. (default: current engine)
  71134. * @param reusable If the post process can be reused on the same frame. (default: false)
  71135. * @param textureType Type of textures used when performing the post process. (default: 0)
  71136. * @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)
  71137. */
  71138. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71139. /**
  71140. * Support test.
  71141. */
  71142. static get IsSupported(): boolean;
  71143. }
  71144. }
  71145. declare module BABYLON {
  71146. interface Scene {
  71147. /** @hidden (Backing field) */
  71148. _boundingBoxRenderer: BoundingBoxRenderer;
  71149. /** @hidden (Backing field) */
  71150. _forceShowBoundingBoxes: boolean;
  71151. /**
  71152. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71153. */
  71154. forceShowBoundingBoxes: boolean;
  71155. /**
  71156. * Gets the bounding box renderer associated with the scene
  71157. * @returns a BoundingBoxRenderer
  71158. */
  71159. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71160. }
  71161. interface AbstractMesh {
  71162. /** @hidden (Backing field) */
  71163. _showBoundingBox: boolean;
  71164. /**
  71165. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71166. */
  71167. showBoundingBox: boolean;
  71168. }
  71169. /**
  71170. * Component responsible of rendering the bounding box of the meshes in a scene.
  71171. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71172. */
  71173. export class BoundingBoxRenderer implements ISceneComponent {
  71174. /**
  71175. * The component name helpfull to identify the component in the list of scene components.
  71176. */
  71177. readonly name: string;
  71178. /**
  71179. * The scene the component belongs to.
  71180. */
  71181. scene: Scene;
  71182. /**
  71183. * Color of the bounding box lines placed in front of an object
  71184. */
  71185. frontColor: Color3;
  71186. /**
  71187. * Color of the bounding box lines placed behind an object
  71188. */
  71189. backColor: Color3;
  71190. /**
  71191. * Defines if the renderer should show the back lines or not
  71192. */
  71193. showBackLines: boolean;
  71194. /**
  71195. * Observable raised before rendering a bounding box
  71196. */
  71197. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71198. /**
  71199. * Observable raised after rendering a bounding box
  71200. */
  71201. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71202. /**
  71203. * @hidden
  71204. */
  71205. renderList: SmartArray<BoundingBox>;
  71206. private _colorShader;
  71207. private _vertexBuffers;
  71208. private _indexBuffer;
  71209. private _fillIndexBuffer;
  71210. private _fillIndexData;
  71211. /**
  71212. * Instantiates a new bounding box renderer in a scene.
  71213. * @param scene the scene the renderer renders in
  71214. */
  71215. constructor(scene: Scene);
  71216. /**
  71217. * Registers the component in a given scene
  71218. */
  71219. register(): void;
  71220. private _evaluateSubMesh;
  71221. private _activeMesh;
  71222. private _prepareRessources;
  71223. private _createIndexBuffer;
  71224. /**
  71225. * Rebuilds the elements related to this component in case of
  71226. * context lost for instance.
  71227. */
  71228. rebuild(): void;
  71229. /**
  71230. * @hidden
  71231. */
  71232. reset(): void;
  71233. /**
  71234. * Render the bounding boxes of a specific rendering group
  71235. * @param renderingGroupId defines the rendering group to render
  71236. */
  71237. render(renderingGroupId: number): void;
  71238. /**
  71239. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71240. * @param mesh Define the mesh to render the occlusion bounding box for
  71241. */
  71242. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71243. /**
  71244. * Dispose and release the resources attached to this renderer.
  71245. */
  71246. dispose(): void;
  71247. }
  71248. }
  71249. declare module BABYLON {
  71250. interface Scene {
  71251. /** @hidden (Backing field) */
  71252. _depthRenderer: {
  71253. [id: string]: DepthRenderer;
  71254. };
  71255. /**
  71256. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71257. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71258. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71259. * @returns the created depth renderer
  71260. */
  71261. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71262. /**
  71263. * Disables a depth renderer for a given camera
  71264. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71265. */
  71266. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71267. }
  71268. /**
  71269. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71270. * in several rendering techniques.
  71271. */
  71272. export class DepthRendererSceneComponent implements ISceneComponent {
  71273. /**
  71274. * The component name helpfull to identify the component in the list of scene components.
  71275. */
  71276. readonly name: string;
  71277. /**
  71278. * The scene the component belongs to.
  71279. */
  71280. scene: Scene;
  71281. /**
  71282. * Creates a new instance of the component for the given scene
  71283. * @param scene Defines the scene to register the component in
  71284. */
  71285. constructor(scene: Scene);
  71286. /**
  71287. * Registers the component in a given scene
  71288. */
  71289. register(): void;
  71290. /**
  71291. * Rebuilds the elements related to this component in case of
  71292. * context lost for instance.
  71293. */
  71294. rebuild(): void;
  71295. /**
  71296. * Disposes the component and the associated ressources
  71297. */
  71298. dispose(): void;
  71299. private _gatherRenderTargets;
  71300. private _gatherActiveCameraRenderTargets;
  71301. }
  71302. }
  71303. declare module BABYLON {
  71304. interface AbstractScene {
  71305. /** @hidden (Backing field) */
  71306. _prePassRenderer: Nullable<PrePassRenderer>;
  71307. /**
  71308. * Gets or Sets the current prepass renderer associated to the scene.
  71309. */
  71310. prePassRenderer: Nullable<PrePassRenderer>;
  71311. /**
  71312. * Enables the prepass and associates it with the scene
  71313. * @returns the PrePassRenderer
  71314. */
  71315. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71316. /**
  71317. * Disables the prepass associated with the scene
  71318. */
  71319. disablePrePassRenderer(): void;
  71320. }
  71321. /**
  71322. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71323. * in several rendering techniques.
  71324. */
  71325. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71326. /**
  71327. * The component name helpful to identify the component in the list of scene components.
  71328. */
  71329. readonly name: string;
  71330. /**
  71331. * The scene the component belongs to.
  71332. */
  71333. scene: Scene;
  71334. /**
  71335. * Creates a new instance of the component for the given scene
  71336. * @param scene Defines the scene to register the component in
  71337. */
  71338. constructor(scene: Scene);
  71339. /**
  71340. * Registers the component in a given scene
  71341. */
  71342. register(): void;
  71343. private _beforeCameraDraw;
  71344. private _afterCameraDraw;
  71345. private _beforeClearStage;
  71346. /**
  71347. * Serializes the component data to the specified json object
  71348. * @param serializationObject The object to serialize to
  71349. */
  71350. serialize(serializationObject: any): void;
  71351. /**
  71352. * Adds all the elements from the container to the scene
  71353. * @param container the container holding the elements
  71354. */
  71355. addFromContainer(container: AbstractScene): void;
  71356. /**
  71357. * Removes all the elements in the container from the scene
  71358. * @param container contains the elements to remove
  71359. * @param dispose if the removed element should be disposed (default: false)
  71360. */
  71361. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71362. /**
  71363. * Rebuilds the elements related to this component in case of
  71364. * context lost for instance.
  71365. */
  71366. rebuild(): void;
  71367. /**
  71368. * Disposes the component and the associated ressources
  71369. */
  71370. dispose(): void;
  71371. }
  71372. }
  71373. declare module BABYLON {
  71374. /** @hidden */
  71375. export var outlinePixelShader: {
  71376. name: string;
  71377. shader: string;
  71378. };
  71379. }
  71380. declare module BABYLON {
  71381. /** @hidden */
  71382. export var outlineVertexShader: {
  71383. name: string;
  71384. shader: string;
  71385. };
  71386. }
  71387. declare module BABYLON {
  71388. interface Scene {
  71389. /** @hidden */
  71390. _outlineRenderer: OutlineRenderer;
  71391. /**
  71392. * Gets the outline renderer associated with the scene
  71393. * @returns a OutlineRenderer
  71394. */
  71395. getOutlineRenderer(): OutlineRenderer;
  71396. }
  71397. interface AbstractMesh {
  71398. /** @hidden (Backing field) */
  71399. _renderOutline: boolean;
  71400. /**
  71401. * Gets or sets a boolean indicating if the outline must be rendered as well
  71402. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71403. */
  71404. renderOutline: boolean;
  71405. /** @hidden (Backing field) */
  71406. _renderOverlay: boolean;
  71407. /**
  71408. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71409. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71410. */
  71411. renderOverlay: boolean;
  71412. }
  71413. /**
  71414. * This class is responsible to draw bothe outline/overlay of meshes.
  71415. * It should not be used directly but through the available method on mesh.
  71416. */
  71417. export class OutlineRenderer implements ISceneComponent {
  71418. /**
  71419. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71420. */
  71421. private static _StencilReference;
  71422. /**
  71423. * The name of the component. Each component must have a unique name.
  71424. */
  71425. name: string;
  71426. /**
  71427. * The scene the component belongs to.
  71428. */
  71429. scene: Scene;
  71430. /**
  71431. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71432. */
  71433. zOffset: number;
  71434. private _engine;
  71435. private _effect;
  71436. private _cachedDefines;
  71437. private _savedDepthWrite;
  71438. /**
  71439. * Instantiates a new outline renderer. (There could be only one per scene).
  71440. * @param scene Defines the scene it belongs to
  71441. */
  71442. constructor(scene: Scene);
  71443. /**
  71444. * Register the component to one instance of a scene.
  71445. */
  71446. register(): void;
  71447. /**
  71448. * Rebuilds the elements related to this component in case of
  71449. * context lost for instance.
  71450. */
  71451. rebuild(): void;
  71452. /**
  71453. * Disposes the component and the associated ressources.
  71454. */
  71455. dispose(): void;
  71456. /**
  71457. * Renders the outline in the canvas.
  71458. * @param subMesh Defines the sumesh to render
  71459. * @param batch Defines the batch of meshes in case of instances
  71460. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71461. */
  71462. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71463. /**
  71464. * Returns whether or not the outline renderer is ready for a given submesh.
  71465. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71466. * @param subMesh Defines the submesh to check readyness for
  71467. * @param useInstances Defines wheter wee are trying to render instances or not
  71468. * @returns true if ready otherwise false
  71469. */
  71470. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71471. private _beforeRenderingMesh;
  71472. private _afterRenderingMesh;
  71473. }
  71474. }
  71475. declare module BABYLON {
  71476. /**
  71477. * Defines the basic options interface of a Sprite Frame Source Size.
  71478. */
  71479. export interface ISpriteJSONSpriteSourceSize {
  71480. /**
  71481. * number of the original width of the Frame
  71482. */
  71483. w: number;
  71484. /**
  71485. * number of the original height of the Frame
  71486. */
  71487. h: number;
  71488. }
  71489. /**
  71490. * Defines the basic options interface of a Sprite Frame Data.
  71491. */
  71492. export interface ISpriteJSONSpriteFrameData {
  71493. /**
  71494. * number of the x offset of the Frame
  71495. */
  71496. x: number;
  71497. /**
  71498. * number of the y offset of the Frame
  71499. */
  71500. y: number;
  71501. /**
  71502. * number of the width of the Frame
  71503. */
  71504. w: number;
  71505. /**
  71506. * number of the height of the Frame
  71507. */
  71508. h: number;
  71509. }
  71510. /**
  71511. * Defines the basic options interface of a JSON Sprite.
  71512. */
  71513. export interface ISpriteJSONSprite {
  71514. /**
  71515. * string name of the Frame
  71516. */
  71517. filename: string;
  71518. /**
  71519. * ISpriteJSONSpriteFrame basic object of the frame data
  71520. */
  71521. frame: ISpriteJSONSpriteFrameData;
  71522. /**
  71523. * boolean to flag is the frame was rotated.
  71524. */
  71525. rotated: boolean;
  71526. /**
  71527. * boolean to flag is the frame was trimmed.
  71528. */
  71529. trimmed: boolean;
  71530. /**
  71531. * ISpriteJSONSpriteFrame basic object of the source data
  71532. */
  71533. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71534. /**
  71535. * ISpriteJSONSpriteFrame basic object of the source data
  71536. */
  71537. sourceSize: ISpriteJSONSpriteSourceSize;
  71538. }
  71539. /**
  71540. * Defines the basic options interface of a JSON atlas.
  71541. */
  71542. export interface ISpriteJSONAtlas {
  71543. /**
  71544. * Array of objects that contain the frame data.
  71545. */
  71546. frames: Array<ISpriteJSONSprite>;
  71547. /**
  71548. * object basic object containing the sprite meta data.
  71549. */
  71550. meta?: object;
  71551. }
  71552. }
  71553. declare module BABYLON {
  71554. /** @hidden */
  71555. export var spriteMapPixelShader: {
  71556. name: string;
  71557. shader: string;
  71558. };
  71559. }
  71560. declare module BABYLON {
  71561. /** @hidden */
  71562. export var spriteMapVertexShader: {
  71563. name: string;
  71564. shader: string;
  71565. };
  71566. }
  71567. declare module BABYLON {
  71568. /**
  71569. * Defines the basic options interface of a SpriteMap
  71570. */
  71571. export interface ISpriteMapOptions {
  71572. /**
  71573. * Vector2 of the number of cells in the grid.
  71574. */
  71575. stageSize?: Vector2;
  71576. /**
  71577. * Vector2 of the size of the output plane in World Units.
  71578. */
  71579. outputSize?: Vector2;
  71580. /**
  71581. * Vector3 of the position of the output plane in World Units.
  71582. */
  71583. outputPosition?: Vector3;
  71584. /**
  71585. * Vector3 of the rotation of the output plane.
  71586. */
  71587. outputRotation?: Vector3;
  71588. /**
  71589. * number of layers that the system will reserve in resources.
  71590. */
  71591. layerCount?: number;
  71592. /**
  71593. * number of max animation frames a single cell will reserve in resources.
  71594. */
  71595. maxAnimationFrames?: number;
  71596. /**
  71597. * number cell index of the base tile when the system compiles.
  71598. */
  71599. baseTile?: number;
  71600. /**
  71601. * boolean flip the sprite after its been repositioned by the framing data.
  71602. */
  71603. flipU?: boolean;
  71604. /**
  71605. * Vector3 scalar of the global RGB values of the SpriteMap.
  71606. */
  71607. colorMultiply?: Vector3;
  71608. }
  71609. /**
  71610. * Defines the IDisposable interface in order to be cleanable from resources.
  71611. */
  71612. export interface ISpriteMap extends IDisposable {
  71613. /**
  71614. * String name of the SpriteMap.
  71615. */
  71616. name: string;
  71617. /**
  71618. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71619. */
  71620. atlasJSON: ISpriteJSONAtlas;
  71621. /**
  71622. * Texture of the SpriteMap.
  71623. */
  71624. spriteSheet: Texture;
  71625. /**
  71626. * The parameters to initialize the SpriteMap with.
  71627. */
  71628. options: ISpriteMapOptions;
  71629. }
  71630. /**
  71631. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71632. */
  71633. export class SpriteMap implements ISpriteMap {
  71634. /** The Name of the spriteMap */
  71635. name: string;
  71636. /** The JSON file with the frame and meta data */
  71637. atlasJSON: ISpriteJSONAtlas;
  71638. /** The systems Sprite Sheet Texture */
  71639. spriteSheet: Texture;
  71640. /** Arguments passed with the Constructor */
  71641. options: ISpriteMapOptions;
  71642. /** Public Sprite Storage array, parsed from atlasJSON */
  71643. sprites: Array<ISpriteJSONSprite>;
  71644. /** Returns the Number of Sprites in the System */
  71645. get spriteCount(): number;
  71646. /** Returns the Position of Output Plane*/
  71647. get position(): Vector3;
  71648. /** Returns the Position of Output Plane*/
  71649. set position(v: Vector3);
  71650. /** Returns the Rotation of Output Plane*/
  71651. get rotation(): Vector3;
  71652. /** Returns the Rotation of Output Plane*/
  71653. set rotation(v: Vector3);
  71654. /** Sets the AnimationMap*/
  71655. get animationMap(): RawTexture;
  71656. /** Sets the AnimationMap*/
  71657. set animationMap(v: RawTexture);
  71658. /** Scene that the SpriteMap was created in */
  71659. private _scene;
  71660. /** Texture Buffer of Float32 that holds tile frame data*/
  71661. private _frameMap;
  71662. /** Texture Buffers of Float32 that holds tileMap data*/
  71663. private _tileMaps;
  71664. /** Texture Buffer of Float32 that holds Animation Data*/
  71665. private _animationMap;
  71666. /** Custom ShaderMaterial Central to the System*/
  71667. private _material;
  71668. /** Custom ShaderMaterial Central to the System*/
  71669. private _output;
  71670. /** Systems Time Ticker*/
  71671. private _time;
  71672. /**
  71673. * Creates a new SpriteMap
  71674. * @param name defines the SpriteMaps Name
  71675. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71676. * @param spriteSheet is the Texture that the Sprites are on.
  71677. * @param options a basic deployment configuration
  71678. * @param scene The Scene that the map is deployed on
  71679. */
  71680. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71681. /**
  71682. * Returns tileID location
  71683. * @returns Vector2 the cell position ID
  71684. */
  71685. getTileID(): Vector2;
  71686. /**
  71687. * Gets the UV location of the mouse over the SpriteMap.
  71688. * @returns Vector2 the UV position of the mouse interaction
  71689. */
  71690. getMousePosition(): Vector2;
  71691. /**
  71692. * Creates the "frame" texture Buffer
  71693. * -------------------------------------
  71694. * Structure of frames
  71695. * "filename": "Falling-Water-2.png",
  71696. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71697. * "rotated": true,
  71698. * "trimmed": true,
  71699. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71700. * "sourceSize": {"w":32,"h":32}
  71701. * @returns RawTexture of the frameMap
  71702. */
  71703. private _createFrameBuffer;
  71704. /**
  71705. * Creates the tileMap texture Buffer
  71706. * @param buffer normally and array of numbers, or a false to generate from scratch
  71707. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71708. * @returns RawTexture of the tileMap
  71709. */
  71710. private _createTileBuffer;
  71711. /**
  71712. * Modifies the data of the tileMaps
  71713. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71714. * @param pos is the iVector2 Coordinates of the Tile
  71715. * @param tile The SpriteIndex of the new Tile
  71716. */
  71717. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71718. /**
  71719. * Creates the animationMap texture Buffer
  71720. * @param buffer normally and array of numbers, or a false to generate from scratch
  71721. * @returns RawTexture of the animationMap
  71722. */
  71723. private _createTileAnimationBuffer;
  71724. /**
  71725. * Modifies the data of the animationMap
  71726. * @param cellID is the Index of the Sprite
  71727. * @param _frame is the target Animation frame
  71728. * @param toCell is the Target Index of the next frame of the animation
  71729. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71730. * @param speed is a global scalar of the time variable on the map.
  71731. */
  71732. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71733. /**
  71734. * Exports the .tilemaps file
  71735. */
  71736. saveTileMaps(): void;
  71737. /**
  71738. * Imports the .tilemaps file
  71739. * @param url of the .tilemaps file
  71740. */
  71741. loadTileMaps(url: string): void;
  71742. /**
  71743. * Release associated resources
  71744. */
  71745. dispose(): void;
  71746. }
  71747. }
  71748. declare module BABYLON {
  71749. /**
  71750. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71751. * @see https://doc.babylonjs.com/babylon101/sprites
  71752. */
  71753. export class SpritePackedManager extends SpriteManager {
  71754. /** defines the packed manager's name */
  71755. name: string;
  71756. /**
  71757. * Creates a new sprite manager from a packed sprite sheet
  71758. * @param name defines the manager's name
  71759. * @param imgUrl defines the sprite sheet url
  71760. * @param capacity defines the maximum allowed number of sprites
  71761. * @param scene defines the hosting scene
  71762. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71763. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71764. * @param samplingMode defines the smapling mode to use with spritesheet
  71765. * @param fromPacked set to true; do not alter
  71766. */
  71767. constructor(
  71768. /** defines the packed manager's name */
  71769. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71770. }
  71771. }
  71772. declare module BABYLON {
  71773. /**
  71774. * Defines the list of states available for a task inside a AssetsManager
  71775. */
  71776. export enum AssetTaskState {
  71777. /**
  71778. * Initialization
  71779. */
  71780. INIT = 0,
  71781. /**
  71782. * Running
  71783. */
  71784. RUNNING = 1,
  71785. /**
  71786. * Done
  71787. */
  71788. DONE = 2,
  71789. /**
  71790. * Error
  71791. */
  71792. ERROR = 3
  71793. }
  71794. /**
  71795. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71796. */
  71797. export abstract class AbstractAssetTask {
  71798. /**
  71799. * Task name
  71800. */ name: string;
  71801. /**
  71802. * Callback called when the task is successful
  71803. */
  71804. onSuccess: (task: any) => void;
  71805. /**
  71806. * Callback called when the task is not successful
  71807. */
  71808. onError: (task: any, message?: string, exception?: any) => void;
  71809. /**
  71810. * Creates a new AssetsManager
  71811. * @param name defines the name of the task
  71812. */
  71813. constructor(
  71814. /**
  71815. * Task name
  71816. */ name: string);
  71817. private _isCompleted;
  71818. private _taskState;
  71819. private _errorObject;
  71820. /**
  71821. * Get if the task is completed
  71822. */
  71823. get isCompleted(): boolean;
  71824. /**
  71825. * Gets the current state of the task
  71826. */
  71827. get taskState(): AssetTaskState;
  71828. /**
  71829. * Gets the current error object (if task is in error)
  71830. */
  71831. get errorObject(): {
  71832. message?: string;
  71833. exception?: any;
  71834. };
  71835. /**
  71836. * Internal only
  71837. * @hidden
  71838. */
  71839. _setErrorObject(message?: string, exception?: any): void;
  71840. /**
  71841. * Execute the current task
  71842. * @param scene defines the scene where you want your assets to be loaded
  71843. * @param onSuccess is a callback called when the task is successfully executed
  71844. * @param onError is a callback called if an error occurs
  71845. */
  71846. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71847. /**
  71848. * Execute the current task
  71849. * @param scene defines the scene where you want your assets to be loaded
  71850. * @param onSuccess is a callback called when the task is successfully executed
  71851. * @param onError is a callback called if an error occurs
  71852. */
  71853. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71854. /**
  71855. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71856. * This can be used with failed tasks that have the reason for failure fixed.
  71857. */
  71858. reset(): void;
  71859. private onErrorCallback;
  71860. private onDoneCallback;
  71861. }
  71862. /**
  71863. * Define the interface used by progress events raised during assets loading
  71864. */
  71865. export interface IAssetsProgressEvent {
  71866. /**
  71867. * Defines the number of remaining tasks to process
  71868. */
  71869. remainingCount: number;
  71870. /**
  71871. * Defines the total number of tasks
  71872. */
  71873. totalCount: number;
  71874. /**
  71875. * Defines the task that was just processed
  71876. */
  71877. task: AbstractAssetTask;
  71878. }
  71879. /**
  71880. * Class used to share progress information about assets loading
  71881. */
  71882. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71883. /**
  71884. * Defines the number of remaining tasks to process
  71885. */
  71886. remainingCount: number;
  71887. /**
  71888. * Defines the total number of tasks
  71889. */
  71890. totalCount: number;
  71891. /**
  71892. * Defines the task that was just processed
  71893. */
  71894. task: AbstractAssetTask;
  71895. /**
  71896. * Creates a AssetsProgressEvent
  71897. * @param remainingCount defines the number of remaining tasks to process
  71898. * @param totalCount defines the total number of tasks
  71899. * @param task defines the task that was just processed
  71900. */
  71901. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71902. }
  71903. /**
  71904. * Define a task used by AssetsManager to load meshes
  71905. */
  71906. export class MeshAssetTask extends AbstractAssetTask {
  71907. /**
  71908. * Defines the name of the task
  71909. */
  71910. name: string;
  71911. /**
  71912. * Defines the list of mesh's names you want to load
  71913. */
  71914. meshesNames: any;
  71915. /**
  71916. * Defines the root url to use as a base to load your meshes and associated resources
  71917. */
  71918. rootUrl: string;
  71919. /**
  71920. * Defines the filename or File of the scene to load from
  71921. */
  71922. sceneFilename: string | File;
  71923. /**
  71924. * Gets the list of loaded meshes
  71925. */
  71926. loadedMeshes: Array<AbstractMesh>;
  71927. /**
  71928. * Gets the list of loaded particle systems
  71929. */
  71930. loadedParticleSystems: Array<IParticleSystem>;
  71931. /**
  71932. * Gets the list of loaded skeletons
  71933. */
  71934. loadedSkeletons: Array<Skeleton>;
  71935. /**
  71936. * Gets the list of loaded animation groups
  71937. */
  71938. loadedAnimationGroups: Array<AnimationGroup>;
  71939. /**
  71940. * Callback called when the task is successful
  71941. */
  71942. onSuccess: (task: MeshAssetTask) => void;
  71943. /**
  71944. * Callback called when the task is successful
  71945. */
  71946. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71947. /**
  71948. * Creates a new MeshAssetTask
  71949. * @param name defines the name of the task
  71950. * @param meshesNames defines the list of mesh's names you want to load
  71951. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71952. * @param sceneFilename defines the filename or File of the scene to load from
  71953. */
  71954. constructor(
  71955. /**
  71956. * Defines the name of the task
  71957. */
  71958. name: string,
  71959. /**
  71960. * Defines the list of mesh's names you want to load
  71961. */
  71962. meshesNames: any,
  71963. /**
  71964. * Defines the root url to use as a base to load your meshes and associated resources
  71965. */
  71966. rootUrl: string,
  71967. /**
  71968. * Defines the filename or File of the scene to load from
  71969. */
  71970. sceneFilename: string | File);
  71971. /**
  71972. * Execute the current task
  71973. * @param scene defines the scene where you want your assets to be loaded
  71974. * @param onSuccess is a callback called when the task is successfully executed
  71975. * @param onError is a callback called if an error occurs
  71976. */
  71977. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71978. }
  71979. /**
  71980. * Define a task used by AssetsManager to load text content
  71981. */
  71982. export class TextFileAssetTask extends AbstractAssetTask {
  71983. /**
  71984. * Defines the name of the task
  71985. */
  71986. name: string;
  71987. /**
  71988. * Defines the location of the file to load
  71989. */
  71990. url: string;
  71991. /**
  71992. * Gets the loaded text string
  71993. */
  71994. text: string;
  71995. /**
  71996. * Callback called when the task is successful
  71997. */
  71998. onSuccess: (task: TextFileAssetTask) => void;
  71999. /**
  72000. * Callback called when the task is successful
  72001. */
  72002. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72003. /**
  72004. * Creates a new TextFileAssetTask object
  72005. * @param name defines the name of the task
  72006. * @param url defines the location of the file to load
  72007. */
  72008. constructor(
  72009. /**
  72010. * Defines the name of the task
  72011. */
  72012. name: string,
  72013. /**
  72014. * Defines the location of the file to load
  72015. */
  72016. url: string);
  72017. /**
  72018. * Execute the current task
  72019. * @param scene defines the scene where you want your assets to be loaded
  72020. * @param onSuccess is a callback called when the task is successfully executed
  72021. * @param onError is a callback called if an error occurs
  72022. */
  72023. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72024. }
  72025. /**
  72026. * Define a task used by AssetsManager to load binary data
  72027. */
  72028. export class BinaryFileAssetTask extends AbstractAssetTask {
  72029. /**
  72030. * Defines the name of the task
  72031. */
  72032. name: string;
  72033. /**
  72034. * Defines the location of the file to load
  72035. */
  72036. url: string;
  72037. /**
  72038. * Gets the lodaded data (as an array buffer)
  72039. */
  72040. data: ArrayBuffer;
  72041. /**
  72042. * Callback called when the task is successful
  72043. */
  72044. onSuccess: (task: BinaryFileAssetTask) => void;
  72045. /**
  72046. * Callback called when the task is successful
  72047. */
  72048. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72049. /**
  72050. * Creates a new BinaryFileAssetTask object
  72051. * @param name defines the name of the new task
  72052. * @param url defines the location of the file to load
  72053. */
  72054. constructor(
  72055. /**
  72056. * Defines the name of the task
  72057. */
  72058. name: string,
  72059. /**
  72060. * Defines the location of the file to load
  72061. */
  72062. url: string);
  72063. /**
  72064. * Execute the current task
  72065. * @param scene defines the scene where you want your assets to be loaded
  72066. * @param onSuccess is a callback called when the task is successfully executed
  72067. * @param onError is a callback called if an error occurs
  72068. */
  72069. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72070. }
  72071. /**
  72072. * Define a task used by AssetsManager to load images
  72073. */
  72074. export class ImageAssetTask extends AbstractAssetTask {
  72075. /**
  72076. * Defines the name of the task
  72077. */
  72078. name: string;
  72079. /**
  72080. * Defines the location of the image to load
  72081. */
  72082. url: string;
  72083. /**
  72084. * Gets the loaded images
  72085. */
  72086. image: HTMLImageElement;
  72087. /**
  72088. * Callback called when the task is successful
  72089. */
  72090. onSuccess: (task: ImageAssetTask) => void;
  72091. /**
  72092. * Callback called when the task is successful
  72093. */
  72094. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72095. /**
  72096. * Creates a new ImageAssetTask
  72097. * @param name defines the name of the task
  72098. * @param url defines the location of the image to load
  72099. */
  72100. constructor(
  72101. /**
  72102. * Defines the name of the task
  72103. */
  72104. name: string,
  72105. /**
  72106. * Defines the location of the image to load
  72107. */
  72108. url: string);
  72109. /**
  72110. * Execute the current task
  72111. * @param scene defines the scene where you want your assets to be loaded
  72112. * @param onSuccess is a callback called when the task is successfully executed
  72113. * @param onError is a callback called if an error occurs
  72114. */
  72115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72116. }
  72117. /**
  72118. * Defines the interface used by texture loading tasks
  72119. */
  72120. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72121. /**
  72122. * Gets the loaded texture
  72123. */
  72124. texture: TEX;
  72125. }
  72126. /**
  72127. * Define a task used by AssetsManager to load 2D textures
  72128. */
  72129. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72130. /**
  72131. * Defines the name of the task
  72132. */
  72133. name: string;
  72134. /**
  72135. * Defines the location of the file to load
  72136. */
  72137. url: string;
  72138. /**
  72139. * Defines if mipmap should not be generated (default is false)
  72140. */
  72141. noMipmap?: boolean | undefined;
  72142. /**
  72143. * Defines if texture must be inverted on Y axis (default is true)
  72144. */
  72145. invertY: boolean;
  72146. /**
  72147. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72148. */
  72149. samplingMode: number;
  72150. /**
  72151. * Gets the loaded texture
  72152. */
  72153. texture: Texture;
  72154. /**
  72155. * Callback called when the task is successful
  72156. */
  72157. onSuccess: (task: TextureAssetTask) => void;
  72158. /**
  72159. * Callback called when the task is successful
  72160. */
  72161. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72162. /**
  72163. * Creates a new TextureAssetTask object
  72164. * @param name defines the name of the task
  72165. * @param url defines the location of the file to load
  72166. * @param noMipmap defines if mipmap should not be generated (default is false)
  72167. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72168. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72169. */
  72170. constructor(
  72171. /**
  72172. * Defines the name of the task
  72173. */
  72174. name: string,
  72175. /**
  72176. * Defines the location of the file to load
  72177. */
  72178. url: string,
  72179. /**
  72180. * Defines if mipmap should not be generated (default is false)
  72181. */
  72182. noMipmap?: boolean | undefined,
  72183. /**
  72184. * Defines if texture must be inverted on Y axis (default is true)
  72185. */
  72186. invertY?: boolean,
  72187. /**
  72188. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72189. */
  72190. samplingMode?: number);
  72191. /**
  72192. * Execute the current task
  72193. * @param scene defines the scene where you want your assets to be loaded
  72194. * @param onSuccess is a callback called when the task is successfully executed
  72195. * @param onError is a callback called if an error occurs
  72196. */
  72197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72198. }
  72199. /**
  72200. * Define a task used by AssetsManager to load cube textures
  72201. */
  72202. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72203. /**
  72204. * Defines the name of the task
  72205. */
  72206. name: string;
  72207. /**
  72208. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72209. */
  72210. url: string;
  72211. /**
  72212. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72213. */
  72214. extensions?: string[] | undefined;
  72215. /**
  72216. * Defines if mipmaps should not be generated (default is false)
  72217. */
  72218. noMipmap?: boolean | undefined;
  72219. /**
  72220. * Defines the explicit list of files (undefined by default)
  72221. */
  72222. files?: string[] | undefined;
  72223. /**
  72224. * Gets the loaded texture
  72225. */
  72226. texture: CubeTexture;
  72227. /**
  72228. * Callback called when the task is successful
  72229. */
  72230. onSuccess: (task: CubeTextureAssetTask) => void;
  72231. /**
  72232. * Callback called when the task is successful
  72233. */
  72234. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72235. /**
  72236. * Creates a new CubeTextureAssetTask
  72237. * @param name defines the name of the task
  72238. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72239. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72240. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72241. * @param files defines the explicit list of files (undefined by default)
  72242. */
  72243. constructor(
  72244. /**
  72245. * Defines the name of the task
  72246. */
  72247. name: string,
  72248. /**
  72249. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72250. */
  72251. url: string,
  72252. /**
  72253. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72254. */
  72255. extensions?: string[] | undefined,
  72256. /**
  72257. * Defines if mipmaps should not be generated (default is false)
  72258. */
  72259. noMipmap?: boolean | undefined,
  72260. /**
  72261. * Defines the explicit list of files (undefined by default)
  72262. */
  72263. files?: string[] | undefined);
  72264. /**
  72265. * Execute the current task
  72266. * @param scene defines the scene where you want your assets to be loaded
  72267. * @param onSuccess is a callback called when the task is successfully executed
  72268. * @param onError is a callback called if an error occurs
  72269. */
  72270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72271. }
  72272. /**
  72273. * Define a task used by AssetsManager to load HDR cube textures
  72274. */
  72275. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72276. /**
  72277. * Defines the name of the task
  72278. */
  72279. name: string;
  72280. /**
  72281. * Defines the location of the file to load
  72282. */
  72283. url: string;
  72284. /**
  72285. * Defines the desired size (the more it increases the longer the generation will be)
  72286. */
  72287. size: number;
  72288. /**
  72289. * Defines if mipmaps should not be generated (default is false)
  72290. */
  72291. noMipmap: boolean;
  72292. /**
  72293. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72294. */
  72295. generateHarmonics: boolean;
  72296. /**
  72297. * 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)
  72298. */
  72299. gammaSpace: boolean;
  72300. /**
  72301. * Internal Use Only
  72302. */
  72303. reserved: boolean;
  72304. /**
  72305. * Gets the loaded texture
  72306. */
  72307. texture: HDRCubeTexture;
  72308. /**
  72309. * Callback called when the task is successful
  72310. */
  72311. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72312. /**
  72313. * Callback called when the task is successful
  72314. */
  72315. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72316. /**
  72317. * Creates a new HDRCubeTextureAssetTask object
  72318. * @param name defines the name of the task
  72319. * @param url defines the location of the file to load
  72320. * @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.
  72321. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72322. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72323. * @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)
  72324. * @param reserved Internal use only
  72325. */
  72326. constructor(
  72327. /**
  72328. * Defines the name of the task
  72329. */
  72330. name: string,
  72331. /**
  72332. * Defines the location of the file to load
  72333. */
  72334. url: string,
  72335. /**
  72336. * Defines the desired size (the more it increases the longer the generation will be)
  72337. */
  72338. size: number,
  72339. /**
  72340. * Defines if mipmaps should not be generated (default is false)
  72341. */
  72342. noMipmap?: boolean,
  72343. /**
  72344. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72345. */
  72346. generateHarmonics?: boolean,
  72347. /**
  72348. * 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)
  72349. */
  72350. gammaSpace?: boolean,
  72351. /**
  72352. * Internal Use Only
  72353. */
  72354. reserved?: boolean);
  72355. /**
  72356. * Execute the current task
  72357. * @param scene defines the scene where you want your assets to be loaded
  72358. * @param onSuccess is a callback called when the task is successfully executed
  72359. * @param onError is a callback called if an error occurs
  72360. */
  72361. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72362. }
  72363. /**
  72364. * Define a task used by AssetsManager to load Equirectangular cube textures
  72365. */
  72366. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72367. /**
  72368. * Defines the name of the task
  72369. */
  72370. name: string;
  72371. /**
  72372. * Defines the location of the file to load
  72373. */
  72374. url: string;
  72375. /**
  72376. * Defines the desired size (the more it increases the longer the generation will be)
  72377. */
  72378. size: number;
  72379. /**
  72380. * Defines if mipmaps should not be generated (default is false)
  72381. */
  72382. noMipmap: boolean;
  72383. /**
  72384. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72385. * but the standard material would require them in Gamma space) (default is true)
  72386. */
  72387. gammaSpace: boolean;
  72388. /**
  72389. * Gets the loaded texture
  72390. */
  72391. texture: EquiRectangularCubeTexture;
  72392. /**
  72393. * Callback called when the task is successful
  72394. */
  72395. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72396. /**
  72397. * Callback called when the task is successful
  72398. */
  72399. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72400. /**
  72401. * Creates a new EquiRectangularCubeTextureAssetTask object
  72402. * @param name defines the name of the task
  72403. * @param url defines the location of the file to load
  72404. * @param size defines the desired size (the more it increases the longer the generation will be)
  72405. * If the size is omitted this implies you are using a preprocessed cubemap.
  72406. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72407. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72408. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72409. * (default is true)
  72410. */
  72411. constructor(
  72412. /**
  72413. * Defines the name of the task
  72414. */
  72415. name: string,
  72416. /**
  72417. * Defines the location of the file to load
  72418. */
  72419. url: string,
  72420. /**
  72421. * Defines the desired size (the more it increases the longer the generation will be)
  72422. */
  72423. size: number,
  72424. /**
  72425. * Defines if mipmaps should not be generated (default is false)
  72426. */
  72427. noMipmap?: boolean,
  72428. /**
  72429. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72430. * but the standard material would require them in Gamma space) (default is true)
  72431. */
  72432. gammaSpace?: boolean);
  72433. /**
  72434. * Execute the current task
  72435. * @param scene defines the scene where you want your assets to be loaded
  72436. * @param onSuccess is a callback called when the task is successfully executed
  72437. * @param onError is a callback called if an error occurs
  72438. */
  72439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72440. }
  72441. /**
  72442. * This class can be used to easily import assets into a scene
  72443. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72444. */
  72445. export class AssetsManager {
  72446. private _scene;
  72447. private _isLoading;
  72448. protected _tasks: AbstractAssetTask[];
  72449. protected _waitingTasksCount: number;
  72450. protected _totalTasksCount: number;
  72451. /**
  72452. * Callback called when all tasks are processed
  72453. */
  72454. onFinish: (tasks: AbstractAssetTask[]) => void;
  72455. /**
  72456. * Callback called when a task is successful
  72457. */
  72458. onTaskSuccess: (task: AbstractAssetTask) => void;
  72459. /**
  72460. * Callback called when a task had an error
  72461. */
  72462. onTaskError: (task: AbstractAssetTask) => void;
  72463. /**
  72464. * Callback called when a task is done (whatever the result is)
  72465. */
  72466. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72467. /**
  72468. * Observable called when all tasks are processed
  72469. */
  72470. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72471. /**
  72472. * Observable called when a task had an error
  72473. */
  72474. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72475. /**
  72476. * Observable called when all tasks were executed
  72477. */
  72478. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72479. /**
  72480. * Observable called when a task is done (whatever the result is)
  72481. */
  72482. onProgressObservable: Observable<IAssetsProgressEvent>;
  72483. /**
  72484. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72485. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72486. */
  72487. useDefaultLoadingScreen: boolean;
  72488. /**
  72489. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72490. * when all assets have been downloaded.
  72491. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72492. */
  72493. autoHideLoadingUI: boolean;
  72494. /**
  72495. * Creates a new AssetsManager
  72496. * @param scene defines the scene to work on
  72497. */
  72498. constructor(scene: Scene);
  72499. /**
  72500. * Add a MeshAssetTask to the list of active tasks
  72501. * @param taskName defines the name of the new task
  72502. * @param meshesNames defines the name of meshes to load
  72503. * @param rootUrl defines the root url to use to locate files
  72504. * @param sceneFilename defines the filename of the scene file
  72505. * @returns a new MeshAssetTask object
  72506. */
  72507. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72508. /**
  72509. * Add a TextFileAssetTask to the list of active tasks
  72510. * @param taskName defines the name of the new task
  72511. * @param url defines the url of the file to load
  72512. * @returns a new TextFileAssetTask object
  72513. */
  72514. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72515. /**
  72516. * Add a BinaryFileAssetTask to the list of active tasks
  72517. * @param taskName defines the name of the new task
  72518. * @param url defines the url of the file to load
  72519. * @returns a new BinaryFileAssetTask object
  72520. */
  72521. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72522. /**
  72523. * Add a ImageAssetTask to the list of active tasks
  72524. * @param taskName defines the name of the new task
  72525. * @param url defines the url of the file to load
  72526. * @returns a new ImageAssetTask object
  72527. */
  72528. addImageTask(taskName: string, url: string): ImageAssetTask;
  72529. /**
  72530. * Add a TextureAssetTask to the list of active tasks
  72531. * @param taskName defines the name of the new task
  72532. * @param url defines the url of the file to load
  72533. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72534. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72535. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72536. * @returns a new TextureAssetTask object
  72537. */
  72538. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72539. /**
  72540. * Add a CubeTextureAssetTask to the list of active tasks
  72541. * @param taskName defines the name of the new task
  72542. * @param url defines the url of the file to load
  72543. * @param extensions defines the extension to use to load the cube map (can be null)
  72544. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72545. * @param files defines the list of files to load (can be null)
  72546. * @returns a new CubeTextureAssetTask object
  72547. */
  72548. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72549. /**
  72550. *
  72551. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72552. * @param taskName defines the name of the new task
  72553. * @param url defines the url of the file to load
  72554. * @param size defines the size you want for the cubemap (can be null)
  72555. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72556. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72557. * @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)
  72558. * @param reserved Internal use only
  72559. * @returns a new HDRCubeTextureAssetTask object
  72560. */
  72561. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72562. /**
  72563. *
  72564. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72565. * @param taskName defines the name of the new task
  72566. * @param url defines the url of the file to load
  72567. * @param size defines the size you want for the cubemap (can be null)
  72568. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72569. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72570. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72571. * @returns a new EquiRectangularCubeTextureAssetTask object
  72572. */
  72573. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72574. /**
  72575. * Remove a task from the assets manager.
  72576. * @param task the task to remove
  72577. */
  72578. removeTask(task: AbstractAssetTask): void;
  72579. private _decreaseWaitingTasksCount;
  72580. private _runTask;
  72581. /**
  72582. * Reset the AssetsManager and remove all tasks
  72583. * @return the current instance of the AssetsManager
  72584. */
  72585. reset(): AssetsManager;
  72586. /**
  72587. * Start the loading process
  72588. * @return the current instance of the AssetsManager
  72589. */
  72590. load(): AssetsManager;
  72591. /**
  72592. * Start the loading process as an async operation
  72593. * @return a promise returning the list of failed tasks
  72594. */
  72595. loadAsync(): Promise<void>;
  72596. }
  72597. }
  72598. declare module BABYLON {
  72599. /**
  72600. * Wrapper class for promise with external resolve and reject.
  72601. */
  72602. export class Deferred<T> {
  72603. /**
  72604. * The promise associated with this deferred object.
  72605. */
  72606. readonly promise: Promise<T>;
  72607. private _resolve;
  72608. private _reject;
  72609. /**
  72610. * The resolve method of the promise associated with this deferred object.
  72611. */
  72612. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72613. /**
  72614. * The reject method of the promise associated with this deferred object.
  72615. */
  72616. get reject(): (reason?: any) => void;
  72617. /**
  72618. * Constructor for this deferred object.
  72619. */
  72620. constructor();
  72621. }
  72622. }
  72623. declare module BABYLON {
  72624. /**
  72625. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72626. */
  72627. export class MeshExploder {
  72628. private _centerMesh;
  72629. private _meshes;
  72630. private _meshesOrigins;
  72631. private _toCenterVectors;
  72632. private _scaledDirection;
  72633. private _newPosition;
  72634. private _centerPosition;
  72635. /**
  72636. * Explodes meshes from a center mesh.
  72637. * @param meshes The meshes to explode.
  72638. * @param centerMesh The mesh to be center of explosion.
  72639. */
  72640. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72641. private _setCenterMesh;
  72642. /**
  72643. * Get class name
  72644. * @returns "MeshExploder"
  72645. */
  72646. getClassName(): string;
  72647. /**
  72648. * "Exploded meshes"
  72649. * @returns Array of meshes with the centerMesh at index 0.
  72650. */
  72651. getMeshes(): Array<Mesh>;
  72652. /**
  72653. * Explodes meshes giving a specific direction
  72654. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72655. */
  72656. explode(direction?: number): void;
  72657. }
  72658. }
  72659. declare module BABYLON {
  72660. /**
  72661. * Class used to help managing file picking and drag'n'drop
  72662. */
  72663. export class FilesInput {
  72664. /**
  72665. * List of files ready to be loaded
  72666. */
  72667. static get FilesToLoad(): {
  72668. [key: string]: File;
  72669. };
  72670. /**
  72671. * Callback called when a file is processed
  72672. */
  72673. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72674. private _engine;
  72675. private _currentScene;
  72676. private _sceneLoadedCallback;
  72677. private _progressCallback;
  72678. private _additionalRenderLoopLogicCallback;
  72679. private _textureLoadingCallback;
  72680. private _startingProcessingFilesCallback;
  72681. private _onReloadCallback;
  72682. private _errorCallback;
  72683. private _elementToMonitor;
  72684. private _sceneFileToLoad;
  72685. private _filesToLoad;
  72686. /**
  72687. * Creates a new FilesInput
  72688. * @param engine defines the rendering engine
  72689. * @param scene defines the hosting scene
  72690. * @param sceneLoadedCallback callback called when scene is loaded
  72691. * @param progressCallback callback called to track progress
  72692. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72693. * @param textureLoadingCallback callback called when a texture is loading
  72694. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72695. * @param onReloadCallback callback called when a reload is requested
  72696. * @param errorCallback callback call if an error occurs
  72697. */
  72698. 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>);
  72699. private _dragEnterHandler;
  72700. private _dragOverHandler;
  72701. private _dropHandler;
  72702. /**
  72703. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72704. * @param elementToMonitor defines the DOM element to track
  72705. */
  72706. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72707. /** Gets the current list of files to load */
  72708. get filesToLoad(): File[];
  72709. /**
  72710. * Release all associated resources
  72711. */
  72712. dispose(): void;
  72713. private renderFunction;
  72714. private drag;
  72715. private drop;
  72716. private _traverseFolder;
  72717. private _processFiles;
  72718. /**
  72719. * Load files from a drop event
  72720. * @param event defines the drop event to use as source
  72721. */
  72722. loadFiles(event: any): void;
  72723. private _processReload;
  72724. /**
  72725. * Reload the current scene from the loaded files
  72726. */
  72727. reload(): void;
  72728. }
  72729. }
  72730. declare module BABYLON {
  72731. /**
  72732. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72733. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72734. */
  72735. export class SceneOptimization {
  72736. /**
  72737. * Defines the priority of this optimization (0 by default which means first in the list)
  72738. */
  72739. priority: number;
  72740. /**
  72741. * Gets a string describing the action executed by the current optimization
  72742. * @returns description string
  72743. */
  72744. getDescription(): string;
  72745. /**
  72746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72747. * @param scene defines the current scene where to apply this optimization
  72748. * @param optimizer defines the current optimizer
  72749. * @returns true if everything that can be done was applied
  72750. */
  72751. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72752. /**
  72753. * Creates the SceneOptimization object
  72754. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72755. * @param desc defines the description associated with the optimization
  72756. */
  72757. constructor(
  72758. /**
  72759. * Defines the priority of this optimization (0 by default which means first in the list)
  72760. */
  72761. priority?: number);
  72762. }
  72763. /**
  72764. * Defines an optimization used to reduce the size of render target textures
  72765. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72766. */
  72767. export class TextureOptimization extends SceneOptimization {
  72768. /**
  72769. * Defines the priority of this optimization (0 by default which means first in the list)
  72770. */
  72771. priority: number;
  72772. /**
  72773. * 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
  72774. */
  72775. maximumSize: number;
  72776. /**
  72777. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72778. */
  72779. step: number;
  72780. /**
  72781. * Gets a string describing the action executed by the current optimization
  72782. * @returns description string
  72783. */
  72784. getDescription(): string;
  72785. /**
  72786. * Creates the TextureOptimization object
  72787. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72788. * @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
  72789. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72790. */
  72791. constructor(
  72792. /**
  72793. * Defines the priority of this optimization (0 by default which means first in the list)
  72794. */
  72795. priority?: number,
  72796. /**
  72797. * 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
  72798. */
  72799. maximumSize?: number,
  72800. /**
  72801. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72802. */
  72803. step?: number);
  72804. /**
  72805. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72806. * @param scene defines the current scene where to apply this optimization
  72807. * @param optimizer defines the current optimizer
  72808. * @returns true if everything that can be done was applied
  72809. */
  72810. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72811. }
  72812. /**
  72813. * Defines an optimization used to increase or decrease the rendering resolution
  72814. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72815. */
  72816. export class HardwareScalingOptimization extends SceneOptimization {
  72817. /**
  72818. * Defines the priority of this optimization (0 by default which means first in the list)
  72819. */
  72820. priority: number;
  72821. /**
  72822. * Defines the maximum scale to use (2 by default)
  72823. */
  72824. maximumScale: number;
  72825. /**
  72826. * Defines the step to use between two passes (0.5 by default)
  72827. */
  72828. step: number;
  72829. private _currentScale;
  72830. private _directionOffset;
  72831. /**
  72832. * Gets a string describing the action executed by the current optimization
  72833. * @return description string
  72834. */
  72835. getDescription(): string;
  72836. /**
  72837. * Creates the HardwareScalingOptimization object
  72838. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72839. * @param maximumScale defines the maximum scale to use (2 by default)
  72840. * @param step defines the step to use between two passes (0.5 by default)
  72841. */
  72842. constructor(
  72843. /**
  72844. * Defines the priority of this optimization (0 by default which means first in the list)
  72845. */
  72846. priority?: number,
  72847. /**
  72848. * Defines the maximum scale to use (2 by default)
  72849. */
  72850. maximumScale?: number,
  72851. /**
  72852. * Defines the step to use between two passes (0.5 by default)
  72853. */
  72854. step?: number);
  72855. /**
  72856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72857. * @param scene defines the current scene where to apply this optimization
  72858. * @param optimizer defines the current optimizer
  72859. * @returns true if everything that can be done was applied
  72860. */
  72861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72862. }
  72863. /**
  72864. * Defines an optimization used to remove shadows
  72865. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72866. */
  72867. export class ShadowsOptimization extends SceneOptimization {
  72868. /**
  72869. * Gets a string describing the action executed by the current optimization
  72870. * @return description string
  72871. */
  72872. getDescription(): string;
  72873. /**
  72874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72875. * @param scene defines the current scene where to apply this optimization
  72876. * @param optimizer defines the current optimizer
  72877. * @returns true if everything that can be done was applied
  72878. */
  72879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72880. }
  72881. /**
  72882. * Defines an optimization used to turn post-processes off
  72883. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72884. */
  72885. export class PostProcessesOptimization extends SceneOptimization {
  72886. /**
  72887. * Gets a string describing the action executed by the current optimization
  72888. * @return description string
  72889. */
  72890. getDescription(): string;
  72891. /**
  72892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72893. * @param scene defines the current scene where to apply this optimization
  72894. * @param optimizer defines the current optimizer
  72895. * @returns true if everything that can be done was applied
  72896. */
  72897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72898. }
  72899. /**
  72900. * Defines an optimization used to turn lens flares off
  72901. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72902. */
  72903. export class LensFlaresOptimization extends SceneOptimization {
  72904. /**
  72905. * Gets a string describing the action executed by the current optimization
  72906. * @return description string
  72907. */
  72908. getDescription(): string;
  72909. /**
  72910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72911. * @param scene defines the current scene where to apply this optimization
  72912. * @param optimizer defines the current optimizer
  72913. * @returns true if everything that can be done was applied
  72914. */
  72915. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72916. }
  72917. /**
  72918. * Defines an optimization based on user defined callback.
  72919. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72920. */
  72921. export class CustomOptimization extends SceneOptimization {
  72922. /**
  72923. * Callback called to apply the custom optimization.
  72924. */
  72925. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72926. /**
  72927. * Callback called to get custom description
  72928. */
  72929. onGetDescription: () => string;
  72930. /**
  72931. * Gets a string describing the action executed by the current optimization
  72932. * @returns description string
  72933. */
  72934. getDescription(): string;
  72935. /**
  72936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72937. * @param scene defines the current scene where to apply this optimization
  72938. * @param optimizer defines the current optimizer
  72939. * @returns true if everything that can be done was applied
  72940. */
  72941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72942. }
  72943. /**
  72944. * Defines an optimization used to turn particles off
  72945. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72946. */
  72947. export class ParticlesOptimization extends SceneOptimization {
  72948. /**
  72949. * Gets a string describing the action executed by the current optimization
  72950. * @return description string
  72951. */
  72952. getDescription(): string;
  72953. /**
  72954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72955. * @param scene defines the current scene where to apply this optimization
  72956. * @param optimizer defines the current optimizer
  72957. * @returns true if everything that can be done was applied
  72958. */
  72959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72960. }
  72961. /**
  72962. * Defines an optimization used to turn render targets off
  72963. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72964. */
  72965. export class RenderTargetsOptimization extends SceneOptimization {
  72966. /**
  72967. * Gets a string describing the action executed by the current optimization
  72968. * @return description string
  72969. */
  72970. getDescription(): string;
  72971. /**
  72972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72973. * @param scene defines the current scene where to apply this optimization
  72974. * @param optimizer defines the current optimizer
  72975. * @returns true if everything that can be done was applied
  72976. */
  72977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72978. }
  72979. /**
  72980. * Defines an optimization used to merge meshes with compatible materials
  72981. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72982. */
  72983. export class MergeMeshesOptimization extends SceneOptimization {
  72984. private static _UpdateSelectionTree;
  72985. /**
  72986. * Gets or sets a boolean which defines if optimization octree has to be updated
  72987. */
  72988. static get UpdateSelectionTree(): boolean;
  72989. /**
  72990. * Gets or sets a boolean which defines if optimization octree has to be updated
  72991. */
  72992. static set UpdateSelectionTree(value: boolean);
  72993. /**
  72994. * Gets a string describing the action executed by the current optimization
  72995. * @return description string
  72996. */
  72997. getDescription(): string;
  72998. private _canBeMerged;
  72999. /**
  73000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73001. * @param scene defines the current scene where to apply this optimization
  73002. * @param optimizer defines the current optimizer
  73003. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73004. * @returns true if everything that can be done was applied
  73005. */
  73006. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73007. }
  73008. /**
  73009. * Defines a list of options used by SceneOptimizer
  73010. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73011. */
  73012. export class SceneOptimizerOptions {
  73013. /**
  73014. * Defines the target frame rate to reach (60 by default)
  73015. */
  73016. targetFrameRate: number;
  73017. /**
  73018. * Defines the interval between two checkes (2000ms by default)
  73019. */
  73020. trackerDuration: number;
  73021. /**
  73022. * Gets the list of optimizations to apply
  73023. */
  73024. optimizations: SceneOptimization[];
  73025. /**
  73026. * Creates a new list of options used by SceneOptimizer
  73027. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73028. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73029. */
  73030. constructor(
  73031. /**
  73032. * Defines the target frame rate to reach (60 by default)
  73033. */
  73034. targetFrameRate?: number,
  73035. /**
  73036. * Defines the interval between two checkes (2000ms by default)
  73037. */
  73038. trackerDuration?: number);
  73039. /**
  73040. * Add a new optimization
  73041. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73042. * @returns the current SceneOptimizerOptions
  73043. */
  73044. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73045. /**
  73046. * Add a new custom optimization
  73047. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73048. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73049. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73050. * @returns the current SceneOptimizerOptions
  73051. */
  73052. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73053. /**
  73054. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73055. * @param targetFrameRate defines the target frame rate (60 by default)
  73056. * @returns a SceneOptimizerOptions object
  73057. */
  73058. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73059. /**
  73060. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73061. * @param targetFrameRate defines the target frame rate (60 by default)
  73062. * @returns a SceneOptimizerOptions object
  73063. */
  73064. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73065. /**
  73066. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73067. * @param targetFrameRate defines the target frame rate (60 by default)
  73068. * @returns a SceneOptimizerOptions object
  73069. */
  73070. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73071. }
  73072. /**
  73073. * Class used to run optimizations in order to reach a target frame rate
  73074. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73075. */
  73076. export class SceneOptimizer implements IDisposable {
  73077. private _isRunning;
  73078. private _options;
  73079. private _scene;
  73080. private _currentPriorityLevel;
  73081. private _targetFrameRate;
  73082. private _trackerDuration;
  73083. private _currentFrameRate;
  73084. private _sceneDisposeObserver;
  73085. private _improvementMode;
  73086. /**
  73087. * Defines an observable called when the optimizer reaches the target frame rate
  73088. */
  73089. onSuccessObservable: Observable<SceneOptimizer>;
  73090. /**
  73091. * Defines an observable called when the optimizer enables an optimization
  73092. */
  73093. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73094. /**
  73095. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73096. */
  73097. onFailureObservable: Observable<SceneOptimizer>;
  73098. /**
  73099. * Gets a boolean indicating if the optimizer is in improvement mode
  73100. */
  73101. get isInImprovementMode(): boolean;
  73102. /**
  73103. * Gets the current priority level (0 at start)
  73104. */
  73105. get currentPriorityLevel(): number;
  73106. /**
  73107. * Gets the current frame rate checked by the SceneOptimizer
  73108. */
  73109. get currentFrameRate(): number;
  73110. /**
  73111. * Gets or sets the current target frame rate (60 by default)
  73112. */
  73113. get targetFrameRate(): number;
  73114. /**
  73115. * Gets or sets the current target frame rate (60 by default)
  73116. */
  73117. set targetFrameRate(value: number);
  73118. /**
  73119. * Gets or sets the current interval between two checks (every 2000ms by default)
  73120. */
  73121. get trackerDuration(): number;
  73122. /**
  73123. * Gets or sets the current interval between two checks (every 2000ms by default)
  73124. */
  73125. set trackerDuration(value: number);
  73126. /**
  73127. * Gets the list of active optimizations
  73128. */
  73129. get optimizations(): SceneOptimization[];
  73130. /**
  73131. * Creates a new SceneOptimizer
  73132. * @param scene defines the scene to work on
  73133. * @param options defines the options to use with the SceneOptimizer
  73134. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73135. * @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)
  73136. */
  73137. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73138. /**
  73139. * Stops the current optimizer
  73140. */
  73141. stop(): void;
  73142. /**
  73143. * Reset the optimizer to initial step (current priority level = 0)
  73144. */
  73145. reset(): void;
  73146. /**
  73147. * Start the optimizer. By default it will try to reach a specific framerate
  73148. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73149. */
  73150. start(): void;
  73151. private _checkCurrentState;
  73152. /**
  73153. * Release all resources
  73154. */
  73155. dispose(): void;
  73156. /**
  73157. * Helper function to create a SceneOptimizer with one single line of code
  73158. * @param scene defines the scene to work on
  73159. * @param options defines the options to use with the SceneOptimizer
  73160. * @param onSuccess defines a callback to call on success
  73161. * @param onFailure defines a callback to call on failure
  73162. * @returns the new SceneOptimizer object
  73163. */
  73164. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73165. }
  73166. }
  73167. declare module BABYLON {
  73168. /**
  73169. * Class used to serialize a scene into a string
  73170. */
  73171. export class SceneSerializer {
  73172. /**
  73173. * Clear cache used by a previous serialization
  73174. */
  73175. static ClearCache(): void;
  73176. /**
  73177. * Serialize a scene into a JSON compatible object
  73178. * @param scene defines the scene to serialize
  73179. * @returns a JSON compatible object
  73180. */
  73181. static Serialize(scene: Scene): any;
  73182. /**
  73183. * Serialize a mesh into a JSON compatible object
  73184. * @param toSerialize defines the mesh to serialize
  73185. * @param withParents defines if parents must be serialized as well
  73186. * @param withChildren defines if children must be serialized as well
  73187. * @returns a JSON compatible object
  73188. */
  73189. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73190. }
  73191. }
  73192. declare module BABYLON {
  73193. /**
  73194. * Class used to host texture specific utilities
  73195. */
  73196. export class TextureTools {
  73197. /**
  73198. * Uses the GPU to create a copy texture rescaled at a given size
  73199. * @param texture Texture to copy from
  73200. * @param width defines the desired width
  73201. * @param height defines the desired height
  73202. * @param useBilinearMode defines if bilinear mode has to be used
  73203. * @return the generated texture
  73204. */
  73205. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73206. }
  73207. }
  73208. declare module BABYLON {
  73209. /**
  73210. * This represents the different options available for the video capture.
  73211. */
  73212. export interface VideoRecorderOptions {
  73213. /** Defines the mime type of the video. */
  73214. mimeType: string;
  73215. /** Defines the FPS the video should be recorded at. */
  73216. fps: number;
  73217. /** Defines the chunk size for the recording data. */
  73218. recordChunckSize: number;
  73219. /** The audio tracks to attach to the recording. */
  73220. audioTracks?: MediaStreamTrack[];
  73221. }
  73222. /**
  73223. * This can help with recording videos from BabylonJS.
  73224. * This is based on the available WebRTC functionalities of the browser.
  73225. *
  73226. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73227. */
  73228. export class VideoRecorder {
  73229. private static readonly _defaultOptions;
  73230. /**
  73231. * Returns whether or not the VideoRecorder is available in your browser.
  73232. * @param engine Defines the Babylon Engine.
  73233. * @returns true if supported otherwise false.
  73234. */
  73235. static IsSupported(engine: Engine): boolean;
  73236. private readonly _options;
  73237. private _canvas;
  73238. private _mediaRecorder;
  73239. private _recordedChunks;
  73240. private _fileName;
  73241. private _resolve;
  73242. private _reject;
  73243. /**
  73244. * True when a recording is already in progress.
  73245. */
  73246. get isRecording(): boolean;
  73247. /**
  73248. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73249. * @param engine Defines the BabylonJS Engine you wish to record.
  73250. * @param options Defines options that can be used to customize the capture.
  73251. */
  73252. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73253. /**
  73254. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73255. */
  73256. stopRecording(): void;
  73257. /**
  73258. * Starts recording the canvas for a max duration specified in parameters.
  73259. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73260. * If null no automatic download will start and you can rely on the promise to get the data back.
  73261. * @param maxDuration Defines the maximum recording time in seconds.
  73262. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73263. * @return A promise callback at the end of the recording with the video data in Blob.
  73264. */
  73265. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73266. /**
  73267. * Releases internal resources used during the recording.
  73268. */
  73269. dispose(): void;
  73270. private _handleDataAvailable;
  73271. private _handleError;
  73272. private _handleStop;
  73273. }
  73274. }
  73275. declare module BABYLON {
  73276. /**
  73277. * Class containing a set of static utilities functions for screenshots
  73278. */
  73279. export class ScreenshotTools {
  73280. /**
  73281. * Captures a screenshot of the current rendering
  73282. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73283. * @param engine defines the rendering engine
  73284. * @param camera defines the source camera
  73285. * @param size This parameter can be set to a single number or to an object with the
  73286. * following (optional) properties: precision, width, height. If a single number is passed,
  73287. * it will be used for both width and height. If an object is passed, the screenshot size
  73288. * will be derived from the parameters. The precision property is a multiplier allowing
  73289. * rendering at a higher or lower resolution
  73290. * @param successCallback defines the callback receives a single parameter which contains the
  73291. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73292. * src parameter of an <img> to display it
  73293. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73294. * Check your browser for supported MIME types
  73295. */
  73296. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73297. /**
  73298. * Captures a screenshot of the current rendering
  73299. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73300. * @param engine defines the rendering engine
  73301. * @param camera defines the source camera
  73302. * @param size This parameter can be set to a single number or to an object with the
  73303. * following (optional) properties: precision, width, height. If a single number is passed,
  73304. * it will be used for both width and height. If an object is passed, the screenshot size
  73305. * will be derived from the parameters. The precision property is a multiplier allowing
  73306. * rendering at a higher or lower resolution
  73307. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73308. * Check your browser for supported MIME types
  73309. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73310. * to the src parameter of an <img> to display it
  73311. */
  73312. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73313. /**
  73314. * Generates an image screenshot from the specified camera.
  73315. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73316. * @param engine The engine to use for rendering
  73317. * @param camera The camera to use for rendering
  73318. * @param size This parameter can be set to a single number or to an object with the
  73319. * following (optional) properties: precision, width, height. If a single number is passed,
  73320. * it will be used for both width and height. If an object is passed, the screenshot size
  73321. * will be derived from the parameters. The precision property is a multiplier allowing
  73322. * rendering at a higher or lower resolution
  73323. * @param successCallback The callback receives a single parameter which contains the
  73324. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73325. * src parameter of an <img> to display it
  73326. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73327. * Check your browser for supported MIME types
  73328. * @param samples Texture samples (default: 1)
  73329. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73330. * @param fileName A name for for the downloaded file.
  73331. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73332. */
  73333. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73334. /**
  73335. * Generates an image screenshot from the specified camera.
  73336. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73337. * @param engine The engine to use for rendering
  73338. * @param camera The camera to use for rendering
  73339. * @param size This parameter can be set to a single number or to an object with the
  73340. * following (optional) properties: precision, width, height. If a single number is passed,
  73341. * it will be used for both width and height. If an object is passed, the screenshot size
  73342. * will be derived from the parameters. The precision property is a multiplier allowing
  73343. * rendering at a higher or lower resolution
  73344. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73345. * Check your browser for supported MIME types
  73346. * @param samples Texture samples (default: 1)
  73347. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73348. * @param fileName A name for for the downloaded file.
  73349. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73350. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73351. * to the src parameter of an <img> to display it
  73352. */
  73353. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73354. /**
  73355. * Gets height and width for screenshot size
  73356. * @private
  73357. */
  73358. private static _getScreenshotSize;
  73359. }
  73360. }
  73361. declare module BABYLON {
  73362. /**
  73363. * Interface for a data buffer
  73364. */
  73365. export interface IDataBuffer {
  73366. /**
  73367. * Reads bytes from the data buffer.
  73368. * @param byteOffset The byte offset to read
  73369. * @param byteLength The byte length to read
  73370. * @returns A promise that resolves when the bytes are read
  73371. */
  73372. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73373. /**
  73374. * The byte length of the buffer.
  73375. */
  73376. readonly byteLength: number;
  73377. }
  73378. /**
  73379. * Utility class for reading from a data buffer
  73380. */
  73381. export class DataReader {
  73382. /**
  73383. * The data buffer associated with this data reader.
  73384. */
  73385. readonly buffer: IDataBuffer;
  73386. /**
  73387. * The current byte offset from the beginning of the data buffer.
  73388. */
  73389. byteOffset: number;
  73390. private _dataView;
  73391. private _dataByteOffset;
  73392. /**
  73393. * Constructor
  73394. * @param buffer The buffer to read
  73395. */
  73396. constructor(buffer: IDataBuffer);
  73397. /**
  73398. * Loads the given byte length.
  73399. * @param byteLength The byte length to load
  73400. * @returns A promise that resolves when the load is complete
  73401. */
  73402. loadAsync(byteLength: number): Promise<void>;
  73403. /**
  73404. * Read a unsigned 32-bit integer from the currently loaded data range.
  73405. * @returns The 32-bit integer read
  73406. */
  73407. readUint32(): number;
  73408. /**
  73409. * Read a byte array from the currently loaded data range.
  73410. * @param byteLength The byte length to read
  73411. * @returns The byte array read
  73412. */
  73413. readUint8Array(byteLength: number): Uint8Array;
  73414. /**
  73415. * Read a string from the currently loaded data range.
  73416. * @param byteLength The byte length to read
  73417. * @returns The string read
  73418. */
  73419. readString(byteLength: number): string;
  73420. /**
  73421. * Skips the given byte length the currently loaded data range.
  73422. * @param byteLength The byte length to skip
  73423. */
  73424. skipBytes(byteLength: number): void;
  73425. }
  73426. }
  73427. declare module BABYLON {
  73428. /**
  73429. * Class for storing data to local storage if available or in-memory storage otherwise
  73430. */
  73431. export class DataStorage {
  73432. private static _Storage;
  73433. private static _GetStorage;
  73434. /**
  73435. * Reads a string from the data storage
  73436. * @param key The key to read
  73437. * @param defaultValue The value if the key doesn't exist
  73438. * @returns The string value
  73439. */
  73440. static ReadString(key: string, defaultValue: string): string;
  73441. /**
  73442. * Writes a string to the data storage
  73443. * @param key The key to write
  73444. * @param value The value to write
  73445. */
  73446. static WriteString(key: string, value: string): void;
  73447. /**
  73448. * Reads a boolean from the data storage
  73449. * @param key The key to read
  73450. * @param defaultValue The value if the key doesn't exist
  73451. * @returns The boolean value
  73452. */
  73453. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73454. /**
  73455. * Writes a boolean to the data storage
  73456. * @param key The key to write
  73457. * @param value The value to write
  73458. */
  73459. static WriteBoolean(key: string, value: boolean): void;
  73460. /**
  73461. * Reads a number from the data storage
  73462. * @param key The key to read
  73463. * @param defaultValue The value if the key doesn't exist
  73464. * @returns The number value
  73465. */
  73466. static ReadNumber(key: string, defaultValue: number): number;
  73467. /**
  73468. * Writes a number to the data storage
  73469. * @param key The key to write
  73470. * @param value The value to write
  73471. */
  73472. static WriteNumber(key: string, value: number): void;
  73473. }
  73474. }
  73475. declare module BABYLON {
  73476. /**
  73477. * Class used to record delta files between 2 scene states
  73478. */
  73479. export class SceneRecorder {
  73480. private _trackedScene;
  73481. private _savedJSON;
  73482. /**
  73483. * Track a given scene. This means the current scene state will be considered the original state
  73484. * @param scene defines the scene to track
  73485. */
  73486. track(scene: Scene): void;
  73487. /**
  73488. * Get the delta between current state and original state
  73489. * @returns a string containing the delta
  73490. */
  73491. getDelta(): any;
  73492. private _compareArray;
  73493. private _compareObjects;
  73494. private _compareCollections;
  73495. /**
  73496. * Apply a given delta to a given scene
  73497. * @param deltaJSON defines the JSON containing the delta
  73498. * @param scene defines the scene to apply the delta to
  73499. */
  73500. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  73501. private static _ApplyPropertiesToEntity;
  73502. private static _ApplyDeltaForEntity;
  73503. }
  73504. }
  73505. declare module BABYLON {
  73506. /**
  73507. * An interface for all Hit test features
  73508. */
  73509. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73510. /**
  73511. * Triggered when new babylon (transformed) hit test results are available
  73512. */
  73513. onHitTestResultObservable: Observable<T[]>;
  73514. }
  73515. /**
  73516. * Options used for hit testing
  73517. */
  73518. export interface IWebXRLegacyHitTestOptions {
  73519. /**
  73520. * Only test when user interacted with the scene. Default - hit test every frame
  73521. */
  73522. testOnPointerDownOnly?: boolean;
  73523. /**
  73524. * The node to use to transform the local results to world coordinates
  73525. */
  73526. worldParentNode?: TransformNode;
  73527. }
  73528. /**
  73529. * Interface defining the babylon result of raycasting/hit-test
  73530. */
  73531. export interface IWebXRLegacyHitResult {
  73532. /**
  73533. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73534. */
  73535. transformationMatrix: Matrix;
  73536. /**
  73537. * The native hit test result
  73538. */
  73539. xrHitResult: XRHitResult | XRHitTestResult;
  73540. }
  73541. /**
  73542. * The currently-working hit-test module.
  73543. * Hit test (or Ray-casting) is used to interact with the real world.
  73544. * For further information read here - https://github.com/immersive-web/hit-test
  73545. */
  73546. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73547. /**
  73548. * options to use when constructing this feature
  73549. */
  73550. readonly options: IWebXRLegacyHitTestOptions;
  73551. private _direction;
  73552. private _mat;
  73553. private _onSelectEnabled;
  73554. private _origin;
  73555. /**
  73556. * The module's name
  73557. */
  73558. static readonly Name: string;
  73559. /**
  73560. * The (Babylon) version of this module.
  73561. * This is an integer representing the implementation version.
  73562. * This number does not correspond to the WebXR specs version
  73563. */
  73564. static readonly Version: number;
  73565. /**
  73566. * Populated with the last native XR Hit Results
  73567. */
  73568. lastNativeXRHitResults: XRHitResult[];
  73569. /**
  73570. * Triggered when new babylon (transformed) hit test results are available
  73571. */
  73572. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73573. /**
  73574. * Creates a new instance of the (legacy version) hit test feature
  73575. * @param _xrSessionManager an instance of WebXRSessionManager
  73576. * @param options options to use when constructing this feature
  73577. */
  73578. constructor(_xrSessionManager: WebXRSessionManager,
  73579. /**
  73580. * options to use when constructing this feature
  73581. */
  73582. options?: IWebXRLegacyHitTestOptions);
  73583. /**
  73584. * execute a hit test with an XR Ray
  73585. *
  73586. * @param xrSession a native xrSession that will execute this hit test
  73587. * @param xrRay the ray (position and direction) to use for ray-casting
  73588. * @param referenceSpace native XR reference space to use for the hit-test
  73589. * @param filter filter function that will filter the results
  73590. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73591. */
  73592. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73593. /**
  73594. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73595. * @param event the (select) event to use to select with
  73596. * @param referenceSpace the reference space to use for this hit test
  73597. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73598. */
  73599. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73600. /**
  73601. * attach this feature
  73602. * Will usually be called by the features manager
  73603. *
  73604. * @returns true if successful.
  73605. */
  73606. attach(): boolean;
  73607. /**
  73608. * detach this feature.
  73609. * Will usually be called by the features manager
  73610. *
  73611. * @returns true if successful.
  73612. */
  73613. detach(): boolean;
  73614. /**
  73615. * Dispose this feature and all of the resources attached
  73616. */
  73617. dispose(): void;
  73618. protected _onXRFrame(frame: XRFrame): void;
  73619. private _onHitTestResults;
  73620. private _onSelect;
  73621. }
  73622. }
  73623. declare module BABYLON {
  73624. /**
  73625. * Options used for hit testing (version 2)
  73626. */
  73627. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73628. /**
  73629. * Do not create a permanent hit test. Will usually be used when only
  73630. * transient inputs are needed.
  73631. */
  73632. disablePermanentHitTest?: boolean;
  73633. /**
  73634. * Enable transient (for example touch-based) hit test inspections
  73635. */
  73636. enableTransientHitTest?: boolean;
  73637. /**
  73638. * Offset ray for the permanent hit test
  73639. */
  73640. offsetRay?: Vector3;
  73641. /**
  73642. * Offset ray for the transient hit test
  73643. */
  73644. transientOffsetRay?: Vector3;
  73645. /**
  73646. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73647. */
  73648. useReferenceSpace?: boolean;
  73649. }
  73650. /**
  73651. * Interface defining the babylon result of hit-test
  73652. */
  73653. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73654. /**
  73655. * The input source that generated this hit test (if transient)
  73656. */
  73657. inputSource?: XRInputSource;
  73658. /**
  73659. * Is this a transient hit test
  73660. */
  73661. isTransient?: boolean;
  73662. /**
  73663. * Position of the hit test result
  73664. */
  73665. position: Vector3;
  73666. /**
  73667. * Rotation of the hit test result
  73668. */
  73669. rotationQuaternion: Quaternion;
  73670. /**
  73671. * The native hit test result
  73672. */
  73673. xrHitResult: XRHitTestResult;
  73674. }
  73675. /**
  73676. * The currently-working hit-test module.
  73677. * Hit test (or Ray-casting) is used to interact with the real world.
  73678. * For further information read here - https://github.com/immersive-web/hit-test
  73679. *
  73680. * Tested on chrome (mobile) 80.
  73681. */
  73682. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73683. /**
  73684. * options to use when constructing this feature
  73685. */
  73686. readonly options: IWebXRHitTestOptions;
  73687. private _tmpMat;
  73688. private _tmpPos;
  73689. private _tmpQuat;
  73690. private _transientXrHitTestSource;
  73691. private _xrHitTestSource;
  73692. private initHitTestSource;
  73693. /**
  73694. * The module's name
  73695. */
  73696. static readonly Name: string;
  73697. /**
  73698. * The (Babylon) version of this module.
  73699. * This is an integer representing the implementation version.
  73700. * This number does not correspond to the WebXR specs version
  73701. */
  73702. static readonly Version: number;
  73703. /**
  73704. * When set to true, each hit test will have its own position/rotation objects
  73705. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73706. * the developers will clone them or copy them as they see fit.
  73707. */
  73708. autoCloneTransformation: boolean;
  73709. /**
  73710. * Triggered when new babylon (transformed) hit test results are available
  73711. */
  73712. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73713. /**
  73714. * Use this to temporarily pause hit test checks.
  73715. */
  73716. paused: boolean;
  73717. /**
  73718. * Creates a new instance of the hit test feature
  73719. * @param _xrSessionManager an instance of WebXRSessionManager
  73720. * @param options options to use when constructing this feature
  73721. */
  73722. constructor(_xrSessionManager: WebXRSessionManager,
  73723. /**
  73724. * options to use when constructing this feature
  73725. */
  73726. options?: IWebXRHitTestOptions);
  73727. /**
  73728. * attach this feature
  73729. * Will usually be called by the features manager
  73730. *
  73731. * @returns true if successful.
  73732. */
  73733. attach(): boolean;
  73734. /**
  73735. * detach this feature.
  73736. * Will usually be called by the features manager
  73737. *
  73738. * @returns true if successful.
  73739. */
  73740. detach(): boolean;
  73741. /**
  73742. * Dispose this feature and all of the resources attached
  73743. */
  73744. dispose(): void;
  73745. protected _onXRFrame(frame: XRFrame): void;
  73746. private _processWebXRHitTestResult;
  73747. }
  73748. }
  73749. declare module BABYLON {
  73750. /**
  73751. * Configuration options of the anchor system
  73752. */
  73753. export interface IWebXRAnchorSystemOptions {
  73754. /**
  73755. * a node that will be used to convert local to world coordinates
  73756. */
  73757. worldParentNode?: TransformNode;
  73758. /**
  73759. * If set to true a reference of the created anchors will be kept until the next session starts
  73760. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73761. */
  73762. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73763. }
  73764. /**
  73765. * A babylon container for an XR Anchor
  73766. */
  73767. export interface IWebXRAnchor {
  73768. /**
  73769. * A babylon-assigned ID for this anchor
  73770. */
  73771. id: number;
  73772. /**
  73773. * Transformation matrix to apply to an object attached to this anchor
  73774. */
  73775. transformationMatrix: Matrix;
  73776. /**
  73777. * The native anchor object
  73778. */
  73779. xrAnchor: XRAnchor;
  73780. /**
  73781. * if defined, this object will be constantly updated by the anchor's position and rotation
  73782. */
  73783. attachedNode?: TransformNode;
  73784. }
  73785. /**
  73786. * An implementation of the anchor system for WebXR.
  73787. * For further information see https://github.com/immersive-web/anchors/
  73788. */
  73789. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73790. private _options;
  73791. private _lastFrameDetected;
  73792. private _trackedAnchors;
  73793. private _referenceSpaceForFrameAnchors;
  73794. private _futureAnchors;
  73795. /**
  73796. * The module's name
  73797. */
  73798. static readonly Name: string;
  73799. /**
  73800. * The (Babylon) version of this module.
  73801. * This is an integer representing the implementation version.
  73802. * This number does not correspond to the WebXR specs version
  73803. */
  73804. static readonly Version: number;
  73805. /**
  73806. * Observers registered here will be executed when a new anchor was added to the session
  73807. */
  73808. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73809. /**
  73810. * Observers registered here will be executed when an anchor was removed from the session
  73811. */
  73812. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73813. /**
  73814. * Observers registered here will be executed when an existing anchor updates
  73815. * This can execute N times every frame
  73816. */
  73817. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73818. /**
  73819. * Set the reference space to use for anchor creation, when not using a hit test.
  73820. * Will default to the session's reference space if not defined
  73821. */
  73822. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73823. /**
  73824. * constructs a new anchor system
  73825. * @param _xrSessionManager an instance of WebXRSessionManager
  73826. * @param _options configuration object for this feature
  73827. */
  73828. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73829. private _tmpVector;
  73830. private _tmpQuaternion;
  73831. private _populateTmpTransformation;
  73832. /**
  73833. * Create a new anchor point using a hit test result at a specific point in the scene
  73834. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73835. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73836. *
  73837. * @param hitTestResult The hit test result to use for this anchor creation
  73838. * @param position an optional position offset for this anchor
  73839. * @param rotationQuaternion an optional rotation offset for this anchor
  73840. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73841. */
  73842. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73843. /**
  73844. * Add a new anchor at a specific position and rotation
  73845. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73846. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73847. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73848. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73849. *
  73850. * @param position the position in which to add an anchor
  73851. * @param rotationQuaternion an optional rotation for the anchor transformation
  73852. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73853. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73854. */
  73855. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73856. /**
  73857. * detach this feature.
  73858. * Will usually be called by the features manager
  73859. *
  73860. * @returns true if successful.
  73861. */
  73862. detach(): boolean;
  73863. /**
  73864. * Dispose this feature and all of the resources attached
  73865. */
  73866. dispose(): void;
  73867. protected _onXRFrame(frame: XRFrame): void;
  73868. /**
  73869. * avoiding using Array.find for global support.
  73870. * @param xrAnchor the plane to find in the array
  73871. */
  73872. private _findIndexInAnchorArray;
  73873. private _updateAnchorWithXRFrame;
  73874. private _createAnchorAtTransformation;
  73875. }
  73876. }
  73877. declare module BABYLON {
  73878. /**
  73879. * Options used in the plane detector module
  73880. */
  73881. export interface IWebXRPlaneDetectorOptions {
  73882. /**
  73883. * The node to use to transform the local results to world coordinates
  73884. */
  73885. worldParentNode?: TransformNode;
  73886. /**
  73887. * If set to true a reference of the created planes will be kept until the next session starts
  73888. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73889. */
  73890. doNotRemovePlanesOnSessionEnded?: boolean;
  73891. }
  73892. /**
  73893. * A babylon interface for a WebXR plane.
  73894. * A Plane is actually a polygon, built from N points in space
  73895. *
  73896. * Supported in chrome 79, not supported in canary 81 ATM
  73897. */
  73898. export interface IWebXRPlane {
  73899. /**
  73900. * a babylon-assigned ID for this polygon
  73901. */
  73902. id: number;
  73903. /**
  73904. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73905. */
  73906. polygonDefinition: Array<Vector3>;
  73907. /**
  73908. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73909. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73910. */
  73911. transformationMatrix: Matrix;
  73912. /**
  73913. * the native xr-plane object
  73914. */
  73915. xrPlane: XRPlane;
  73916. }
  73917. /**
  73918. * The plane detector is used to detect planes in the real world when in AR
  73919. * For more information see https://github.com/immersive-web/real-world-geometry/
  73920. */
  73921. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73922. private _options;
  73923. private _detectedPlanes;
  73924. private _enabled;
  73925. private _lastFrameDetected;
  73926. /**
  73927. * The module's name
  73928. */
  73929. static readonly Name: string;
  73930. /**
  73931. * The (Babylon) version of this module.
  73932. * This is an integer representing the implementation version.
  73933. * This number does not correspond to the WebXR specs version
  73934. */
  73935. static readonly Version: number;
  73936. /**
  73937. * Observers registered here will be executed when a new plane was added to the session
  73938. */
  73939. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73940. /**
  73941. * Observers registered here will be executed when a plane is no longer detected in the session
  73942. */
  73943. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73944. /**
  73945. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73946. * This can execute N times every frame
  73947. */
  73948. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73949. /**
  73950. * construct a new Plane Detector
  73951. * @param _xrSessionManager an instance of xr Session manager
  73952. * @param _options configuration to use when constructing this feature
  73953. */
  73954. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73955. /**
  73956. * detach this feature.
  73957. * Will usually be called by the features manager
  73958. *
  73959. * @returns true if successful.
  73960. */
  73961. detach(): boolean;
  73962. /**
  73963. * Dispose this feature and all of the resources attached
  73964. */
  73965. dispose(): void;
  73966. protected _onXRFrame(frame: XRFrame): void;
  73967. private _init;
  73968. private _updatePlaneWithXRPlane;
  73969. /**
  73970. * avoiding using Array.find for global support.
  73971. * @param xrPlane the plane to find in the array
  73972. */
  73973. private findIndexInPlaneArray;
  73974. }
  73975. }
  73976. declare module BABYLON {
  73977. /**
  73978. * Options interface for the background remover plugin
  73979. */
  73980. export interface IWebXRBackgroundRemoverOptions {
  73981. /**
  73982. * Further background meshes to disable when entering AR
  73983. */
  73984. backgroundMeshes?: AbstractMesh[];
  73985. /**
  73986. * flags to configure the removal of the environment helper.
  73987. * If not set, the entire background will be removed. If set, flags should be set as well.
  73988. */
  73989. environmentHelperRemovalFlags?: {
  73990. /**
  73991. * Should the skybox be removed (default false)
  73992. */
  73993. skyBox?: boolean;
  73994. /**
  73995. * Should the ground be removed (default false)
  73996. */
  73997. ground?: boolean;
  73998. };
  73999. /**
  74000. * don't disable the environment helper
  74001. */
  74002. ignoreEnvironmentHelper?: boolean;
  74003. }
  74004. /**
  74005. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74006. */
  74007. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74008. /**
  74009. * read-only options to be used in this module
  74010. */
  74011. readonly options: IWebXRBackgroundRemoverOptions;
  74012. /**
  74013. * The module's name
  74014. */
  74015. static readonly Name: string;
  74016. /**
  74017. * The (Babylon) version of this module.
  74018. * This is an integer representing the implementation version.
  74019. * This number does not correspond to the WebXR specs version
  74020. */
  74021. static readonly Version: number;
  74022. /**
  74023. * registered observers will be triggered when the background state changes
  74024. */
  74025. onBackgroundStateChangedObservable: Observable<boolean>;
  74026. /**
  74027. * constructs a new background remover module
  74028. * @param _xrSessionManager the session manager for this module
  74029. * @param options read-only options to be used in this module
  74030. */
  74031. constructor(_xrSessionManager: WebXRSessionManager,
  74032. /**
  74033. * read-only options to be used in this module
  74034. */
  74035. options?: IWebXRBackgroundRemoverOptions);
  74036. /**
  74037. * attach this feature
  74038. * Will usually be called by the features manager
  74039. *
  74040. * @returns true if successful.
  74041. */
  74042. attach(): boolean;
  74043. /**
  74044. * detach this feature.
  74045. * Will usually be called by the features manager
  74046. *
  74047. * @returns true if successful.
  74048. */
  74049. detach(): boolean;
  74050. /**
  74051. * Dispose this feature and all of the resources attached
  74052. */
  74053. dispose(): void;
  74054. protected _onXRFrame(_xrFrame: XRFrame): void;
  74055. private _setBackgroundState;
  74056. }
  74057. }
  74058. declare module BABYLON {
  74059. /**
  74060. * Options for the controller physics feature
  74061. */
  74062. export class IWebXRControllerPhysicsOptions {
  74063. /**
  74064. * Should the headset get its own impostor
  74065. */
  74066. enableHeadsetImpostor?: boolean;
  74067. /**
  74068. * Optional parameters for the headset impostor
  74069. */
  74070. headsetImpostorParams?: {
  74071. /**
  74072. * The type of impostor to create. Default is sphere
  74073. */
  74074. impostorType: number;
  74075. /**
  74076. * the size of the impostor. Defaults to 10cm
  74077. */
  74078. impostorSize?: number | {
  74079. width: number;
  74080. height: number;
  74081. depth: number;
  74082. };
  74083. /**
  74084. * Friction definitions
  74085. */
  74086. friction?: number;
  74087. /**
  74088. * Restitution
  74089. */
  74090. restitution?: number;
  74091. };
  74092. /**
  74093. * The physics properties of the future impostors
  74094. */
  74095. physicsProperties?: {
  74096. /**
  74097. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74098. * Note that this requires a physics engine that supports mesh impostors!
  74099. */
  74100. useControllerMesh?: boolean;
  74101. /**
  74102. * The type of impostor to create. Default is sphere
  74103. */
  74104. impostorType?: number;
  74105. /**
  74106. * the size of the impostor. Defaults to 10cm
  74107. */
  74108. impostorSize?: number | {
  74109. width: number;
  74110. height: number;
  74111. depth: number;
  74112. };
  74113. /**
  74114. * Friction definitions
  74115. */
  74116. friction?: number;
  74117. /**
  74118. * Restitution
  74119. */
  74120. restitution?: number;
  74121. };
  74122. /**
  74123. * the xr input to use with this pointer selection
  74124. */
  74125. xrInput: WebXRInput;
  74126. }
  74127. /**
  74128. * Add physics impostor to your webxr controllers,
  74129. * including naive calculation of their linear and angular velocity
  74130. */
  74131. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74132. private readonly _options;
  74133. private _attachController;
  74134. private _controllers;
  74135. private _debugMode;
  74136. private _delta;
  74137. private _headsetImpostor?;
  74138. private _headsetMesh?;
  74139. private _lastTimestamp;
  74140. private _tmpQuaternion;
  74141. private _tmpVector;
  74142. /**
  74143. * The module's name
  74144. */
  74145. static readonly Name: string;
  74146. /**
  74147. * The (Babylon) version of this module.
  74148. * This is an integer representing the implementation version.
  74149. * This number does not correspond to the webxr specs version
  74150. */
  74151. static readonly Version: number;
  74152. /**
  74153. * Construct a new Controller Physics Feature
  74154. * @param _xrSessionManager the corresponding xr session manager
  74155. * @param _options options to create this feature with
  74156. */
  74157. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74158. /**
  74159. * @hidden
  74160. * enable debugging - will show console outputs and the impostor mesh
  74161. */
  74162. _enablePhysicsDebug(): void;
  74163. /**
  74164. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74165. * @param xrController the controller to add
  74166. */
  74167. addController(xrController: WebXRInputSource): void;
  74168. /**
  74169. * attach this feature
  74170. * Will usually be called by the features manager
  74171. *
  74172. * @returns true if successful.
  74173. */
  74174. attach(): boolean;
  74175. /**
  74176. * detach this feature.
  74177. * Will usually be called by the features manager
  74178. *
  74179. * @returns true if successful.
  74180. */
  74181. detach(): boolean;
  74182. /**
  74183. * Get the headset impostor, if enabled
  74184. * @returns the impostor
  74185. */
  74186. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74187. /**
  74188. * Get the physics impostor of a specific controller.
  74189. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74190. * @param controller the controller or the controller id of which to get the impostor
  74191. * @returns the impostor or null
  74192. */
  74193. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74194. /**
  74195. * Update the physics properties provided in the constructor
  74196. * @param newProperties the new properties object
  74197. */
  74198. setPhysicsProperties(newProperties: {
  74199. impostorType?: number;
  74200. impostorSize?: number | {
  74201. width: number;
  74202. height: number;
  74203. depth: number;
  74204. };
  74205. friction?: number;
  74206. restitution?: number;
  74207. }): void;
  74208. protected _onXRFrame(_xrFrame: any): void;
  74209. private _detachController;
  74210. }
  74211. }
  74212. declare module BABYLON {
  74213. /**
  74214. * The motion controller class for all microsoft mixed reality controllers
  74215. */
  74216. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74217. protected readonly _mapping: {
  74218. defaultButton: {
  74219. valueNodeName: string;
  74220. unpressedNodeName: string;
  74221. pressedNodeName: string;
  74222. };
  74223. defaultAxis: {
  74224. valueNodeName: string;
  74225. minNodeName: string;
  74226. maxNodeName: string;
  74227. };
  74228. buttons: {
  74229. "xr-standard-trigger": {
  74230. rootNodeName: string;
  74231. componentProperty: string;
  74232. states: string[];
  74233. };
  74234. "xr-standard-squeeze": {
  74235. rootNodeName: string;
  74236. componentProperty: string;
  74237. states: string[];
  74238. };
  74239. "xr-standard-touchpad": {
  74240. rootNodeName: string;
  74241. labelAnchorNodeName: string;
  74242. touchPointNodeName: string;
  74243. };
  74244. "xr-standard-thumbstick": {
  74245. rootNodeName: string;
  74246. componentProperty: string;
  74247. states: string[];
  74248. };
  74249. };
  74250. axes: {
  74251. "xr-standard-touchpad": {
  74252. "x-axis": {
  74253. rootNodeName: string;
  74254. };
  74255. "y-axis": {
  74256. rootNodeName: string;
  74257. };
  74258. };
  74259. "xr-standard-thumbstick": {
  74260. "x-axis": {
  74261. rootNodeName: string;
  74262. };
  74263. "y-axis": {
  74264. rootNodeName: string;
  74265. };
  74266. };
  74267. };
  74268. };
  74269. /**
  74270. * The base url used to load the left and right controller models
  74271. */
  74272. static MODEL_BASE_URL: string;
  74273. /**
  74274. * The name of the left controller model file
  74275. */
  74276. static MODEL_LEFT_FILENAME: string;
  74277. /**
  74278. * The name of the right controller model file
  74279. */
  74280. static MODEL_RIGHT_FILENAME: string;
  74281. profileId: string;
  74282. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74283. protected _getFilenameAndPath(): {
  74284. filename: string;
  74285. path: string;
  74286. };
  74287. protected _getModelLoadingConstraints(): boolean;
  74288. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74289. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74290. protected _updateModel(): void;
  74291. }
  74292. }
  74293. declare module BABYLON {
  74294. /**
  74295. * The motion controller class for oculus touch (quest, rift).
  74296. * This class supports legacy mapping as well the standard xr mapping
  74297. */
  74298. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74299. private _forceLegacyControllers;
  74300. private _modelRootNode;
  74301. /**
  74302. * The base url used to load the left and right controller models
  74303. */
  74304. static MODEL_BASE_URL: string;
  74305. /**
  74306. * The name of the left controller model file
  74307. */
  74308. static MODEL_LEFT_FILENAME: string;
  74309. /**
  74310. * The name of the right controller model file
  74311. */
  74312. static MODEL_RIGHT_FILENAME: string;
  74313. /**
  74314. * Base Url for the Quest controller model.
  74315. */
  74316. static QUEST_MODEL_BASE_URL: string;
  74317. profileId: string;
  74318. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74319. protected _getFilenameAndPath(): {
  74320. filename: string;
  74321. path: string;
  74322. };
  74323. protected _getModelLoadingConstraints(): boolean;
  74324. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74325. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74326. protected _updateModel(): void;
  74327. /**
  74328. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74329. * between the touch and touch 2.
  74330. */
  74331. private _isQuest;
  74332. }
  74333. }
  74334. declare module BABYLON {
  74335. /**
  74336. * The motion controller class for the standard HTC-Vive controllers
  74337. */
  74338. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74339. private _modelRootNode;
  74340. /**
  74341. * The base url used to load the left and right controller models
  74342. */
  74343. static MODEL_BASE_URL: string;
  74344. /**
  74345. * File name for the controller model.
  74346. */
  74347. static MODEL_FILENAME: string;
  74348. profileId: string;
  74349. /**
  74350. * Create a new Vive motion controller object
  74351. * @param scene the scene to use to create this controller
  74352. * @param gamepadObject the corresponding gamepad object
  74353. * @param handedness the handedness of the controller
  74354. */
  74355. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74356. protected _getFilenameAndPath(): {
  74357. filename: string;
  74358. path: string;
  74359. };
  74360. protected _getModelLoadingConstraints(): boolean;
  74361. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74362. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74363. protected _updateModel(): void;
  74364. }
  74365. }
  74366. declare module BABYLON {
  74367. /**
  74368. * A cursor which tracks a point on a path
  74369. */
  74370. export class PathCursor {
  74371. private path;
  74372. /**
  74373. * Stores path cursor callbacks for when an onchange event is triggered
  74374. */
  74375. private _onchange;
  74376. /**
  74377. * The value of the path cursor
  74378. */
  74379. value: number;
  74380. /**
  74381. * The animation array of the path cursor
  74382. */
  74383. animations: Animation[];
  74384. /**
  74385. * Initializes the path cursor
  74386. * @param path The path to track
  74387. */
  74388. constructor(path: Path2);
  74389. /**
  74390. * Gets the cursor point on the path
  74391. * @returns A point on the path cursor at the cursor location
  74392. */
  74393. getPoint(): Vector3;
  74394. /**
  74395. * Moves the cursor ahead by the step amount
  74396. * @param step The amount to move the cursor forward
  74397. * @returns This path cursor
  74398. */
  74399. moveAhead(step?: number): PathCursor;
  74400. /**
  74401. * Moves the cursor behind by the step amount
  74402. * @param step The amount to move the cursor back
  74403. * @returns This path cursor
  74404. */
  74405. moveBack(step?: number): PathCursor;
  74406. /**
  74407. * Moves the cursor by the step amount
  74408. * If the step amount is greater than one, an exception is thrown
  74409. * @param step The amount to move the cursor
  74410. * @returns This path cursor
  74411. */
  74412. move(step: number): PathCursor;
  74413. /**
  74414. * Ensures that the value is limited between zero and one
  74415. * @returns This path cursor
  74416. */
  74417. private ensureLimits;
  74418. /**
  74419. * Runs onchange callbacks on change (used by the animation engine)
  74420. * @returns This path cursor
  74421. */
  74422. private raiseOnChange;
  74423. /**
  74424. * Executes a function on change
  74425. * @param f A path cursor onchange callback
  74426. * @returns This path cursor
  74427. */
  74428. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74429. }
  74430. }
  74431. declare module BABYLON {
  74432. /** @hidden */
  74433. export var blurPixelShader: {
  74434. name: string;
  74435. shader: string;
  74436. };
  74437. }
  74438. declare module BABYLON {
  74439. /** @hidden */
  74440. export var pointCloudVertexDeclaration: {
  74441. name: string;
  74442. shader: string;
  74443. };
  74444. }
  74445. // Mixins
  74446. interface Window {
  74447. mozIndexedDB: IDBFactory;
  74448. webkitIndexedDB: IDBFactory;
  74449. msIndexedDB: IDBFactory;
  74450. webkitURL: typeof URL;
  74451. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74452. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74453. WebGLRenderingContext: WebGLRenderingContext;
  74454. MSGesture: MSGesture;
  74455. CANNON: any;
  74456. AudioContext: AudioContext;
  74457. webkitAudioContext: AudioContext;
  74458. PointerEvent: any;
  74459. Math: Math;
  74460. Uint8Array: Uint8ArrayConstructor;
  74461. Float32Array: Float32ArrayConstructor;
  74462. mozURL: typeof URL;
  74463. msURL: typeof URL;
  74464. VRFrameData: any; // WebVR, from specs 1.1
  74465. DracoDecoderModule: any;
  74466. setImmediate(handler: (...args: any[]) => void): number;
  74467. }
  74468. interface HTMLCanvasElement {
  74469. requestPointerLock(): void;
  74470. msRequestPointerLock?(): void;
  74471. mozRequestPointerLock?(): void;
  74472. webkitRequestPointerLock?(): void;
  74473. /** Track wether a record is in progress */
  74474. isRecording: boolean;
  74475. /** Capture Stream method defined by some browsers */
  74476. captureStream(fps?: number): MediaStream;
  74477. }
  74478. interface CanvasRenderingContext2D {
  74479. msImageSmoothingEnabled: boolean;
  74480. }
  74481. interface MouseEvent {
  74482. mozMovementX: number;
  74483. mozMovementY: number;
  74484. webkitMovementX: number;
  74485. webkitMovementY: number;
  74486. msMovementX: number;
  74487. msMovementY: number;
  74488. }
  74489. interface Navigator {
  74490. mozGetVRDevices: (any: any) => any;
  74491. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74492. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74493. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74494. webkitGetGamepads(): Gamepad[];
  74495. msGetGamepads(): Gamepad[];
  74496. webkitGamepads(): Gamepad[];
  74497. }
  74498. interface HTMLVideoElement {
  74499. mozSrcObject: any;
  74500. }
  74501. interface Math {
  74502. fround(x: number): number;
  74503. imul(a: number, b: number): number;
  74504. }
  74505. interface WebGLRenderingContext {
  74506. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74507. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74508. vertexAttribDivisor(index: number, divisor: number): void;
  74509. createVertexArray(): any;
  74510. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74511. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74512. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74513. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74514. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74515. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74516. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74517. // Queries
  74518. createQuery(): WebGLQuery;
  74519. deleteQuery(query: WebGLQuery): void;
  74520. beginQuery(target: number, query: WebGLQuery): void;
  74521. endQuery(target: number): void;
  74522. getQueryParameter(query: WebGLQuery, pname: number): any;
  74523. getQuery(target: number, pname: number): any;
  74524. MAX_SAMPLES: number;
  74525. RGBA8: number;
  74526. READ_FRAMEBUFFER: number;
  74527. DRAW_FRAMEBUFFER: number;
  74528. UNIFORM_BUFFER: number;
  74529. HALF_FLOAT_OES: number;
  74530. RGBA16F: number;
  74531. RGBA32F: number;
  74532. R32F: number;
  74533. RG32F: number;
  74534. RGB32F: number;
  74535. R16F: number;
  74536. RG16F: number;
  74537. RGB16F: number;
  74538. RED: number;
  74539. RG: number;
  74540. R8: number;
  74541. RG8: number;
  74542. UNSIGNED_INT_24_8: number;
  74543. DEPTH24_STENCIL8: number;
  74544. MIN: number;
  74545. MAX: number;
  74546. /* Multiple Render Targets */
  74547. drawBuffers(buffers: number[]): void;
  74548. readBuffer(src: number): void;
  74549. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74550. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74551. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74552. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74553. // Occlusion Query
  74554. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74555. ANY_SAMPLES_PASSED: number;
  74556. QUERY_RESULT_AVAILABLE: number;
  74557. QUERY_RESULT: number;
  74558. }
  74559. interface WebGLProgram {
  74560. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74561. }
  74562. interface EXT_disjoint_timer_query {
  74563. QUERY_COUNTER_BITS_EXT: number;
  74564. TIME_ELAPSED_EXT: number;
  74565. TIMESTAMP_EXT: number;
  74566. GPU_DISJOINT_EXT: number;
  74567. QUERY_RESULT_EXT: number;
  74568. QUERY_RESULT_AVAILABLE_EXT: number;
  74569. queryCounterEXT(query: WebGLQuery, target: number): void;
  74570. createQueryEXT(): WebGLQuery;
  74571. beginQueryEXT(target: number, query: WebGLQuery): void;
  74572. endQueryEXT(target: number): void;
  74573. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74574. deleteQueryEXT(query: WebGLQuery): void;
  74575. }
  74576. interface WebGLUniformLocation {
  74577. _currentState: any;
  74578. }
  74579. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74580. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74581. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74582. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74583. interface WebGLRenderingContext {
  74584. readonly RASTERIZER_DISCARD: number;
  74585. readonly DEPTH_COMPONENT24: number;
  74586. readonly TEXTURE_3D: number;
  74587. readonly TEXTURE_2D_ARRAY: number;
  74588. readonly TEXTURE_COMPARE_FUNC: number;
  74589. readonly TEXTURE_COMPARE_MODE: number;
  74590. readonly COMPARE_REF_TO_TEXTURE: number;
  74591. readonly TEXTURE_WRAP_R: number;
  74592. readonly HALF_FLOAT: number;
  74593. readonly RGB8: number;
  74594. readonly RED_INTEGER: number;
  74595. readonly RG_INTEGER: number;
  74596. readonly RGB_INTEGER: number;
  74597. readonly RGBA_INTEGER: number;
  74598. readonly R8_SNORM: number;
  74599. readonly RG8_SNORM: number;
  74600. readonly RGB8_SNORM: number;
  74601. readonly RGBA8_SNORM: number;
  74602. readonly R8I: number;
  74603. readonly RG8I: number;
  74604. readonly RGB8I: number;
  74605. readonly RGBA8I: number;
  74606. readonly R8UI: number;
  74607. readonly RG8UI: number;
  74608. readonly RGB8UI: number;
  74609. readonly RGBA8UI: number;
  74610. readonly R16I: number;
  74611. readonly RG16I: number;
  74612. readonly RGB16I: number;
  74613. readonly RGBA16I: number;
  74614. readonly R16UI: number;
  74615. readonly RG16UI: number;
  74616. readonly RGB16UI: number;
  74617. readonly RGBA16UI: number;
  74618. readonly R32I: number;
  74619. readonly RG32I: number;
  74620. readonly RGB32I: number;
  74621. readonly RGBA32I: number;
  74622. readonly R32UI: number;
  74623. readonly RG32UI: number;
  74624. readonly RGB32UI: number;
  74625. readonly RGBA32UI: number;
  74626. readonly RGB10_A2UI: number;
  74627. readonly R11F_G11F_B10F: number;
  74628. readonly RGB9_E5: number;
  74629. readonly RGB10_A2: number;
  74630. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74631. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74632. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74633. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74634. readonly DEPTH_COMPONENT32F: number;
  74635. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74636. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74637. 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;
  74638. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74639. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74640. readonly TRANSFORM_FEEDBACK: number;
  74641. readonly INTERLEAVED_ATTRIBS: number;
  74642. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74643. createTransformFeedback(): WebGLTransformFeedback;
  74644. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74645. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74646. beginTransformFeedback(primitiveMode: number): void;
  74647. endTransformFeedback(): void;
  74648. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74649. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74650. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74651. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74652. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74653. }
  74654. interface ImageBitmap {
  74655. readonly width: number;
  74656. readonly height: number;
  74657. close(): void;
  74658. }
  74659. interface WebGLQuery extends WebGLObject {
  74660. }
  74661. declare var WebGLQuery: {
  74662. prototype: WebGLQuery;
  74663. new(): WebGLQuery;
  74664. };
  74665. interface WebGLSampler extends WebGLObject {
  74666. }
  74667. declare var WebGLSampler: {
  74668. prototype: WebGLSampler;
  74669. new(): WebGLSampler;
  74670. };
  74671. interface WebGLSync extends WebGLObject {
  74672. }
  74673. declare var WebGLSync: {
  74674. prototype: WebGLSync;
  74675. new(): WebGLSync;
  74676. };
  74677. interface WebGLTransformFeedback extends WebGLObject {
  74678. }
  74679. declare var WebGLTransformFeedback: {
  74680. prototype: WebGLTransformFeedback;
  74681. new(): WebGLTransformFeedback;
  74682. };
  74683. interface WebGLVertexArrayObject extends WebGLObject {
  74684. }
  74685. declare var WebGLVertexArrayObject: {
  74686. prototype: WebGLVertexArrayObject;
  74687. new(): WebGLVertexArrayObject;
  74688. };
  74689. // Type definitions for WebVR API
  74690. // Project: https://w3c.github.io/webvr/
  74691. // Definitions by: six a <https://github.com/lostfictions>
  74692. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74693. interface VRDisplay extends EventTarget {
  74694. /**
  74695. * Dictionary of capabilities describing the VRDisplay.
  74696. */
  74697. readonly capabilities: VRDisplayCapabilities;
  74698. /**
  74699. * z-depth defining the far plane of the eye view frustum
  74700. * enables mapping of values in the render target depth
  74701. * attachment to scene coordinates. Initially set to 10000.0.
  74702. */
  74703. depthFar: number;
  74704. /**
  74705. * z-depth defining the near plane of the eye view frustum
  74706. * enables mapping of values in the render target depth
  74707. * attachment to scene coordinates. Initially set to 0.01.
  74708. */
  74709. depthNear: number;
  74710. /**
  74711. * An identifier for this distinct VRDisplay. Used as an
  74712. * association point in the Gamepad API.
  74713. */
  74714. readonly displayId: number;
  74715. /**
  74716. * A display name, a user-readable name identifying it.
  74717. */
  74718. readonly displayName: string;
  74719. readonly isConnected: boolean;
  74720. readonly isPresenting: boolean;
  74721. /**
  74722. * If this VRDisplay supports room-scale experiences, the optional
  74723. * stage attribute contains details on the room-scale parameters.
  74724. */
  74725. readonly stageParameters: VRStageParameters | null;
  74726. /**
  74727. * Passing the value returned by `requestAnimationFrame` to
  74728. * `cancelAnimationFrame` will unregister the callback.
  74729. * @param handle Define the hanle of the request to cancel
  74730. */
  74731. cancelAnimationFrame(handle: number): void;
  74732. /**
  74733. * Stops presenting to the VRDisplay.
  74734. * @returns a promise to know when it stopped
  74735. */
  74736. exitPresent(): Promise<void>;
  74737. /**
  74738. * Return the current VREyeParameters for the given eye.
  74739. * @param whichEye Define the eye we want the parameter for
  74740. * @returns the eye parameters
  74741. */
  74742. getEyeParameters(whichEye: string): VREyeParameters;
  74743. /**
  74744. * Populates the passed VRFrameData with the information required to render
  74745. * the current frame.
  74746. * @param frameData Define the data structure to populate
  74747. * @returns true if ok otherwise false
  74748. */
  74749. getFrameData(frameData: VRFrameData): boolean;
  74750. /**
  74751. * Get the layers currently being presented.
  74752. * @returns the list of VR layers
  74753. */
  74754. getLayers(): VRLayer[];
  74755. /**
  74756. * Return a VRPose containing the future predicted pose of the VRDisplay
  74757. * when the current frame will be presented. The value returned will not
  74758. * change until JavaScript has returned control to the browser.
  74759. *
  74760. * The VRPose will contain the position, orientation, velocity,
  74761. * and acceleration of each of these properties.
  74762. * @returns the pose object
  74763. */
  74764. getPose(): VRPose;
  74765. /**
  74766. * Return the current instantaneous pose of the VRDisplay, with no
  74767. * prediction applied.
  74768. * @returns the current instantaneous pose
  74769. */
  74770. getImmediatePose(): VRPose;
  74771. /**
  74772. * The callback passed to `requestAnimationFrame` will be called
  74773. * any time a new frame should be rendered. When the VRDisplay is
  74774. * presenting the callback will be called at the native refresh
  74775. * rate of the HMD. When not presenting this function acts
  74776. * identically to how window.requestAnimationFrame acts. Content should
  74777. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74778. * asynchronously from other displays and at differing refresh rates.
  74779. * @param callback Define the eaction to run next frame
  74780. * @returns the request handle it
  74781. */
  74782. requestAnimationFrame(callback: FrameRequestCallback): number;
  74783. /**
  74784. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74785. * Repeat calls while already presenting will update the VRLayers being displayed.
  74786. * @param layers Define the list of layer to present
  74787. * @returns a promise to know when the request has been fulfilled
  74788. */
  74789. requestPresent(layers: VRLayer[]): Promise<void>;
  74790. /**
  74791. * Reset the pose for this display, treating its current position and
  74792. * orientation as the "origin/zero" values. VRPose.position,
  74793. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74794. * updated when calling resetPose(). This should be called in only
  74795. * sitting-space experiences.
  74796. */
  74797. resetPose(): void;
  74798. /**
  74799. * The VRLayer provided to the VRDisplay will be captured and presented
  74800. * in the HMD. Calling this function has the same effect on the source
  74801. * canvas as any other operation that uses its source image, and canvases
  74802. * created without preserveDrawingBuffer set to true will be cleared.
  74803. * @param pose Define the pose to submit
  74804. */
  74805. submitFrame(pose?: VRPose): void;
  74806. }
  74807. declare var VRDisplay: {
  74808. prototype: VRDisplay;
  74809. new(): VRDisplay;
  74810. };
  74811. interface VRLayer {
  74812. leftBounds?: number[] | Float32Array | null;
  74813. rightBounds?: number[] | Float32Array | null;
  74814. source?: HTMLCanvasElement | null;
  74815. }
  74816. interface VRDisplayCapabilities {
  74817. readonly canPresent: boolean;
  74818. readonly hasExternalDisplay: boolean;
  74819. readonly hasOrientation: boolean;
  74820. readonly hasPosition: boolean;
  74821. readonly maxLayers: number;
  74822. }
  74823. interface VREyeParameters {
  74824. /** @deprecated */
  74825. readonly fieldOfView: VRFieldOfView;
  74826. readonly offset: Float32Array;
  74827. readonly renderHeight: number;
  74828. readonly renderWidth: number;
  74829. }
  74830. interface VRFieldOfView {
  74831. readonly downDegrees: number;
  74832. readonly leftDegrees: number;
  74833. readonly rightDegrees: number;
  74834. readonly upDegrees: number;
  74835. }
  74836. interface VRFrameData {
  74837. readonly leftProjectionMatrix: Float32Array;
  74838. readonly leftViewMatrix: Float32Array;
  74839. readonly pose: VRPose;
  74840. readonly rightProjectionMatrix: Float32Array;
  74841. readonly rightViewMatrix: Float32Array;
  74842. readonly timestamp: number;
  74843. }
  74844. interface VRPose {
  74845. readonly angularAcceleration: Float32Array | null;
  74846. readonly angularVelocity: Float32Array | null;
  74847. readonly linearAcceleration: Float32Array | null;
  74848. readonly linearVelocity: Float32Array | null;
  74849. readonly orientation: Float32Array | null;
  74850. readonly position: Float32Array | null;
  74851. readonly timestamp: number;
  74852. }
  74853. interface VRStageParameters {
  74854. sittingToStandingTransform?: Float32Array;
  74855. sizeX?: number;
  74856. sizeY?: number;
  74857. }
  74858. interface Navigator {
  74859. getVRDisplays(): Promise<VRDisplay[]>;
  74860. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74861. }
  74862. interface Window {
  74863. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74864. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74865. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74866. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74867. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74868. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74869. }
  74870. interface Gamepad {
  74871. readonly displayId: number;
  74872. }
  74873. type XRSessionMode =
  74874. | "inline"
  74875. | "immersive-vr"
  74876. | "immersive-ar";
  74877. type XRReferenceSpaceType =
  74878. | "viewer"
  74879. | "local"
  74880. | "local-floor"
  74881. | "bounded-floor"
  74882. | "unbounded";
  74883. type XREnvironmentBlendMode =
  74884. | "opaque"
  74885. | "additive"
  74886. | "alpha-blend";
  74887. type XRVisibilityState =
  74888. | "visible"
  74889. | "visible-blurred"
  74890. | "hidden";
  74891. type XRHandedness =
  74892. | "none"
  74893. | "left"
  74894. | "right";
  74895. type XRTargetRayMode =
  74896. | "gaze"
  74897. | "tracked-pointer"
  74898. | "screen";
  74899. type XREye =
  74900. | "none"
  74901. | "left"
  74902. | "right";
  74903. type XREventType =
  74904. | "devicechange"
  74905. | "visibilitychange"
  74906. | "end"
  74907. | "inputsourceschange"
  74908. | "select"
  74909. | "selectstart"
  74910. | "selectend"
  74911. | "squeeze"
  74912. | "squeezestart"
  74913. | "squeezeend"
  74914. | "reset";
  74915. interface XRSpace extends EventTarget {
  74916. }
  74917. interface XRRenderState {
  74918. depthNear?: number;
  74919. depthFar?: number;
  74920. inlineVerticalFieldOfView?: number;
  74921. baseLayer?: XRWebGLLayer;
  74922. }
  74923. interface XRInputSource {
  74924. handedness: XRHandedness;
  74925. targetRayMode: XRTargetRayMode;
  74926. targetRaySpace: XRSpace;
  74927. gripSpace: XRSpace | undefined;
  74928. gamepad: Gamepad | undefined;
  74929. profiles: Array<string>;
  74930. }
  74931. interface XRSessionInit {
  74932. optionalFeatures?: string[];
  74933. requiredFeatures?: string[];
  74934. }
  74935. interface XRSession {
  74936. addEventListener: Function;
  74937. removeEventListener: Function;
  74938. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74939. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74940. requestAnimationFrame: Function;
  74941. end(): Promise<void>;
  74942. renderState: XRRenderState;
  74943. inputSources: Array<XRInputSource>;
  74944. // hit test
  74945. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74946. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74947. // legacy AR hit test
  74948. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74949. // legacy plane detection
  74950. updateWorldTrackingState(options: {
  74951. planeDetectionState?: { enabled: boolean; }
  74952. }): void;
  74953. }
  74954. interface XRReferenceSpace extends XRSpace {
  74955. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74956. onreset: any;
  74957. }
  74958. type XRPlaneSet = Set<XRPlane>;
  74959. type XRAnchorSet = Set<XRAnchor>;
  74960. interface XRFrame {
  74961. session: XRSession;
  74962. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74963. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74964. // AR
  74965. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74966. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74967. // Anchors
  74968. trackedAnchors?: XRAnchorSet;
  74969. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74970. // Planes
  74971. worldInformation: {
  74972. detectedPlanes?: XRPlaneSet;
  74973. };
  74974. }
  74975. interface XRViewerPose extends XRPose {
  74976. views: Array<XRView>;
  74977. }
  74978. interface XRPose {
  74979. transform: XRRigidTransform;
  74980. emulatedPosition: boolean;
  74981. }
  74982. interface XRWebGLLayerOptions {
  74983. antialias?: boolean;
  74984. depth?: boolean;
  74985. stencil?: boolean;
  74986. alpha?: boolean;
  74987. multiview?: boolean;
  74988. framebufferScaleFactor?: number;
  74989. }
  74990. declare var XRWebGLLayer: {
  74991. prototype: XRWebGLLayer;
  74992. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74993. };
  74994. interface XRWebGLLayer {
  74995. framebuffer: WebGLFramebuffer;
  74996. framebufferWidth: number;
  74997. framebufferHeight: number;
  74998. getViewport: Function;
  74999. }
  75000. declare class XRRigidTransform {
  75001. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75002. position: DOMPointReadOnly;
  75003. orientation: DOMPointReadOnly;
  75004. matrix: Float32Array;
  75005. inverse: XRRigidTransform;
  75006. }
  75007. interface XRView {
  75008. eye: XREye;
  75009. projectionMatrix: Float32Array;
  75010. transform: XRRigidTransform;
  75011. }
  75012. interface XRInputSourceChangeEvent {
  75013. session: XRSession;
  75014. removed: Array<XRInputSource>;
  75015. added: Array<XRInputSource>;
  75016. }
  75017. interface XRInputSourceEvent extends Event {
  75018. readonly frame: XRFrame;
  75019. readonly inputSource: XRInputSource;
  75020. }
  75021. // Experimental(er) features
  75022. declare class XRRay {
  75023. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75024. origin: DOMPointReadOnly;
  75025. direction: DOMPointReadOnly;
  75026. matrix: Float32Array;
  75027. }
  75028. declare enum XRHitTestTrackableType {
  75029. "point",
  75030. "plane"
  75031. }
  75032. interface XRHitResult {
  75033. hitMatrix: Float32Array;
  75034. }
  75035. interface XRTransientInputHitTestResult {
  75036. readonly inputSource: XRInputSource;
  75037. readonly results: Array<XRHitTestResult>;
  75038. }
  75039. interface XRHitTestResult {
  75040. getPose(baseSpace: XRSpace): XRPose | undefined;
  75041. // When anchor system is enabled
  75042. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75043. }
  75044. interface XRHitTestSource {
  75045. cancel(): void;
  75046. }
  75047. interface XRTransientInputHitTestSource {
  75048. cancel(): void;
  75049. }
  75050. interface XRHitTestOptionsInit {
  75051. space: XRSpace;
  75052. entityTypes?: Array<XRHitTestTrackableType>;
  75053. offsetRay?: XRRay;
  75054. }
  75055. interface XRTransientInputHitTestOptionsInit {
  75056. profile: string;
  75057. entityTypes?: Array<XRHitTestTrackableType>;
  75058. offsetRay?: XRRay;
  75059. }
  75060. interface XRAnchor {
  75061. anchorSpace: XRSpace;
  75062. delete(): void;
  75063. }
  75064. interface XRPlane {
  75065. orientation: "Horizontal" | "Vertical";
  75066. planeSpace: XRSpace;
  75067. polygon: Array<DOMPointReadOnly>;
  75068. lastChangedTime: number;
  75069. }
  75070. /**
  75071. * @ignore
  75072. */
  75073. declare module BABYLON.GLTF2.Exporter {
  75074. }
  75075. /**
  75076. * @ignore
  75077. */
  75078. declare module BABYLON.GLTF1 {
  75079. }
  75080. declare module BABYLON.GUI {
  75081. /**
  75082. * Class used to specific a value and its associated unit
  75083. */
  75084. export class ValueAndUnit {
  75085. /** defines the unit to store */
  75086. unit: number;
  75087. /** defines a boolean indicating if the value can be negative */
  75088. negativeValueAllowed: boolean;
  75089. private _value;
  75090. private _originalUnit;
  75091. /**
  75092. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75093. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75094. */
  75095. ignoreAdaptiveScaling: boolean;
  75096. /**
  75097. * Creates a new ValueAndUnit
  75098. * @param value defines the value to store
  75099. * @param unit defines the unit to store
  75100. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75101. */
  75102. constructor(value: number,
  75103. /** defines the unit to store */
  75104. unit?: number,
  75105. /** defines a boolean indicating if the value can be negative */
  75106. negativeValueAllowed?: boolean);
  75107. /** Gets a boolean indicating if the value is a percentage */
  75108. get isPercentage(): boolean;
  75109. /** Gets a boolean indicating if the value is store as pixel */
  75110. get isPixel(): boolean;
  75111. /** Gets direct internal value */
  75112. get internalValue(): number;
  75113. /**
  75114. * Gets value as pixel
  75115. * @param host defines the root host
  75116. * @param refValue defines the reference value for percentages
  75117. * @returns the value as pixel
  75118. */
  75119. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  75120. /**
  75121. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  75122. * @param value defines the value to store
  75123. * @param unit defines the unit to store
  75124. * @returns the current ValueAndUnit
  75125. */
  75126. updateInPlace(value: number, unit?: number): ValueAndUnit;
  75127. /**
  75128. * Gets the value accordingly to its unit
  75129. * @param host defines the root host
  75130. * @returns the value
  75131. */
  75132. getValue(host: AdvancedDynamicTexture): number;
  75133. /**
  75134. * Gets a string representation of the value
  75135. * @param host defines the root host
  75136. * @param decimals defines an optional number of decimals to display
  75137. * @returns a string
  75138. */
  75139. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  75140. /**
  75141. * Store a value parsed from a string
  75142. * @param source defines the source string
  75143. * @returns true if the value was successfully parsed
  75144. */
  75145. fromString(source: string | number): boolean;
  75146. private static _Regex;
  75147. private static _UNITMODE_PERCENTAGE;
  75148. private static _UNITMODE_PIXEL;
  75149. /** UNITMODE_PERCENTAGE */
  75150. static get UNITMODE_PERCENTAGE(): number;
  75151. /** UNITMODE_PIXEL */
  75152. static get UNITMODE_PIXEL(): number;
  75153. }
  75154. }
  75155. declare module BABYLON.GUI {
  75156. /**
  75157. * Define a style used by control to automatically setup properties based on a template.
  75158. * Only support font related properties so far
  75159. */
  75160. export class Style implements BABYLON.IDisposable {
  75161. private _fontFamily;
  75162. private _fontStyle;
  75163. private _fontWeight;
  75164. /** @hidden */
  75165. _host: AdvancedDynamicTexture;
  75166. /** @hidden */
  75167. _fontSize: ValueAndUnit;
  75168. /**
  75169. * BABYLON.Observable raised when the style values are changed
  75170. */
  75171. onChangedObservable: BABYLON.Observable<Style>;
  75172. /**
  75173. * Creates a new style object
  75174. * @param host defines the AdvancedDynamicTexture which hosts this style
  75175. */
  75176. constructor(host: AdvancedDynamicTexture);
  75177. /**
  75178. * Gets or sets the font size
  75179. */
  75180. get fontSize(): string | number;
  75181. set fontSize(value: string | number);
  75182. /**
  75183. * Gets or sets the font family
  75184. */
  75185. get fontFamily(): string;
  75186. set fontFamily(value: string);
  75187. /**
  75188. * Gets or sets the font style
  75189. */
  75190. get fontStyle(): string;
  75191. set fontStyle(value: string);
  75192. /** Gets or sets font weight */
  75193. get fontWeight(): string;
  75194. set fontWeight(value: string);
  75195. /** Dispose all associated resources */
  75196. dispose(): void;
  75197. }
  75198. }
  75199. declare module BABYLON.GUI {
  75200. /**
  75201. * Class used to transport BABYLON.Vector2 information for pointer events
  75202. */
  75203. export class Vector2WithInfo extends BABYLON.Vector2 {
  75204. /** defines the current mouse button index */
  75205. buttonIndex: number;
  75206. /**
  75207. * Creates a new Vector2WithInfo
  75208. * @param source defines the vector2 data to transport
  75209. * @param buttonIndex defines the current mouse button index
  75210. */
  75211. constructor(source: BABYLON.Vector2,
  75212. /** defines the current mouse button index */
  75213. buttonIndex?: number);
  75214. }
  75215. /** Class used to provide 2D matrix features */
  75216. export class Matrix2D {
  75217. /** Gets the internal array of 6 floats used to store matrix data */
  75218. m: Float32Array;
  75219. /**
  75220. * Creates a new matrix
  75221. * @param m00 defines value for (0, 0)
  75222. * @param m01 defines value for (0, 1)
  75223. * @param m10 defines value for (1, 0)
  75224. * @param m11 defines value for (1, 1)
  75225. * @param m20 defines value for (2, 0)
  75226. * @param m21 defines value for (2, 1)
  75227. */
  75228. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  75229. /**
  75230. * Fills the matrix from direct values
  75231. * @param m00 defines value for (0, 0)
  75232. * @param m01 defines value for (0, 1)
  75233. * @param m10 defines value for (1, 0)
  75234. * @param m11 defines value for (1, 1)
  75235. * @param m20 defines value for (2, 0)
  75236. * @param m21 defines value for (2, 1)
  75237. * @returns the current modified matrix
  75238. */
  75239. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  75240. /**
  75241. * Gets matrix determinant
  75242. * @returns the determinant
  75243. */
  75244. determinant(): number;
  75245. /**
  75246. * Inverses the matrix and stores it in a target matrix
  75247. * @param result defines the target matrix
  75248. * @returns the current matrix
  75249. */
  75250. invertToRef(result: Matrix2D): Matrix2D;
  75251. /**
  75252. * Multiplies the current matrix with another one
  75253. * @param other defines the second operand
  75254. * @param result defines the target matrix
  75255. * @returns the current matrix
  75256. */
  75257. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  75258. /**
  75259. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  75260. * @param x defines the x coordinate to transform
  75261. * @param y defines the x coordinate to transform
  75262. * @param result defines the target vector2
  75263. * @returns the current matrix
  75264. */
  75265. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  75266. /**
  75267. * Creates an identity matrix
  75268. * @returns a new matrix
  75269. */
  75270. static Identity(): Matrix2D;
  75271. /**
  75272. * Creates a translation matrix and stores it in a target matrix
  75273. * @param x defines the x coordinate of the translation
  75274. * @param y defines the y coordinate of the translation
  75275. * @param result defines the target matrix
  75276. */
  75277. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  75278. /**
  75279. * Creates a scaling matrix and stores it in a target matrix
  75280. * @param x defines the x coordinate of the scaling
  75281. * @param y defines the y coordinate of the scaling
  75282. * @param result defines the target matrix
  75283. */
  75284. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  75285. /**
  75286. * Creates a rotation matrix and stores it in a target matrix
  75287. * @param angle defines the rotation angle
  75288. * @param result defines the target matrix
  75289. */
  75290. static RotationToRef(angle: number, result: Matrix2D): void;
  75291. private static _TempPreTranslationMatrix;
  75292. private static _TempPostTranslationMatrix;
  75293. private static _TempRotationMatrix;
  75294. private static _TempScalingMatrix;
  75295. private static _TempCompose0;
  75296. private static _TempCompose1;
  75297. private static _TempCompose2;
  75298. /**
  75299. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75300. * @param tx defines the x coordinate of the translation
  75301. * @param ty defines the y coordinate of the translation
  75302. * @param angle defines the rotation angle
  75303. * @param scaleX defines the x coordinate of the scaling
  75304. * @param scaleY defines the y coordinate of the scaling
  75305. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75306. * @param result defines the target matrix
  75307. */
  75308. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75309. }
  75310. }
  75311. declare module BABYLON.GUI {
  75312. /**
  75313. * Class used to store 2D control sizes
  75314. */
  75315. export class Measure {
  75316. /** defines left coordinate */
  75317. left: number;
  75318. /** defines top coordinate */
  75319. top: number;
  75320. /** defines width dimension */
  75321. width: number;
  75322. /** defines height dimension */
  75323. height: number;
  75324. /**
  75325. * Creates a new measure
  75326. * @param left defines left coordinate
  75327. * @param top defines top coordinate
  75328. * @param width defines width dimension
  75329. * @param height defines height dimension
  75330. */
  75331. constructor(
  75332. /** defines left coordinate */
  75333. left: number,
  75334. /** defines top coordinate */
  75335. top: number,
  75336. /** defines width dimension */
  75337. width: number,
  75338. /** defines height dimension */
  75339. height: number);
  75340. /**
  75341. * Copy from another measure
  75342. * @param other defines the other measure to copy from
  75343. */
  75344. copyFrom(other: Measure): void;
  75345. /**
  75346. * Copy from a group of 4 floats
  75347. * @param left defines left coordinate
  75348. * @param top defines top coordinate
  75349. * @param width defines width dimension
  75350. * @param height defines height dimension
  75351. */
  75352. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75353. /**
  75354. * Computes the axis aligned bounding box measure for two given measures
  75355. * @param a Input measure
  75356. * @param b Input measure
  75357. * @param result the resulting bounding measure
  75358. */
  75359. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75360. /**
  75361. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75362. * @param transform the matrix to transform the measure before computing the AABB
  75363. * @param result the resulting AABB
  75364. */
  75365. transformToRef(transform: Matrix2D, result: Measure): void;
  75366. /**
  75367. * Check equality between this measure and another one
  75368. * @param other defines the other measures
  75369. * @returns true if both measures are equals
  75370. */
  75371. isEqualsTo(other: Measure): boolean;
  75372. /**
  75373. * Creates an empty measure
  75374. * @returns a new measure
  75375. */
  75376. static Empty(): Measure;
  75377. }
  75378. }
  75379. declare module BABYLON.GUI {
  75380. /**
  75381. * Interface used to define a control that can receive focus
  75382. */
  75383. export interface IFocusableControl {
  75384. /**
  75385. * Function called when the control receives the focus
  75386. */
  75387. onFocus(): void;
  75388. /**
  75389. * Function called when the control loses the focus
  75390. */
  75391. onBlur(): void;
  75392. /**
  75393. * Function called to let the control handle keyboard events
  75394. * @param evt defines the current keyboard event
  75395. */
  75396. processKeyboard(evt: KeyboardEvent): void;
  75397. /**
  75398. * Function called to get the list of controls that should not steal the focus from this control
  75399. * @returns an array of controls
  75400. */
  75401. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75402. }
  75403. /**
  75404. * Class used to create texture to support 2D GUI elements
  75405. * @see https://doc.babylonjs.com/how_to/gui
  75406. */
  75407. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75408. private _isDirty;
  75409. private _renderObserver;
  75410. private _resizeObserver;
  75411. private _preKeyboardObserver;
  75412. private _pointerMoveObserver;
  75413. private _pointerObserver;
  75414. private _canvasPointerOutObserver;
  75415. private _background;
  75416. /** @hidden */
  75417. _rootContainer: Container;
  75418. /** @hidden */
  75419. _lastPickedControl: Control;
  75420. /** @hidden */
  75421. _lastControlOver: {
  75422. [pointerId: number]: Control;
  75423. };
  75424. /** @hidden */
  75425. _lastControlDown: {
  75426. [pointerId: number]: Control;
  75427. };
  75428. /** @hidden */
  75429. _capturingControl: {
  75430. [pointerId: number]: Control;
  75431. };
  75432. /** @hidden */
  75433. _shouldBlockPointer: boolean;
  75434. /** @hidden */
  75435. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75436. /** @hidden */
  75437. _linkedControls: Control[];
  75438. private _isFullscreen;
  75439. private _fullscreenViewport;
  75440. private _idealWidth;
  75441. private _idealHeight;
  75442. private _useSmallestIdeal;
  75443. private _renderAtIdealSize;
  75444. private _focusedControl;
  75445. private _blockNextFocusCheck;
  75446. private _renderScale;
  75447. private _rootElement;
  75448. private _cursorChanged;
  75449. private _defaultMousePointerId;
  75450. /** @hidden */
  75451. _numLayoutCalls: number;
  75452. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75453. get numLayoutCalls(): number;
  75454. /** @hidden */
  75455. _numRenderCalls: number;
  75456. /** Gets the number of render calls made the last time the ADT has been rendered */
  75457. get numRenderCalls(): number;
  75458. /**
  75459. * Define type to string to ensure compatibility across browsers
  75460. * Safari doesn't support DataTransfer constructor
  75461. */
  75462. private _clipboardData;
  75463. /**
  75464. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75465. */
  75466. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75467. /**
  75468. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75469. */
  75470. onControlPickedObservable: BABYLON.Observable<Control>;
  75471. /**
  75472. * BABYLON.Observable event triggered before layout is evaluated
  75473. */
  75474. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75475. /**
  75476. * BABYLON.Observable event triggered after the layout was evaluated
  75477. */
  75478. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75479. /**
  75480. * BABYLON.Observable event triggered before the texture is rendered
  75481. */
  75482. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75483. /**
  75484. * BABYLON.Observable event triggered after the texture was rendered
  75485. */
  75486. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75487. /**
  75488. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75489. */
  75490. premulAlpha: boolean;
  75491. /**
  75492. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75493. * Useful when you want more antialiasing
  75494. */
  75495. get renderScale(): number;
  75496. set renderScale(value: number);
  75497. /** Gets or sets the background color */
  75498. get background(): string;
  75499. set background(value: string);
  75500. /**
  75501. * Gets or sets the ideal width used to design controls.
  75502. * The GUI will then rescale everything accordingly
  75503. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75504. */
  75505. get idealWidth(): number;
  75506. set idealWidth(value: number);
  75507. /**
  75508. * Gets or sets the ideal height used to design controls.
  75509. * The GUI will then rescale everything accordingly
  75510. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75511. */
  75512. get idealHeight(): number;
  75513. set idealHeight(value: number);
  75514. /**
  75515. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75516. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75517. */
  75518. get useSmallestIdeal(): boolean;
  75519. set useSmallestIdeal(value: boolean);
  75520. /**
  75521. * Gets or sets a boolean indicating if adaptive scaling must be used
  75522. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75523. */
  75524. get renderAtIdealSize(): boolean;
  75525. set renderAtIdealSize(value: boolean);
  75526. /**
  75527. * Gets the ratio used when in "ideal mode"
  75528. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75529. * */
  75530. get idealRatio(): number;
  75531. /**
  75532. * Gets the underlying layer used to render the texture when in fullscreen mode
  75533. */
  75534. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75535. /**
  75536. * Gets the root container control
  75537. */
  75538. get rootContainer(): Container;
  75539. /**
  75540. * Returns an array containing the root container.
  75541. * This is mostly used to let the Inspector introspects the ADT
  75542. * @returns an array containing the rootContainer
  75543. */
  75544. getChildren(): Array<Container>;
  75545. /**
  75546. * Will return all controls that are inside this texture
  75547. * @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
  75548. * @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
  75549. * @return all child controls
  75550. */
  75551. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75552. /**
  75553. * Gets or sets the current focused control
  75554. */
  75555. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75556. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75557. /**
  75558. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75559. */
  75560. get isForeground(): boolean;
  75561. set isForeground(value: boolean);
  75562. /**
  75563. * Gets or set information about clipboardData
  75564. */
  75565. get clipboardData(): string;
  75566. set clipboardData(value: string);
  75567. /**
  75568. * Creates a new AdvancedDynamicTexture
  75569. * @param name defines the name of the texture
  75570. * @param width defines the width of the texture
  75571. * @param height defines the height of the texture
  75572. * @param scene defines the hosting scene
  75573. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75574. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75575. */
  75576. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75577. /**
  75578. * Get the current class name of the texture useful for serialization or dynamic coding.
  75579. * @returns "AdvancedDynamicTexture"
  75580. */
  75581. getClassName(): string;
  75582. /**
  75583. * Function used to execute a function on all controls
  75584. * @param func defines the function to execute
  75585. * @param container defines the container where controls belong. If null the root container will be used
  75586. */
  75587. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75588. private _useInvalidateRectOptimization;
  75589. /**
  75590. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75591. */
  75592. get useInvalidateRectOptimization(): boolean;
  75593. set useInvalidateRectOptimization(value: boolean);
  75594. private _invalidatedRectangle;
  75595. /**
  75596. * Invalidates a rectangle area on the gui texture
  75597. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75598. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75599. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75600. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75601. */
  75602. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75603. /**
  75604. * Marks the texture as dirty forcing a complete update
  75605. */
  75606. markAsDirty(): void;
  75607. /**
  75608. * Helper function used to create a new style
  75609. * @returns a new style
  75610. * @see https://doc.babylonjs.com/how_to/gui#styles
  75611. */
  75612. createStyle(): Style;
  75613. /**
  75614. * Adds a new control to the root container
  75615. * @param control defines the control to add
  75616. * @returns the current texture
  75617. */
  75618. addControl(control: Control): AdvancedDynamicTexture;
  75619. /**
  75620. * Removes a control from the root container
  75621. * @param control defines the control to remove
  75622. * @returns the current texture
  75623. */
  75624. removeControl(control: Control): AdvancedDynamicTexture;
  75625. /**
  75626. * Release all resources
  75627. */
  75628. dispose(): void;
  75629. private _onResize;
  75630. /** @hidden */
  75631. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75632. /**
  75633. * Get screen coordinates for a vector3
  75634. * @param position defines the position to project
  75635. * @param worldMatrix defines the world matrix to use
  75636. * @returns the projected position
  75637. */
  75638. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75639. private _checkUpdate;
  75640. private _clearMeasure;
  75641. private _render;
  75642. /** @hidden */
  75643. _changeCursor(cursor: string): void;
  75644. /** @hidden */
  75645. _registerLastControlDown(control: Control, pointerId: number): void;
  75646. private _doPicking;
  75647. /** @hidden */
  75648. _cleanControlAfterRemovalFromList(list: {
  75649. [pointerId: number]: Control;
  75650. }, control: Control): void;
  75651. /** @hidden */
  75652. _cleanControlAfterRemoval(control: Control): void;
  75653. /** Attach to all scene events required to support pointer events */
  75654. attach(): void;
  75655. /** @hidden */
  75656. private onClipboardCopy;
  75657. /** @hidden */
  75658. private onClipboardCut;
  75659. /** @hidden */
  75660. private onClipboardPaste;
  75661. /**
  75662. * Register the clipboard Events onto the canvas
  75663. */
  75664. registerClipboardEvents(): void;
  75665. /**
  75666. * Unregister the clipboard Events from the canvas
  75667. */
  75668. unRegisterClipboardEvents(): void;
  75669. /**
  75670. * Connect the texture to a hosting mesh to enable interactions
  75671. * @param mesh defines the mesh to attach to
  75672. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75673. */
  75674. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75675. /**
  75676. * Move the focus to a specific control
  75677. * @param control defines the control which will receive the focus
  75678. */
  75679. moveFocusToControl(control: IFocusableControl): void;
  75680. private _manageFocus;
  75681. private _attachToOnPointerOut;
  75682. /**
  75683. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75684. * @param mesh defines the mesh which will receive the texture
  75685. * @param width defines the texture width (1024 by default)
  75686. * @param height defines the texture height (1024 by default)
  75687. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75688. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75689. * @returns a new AdvancedDynamicTexture
  75690. */
  75691. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75692. /**
  75693. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75694. * In this mode the texture will rely on a layer for its rendering.
  75695. * This allows it to be treated like any other layer.
  75696. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75697. * LayerMask is set through advancedTexture.layer.layerMask
  75698. * @param name defines name for the texture
  75699. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75700. * @param scene defines the hsoting scene
  75701. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75702. * @returns a new AdvancedDynamicTexture
  75703. */
  75704. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75705. }
  75706. }
  75707. declare module BABYLON.GUI {
  75708. /**
  75709. * Root class used for all 2D controls
  75710. * @see https://doc.babylonjs.com/how_to/gui#controls
  75711. */
  75712. export class Control {
  75713. /** defines the name of the control */
  75714. name?: string | undefined;
  75715. /**
  75716. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75717. */
  75718. static AllowAlphaInheritance: boolean;
  75719. private _alpha;
  75720. private _alphaSet;
  75721. private _zIndex;
  75722. /** @hidden */
  75723. _host: AdvancedDynamicTexture;
  75724. /** Gets or sets the control parent */
  75725. parent: BABYLON.Nullable<Container>;
  75726. /** @hidden */
  75727. _currentMeasure: Measure;
  75728. private _fontFamily;
  75729. private _fontStyle;
  75730. private _fontWeight;
  75731. private _fontSize;
  75732. private _font;
  75733. /** @hidden */
  75734. _width: ValueAndUnit;
  75735. /** @hidden */
  75736. _height: ValueAndUnit;
  75737. /** @hidden */
  75738. protected _fontOffset: {
  75739. ascent: number;
  75740. height: number;
  75741. descent: number;
  75742. };
  75743. private _color;
  75744. private _style;
  75745. private _styleObserver;
  75746. /** @hidden */
  75747. protected _horizontalAlignment: number;
  75748. /** @hidden */
  75749. protected _verticalAlignment: number;
  75750. /** @hidden */
  75751. protected _isDirty: boolean;
  75752. /** @hidden */
  75753. protected _wasDirty: boolean;
  75754. /** @hidden */
  75755. _tempParentMeasure: Measure;
  75756. /** @hidden */
  75757. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75758. /** @hidden */
  75759. protected _cachedParentMeasure: Measure;
  75760. private _paddingLeft;
  75761. private _paddingRight;
  75762. private _paddingTop;
  75763. private _paddingBottom;
  75764. /** @hidden */
  75765. _left: ValueAndUnit;
  75766. /** @hidden */
  75767. _top: ValueAndUnit;
  75768. private _scaleX;
  75769. private _scaleY;
  75770. private _rotation;
  75771. private _transformCenterX;
  75772. private _transformCenterY;
  75773. /** @hidden */
  75774. _transformMatrix: Matrix2D;
  75775. /** @hidden */
  75776. protected _invertTransformMatrix: Matrix2D;
  75777. /** @hidden */
  75778. protected _transformedPosition: BABYLON.Vector2;
  75779. private _isMatrixDirty;
  75780. private _cachedOffsetX;
  75781. private _cachedOffsetY;
  75782. private _isVisible;
  75783. private _isHighlighted;
  75784. /** @hidden */
  75785. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75786. private _fontSet;
  75787. private _dummyVector2;
  75788. private _downCount;
  75789. private _enterCount;
  75790. private _doNotRender;
  75791. private _downPointerIds;
  75792. protected _isEnabled: boolean;
  75793. protected _disabledColor: string;
  75794. protected _disabledColorItem: string;
  75795. /** @hidden */
  75796. protected _rebuildLayout: boolean;
  75797. /** @hidden */
  75798. _customData: any;
  75799. /** @hidden */
  75800. _isClipped: boolean;
  75801. /** @hidden */
  75802. _automaticSize: boolean;
  75803. /** @hidden */
  75804. _tag: any;
  75805. /**
  75806. * 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
  75807. */
  75808. uniqueId: number;
  75809. /**
  75810. * Gets or sets an object used to store user defined information for the node
  75811. */
  75812. metadata: any;
  75813. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75814. isHitTestVisible: boolean;
  75815. /** Gets or sets a boolean indicating if the control can block pointer events */
  75816. isPointerBlocker: boolean;
  75817. /** Gets or sets a boolean indicating if the control can be focusable */
  75818. isFocusInvisible: boolean;
  75819. /**
  75820. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75821. * 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
  75822. */
  75823. clipChildren: boolean;
  75824. /**
  75825. * Gets or sets a boolean indicating that control content must be clipped
  75826. * 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
  75827. */
  75828. clipContent: boolean;
  75829. /**
  75830. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75831. */
  75832. useBitmapCache: boolean;
  75833. private _cacheData;
  75834. private _shadowOffsetX;
  75835. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75836. get shadowOffsetX(): number;
  75837. set shadowOffsetX(value: number);
  75838. private _shadowOffsetY;
  75839. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75840. get shadowOffsetY(): number;
  75841. set shadowOffsetY(value: number);
  75842. private _shadowBlur;
  75843. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75844. get shadowBlur(): number;
  75845. set shadowBlur(value: number);
  75846. private _shadowColor;
  75847. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75848. get shadowColor(): string;
  75849. set shadowColor(value: string);
  75850. /** Gets or sets the cursor to use when the control is hovered */
  75851. hoverCursor: string;
  75852. /** @hidden */
  75853. protected _linkOffsetX: ValueAndUnit;
  75854. /** @hidden */
  75855. protected _linkOffsetY: ValueAndUnit;
  75856. /** Gets the control type name */
  75857. get typeName(): string;
  75858. /**
  75859. * Get the current class name of the control.
  75860. * @returns current class name
  75861. */
  75862. getClassName(): string;
  75863. /**
  75864. * An event triggered when pointer wheel is scrolled
  75865. */
  75866. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75867. /**
  75868. * An event triggered when the pointer move over the control.
  75869. */
  75870. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75871. /**
  75872. * An event triggered when the pointer move out of the control.
  75873. */
  75874. onPointerOutObservable: BABYLON.Observable<Control>;
  75875. /**
  75876. * An event triggered when the pointer taps the control
  75877. */
  75878. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75879. /**
  75880. * An event triggered when pointer up
  75881. */
  75882. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75883. /**
  75884. * An event triggered when a control is clicked on
  75885. */
  75886. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75887. /**
  75888. * An event triggered when pointer enters the control
  75889. */
  75890. onPointerEnterObservable: BABYLON.Observable<Control>;
  75891. /**
  75892. * An event triggered when the control is marked as dirty
  75893. */
  75894. onDirtyObservable: BABYLON.Observable<Control>;
  75895. /**
  75896. * An event triggered before drawing the control
  75897. */
  75898. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75899. /**
  75900. * An event triggered after the control was drawn
  75901. */
  75902. onAfterDrawObservable: BABYLON.Observable<Control>;
  75903. /**
  75904. * An event triggered when the control has been disposed
  75905. */
  75906. onDisposeObservable: BABYLON.Observable<Control>;
  75907. /**
  75908. * Get the hosting AdvancedDynamicTexture
  75909. */
  75910. get host(): AdvancedDynamicTexture;
  75911. /** Gets or set information about font offsets (used to render and align text) */
  75912. get fontOffset(): {
  75913. ascent: number;
  75914. height: number;
  75915. descent: number;
  75916. };
  75917. set fontOffset(offset: {
  75918. ascent: number;
  75919. height: number;
  75920. descent: number;
  75921. });
  75922. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75923. get alpha(): number;
  75924. set alpha(value: number);
  75925. /**
  75926. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75927. */
  75928. get isHighlighted(): boolean;
  75929. set isHighlighted(value: boolean);
  75930. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75931. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75932. */
  75933. get scaleX(): number;
  75934. set scaleX(value: number);
  75935. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75936. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75937. */
  75938. get scaleY(): number;
  75939. set scaleY(value: number);
  75940. /** Gets or sets the rotation angle (0 by default)
  75941. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75942. */
  75943. get rotation(): number;
  75944. set rotation(value: number);
  75945. /** Gets or sets the transformation center on Y axis (0 by default)
  75946. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75947. */
  75948. get transformCenterY(): number;
  75949. set transformCenterY(value: number);
  75950. /** Gets or sets the transformation center on X axis (0 by default)
  75951. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75952. */
  75953. get transformCenterX(): number;
  75954. set transformCenterX(value: number);
  75955. /**
  75956. * Gets or sets the horizontal alignment
  75957. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75958. */
  75959. get horizontalAlignment(): number;
  75960. set horizontalAlignment(value: number);
  75961. /**
  75962. * Gets or sets the vertical alignment
  75963. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75964. */
  75965. get verticalAlignment(): number;
  75966. set verticalAlignment(value: number);
  75967. /**
  75968. * Gets or sets control width
  75969. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75970. */
  75971. get width(): string | number;
  75972. set width(value: string | number);
  75973. /**
  75974. * Gets or sets the control width in pixel
  75975. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75976. */
  75977. get widthInPixels(): number;
  75978. set widthInPixels(value: number);
  75979. /**
  75980. * Gets or sets control height
  75981. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75982. */
  75983. get height(): string | number;
  75984. set height(value: string | number);
  75985. /**
  75986. * Gets or sets control height in pixel
  75987. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75988. */
  75989. get heightInPixels(): number;
  75990. set heightInPixels(value: number);
  75991. /** Gets or set font family */
  75992. get fontFamily(): string;
  75993. set fontFamily(value: string);
  75994. /** Gets or sets font style */
  75995. get fontStyle(): string;
  75996. set fontStyle(value: string);
  75997. /** Gets or sets font weight */
  75998. get fontWeight(): string;
  75999. set fontWeight(value: string);
  76000. /**
  76001. * Gets or sets style
  76002. * @see https://doc.babylonjs.com/how_to/gui#styles
  76003. */
  76004. get style(): BABYLON.Nullable<Style>;
  76005. set style(value: BABYLON.Nullable<Style>);
  76006. /** @hidden */
  76007. get _isFontSizeInPercentage(): boolean;
  76008. /** Gets or sets font size in pixels */
  76009. get fontSizeInPixels(): number;
  76010. set fontSizeInPixels(value: number);
  76011. /** Gets or sets font size */
  76012. get fontSize(): string | number;
  76013. set fontSize(value: string | number);
  76014. /** Gets or sets foreground color */
  76015. get color(): string;
  76016. set color(value: string);
  76017. /** Gets or sets z index which is used to reorder controls on the z axis */
  76018. get zIndex(): number;
  76019. set zIndex(value: number);
  76020. /** Gets or sets a boolean indicating if the control can be rendered */
  76021. get notRenderable(): boolean;
  76022. set notRenderable(value: boolean);
  76023. /** Gets or sets a boolean indicating if the control is visible */
  76024. get isVisible(): boolean;
  76025. set isVisible(value: boolean);
  76026. /** Gets a boolean indicating that the control needs to update its rendering */
  76027. get isDirty(): boolean;
  76028. /**
  76029. * Gets the current linked mesh (or null if none)
  76030. */
  76031. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76032. /**
  76033. * Gets or sets a value indicating the padding to use on the left of the control
  76034. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76035. */
  76036. get paddingLeft(): string | number;
  76037. set paddingLeft(value: string | number);
  76038. /**
  76039. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76040. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76041. */
  76042. get paddingLeftInPixels(): number;
  76043. set paddingLeftInPixels(value: number);
  76044. /**
  76045. * Gets or sets a value indicating the padding to use on the right of the control
  76046. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76047. */
  76048. get paddingRight(): string | number;
  76049. set paddingRight(value: string | number);
  76050. /**
  76051. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76052. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76053. */
  76054. get paddingRightInPixels(): number;
  76055. set paddingRightInPixels(value: number);
  76056. /**
  76057. * Gets or sets a value indicating the padding to use on the top of the control
  76058. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76059. */
  76060. get paddingTop(): string | number;
  76061. set paddingTop(value: string | number);
  76062. /**
  76063. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76064. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76065. */
  76066. get paddingTopInPixels(): number;
  76067. set paddingTopInPixels(value: number);
  76068. /**
  76069. * Gets or sets a value indicating the padding to use on the bottom of the control
  76070. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76071. */
  76072. get paddingBottom(): string | number;
  76073. set paddingBottom(value: string | number);
  76074. /**
  76075. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76076. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76077. */
  76078. get paddingBottomInPixels(): number;
  76079. set paddingBottomInPixels(value: number);
  76080. /**
  76081. * Gets or sets a value indicating the left coordinate of the control
  76082. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76083. */
  76084. get left(): string | number;
  76085. set left(value: string | number);
  76086. /**
  76087. * Gets or sets a value indicating the left coordinate in pixels of the control
  76088. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76089. */
  76090. get leftInPixels(): number;
  76091. set leftInPixels(value: number);
  76092. /**
  76093. * Gets or sets a value indicating the top coordinate of the control
  76094. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76095. */
  76096. get top(): string | number;
  76097. set top(value: string | number);
  76098. /**
  76099. * Gets or sets a value indicating the top coordinate in pixels of the control
  76100. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76101. */
  76102. get topInPixels(): number;
  76103. set topInPixels(value: number);
  76104. /**
  76105. * Gets or sets a value indicating the offset on X axis to the linked mesh
  76106. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76107. */
  76108. get linkOffsetX(): string | number;
  76109. set linkOffsetX(value: string | number);
  76110. /**
  76111. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  76112. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76113. */
  76114. get linkOffsetXInPixels(): number;
  76115. set linkOffsetXInPixels(value: number);
  76116. /**
  76117. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  76118. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76119. */
  76120. get linkOffsetY(): string | number;
  76121. set linkOffsetY(value: string | number);
  76122. /**
  76123. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  76124. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76125. */
  76126. get linkOffsetYInPixels(): number;
  76127. set linkOffsetYInPixels(value: number);
  76128. /** Gets the center coordinate on X axis */
  76129. get centerX(): number;
  76130. /** Gets the center coordinate on Y axis */
  76131. get centerY(): number;
  76132. /** Gets or sets if control is Enabled*/
  76133. get isEnabled(): boolean;
  76134. set isEnabled(value: boolean);
  76135. /** Gets or sets background color of control if it's disabled*/
  76136. get disabledColor(): string;
  76137. set disabledColor(value: string);
  76138. /** Gets or sets front color of control if it's disabled*/
  76139. get disabledColorItem(): string;
  76140. set disabledColorItem(value: string);
  76141. /**
  76142. * Creates a new control
  76143. * @param name defines the name of the control
  76144. */
  76145. constructor(
  76146. /** defines the name of the control */
  76147. name?: string | undefined);
  76148. /** @hidden */
  76149. protected _getTypeName(): string;
  76150. /**
  76151. * Gets the first ascendant in the hierarchy of the given type
  76152. * @param className defines the required type
  76153. * @returns the ascendant or null if not found
  76154. */
  76155. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  76156. /** @hidden */
  76157. _resetFontCache(): void;
  76158. /**
  76159. * Determines if a container is an ascendant of the current control
  76160. * @param container defines the container to look for
  76161. * @returns true if the container is one of the ascendant of the control
  76162. */
  76163. isAscendant(container: Control): boolean;
  76164. /**
  76165. * Gets coordinates in local control space
  76166. * @param globalCoordinates defines the coordinates to transform
  76167. * @returns the new coordinates in local space
  76168. */
  76169. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76170. /**
  76171. * Gets coordinates in local control space
  76172. * @param globalCoordinates defines the coordinates to transform
  76173. * @param result defines the target vector2 where to store the result
  76174. * @returns the current control
  76175. */
  76176. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  76177. /**
  76178. * Gets coordinates in parent local control space
  76179. * @param globalCoordinates defines the coordinates to transform
  76180. * @returns the new coordinates in parent local space
  76181. */
  76182. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76183. /**
  76184. * Move the current control to a vector3 position projected onto the screen.
  76185. * @param position defines the target position
  76186. * @param scene defines the hosting scene
  76187. */
  76188. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  76189. /**
  76190. * Will store all controls that have this control as ascendant in a given array
  76191. * @param results defines the array where to store the descendants
  76192. * @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
  76193. * @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
  76194. */
  76195. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76196. /**
  76197. * Will return all controls that have this control as ascendant
  76198. * @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
  76199. * @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
  76200. * @return all child controls
  76201. */
  76202. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76203. /**
  76204. * Link current control with a target mesh
  76205. * @param mesh defines the mesh to link with
  76206. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76207. */
  76208. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  76209. /** @hidden */
  76210. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  76211. /** @hidden */
  76212. _offsetLeft(offset: number): void;
  76213. /** @hidden */
  76214. _offsetTop(offset: number): void;
  76215. /** @hidden */
  76216. _markMatrixAsDirty(): void;
  76217. /** @hidden */
  76218. _flagDescendantsAsMatrixDirty(): void;
  76219. /** @hidden */
  76220. _intersectsRect(rect: Measure): boolean;
  76221. /** @hidden */
  76222. protected invalidateRect(): void;
  76223. /** @hidden */
  76224. _markAsDirty(force?: boolean): void;
  76225. /** @hidden */
  76226. _markAllAsDirty(): void;
  76227. /** @hidden */
  76228. _link(host: AdvancedDynamicTexture): void;
  76229. /** @hidden */
  76230. protected _transform(context?: CanvasRenderingContext2D): void;
  76231. /** @hidden */
  76232. _renderHighlight(context: CanvasRenderingContext2D): void;
  76233. /** @hidden */
  76234. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76235. /** @hidden */
  76236. protected _applyStates(context: CanvasRenderingContext2D): void;
  76237. /** @hidden */
  76238. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76239. /** @hidden */
  76240. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76241. protected _evaluateClippingState(parentMeasure: Measure): void;
  76242. /** @hidden */
  76243. _measure(): void;
  76244. /** @hidden */
  76245. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76246. /** @hidden */
  76247. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76248. /** @hidden */
  76249. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76250. /** @hidden */
  76251. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76252. private static _ClipMeasure;
  76253. private _tmpMeasureA;
  76254. private _clip;
  76255. /** @hidden */
  76256. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  76257. /** @hidden */
  76258. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76259. /**
  76260. * Tests if a given coordinates belong to the current control
  76261. * @param x defines x coordinate to test
  76262. * @param y defines y coordinate to test
  76263. * @returns true if the coordinates are inside the control
  76264. */
  76265. contains(x: number, y: number): boolean;
  76266. /** @hidden */
  76267. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76268. /** @hidden */
  76269. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76270. /** @hidden */
  76271. _onPointerEnter(target: Control): boolean;
  76272. /** @hidden */
  76273. _onPointerOut(target: Control, force?: boolean): void;
  76274. /** @hidden */
  76275. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76276. /** @hidden */
  76277. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76278. /** @hidden */
  76279. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76280. /** @hidden */
  76281. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  76282. /** @hidden */
  76283. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76284. private _prepareFont;
  76285. /** Releases associated resources */
  76286. dispose(): void;
  76287. private static _HORIZONTAL_ALIGNMENT_LEFT;
  76288. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  76289. private static _HORIZONTAL_ALIGNMENT_CENTER;
  76290. private static _VERTICAL_ALIGNMENT_TOP;
  76291. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76292. private static _VERTICAL_ALIGNMENT_CENTER;
  76293. /** HORIZONTAL_ALIGNMENT_LEFT */
  76294. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76295. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76296. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76297. /** HORIZONTAL_ALIGNMENT_CENTER */
  76298. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76299. /** VERTICAL_ALIGNMENT_TOP */
  76300. static get VERTICAL_ALIGNMENT_TOP(): number;
  76301. /** VERTICAL_ALIGNMENT_BOTTOM */
  76302. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76303. /** VERTICAL_ALIGNMENT_CENTER */
  76304. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76305. private static _FontHeightSizes;
  76306. /** @hidden */
  76307. static _GetFontOffset(font: string): {
  76308. ascent: number;
  76309. height: number;
  76310. descent: number;
  76311. };
  76312. /**
  76313. * Creates a stack panel that can be used to render headers
  76314. * @param control defines the control to associate with the header
  76315. * @param text defines the text of the header
  76316. * @param size defines the size of the header
  76317. * @param options defines options used to configure the header
  76318. * @returns a new StackPanel
  76319. * @ignore
  76320. * @hidden
  76321. */
  76322. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76323. isHorizontal: boolean;
  76324. controlFirst: boolean;
  76325. }) => any;
  76326. /** @hidden */
  76327. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76328. }
  76329. }
  76330. declare module BABYLON.GUI {
  76331. /**
  76332. * Root class for 2D containers
  76333. * @see https://doc.babylonjs.com/how_to/gui#containers
  76334. */
  76335. export class Container extends Control {
  76336. name?: string | undefined;
  76337. /** @hidden */
  76338. _children: Control[];
  76339. /** @hidden */
  76340. protected _measureForChildren: Measure;
  76341. /** @hidden */
  76342. protected _background: string;
  76343. /** @hidden */
  76344. protected _adaptWidthToChildren: boolean;
  76345. /** @hidden */
  76346. protected _adaptHeightToChildren: boolean;
  76347. /**
  76348. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76349. */
  76350. logLayoutCycleErrors: boolean;
  76351. /**
  76352. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76353. */
  76354. maxLayoutCycle: number;
  76355. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76356. get adaptHeightToChildren(): boolean;
  76357. set adaptHeightToChildren(value: boolean);
  76358. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76359. get adaptWidthToChildren(): boolean;
  76360. set adaptWidthToChildren(value: boolean);
  76361. /** Gets or sets background color */
  76362. get background(): string;
  76363. set background(value: string);
  76364. /** Gets the list of children */
  76365. get children(): Control[];
  76366. /**
  76367. * Creates a new Container
  76368. * @param name defines the name of the container
  76369. */
  76370. constructor(name?: string | undefined);
  76371. protected _getTypeName(): string;
  76372. _flagDescendantsAsMatrixDirty(): void;
  76373. /**
  76374. * Gets a child using its name
  76375. * @param name defines the child name to look for
  76376. * @returns the child control if found
  76377. */
  76378. getChildByName(name: string): BABYLON.Nullable<Control>;
  76379. /**
  76380. * Gets a child using its type and its name
  76381. * @param name defines the child name to look for
  76382. * @param type defines the child type to look for
  76383. * @returns the child control if found
  76384. */
  76385. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76386. /**
  76387. * Search for a specific control in children
  76388. * @param control defines the control to look for
  76389. * @returns true if the control is in child list
  76390. */
  76391. containsControl(control: Control): boolean;
  76392. /**
  76393. * Adds a new control to the current container
  76394. * @param control defines the control to add
  76395. * @returns the current container
  76396. */
  76397. addControl(control: BABYLON.Nullable<Control>): Container;
  76398. /**
  76399. * Removes all controls from the current container
  76400. * @returns the current container
  76401. */
  76402. clearControls(): Container;
  76403. /**
  76404. * Removes a control from the current container
  76405. * @param control defines the control to remove
  76406. * @returns the current container
  76407. */
  76408. removeControl(control: Control): Container;
  76409. /** @hidden */
  76410. _reOrderControl(control: Control): void;
  76411. /** @hidden */
  76412. _offsetLeft(offset: number): void;
  76413. /** @hidden */
  76414. _offsetTop(offset: number): void;
  76415. /** @hidden */
  76416. _markAllAsDirty(): void;
  76417. /** @hidden */
  76418. protected _localDraw(context: CanvasRenderingContext2D): void;
  76419. /** @hidden */
  76420. _link(host: AdvancedDynamicTexture): void;
  76421. /** @hidden */
  76422. protected _beforeLayout(): void;
  76423. /** @hidden */
  76424. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76425. /** @hidden */
  76426. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76427. protected _postMeasure(): void;
  76428. /** @hidden */
  76429. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76430. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76431. /** @hidden */
  76432. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76433. /** @hidden */
  76434. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76435. /** Releases associated resources */
  76436. dispose(): void;
  76437. }
  76438. }
  76439. declare module BABYLON.GUI {
  76440. /** Class used to create rectangle container */
  76441. export class Rectangle extends Container {
  76442. name?: string | undefined;
  76443. private _thickness;
  76444. private _cornerRadius;
  76445. /** Gets or sets border thickness */
  76446. get thickness(): number;
  76447. set thickness(value: number);
  76448. /** Gets or sets the corner radius angle */
  76449. get cornerRadius(): number;
  76450. set cornerRadius(value: number);
  76451. /**
  76452. * Creates a new Rectangle
  76453. * @param name defines the control name
  76454. */
  76455. constructor(name?: string | undefined);
  76456. protected _getTypeName(): string;
  76457. protected _localDraw(context: CanvasRenderingContext2D): void;
  76458. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76459. private _drawRoundedRect;
  76460. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76461. }
  76462. }
  76463. declare module BABYLON.GUI {
  76464. /**
  76465. * Enum that determines the text-wrapping mode to use.
  76466. */
  76467. export enum TextWrapping {
  76468. /**
  76469. * Clip the text when it's larger than Control.width; this is the default mode.
  76470. */
  76471. Clip = 0,
  76472. /**
  76473. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76474. */
  76475. WordWrap = 1,
  76476. /**
  76477. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76478. */
  76479. Ellipsis = 2
  76480. }
  76481. /**
  76482. * Class used to create text block control
  76483. */
  76484. export class TextBlock extends Control {
  76485. /**
  76486. * Defines the name of the control
  76487. */
  76488. name?: string | undefined;
  76489. private _text;
  76490. private _textWrapping;
  76491. private _textHorizontalAlignment;
  76492. private _textVerticalAlignment;
  76493. private _lines;
  76494. private _resizeToFit;
  76495. private _lineSpacing;
  76496. private _outlineWidth;
  76497. private _outlineColor;
  76498. /**
  76499. * An event triggered after the text is changed
  76500. */
  76501. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76502. /**
  76503. * An event triggered after the text was broken up into lines
  76504. */
  76505. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76506. /**
  76507. * Function used to split a string into words. By default, a string is split at each space character found
  76508. */
  76509. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76510. /**
  76511. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76512. */
  76513. get lines(): any[];
  76514. /**
  76515. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76516. */
  76517. get resizeToFit(): boolean;
  76518. /**
  76519. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76520. */
  76521. set resizeToFit(value: boolean);
  76522. /**
  76523. * Gets or sets a boolean indicating if text must be wrapped
  76524. */
  76525. get textWrapping(): TextWrapping | boolean;
  76526. /**
  76527. * Gets or sets a boolean indicating if text must be wrapped
  76528. */
  76529. set textWrapping(value: TextWrapping | boolean);
  76530. /**
  76531. * Gets or sets text to display
  76532. */
  76533. get text(): string;
  76534. /**
  76535. * Gets or sets text to display
  76536. */
  76537. set text(value: string);
  76538. /**
  76539. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76540. */
  76541. get textHorizontalAlignment(): number;
  76542. /**
  76543. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76544. */
  76545. set textHorizontalAlignment(value: number);
  76546. /**
  76547. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76548. */
  76549. get textVerticalAlignment(): number;
  76550. /**
  76551. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76552. */
  76553. set textVerticalAlignment(value: number);
  76554. /**
  76555. * Gets or sets line spacing value
  76556. */
  76557. set lineSpacing(value: string | number);
  76558. /**
  76559. * Gets or sets line spacing value
  76560. */
  76561. get lineSpacing(): string | number;
  76562. /**
  76563. * Gets or sets outlineWidth of the text to display
  76564. */
  76565. get outlineWidth(): number;
  76566. /**
  76567. * Gets or sets outlineWidth of the text to display
  76568. */
  76569. set outlineWidth(value: number);
  76570. /**
  76571. * Gets or sets outlineColor of the text to display
  76572. */
  76573. get outlineColor(): string;
  76574. /**
  76575. * Gets or sets outlineColor of the text to display
  76576. */
  76577. set outlineColor(value: string);
  76578. /**
  76579. * Creates a new TextBlock object
  76580. * @param name defines the name of the control
  76581. * @param text defines the text to display (emptry string by default)
  76582. */
  76583. constructor(
  76584. /**
  76585. * Defines the name of the control
  76586. */
  76587. name?: string | undefined, text?: string);
  76588. protected _getTypeName(): string;
  76589. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76590. private _drawText;
  76591. /** @hidden */
  76592. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76593. protected _applyStates(context: CanvasRenderingContext2D): void;
  76594. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76595. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76596. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76597. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76598. protected _renderLines(context: CanvasRenderingContext2D): void;
  76599. /**
  76600. * Given a width constraint applied on the text block, find the expected height
  76601. * @returns expected height
  76602. */
  76603. computeExpectedHeight(): number;
  76604. dispose(): void;
  76605. }
  76606. }
  76607. declare module BABYLON.GUI {
  76608. /**
  76609. * Class used to create 2D images
  76610. */
  76611. export class Image extends Control {
  76612. name?: string | undefined;
  76613. private _workingCanvas;
  76614. private _domImage;
  76615. private _imageWidth;
  76616. private _imageHeight;
  76617. private _loaded;
  76618. private _stretch;
  76619. private _source;
  76620. private _autoScale;
  76621. private _sourceLeft;
  76622. private _sourceTop;
  76623. private _sourceWidth;
  76624. private _sourceHeight;
  76625. private _svgAttributesComputationCompleted;
  76626. private _isSVG;
  76627. private _cellWidth;
  76628. private _cellHeight;
  76629. private _cellId;
  76630. private _populateNinePatchSlicesFromImage;
  76631. private _sliceLeft;
  76632. private _sliceRight;
  76633. private _sliceTop;
  76634. private _sliceBottom;
  76635. private _detectPointerOnOpaqueOnly;
  76636. /**
  76637. * BABYLON.Observable notified when the content is loaded
  76638. */
  76639. onImageLoadedObservable: BABYLON.Observable<Image>;
  76640. /**
  76641. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76642. */
  76643. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76644. /**
  76645. * Gets a boolean indicating that the content is loaded
  76646. */
  76647. get isLoaded(): boolean;
  76648. /**
  76649. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76650. */
  76651. get populateNinePatchSlicesFromImage(): boolean;
  76652. set populateNinePatchSlicesFromImage(value: boolean);
  76653. /**
  76654. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76655. * Beware using this as this will comsume more memory as the image has to be stored twice
  76656. */
  76657. get detectPointerOnOpaqueOnly(): boolean;
  76658. set detectPointerOnOpaqueOnly(value: boolean);
  76659. /**
  76660. * Gets or sets the left value for slicing (9-patch)
  76661. */
  76662. get sliceLeft(): number;
  76663. set sliceLeft(value: number);
  76664. /**
  76665. * Gets or sets the right value for slicing (9-patch)
  76666. */
  76667. get sliceRight(): number;
  76668. set sliceRight(value: number);
  76669. /**
  76670. * Gets or sets the top value for slicing (9-patch)
  76671. */
  76672. get sliceTop(): number;
  76673. set sliceTop(value: number);
  76674. /**
  76675. * Gets or sets the bottom value for slicing (9-patch)
  76676. */
  76677. get sliceBottom(): number;
  76678. set sliceBottom(value: number);
  76679. /**
  76680. * Gets or sets the left coordinate in the source image
  76681. */
  76682. get sourceLeft(): number;
  76683. set sourceLeft(value: number);
  76684. /**
  76685. * Gets or sets the top coordinate in the source image
  76686. */
  76687. get sourceTop(): number;
  76688. set sourceTop(value: number);
  76689. /**
  76690. * Gets or sets the width to capture in the source image
  76691. */
  76692. get sourceWidth(): number;
  76693. set sourceWidth(value: number);
  76694. /**
  76695. * Gets or sets the height to capture in the source image
  76696. */
  76697. get sourceHeight(): number;
  76698. set sourceHeight(value: number);
  76699. /** Indicates if the format of the image is SVG */
  76700. get isSVG(): boolean;
  76701. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76702. get svgAttributesComputationCompleted(): boolean;
  76703. /**
  76704. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76705. * @see https://doc.babylonjs.com/how_to/gui#image
  76706. */
  76707. get autoScale(): boolean;
  76708. set autoScale(value: boolean);
  76709. /** Gets or sets the streching mode used by the image */
  76710. get stretch(): number;
  76711. set stretch(value: number);
  76712. /** @hidden */
  76713. _rotate90(n: number, preserveProperties?: boolean): Image;
  76714. private _handleRotationForSVGImage;
  76715. private _rotate90SourceProperties;
  76716. /**
  76717. * Gets or sets the internal DOM image used to render the control
  76718. */
  76719. set domImage(value: HTMLImageElement);
  76720. get domImage(): HTMLImageElement;
  76721. private _onImageLoaded;
  76722. private _extractNinePatchSliceDataFromImage;
  76723. /**
  76724. * Gets or sets image source url
  76725. */
  76726. set source(value: BABYLON.Nullable<string>);
  76727. /**
  76728. * Checks for svg document with icon id present
  76729. */
  76730. private _svgCheck;
  76731. /**
  76732. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76733. * given external svg file and icon id
  76734. */
  76735. private _getSVGAttribs;
  76736. /**
  76737. * Gets or sets the cell width to use when animation sheet is enabled
  76738. * @see https://doc.babylonjs.com/how_to/gui#image
  76739. */
  76740. get cellWidth(): number;
  76741. set cellWidth(value: number);
  76742. /**
  76743. * Gets or sets the cell height to use when animation sheet is enabled
  76744. * @see https://doc.babylonjs.com/how_to/gui#image
  76745. */
  76746. get cellHeight(): number;
  76747. set cellHeight(value: number);
  76748. /**
  76749. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76750. * @see https://doc.babylonjs.com/how_to/gui#image
  76751. */
  76752. get cellId(): number;
  76753. set cellId(value: number);
  76754. /**
  76755. * Creates a new Image
  76756. * @param name defines the control name
  76757. * @param url defines the image url
  76758. */
  76759. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76760. /**
  76761. * Tests if a given coordinates belong to the current control
  76762. * @param x defines x coordinate to test
  76763. * @param y defines y coordinate to test
  76764. * @returns true if the coordinates are inside the control
  76765. */
  76766. contains(x: number, y: number): boolean;
  76767. protected _getTypeName(): string;
  76768. /** Force the control to synchronize with its content */
  76769. synchronizeSizeWithContent(): void;
  76770. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76771. private _prepareWorkingCanvasForOpaqueDetection;
  76772. private _drawImage;
  76773. _draw(context: CanvasRenderingContext2D): void;
  76774. private _renderCornerPatch;
  76775. private _renderNinePatch;
  76776. dispose(): void;
  76777. /** STRETCH_NONE */
  76778. static readonly STRETCH_NONE: number;
  76779. /** STRETCH_FILL */
  76780. static readonly STRETCH_FILL: number;
  76781. /** STRETCH_UNIFORM */
  76782. static readonly STRETCH_UNIFORM: number;
  76783. /** STRETCH_EXTEND */
  76784. static readonly STRETCH_EXTEND: number;
  76785. /** NINE_PATCH */
  76786. static readonly STRETCH_NINE_PATCH: number;
  76787. }
  76788. }
  76789. declare module BABYLON.GUI {
  76790. /**
  76791. * Class used to create 2D buttons
  76792. */
  76793. export class Button extends Rectangle {
  76794. name?: string | undefined;
  76795. /**
  76796. * Function called to generate a pointer enter animation
  76797. */
  76798. pointerEnterAnimation: () => void;
  76799. /**
  76800. * Function called to generate a pointer out animation
  76801. */
  76802. pointerOutAnimation: () => void;
  76803. /**
  76804. * Function called to generate a pointer down animation
  76805. */
  76806. pointerDownAnimation: () => void;
  76807. /**
  76808. * Function called to generate a pointer up animation
  76809. */
  76810. pointerUpAnimation: () => void;
  76811. /**
  76812. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76813. */
  76814. delegatePickingToChildren: boolean;
  76815. private _image;
  76816. /**
  76817. * Returns the image part of the button (if any)
  76818. */
  76819. get image(): BABYLON.Nullable<Image>;
  76820. private _textBlock;
  76821. /**
  76822. * Returns the image part of the button (if any)
  76823. */
  76824. get textBlock(): BABYLON.Nullable<TextBlock>;
  76825. /**
  76826. * Creates a new Button
  76827. * @param name defines the name of the button
  76828. */
  76829. constructor(name?: string | undefined);
  76830. protected _getTypeName(): string;
  76831. /** @hidden */
  76832. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76833. /** @hidden */
  76834. _onPointerEnter(target: Control): boolean;
  76835. /** @hidden */
  76836. _onPointerOut(target: Control, force?: boolean): void;
  76837. /** @hidden */
  76838. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76839. /** @hidden */
  76840. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76841. /**
  76842. * Creates a new button made with an image and a text
  76843. * @param name defines the name of the button
  76844. * @param text defines the text of the button
  76845. * @param imageUrl defines the url of the image
  76846. * @returns a new Button
  76847. */
  76848. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76849. /**
  76850. * Creates a new button made with an image
  76851. * @param name defines the name of the button
  76852. * @param imageUrl defines the url of the image
  76853. * @returns a new Button
  76854. */
  76855. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76856. /**
  76857. * Creates a new button made with a text
  76858. * @param name defines the name of the button
  76859. * @param text defines the text of the button
  76860. * @returns a new Button
  76861. */
  76862. static CreateSimpleButton(name: string, text: string): Button;
  76863. /**
  76864. * Creates a new button made with an image and a centered text
  76865. * @param name defines the name of the button
  76866. * @param text defines the text of the button
  76867. * @param imageUrl defines the url of the image
  76868. * @returns a new Button
  76869. */
  76870. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76871. }
  76872. }
  76873. declare module BABYLON.GUI {
  76874. /**
  76875. * Class used to create a 2D stack panel container
  76876. */
  76877. export class StackPanel extends Container {
  76878. name?: string | undefined;
  76879. private _isVertical;
  76880. private _manualWidth;
  76881. private _manualHeight;
  76882. private _doNotTrackManualChanges;
  76883. /**
  76884. * Gets or sets a boolean indicating that layou warnings should be ignored
  76885. */
  76886. ignoreLayoutWarnings: boolean;
  76887. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76888. get isVertical(): boolean;
  76889. set isVertical(value: boolean);
  76890. /**
  76891. * Gets or sets panel width.
  76892. * This value should not be set when in horizontal mode as it will be computed automatically
  76893. */
  76894. set width(value: string | number);
  76895. get width(): string | number;
  76896. /**
  76897. * Gets or sets panel height.
  76898. * This value should not be set when in vertical mode as it will be computed automatically
  76899. */
  76900. set height(value: string | number);
  76901. get height(): string | number;
  76902. /**
  76903. * Creates a new StackPanel
  76904. * @param name defines control name
  76905. */
  76906. constructor(name?: string | undefined);
  76907. protected _getTypeName(): string;
  76908. /** @hidden */
  76909. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76910. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76911. protected _postMeasure(): void;
  76912. }
  76913. }
  76914. declare module BABYLON.GUI {
  76915. /**
  76916. * Class used to represent a 2D checkbox
  76917. */
  76918. export class Checkbox extends Control {
  76919. name?: string | undefined;
  76920. private _isChecked;
  76921. private _background;
  76922. private _checkSizeRatio;
  76923. private _thickness;
  76924. /** Gets or sets border thickness */
  76925. get thickness(): number;
  76926. set thickness(value: number);
  76927. /**
  76928. * BABYLON.Observable raised when isChecked property changes
  76929. */
  76930. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76931. /** Gets or sets a value indicating the ratio between overall size and check size */
  76932. get checkSizeRatio(): number;
  76933. set checkSizeRatio(value: number);
  76934. /** Gets or sets background color */
  76935. get background(): string;
  76936. set background(value: string);
  76937. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76938. get isChecked(): boolean;
  76939. set isChecked(value: boolean);
  76940. /**
  76941. * Creates a new CheckBox
  76942. * @param name defines the control name
  76943. */
  76944. constructor(name?: string | undefined);
  76945. protected _getTypeName(): string;
  76946. /** @hidden */
  76947. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76948. /** @hidden */
  76949. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76950. /**
  76951. * Utility function to easily create a checkbox with a header
  76952. * @param title defines the label to use for the header
  76953. * @param onValueChanged defines the callback to call when value changes
  76954. * @returns a StackPanel containing the checkbox and a textBlock
  76955. */
  76956. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76957. }
  76958. }
  76959. declare module BABYLON.GUI {
  76960. /**
  76961. * Class used to store key control properties
  76962. */
  76963. export class KeyPropertySet {
  76964. /** Width */
  76965. width?: string;
  76966. /** Height */
  76967. height?: string;
  76968. /** Left padding */
  76969. paddingLeft?: string;
  76970. /** Right padding */
  76971. paddingRight?: string;
  76972. /** Top padding */
  76973. paddingTop?: string;
  76974. /** Bottom padding */
  76975. paddingBottom?: string;
  76976. /** Foreground color */
  76977. color?: string;
  76978. /** Background color */
  76979. background?: string;
  76980. }
  76981. /**
  76982. * Class used to create virtual keyboard
  76983. */
  76984. export class VirtualKeyboard extends StackPanel {
  76985. /** BABYLON.Observable raised when a key is pressed */
  76986. onKeyPressObservable: BABYLON.Observable<string>;
  76987. /** Gets or sets default key button width */
  76988. defaultButtonWidth: string;
  76989. /** Gets or sets default key button height */
  76990. defaultButtonHeight: string;
  76991. /** Gets or sets default key button left padding */
  76992. defaultButtonPaddingLeft: string;
  76993. /** Gets or sets default key button right padding */
  76994. defaultButtonPaddingRight: string;
  76995. /** Gets or sets default key button top padding */
  76996. defaultButtonPaddingTop: string;
  76997. /** Gets or sets default key button bottom padding */
  76998. defaultButtonPaddingBottom: string;
  76999. /** Gets or sets default key button foreground color */
  77000. defaultButtonColor: string;
  77001. /** Gets or sets default key button background color */
  77002. defaultButtonBackground: string;
  77003. /** Gets or sets shift button foreground color */
  77004. shiftButtonColor: string;
  77005. /** Gets or sets shift button thickness*/
  77006. selectedShiftThickness: number;
  77007. /** Gets shift key state */
  77008. shiftState: number;
  77009. protected _getTypeName(): string;
  77010. private _createKey;
  77011. /**
  77012. * Adds a new row of keys
  77013. * @param keys defines the list of keys to add
  77014. * @param propertySets defines the associated property sets
  77015. */
  77016. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77017. /**
  77018. * Set the shift key to a specific state
  77019. * @param shiftState defines the new shift state
  77020. */
  77021. applyShiftState(shiftState: number): void;
  77022. private _currentlyConnectedInputText;
  77023. private _connectedInputTexts;
  77024. private _onKeyPressObserver;
  77025. /** Gets the input text control currently attached to the keyboard */
  77026. get connectedInputText(): BABYLON.Nullable<InputText>;
  77027. /**
  77028. * Connects the keyboard with an input text control
  77029. *
  77030. * @param input defines the target control
  77031. */
  77032. connect(input: InputText): void;
  77033. /**
  77034. * Disconnects the keyboard from connected InputText controls
  77035. *
  77036. * @param input optionally defines a target control, otherwise all are disconnected
  77037. */
  77038. disconnect(input?: InputText): void;
  77039. private _removeConnectedInputObservables;
  77040. /**
  77041. * Release all resources
  77042. */
  77043. dispose(): void;
  77044. /**
  77045. * Creates a new keyboard using a default layout
  77046. *
  77047. * @param name defines control name
  77048. * @returns a new VirtualKeyboard
  77049. */
  77050. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77051. }
  77052. }
  77053. declare module BABYLON.GUI {
  77054. /**
  77055. * Class used to create input text control
  77056. */
  77057. export class InputText extends Control implements IFocusableControl {
  77058. name?: string | undefined;
  77059. private _text;
  77060. private _placeholderText;
  77061. private _background;
  77062. private _focusedBackground;
  77063. private _focusedColor;
  77064. private _placeholderColor;
  77065. private _thickness;
  77066. private _margin;
  77067. private _autoStretchWidth;
  77068. private _maxWidth;
  77069. private _isFocused;
  77070. private _blinkTimeout;
  77071. private _blinkIsEven;
  77072. private _cursorOffset;
  77073. private _scrollLeft;
  77074. private _textWidth;
  77075. private _clickedCoordinate;
  77076. private _deadKey;
  77077. private _addKey;
  77078. private _currentKey;
  77079. private _isTextHighlightOn;
  77080. private _textHighlightColor;
  77081. private _highligherOpacity;
  77082. private _highlightedText;
  77083. private _startHighlightIndex;
  77084. private _endHighlightIndex;
  77085. private _cursorIndex;
  77086. private _onFocusSelectAll;
  77087. private _isPointerDown;
  77088. private _onClipboardObserver;
  77089. private _onPointerDblTapObserver;
  77090. /** @hidden */
  77091. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  77092. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  77093. promptMessage: string;
  77094. /** Force disable prompt on mobile device */
  77095. disableMobilePrompt: boolean;
  77096. /** BABYLON.Observable raised when the text changes */
  77097. onTextChangedObservable: BABYLON.Observable<InputText>;
  77098. /** BABYLON.Observable raised just before an entered character is to be added */
  77099. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  77100. /** BABYLON.Observable raised when the control gets the focus */
  77101. onFocusObservable: BABYLON.Observable<InputText>;
  77102. /** BABYLON.Observable raised when the control loses the focus */
  77103. onBlurObservable: BABYLON.Observable<InputText>;
  77104. /**Observable raised when the text is highlighted */
  77105. onTextHighlightObservable: BABYLON.Observable<InputText>;
  77106. /**Observable raised when copy event is triggered */
  77107. onTextCopyObservable: BABYLON.Observable<InputText>;
  77108. /** BABYLON.Observable raised when cut event is triggered */
  77109. onTextCutObservable: BABYLON.Observable<InputText>;
  77110. /** BABYLON.Observable raised when paste event is triggered */
  77111. onTextPasteObservable: BABYLON.Observable<InputText>;
  77112. /** BABYLON.Observable raised when a key event was processed */
  77113. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  77114. /** Gets or sets the maximum width allowed by the control */
  77115. get maxWidth(): string | number;
  77116. /** Gets the maximum width allowed by the control in pixels */
  77117. get maxWidthInPixels(): number;
  77118. set maxWidth(value: string | number);
  77119. /** Gets or sets the text highlighter transparency; default: 0.4 */
  77120. get highligherOpacity(): number;
  77121. set highligherOpacity(value: number);
  77122. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  77123. get onFocusSelectAll(): boolean;
  77124. set onFocusSelectAll(value: boolean);
  77125. /** Gets or sets the text hightlight color */
  77126. get textHighlightColor(): string;
  77127. set textHighlightColor(value: string);
  77128. /** Gets or sets control margin */
  77129. get margin(): string;
  77130. /** Gets control margin in pixels */
  77131. get marginInPixels(): number;
  77132. set margin(value: string);
  77133. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  77134. get autoStretchWidth(): boolean;
  77135. set autoStretchWidth(value: boolean);
  77136. /** Gets or sets border thickness */
  77137. get thickness(): number;
  77138. set thickness(value: number);
  77139. /** Gets or sets the background color when focused */
  77140. get focusedBackground(): string;
  77141. set focusedBackground(value: string);
  77142. /** Gets or sets the background color when focused */
  77143. get focusedColor(): string;
  77144. set focusedColor(value: string);
  77145. /** Gets or sets the background color */
  77146. get background(): string;
  77147. set background(value: string);
  77148. /** Gets or sets the placeholder color */
  77149. get placeholderColor(): string;
  77150. set placeholderColor(value: string);
  77151. /** Gets or sets the text displayed when the control is empty */
  77152. get placeholderText(): string;
  77153. set placeholderText(value: string);
  77154. /** Gets or sets the dead key flag */
  77155. get deadKey(): boolean;
  77156. set deadKey(flag: boolean);
  77157. /** Gets or sets the highlight text */
  77158. get highlightedText(): string;
  77159. set highlightedText(text: string);
  77160. /** Gets or sets if the current key should be added */
  77161. get addKey(): boolean;
  77162. set addKey(flag: boolean);
  77163. /** Gets or sets the value of the current key being entered */
  77164. get currentKey(): string;
  77165. set currentKey(key: string);
  77166. /** Gets or sets the text displayed in the control */
  77167. get text(): string;
  77168. set text(value: string);
  77169. /** Gets or sets control width */
  77170. get width(): string | number;
  77171. set width(value: string | number);
  77172. /**
  77173. * Creates a new InputText
  77174. * @param name defines the control name
  77175. * @param text defines the text of the control
  77176. */
  77177. constructor(name?: string | undefined, text?: string);
  77178. /** @hidden */
  77179. onBlur(): void;
  77180. /** @hidden */
  77181. onFocus(): void;
  77182. protected _getTypeName(): string;
  77183. /**
  77184. * Function called to get the list of controls that should not steal the focus from this control
  77185. * @returns an array of controls
  77186. */
  77187. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77188. /** @hidden */
  77189. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  77190. /** @hidden */
  77191. private _updateValueFromCursorIndex;
  77192. /** @hidden */
  77193. private _processDblClick;
  77194. /** @hidden */
  77195. private _selectAllText;
  77196. /**
  77197. * Handles the keyboard event
  77198. * @param evt Defines the KeyboardEvent
  77199. */
  77200. processKeyboard(evt: KeyboardEvent): void;
  77201. /** @hidden */
  77202. private _onCopyText;
  77203. /** @hidden */
  77204. private _onCutText;
  77205. /** @hidden */
  77206. private _onPasteText;
  77207. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77208. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77209. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77210. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77211. protected _beforeRenderText(text: string): string;
  77212. dispose(): void;
  77213. }
  77214. }
  77215. declare module BABYLON.GUI {
  77216. /**
  77217. * Class used to create a 2D grid container
  77218. */
  77219. export class Grid extends Container {
  77220. name?: string | undefined;
  77221. private _rowDefinitions;
  77222. private _columnDefinitions;
  77223. private _cells;
  77224. private _childControls;
  77225. /**
  77226. * Gets the number of columns
  77227. */
  77228. get columnCount(): number;
  77229. /**
  77230. * Gets the number of rows
  77231. */
  77232. get rowCount(): number;
  77233. /** Gets the list of children */
  77234. get children(): Control[];
  77235. /** Gets the list of cells (e.g. the containers) */
  77236. get cells(): {
  77237. [key: string]: Container;
  77238. };
  77239. /**
  77240. * Gets the definition of a specific row
  77241. * @param index defines the index of the row
  77242. * @returns the row definition
  77243. */
  77244. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77245. /**
  77246. * Gets the definition of a specific column
  77247. * @param index defines the index of the column
  77248. * @returns the column definition
  77249. */
  77250. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77251. /**
  77252. * Adds a new row to the grid
  77253. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77254. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  77255. * @returns the current grid
  77256. */
  77257. addRowDefinition(height: number, isPixel?: boolean): Grid;
  77258. /**
  77259. * Adds a new column to the grid
  77260. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77261. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77262. * @returns the current grid
  77263. */
  77264. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  77265. /**
  77266. * Update a row definition
  77267. * @param index defines the index of the row to update
  77268. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77269. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  77270. * @returns the current grid
  77271. */
  77272. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  77273. /**
  77274. * Update a column definition
  77275. * @param index defines the index of the column to update
  77276. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77277. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77278. * @returns the current grid
  77279. */
  77280. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  77281. /**
  77282. * Gets the list of children stored in a specific cell
  77283. * @param row defines the row to check
  77284. * @param column defines the column to check
  77285. * @returns the list of controls
  77286. */
  77287. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  77288. /**
  77289. * Gets a string representing the child cell info (row x column)
  77290. * @param child defines the control to get info from
  77291. * @returns a string containing the child cell info (row x column)
  77292. */
  77293. getChildCellInfo(child: Control): string;
  77294. private _removeCell;
  77295. private _offsetCell;
  77296. /**
  77297. * Remove a column definition at specified index
  77298. * @param index defines the index of the column to remove
  77299. * @returns the current grid
  77300. */
  77301. removeColumnDefinition(index: number): Grid;
  77302. /**
  77303. * Remove a row definition at specified index
  77304. * @param index defines the index of the row to remove
  77305. * @returns the current grid
  77306. */
  77307. removeRowDefinition(index: number): Grid;
  77308. /**
  77309. * Adds a new control to the current grid
  77310. * @param control defines the control to add
  77311. * @param row defines the row where to add the control (0 by default)
  77312. * @param column defines the column where to add the control (0 by default)
  77313. * @returns the current grid
  77314. */
  77315. addControl(control: Control, row?: number, column?: number): Grid;
  77316. /**
  77317. * Removes a control from the current container
  77318. * @param control defines the control to remove
  77319. * @returns the current container
  77320. */
  77321. removeControl(control: Control): Container;
  77322. /**
  77323. * Creates a new Grid
  77324. * @param name defines control name
  77325. */
  77326. constructor(name?: string | undefined);
  77327. protected _getTypeName(): string;
  77328. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77329. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77330. _flagDescendantsAsMatrixDirty(): void;
  77331. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77332. /** Releases associated resources */
  77333. dispose(): void;
  77334. }
  77335. }
  77336. declare module BABYLON.GUI {
  77337. /** Class used to create color pickers */
  77338. export class ColorPicker extends Control {
  77339. name?: string | undefined;
  77340. private static _Epsilon;
  77341. private _colorWheelCanvas;
  77342. private _value;
  77343. private _tmpColor;
  77344. private _pointerStartedOnSquare;
  77345. private _pointerStartedOnWheel;
  77346. private _squareLeft;
  77347. private _squareTop;
  77348. private _squareSize;
  77349. private _h;
  77350. private _s;
  77351. private _v;
  77352. private _lastPointerDownID;
  77353. /**
  77354. * BABYLON.Observable raised when the value changes
  77355. */
  77356. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77357. /** Gets or sets the color of the color picker */
  77358. get value(): BABYLON.Color3;
  77359. set value(value: BABYLON.Color3);
  77360. /**
  77361. * Gets or sets control width
  77362. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77363. */
  77364. get width(): string | number;
  77365. set width(value: string | number);
  77366. /**
  77367. * Gets or sets control height
  77368. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77369. */
  77370. get height(): string | number;
  77371. /** Gets or sets control height */
  77372. set height(value: string | number);
  77373. /** Gets or sets control size */
  77374. get size(): string | number;
  77375. set size(value: string | number);
  77376. /**
  77377. * Creates a new ColorPicker
  77378. * @param name defines the control name
  77379. */
  77380. constructor(name?: string | undefined);
  77381. protected _getTypeName(): string;
  77382. /** @hidden */
  77383. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77384. private _updateSquareProps;
  77385. private _drawGradientSquare;
  77386. private _drawCircle;
  77387. private _createColorWheelCanvas;
  77388. /** @hidden */
  77389. _draw(context: CanvasRenderingContext2D): void;
  77390. private _pointerIsDown;
  77391. private _updateValueFromPointer;
  77392. private _isPointOnSquare;
  77393. private _isPointOnWheel;
  77394. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77395. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77396. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77397. /**
  77398. * This function expands the color picker by creating a color picker dialog with manual
  77399. * color value input and the ability to save colors into an array to be used later in
  77400. * subsequent launches of the dialogue.
  77401. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77402. * @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.
  77403. * @returns picked color as a hex string and the saved colors array as hex strings.
  77404. */
  77405. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77406. pickerWidth?: string;
  77407. pickerHeight?: string;
  77408. headerHeight?: string;
  77409. lastColor?: string;
  77410. swatchLimit?: number;
  77411. numSwatchesPerLine?: number;
  77412. savedColors?: Array<string>;
  77413. }): Promise<{
  77414. savedColors?: string[];
  77415. pickedColor: string;
  77416. }>;
  77417. }
  77418. }
  77419. declare module BABYLON.GUI {
  77420. /** Class used to create 2D ellipse containers */
  77421. export class Ellipse extends Container {
  77422. name?: string | undefined;
  77423. private _thickness;
  77424. /** Gets or sets border thickness */
  77425. get thickness(): number;
  77426. set thickness(value: number);
  77427. /**
  77428. * Creates a new Ellipse
  77429. * @param name defines the control name
  77430. */
  77431. constructor(name?: string | undefined);
  77432. protected _getTypeName(): string;
  77433. protected _localDraw(context: CanvasRenderingContext2D): void;
  77434. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77435. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77436. }
  77437. }
  77438. declare module BABYLON.GUI {
  77439. /**
  77440. * Class used to create a password control
  77441. */
  77442. export class InputPassword extends InputText {
  77443. protected _beforeRenderText(text: string): string;
  77444. }
  77445. }
  77446. declare module BABYLON.GUI {
  77447. /** Class used to render 2D lines */
  77448. export class Line extends Control {
  77449. name?: string | undefined;
  77450. private _lineWidth;
  77451. private _x1;
  77452. private _y1;
  77453. private _x2;
  77454. private _y2;
  77455. private _dash;
  77456. private _connectedControl;
  77457. private _connectedControlDirtyObserver;
  77458. /** Gets or sets the dash pattern */
  77459. get dash(): Array<number>;
  77460. set dash(value: Array<number>);
  77461. /** Gets or sets the control connected with the line end */
  77462. get connectedControl(): Control;
  77463. set connectedControl(value: Control);
  77464. /** Gets or sets start coordinates on X axis */
  77465. get x1(): string | number;
  77466. set x1(value: string | number);
  77467. /** Gets or sets start coordinates on Y axis */
  77468. get y1(): string | number;
  77469. set y1(value: string | number);
  77470. /** Gets or sets end coordinates on X axis */
  77471. get x2(): string | number;
  77472. set x2(value: string | number);
  77473. /** Gets or sets end coordinates on Y axis */
  77474. get y2(): string | number;
  77475. set y2(value: string | number);
  77476. /** Gets or sets line width */
  77477. get lineWidth(): number;
  77478. set lineWidth(value: number);
  77479. /** Gets or sets horizontal alignment */
  77480. set horizontalAlignment(value: number);
  77481. /** Gets or sets vertical alignment */
  77482. set verticalAlignment(value: number);
  77483. private get _effectiveX2();
  77484. private get _effectiveY2();
  77485. /**
  77486. * Creates a new Line
  77487. * @param name defines the control name
  77488. */
  77489. constructor(name?: string | undefined);
  77490. protected _getTypeName(): string;
  77491. _draw(context: CanvasRenderingContext2D): void;
  77492. _measure(): void;
  77493. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77494. /**
  77495. * Move one end of the line given 3D cartesian coordinates.
  77496. * @param position Targeted world position
  77497. * @param scene BABYLON.Scene
  77498. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77499. */
  77500. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77501. /**
  77502. * Move one end of the line to a position in screen absolute space.
  77503. * @param projectedPosition Position in screen absolute space (X, Y)
  77504. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77505. */
  77506. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77507. }
  77508. }
  77509. declare module BABYLON.GUI {
  77510. /**
  77511. * Class used to store a point for a MultiLine object.
  77512. * The point can be pure 2D coordinates, a mesh or a control
  77513. */
  77514. export class MultiLinePoint {
  77515. private _multiLine;
  77516. private _x;
  77517. private _y;
  77518. private _control;
  77519. private _mesh;
  77520. private _controlObserver;
  77521. private _meshObserver;
  77522. /** @hidden */
  77523. _point: BABYLON.Vector2;
  77524. /**
  77525. * Creates a new MultiLinePoint
  77526. * @param multiLine defines the source MultiLine object
  77527. */
  77528. constructor(multiLine: MultiLine);
  77529. /** Gets or sets x coordinate */
  77530. get x(): string | number;
  77531. set x(value: string | number);
  77532. /** Gets or sets y coordinate */
  77533. get y(): string | number;
  77534. set y(value: string | number);
  77535. /** Gets or sets the control associated with this point */
  77536. get control(): BABYLON.Nullable<Control>;
  77537. set control(value: BABYLON.Nullable<Control>);
  77538. /** Gets or sets the mesh associated with this point */
  77539. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77540. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77541. /** Resets links */
  77542. resetLinks(): void;
  77543. /**
  77544. * Gets a translation vector
  77545. * @returns the translation vector
  77546. */
  77547. translate(): BABYLON.Vector2;
  77548. private _translatePoint;
  77549. /** Release associated resources */
  77550. dispose(): void;
  77551. }
  77552. }
  77553. declare module BABYLON.GUI {
  77554. /**
  77555. * Class used to create multi line control
  77556. */
  77557. export class MultiLine extends Control {
  77558. name?: string | undefined;
  77559. private _lineWidth;
  77560. private _dash;
  77561. private _points;
  77562. private _minX;
  77563. private _minY;
  77564. private _maxX;
  77565. private _maxY;
  77566. /**
  77567. * Creates a new MultiLine
  77568. * @param name defines the control name
  77569. */
  77570. constructor(name?: string | undefined);
  77571. /** Gets or sets dash pattern */
  77572. get dash(): Array<number>;
  77573. set dash(value: Array<number>);
  77574. /**
  77575. * Gets point stored at specified index
  77576. * @param index defines the index to look for
  77577. * @returns the requested point if found
  77578. */
  77579. getAt(index: number): MultiLinePoint;
  77580. /** Function called when a point is updated */
  77581. onPointUpdate: () => void;
  77582. /**
  77583. * Adds new points to the point collection
  77584. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77585. * @returns the list of created MultiLinePoint
  77586. */
  77587. add(...items: (AbstractMesh | Control | {
  77588. x: string | number;
  77589. y: string | number;
  77590. })[]): MultiLinePoint[];
  77591. /**
  77592. * Adds a new point to the point collection
  77593. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77594. * @returns the created MultiLinePoint
  77595. */
  77596. push(item?: (AbstractMesh | Control | {
  77597. x: string | number;
  77598. y: string | number;
  77599. })): MultiLinePoint;
  77600. /**
  77601. * Remove a specific value or point from the active point collection
  77602. * @param value defines the value or point to remove
  77603. */
  77604. remove(value: number | MultiLinePoint): void;
  77605. /**
  77606. * Resets this object to initial state (no point)
  77607. */
  77608. reset(): void;
  77609. /**
  77610. * Resets all links
  77611. */
  77612. resetLinks(): void;
  77613. /** Gets or sets line width */
  77614. get lineWidth(): number;
  77615. set lineWidth(value: number);
  77616. set horizontalAlignment(value: number);
  77617. set verticalAlignment(value: number);
  77618. protected _getTypeName(): string;
  77619. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77620. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77621. _measure(): void;
  77622. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77623. dispose(): void;
  77624. }
  77625. }
  77626. declare module BABYLON.GUI {
  77627. /**
  77628. * Class used to create radio button controls
  77629. */
  77630. export class RadioButton extends Control {
  77631. name?: string | undefined;
  77632. private _isChecked;
  77633. private _background;
  77634. private _checkSizeRatio;
  77635. private _thickness;
  77636. /** Gets or sets border thickness */
  77637. get thickness(): number;
  77638. set thickness(value: number);
  77639. /** Gets or sets group name */
  77640. group: string;
  77641. /** BABYLON.Observable raised when isChecked is changed */
  77642. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77643. /** Gets or sets a value indicating the ratio between overall size and check size */
  77644. get checkSizeRatio(): number;
  77645. set checkSizeRatio(value: number);
  77646. /** Gets or sets background color */
  77647. get background(): string;
  77648. set background(value: string);
  77649. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77650. get isChecked(): boolean;
  77651. set isChecked(value: boolean);
  77652. /**
  77653. * Creates a new RadioButton
  77654. * @param name defines the control name
  77655. */
  77656. constructor(name?: string | undefined);
  77657. protected _getTypeName(): string;
  77658. _draw(context: CanvasRenderingContext2D): void;
  77659. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77660. /**
  77661. * Utility function to easily create a radio button with a header
  77662. * @param title defines the label to use for the header
  77663. * @param group defines the group to use for the radio button
  77664. * @param isChecked defines the initial state of the radio button
  77665. * @param onValueChanged defines the callback to call when value changes
  77666. * @returns a StackPanel containing the radio button and a textBlock
  77667. */
  77668. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77669. }
  77670. }
  77671. declare module BABYLON.GUI {
  77672. /**
  77673. * Class used to create slider controls
  77674. */
  77675. export class BaseSlider extends Control {
  77676. name?: string | undefined;
  77677. protected _thumbWidth: ValueAndUnit;
  77678. private _minimum;
  77679. private _maximum;
  77680. private _value;
  77681. private _isVertical;
  77682. protected _barOffset: ValueAndUnit;
  77683. private _isThumbClamped;
  77684. protected _displayThumb: boolean;
  77685. private _step;
  77686. private _lastPointerDownID;
  77687. protected _effectiveBarOffset: number;
  77688. protected _renderLeft: number;
  77689. protected _renderTop: number;
  77690. protected _renderWidth: number;
  77691. protected _renderHeight: number;
  77692. protected _backgroundBoxLength: number;
  77693. protected _backgroundBoxThickness: number;
  77694. protected _effectiveThumbThickness: number;
  77695. /** BABYLON.Observable raised when the sldier value changes */
  77696. onValueChangedObservable: BABYLON.Observable<number>;
  77697. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77698. get displayThumb(): boolean;
  77699. set displayThumb(value: boolean);
  77700. /** Gets or sets a step to apply to values (0 by default) */
  77701. get step(): number;
  77702. set step(value: number);
  77703. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77704. get barOffset(): string | number;
  77705. /** Gets main bar offset in pixels*/
  77706. get barOffsetInPixels(): number;
  77707. set barOffset(value: string | number);
  77708. /** Gets or sets thumb width */
  77709. get thumbWidth(): string | number;
  77710. /** Gets thumb width in pixels */
  77711. get thumbWidthInPixels(): number;
  77712. set thumbWidth(value: string | number);
  77713. /** Gets or sets minimum value */
  77714. get minimum(): number;
  77715. set minimum(value: number);
  77716. /** Gets or sets maximum value */
  77717. get maximum(): number;
  77718. set maximum(value: number);
  77719. /** Gets or sets current value */
  77720. get value(): number;
  77721. set value(value: number);
  77722. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77723. get isVertical(): boolean;
  77724. set isVertical(value: boolean);
  77725. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77726. get isThumbClamped(): boolean;
  77727. set isThumbClamped(value: boolean);
  77728. /**
  77729. * Creates a new BaseSlider
  77730. * @param name defines the control name
  77731. */
  77732. constructor(name?: string | undefined);
  77733. protected _getTypeName(): string;
  77734. protected _getThumbPosition(): number;
  77735. protected _getThumbThickness(type: string): number;
  77736. protected _prepareRenderingData(type: string): void;
  77737. private _pointerIsDown;
  77738. /** @hidden */
  77739. protected _updateValueFromPointer(x: number, y: number): void;
  77740. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77741. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77742. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77743. }
  77744. }
  77745. declare module BABYLON.GUI {
  77746. /**
  77747. * Class used to create slider controls
  77748. */
  77749. export class Slider extends BaseSlider {
  77750. name?: string | undefined;
  77751. private _background;
  77752. private _borderColor;
  77753. private _isThumbCircle;
  77754. protected _displayValueBar: boolean;
  77755. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77756. get displayValueBar(): boolean;
  77757. set displayValueBar(value: boolean);
  77758. /** Gets or sets border color */
  77759. get borderColor(): string;
  77760. set borderColor(value: string);
  77761. /** Gets or sets background color */
  77762. get background(): string;
  77763. set background(value: string);
  77764. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77765. get isThumbCircle(): boolean;
  77766. set isThumbCircle(value: boolean);
  77767. /**
  77768. * Creates a new Slider
  77769. * @param name defines the control name
  77770. */
  77771. constructor(name?: string | undefined);
  77772. protected _getTypeName(): string;
  77773. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77774. }
  77775. }
  77776. declare module BABYLON.GUI {
  77777. /** Class used to create a RadioGroup
  77778. * which contains groups of radio buttons
  77779. */
  77780. export class SelectorGroup {
  77781. /** name of SelectorGroup */
  77782. name: string;
  77783. private _groupPanel;
  77784. private _selectors;
  77785. private _groupHeader;
  77786. /**
  77787. * Creates a new SelectorGroup
  77788. * @param name of group, used as a group heading
  77789. */
  77790. constructor(
  77791. /** name of SelectorGroup */
  77792. name: string);
  77793. /** Gets the groupPanel of the SelectorGroup */
  77794. get groupPanel(): StackPanel;
  77795. /** Gets the selectors array */
  77796. get selectors(): StackPanel[];
  77797. /** Gets and sets the group header */
  77798. get header(): string;
  77799. set header(label: string);
  77800. /** @hidden */
  77801. private _addGroupHeader;
  77802. /** @hidden*/
  77803. _getSelector(selectorNb: number): StackPanel | undefined;
  77804. /** Removes the selector at the given position
  77805. * @param selectorNb the position of the selector within the group
  77806. */
  77807. removeSelector(selectorNb: number): void;
  77808. }
  77809. /** Class used to create a CheckboxGroup
  77810. * which contains groups of checkbox buttons
  77811. */
  77812. export class CheckboxGroup extends SelectorGroup {
  77813. /** Adds a checkbox as a control
  77814. * @param text is the label for the selector
  77815. * @param func is the function called when the Selector is checked
  77816. * @param checked is true when Selector is checked
  77817. */
  77818. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77819. /** @hidden */
  77820. _setSelectorLabel(selectorNb: number, label: string): void;
  77821. /** @hidden */
  77822. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77823. /** @hidden */
  77824. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77825. /** @hidden */
  77826. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77827. }
  77828. /** Class used to create a RadioGroup
  77829. * which contains groups of radio buttons
  77830. */
  77831. export class RadioGroup extends SelectorGroup {
  77832. private _selectNb;
  77833. /** Adds a radio button as a control
  77834. * @param label is the label for the selector
  77835. * @param func is the function called when the Selector is checked
  77836. * @param checked is true when Selector is checked
  77837. */
  77838. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77839. /** @hidden */
  77840. _setSelectorLabel(selectorNb: number, label: string): void;
  77841. /** @hidden */
  77842. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77843. /** @hidden */
  77844. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77845. /** @hidden */
  77846. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77847. }
  77848. /** Class used to create a SliderGroup
  77849. * which contains groups of slider buttons
  77850. */
  77851. export class SliderGroup extends SelectorGroup {
  77852. /**
  77853. * Adds a slider to the SelectorGroup
  77854. * @param label is the label for the SliderBar
  77855. * @param func is the function called when the Slider moves
  77856. * @param unit is a string describing the units used, eg degrees or metres
  77857. * @param min is the minimum value for the Slider
  77858. * @param max is the maximum value for the Slider
  77859. * @param value is the start value for the Slider between min and max
  77860. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77861. */
  77862. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77863. /** @hidden */
  77864. _setSelectorLabel(selectorNb: number, label: string): void;
  77865. /** @hidden */
  77866. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77867. /** @hidden */
  77868. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77869. /** @hidden */
  77870. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77871. }
  77872. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77873. * @see https://doc.babylonjs.com/how_to/selector
  77874. */
  77875. export class SelectionPanel extends Rectangle {
  77876. /** name of SelectionPanel */
  77877. name: string;
  77878. /** an array of SelectionGroups */
  77879. groups: SelectorGroup[];
  77880. private _panel;
  77881. private _buttonColor;
  77882. private _buttonBackground;
  77883. private _headerColor;
  77884. private _barColor;
  77885. private _barHeight;
  77886. private _spacerHeight;
  77887. private _labelColor;
  77888. private _groups;
  77889. private _bars;
  77890. /**
  77891. * Creates a new SelectionPanel
  77892. * @param name of SelectionPanel
  77893. * @param groups is an array of SelectionGroups
  77894. */
  77895. constructor(
  77896. /** name of SelectionPanel */
  77897. name: string,
  77898. /** an array of SelectionGroups */
  77899. groups?: SelectorGroup[]);
  77900. protected _getTypeName(): string;
  77901. /** Gets or sets the headerColor */
  77902. get headerColor(): string;
  77903. set headerColor(color: string);
  77904. private _setHeaderColor;
  77905. /** Gets or sets the button color */
  77906. get buttonColor(): string;
  77907. set buttonColor(color: string);
  77908. private _setbuttonColor;
  77909. /** Gets or sets the label color */
  77910. get labelColor(): string;
  77911. set labelColor(color: string);
  77912. private _setLabelColor;
  77913. /** Gets or sets the button background */
  77914. get buttonBackground(): string;
  77915. set buttonBackground(color: string);
  77916. private _setButtonBackground;
  77917. /** Gets or sets the color of separator bar */
  77918. get barColor(): string;
  77919. set barColor(color: string);
  77920. private _setBarColor;
  77921. /** Gets or sets the height of separator bar */
  77922. get barHeight(): string;
  77923. set barHeight(value: string);
  77924. private _setBarHeight;
  77925. /** Gets or sets the height of spacers*/
  77926. get spacerHeight(): string;
  77927. set spacerHeight(value: string);
  77928. private _setSpacerHeight;
  77929. /** Adds a bar between groups */
  77930. private _addSpacer;
  77931. /** Add a group to the selection panel
  77932. * @param group is the selector group to add
  77933. */
  77934. addGroup(group: SelectorGroup): void;
  77935. /** Remove the group from the given position
  77936. * @param groupNb is the position of the group in the list
  77937. */
  77938. removeGroup(groupNb: number): void;
  77939. /** Change a group header label
  77940. * @param label is the new group header label
  77941. * @param groupNb is the number of the group to relabel
  77942. * */
  77943. setHeaderName(label: string, groupNb: number): void;
  77944. /** Change selector label to the one given
  77945. * @param label is the new selector label
  77946. * @param groupNb is the number of the groupcontaining the selector
  77947. * @param selectorNb is the number of the selector within a group to relabel
  77948. * */
  77949. relabel(label: string, groupNb: number, selectorNb: number): void;
  77950. /** For a given group position remove the selector at the given position
  77951. * @param groupNb is the number of the group to remove the selector from
  77952. * @param selectorNb is the number of the selector within the group
  77953. */
  77954. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77955. /** For a given group position of correct type add a checkbox button
  77956. * @param groupNb is the number of the group to remove the selector from
  77957. * @param label is the label for the selector
  77958. * @param func is the function called when the Selector is checked
  77959. * @param checked is true when Selector is checked
  77960. */
  77961. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77962. /** For a given group position of correct type add a radio button
  77963. * @param groupNb is the number of the group to remove the selector from
  77964. * @param label is the label for the selector
  77965. * @param func is the function called when the Selector is checked
  77966. * @param checked is true when Selector is checked
  77967. */
  77968. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77969. /**
  77970. * For a given slider group add a slider
  77971. * @param groupNb is the number of the group to add the slider to
  77972. * @param label is the label for the Slider
  77973. * @param func is the function called when the Slider moves
  77974. * @param unit is a string describing the units used, eg degrees or metres
  77975. * @param min is the minimum value for the Slider
  77976. * @param max is the maximum value for the Slider
  77977. * @param value is the start value for the Slider between min and max
  77978. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77979. */
  77980. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77981. }
  77982. }
  77983. declare module BABYLON.GUI {
  77984. /**
  77985. * Class used to hold a the container for ScrollViewer
  77986. * @hidden
  77987. */
  77988. export class _ScrollViewerWindow extends Container {
  77989. parentClientWidth: number;
  77990. parentClientHeight: number;
  77991. private _freezeControls;
  77992. private _parentMeasure;
  77993. private _oldLeft;
  77994. private _oldTop;
  77995. get freezeControls(): boolean;
  77996. set freezeControls(value: boolean);
  77997. private _bucketWidth;
  77998. private _bucketHeight;
  77999. private _buckets;
  78000. private _bucketLen;
  78001. get bucketWidth(): number;
  78002. get bucketHeight(): number;
  78003. setBucketSizes(width: number, height: number): void;
  78004. private _useBuckets;
  78005. private _makeBuckets;
  78006. private _dispatchInBuckets;
  78007. private _updateMeasures;
  78008. private _updateChildrenMeasures;
  78009. private _restoreMeasures;
  78010. /**
  78011. * Creates a new ScrollViewerWindow
  78012. * @param name of ScrollViewerWindow
  78013. */
  78014. constructor(name?: string);
  78015. protected _getTypeName(): string;
  78016. /** @hidden */
  78017. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78018. /** @hidden */
  78019. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78020. private _scrollChildren;
  78021. private _scrollChildrenWithBuckets;
  78022. /** @hidden */
  78023. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78024. protected _postMeasure(): void;
  78025. }
  78026. }
  78027. declare module BABYLON.GUI {
  78028. /**
  78029. * Class used to create slider controls
  78030. */
  78031. export class ScrollBar extends BaseSlider {
  78032. name?: string | undefined;
  78033. private _background;
  78034. private _borderColor;
  78035. private _tempMeasure;
  78036. /** Gets or sets border color */
  78037. get borderColor(): string;
  78038. set borderColor(value: string);
  78039. /** Gets or sets background color */
  78040. get background(): string;
  78041. set background(value: string);
  78042. /**
  78043. * Creates a new Slider
  78044. * @param name defines the control name
  78045. */
  78046. constructor(name?: string | undefined);
  78047. protected _getTypeName(): string;
  78048. protected _getThumbThickness(): number;
  78049. _draw(context: CanvasRenderingContext2D): void;
  78050. private _first;
  78051. private _originX;
  78052. private _originY;
  78053. /** @hidden */
  78054. protected _updateValueFromPointer(x: number, y: number): void;
  78055. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78056. }
  78057. }
  78058. declare module BABYLON.GUI {
  78059. /**
  78060. * Class used to create slider controls
  78061. */
  78062. export class ImageScrollBar extends BaseSlider {
  78063. name?: string | undefined;
  78064. private _backgroundBaseImage;
  78065. private _backgroundImage;
  78066. private _thumbImage;
  78067. private _thumbBaseImage;
  78068. private _thumbLength;
  78069. private _thumbHeight;
  78070. private _barImageHeight;
  78071. private _tempMeasure;
  78072. /** Number of 90° rotation to apply on the images when in vertical mode */
  78073. num90RotationInVerticalMode: number;
  78074. /**
  78075. * Gets or sets the image used to render the background for horizontal bar
  78076. */
  78077. get backgroundImage(): Image;
  78078. set backgroundImage(value: Image);
  78079. /**
  78080. * Gets or sets the image used to render the thumb
  78081. */
  78082. get thumbImage(): Image;
  78083. set thumbImage(value: Image);
  78084. /**
  78085. * Gets or sets the length of the thumb
  78086. */
  78087. get thumbLength(): number;
  78088. set thumbLength(value: number);
  78089. /**
  78090. * Gets or sets the height of the thumb
  78091. */
  78092. get thumbHeight(): number;
  78093. set thumbHeight(value: number);
  78094. /**
  78095. * Gets or sets the height of the bar image
  78096. */
  78097. get barImageHeight(): number;
  78098. set barImageHeight(value: number);
  78099. /**
  78100. * Creates a new ImageScrollBar
  78101. * @param name defines the control name
  78102. */
  78103. constructor(name?: string | undefined);
  78104. protected _getTypeName(): string;
  78105. protected _getThumbThickness(): number;
  78106. _draw(context: CanvasRenderingContext2D): void;
  78107. private _first;
  78108. private _originX;
  78109. private _originY;
  78110. /** @hidden */
  78111. protected _updateValueFromPointer(x: number, y: number): void;
  78112. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78113. }
  78114. }
  78115. declare module BABYLON.GUI {
  78116. /**
  78117. * Class used to hold a viewer window and sliders in a grid
  78118. */
  78119. export class ScrollViewer extends Rectangle {
  78120. private _grid;
  78121. private _horizontalBarSpace;
  78122. private _verticalBarSpace;
  78123. private _dragSpace;
  78124. private _horizontalBar;
  78125. private _verticalBar;
  78126. private _barColor;
  78127. private _barBackground;
  78128. private _barImage;
  78129. private _horizontalBarImage;
  78130. private _verticalBarImage;
  78131. private _barBackgroundImage;
  78132. private _horizontalBarBackgroundImage;
  78133. private _verticalBarBackgroundImage;
  78134. private _barSize;
  78135. private _window;
  78136. private _pointerIsOver;
  78137. private _wheelPrecision;
  78138. private _onWheelObserver;
  78139. private _clientWidth;
  78140. private _clientHeight;
  78141. private _useImageBar;
  78142. private _thumbLength;
  78143. private _thumbHeight;
  78144. private _barImageHeight;
  78145. private _horizontalBarImageHeight;
  78146. private _verticalBarImageHeight;
  78147. private _oldWindowContentsWidth;
  78148. private _oldWindowContentsHeight;
  78149. /**
  78150. * Gets the horizontal scrollbar
  78151. */
  78152. get horizontalBar(): ScrollBar | ImageScrollBar;
  78153. /**
  78154. * Gets the vertical scrollbar
  78155. */
  78156. get verticalBar(): ScrollBar | ImageScrollBar;
  78157. /**
  78158. * Adds a new control to the current container
  78159. * @param control defines the control to add
  78160. * @returns the current container
  78161. */
  78162. addControl(control: BABYLON.Nullable<Control>): Container;
  78163. /**
  78164. * Removes a control from the current container
  78165. * @param control defines the control to remove
  78166. * @returns the current container
  78167. */
  78168. removeControl(control: Control): Container;
  78169. /** Gets the list of children */
  78170. get children(): Control[];
  78171. _flagDescendantsAsMatrixDirty(): void;
  78172. /**
  78173. * Freezes or unfreezes the controls in the window.
  78174. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  78175. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  78176. */
  78177. get freezeControls(): boolean;
  78178. set freezeControls(value: boolean);
  78179. /** Gets the bucket width */
  78180. get bucketWidth(): number;
  78181. /** Gets the bucket height */
  78182. get bucketHeight(): number;
  78183. /**
  78184. * Sets the bucket sizes.
  78185. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  78186. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  78187. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  78188. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  78189. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  78190. * used), that's why it is not enabled by default.
  78191. * @param width width of the bucket
  78192. * @param height height of the bucket
  78193. */
  78194. setBucketSizes(width: number, height: number): void;
  78195. private _forceHorizontalBar;
  78196. private _forceVerticalBar;
  78197. /**
  78198. * Forces the horizontal scroll bar to be displayed
  78199. */
  78200. get forceHorizontalBar(): boolean;
  78201. set forceHorizontalBar(value: boolean);
  78202. /**
  78203. * Forces the vertical scroll bar to be displayed
  78204. */
  78205. get forceVerticalBar(): boolean;
  78206. set forceVerticalBar(value: boolean);
  78207. /**
  78208. * Creates a new ScrollViewer
  78209. * @param name of ScrollViewer
  78210. */
  78211. constructor(name?: string, isImageBased?: boolean);
  78212. /** Reset the scroll viewer window to initial size */
  78213. resetWindow(): void;
  78214. protected _getTypeName(): string;
  78215. private _buildClientSizes;
  78216. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78217. protected _postMeasure(): void;
  78218. /**
  78219. * Gets or sets the mouse wheel precision
  78220. * from 0 to 1 with a default value of 0.05
  78221. * */
  78222. get wheelPrecision(): number;
  78223. set wheelPrecision(value: number);
  78224. /** Gets or sets the scroll bar container background color */
  78225. get scrollBackground(): string;
  78226. set scrollBackground(color: string);
  78227. /** Gets or sets the bar color */
  78228. get barColor(): string;
  78229. set barColor(color: string);
  78230. /** Gets or sets the bar image */
  78231. get thumbImage(): Image;
  78232. set thumbImage(value: Image);
  78233. /** Gets or sets the horizontal bar image */
  78234. get horizontalThumbImage(): Image;
  78235. set horizontalThumbImage(value: Image);
  78236. /** Gets or sets the vertical bar image */
  78237. get verticalThumbImage(): Image;
  78238. set verticalThumbImage(value: Image);
  78239. /** Gets or sets the size of the bar */
  78240. get barSize(): number;
  78241. set barSize(value: number);
  78242. /** Gets or sets the length of the thumb */
  78243. get thumbLength(): number;
  78244. set thumbLength(value: number);
  78245. /** Gets or sets the height of the thumb */
  78246. get thumbHeight(): number;
  78247. set thumbHeight(value: number);
  78248. /** Gets or sets the height of the bar image */
  78249. get barImageHeight(): number;
  78250. set barImageHeight(value: number);
  78251. /** Gets or sets the height of the horizontal bar image */
  78252. get horizontalBarImageHeight(): number;
  78253. set horizontalBarImageHeight(value: number);
  78254. /** Gets or sets the height of the vertical bar image */
  78255. get verticalBarImageHeight(): number;
  78256. set verticalBarImageHeight(value: number);
  78257. /** Gets or sets the bar background */
  78258. get barBackground(): string;
  78259. set barBackground(color: string);
  78260. /** Gets or sets the bar background image */
  78261. get barImage(): Image;
  78262. set barImage(value: Image);
  78263. /** Gets or sets the horizontal bar background image */
  78264. get horizontalBarImage(): Image;
  78265. set horizontalBarImage(value: Image);
  78266. /** Gets or sets the vertical bar background image */
  78267. get verticalBarImage(): Image;
  78268. set verticalBarImage(value: Image);
  78269. private _setWindowPosition;
  78270. /** @hidden */
  78271. private _updateScroller;
  78272. _link(host: AdvancedDynamicTexture): void;
  78273. /** @hidden */
  78274. private _addBar;
  78275. /** @hidden */
  78276. private _attachWheel;
  78277. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78278. /** Releases associated resources */
  78279. dispose(): void;
  78280. }
  78281. }
  78282. declare module BABYLON.GUI {
  78283. /** Class used to render a grid */
  78284. export class DisplayGrid extends Control {
  78285. name?: string | undefined;
  78286. private _cellWidth;
  78287. private _cellHeight;
  78288. private _minorLineTickness;
  78289. private _minorLineColor;
  78290. private _majorLineTickness;
  78291. private _majorLineColor;
  78292. private _majorLineFrequency;
  78293. private _background;
  78294. private _displayMajorLines;
  78295. private _displayMinorLines;
  78296. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78297. get displayMinorLines(): boolean;
  78298. set displayMinorLines(value: boolean);
  78299. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78300. get displayMajorLines(): boolean;
  78301. set displayMajorLines(value: boolean);
  78302. /** Gets or sets background color (Black by default) */
  78303. get background(): string;
  78304. set background(value: string);
  78305. /** Gets or sets the width of each cell (20 by default) */
  78306. get cellWidth(): number;
  78307. set cellWidth(value: number);
  78308. /** Gets or sets the height of each cell (20 by default) */
  78309. get cellHeight(): number;
  78310. set cellHeight(value: number);
  78311. /** Gets or sets the tickness of minor lines (1 by default) */
  78312. get minorLineTickness(): number;
  78313. set minorLineTickness(value: number);
  78314. /** Gets or sets the color of minor lines (DarkGray by default) */
  78315. get minorLineColor(): string;
  78316. set minorLineColor(value: string);
  78317. /** Gets or sets the tickness of major lines (2 by default) */
  78318. get majorLineTickness(): number;
  78319. set majorLineTickness(value: number);
  78320. /** Gets or sets the color of major lines (White by default) */
  78321. get majorLineColor(): string;
  78322. set majorLineColor(value: string);
  78323. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78324. get majorLineFrequency(): number;
  78325. set majorLineFrequency(value: number);
  78326. /**
  78327. * Creates a new GridDisplayRectangle
  78328. * @param name defines the control name
  78329. */
  78330. constructor(name?: string | undefined);
  78331. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78332. protected _getTypeName(): string;
  78333. }
  78334. }
  78335. declare module BABYLON.GUI {
  78336. /**
  78337. * Class used to create slider controls based on images
  78338. */
  78339. export class ImageBasedSlider extends BaseSlider {
  78340. name?: string | undefined;
  78341. private _backgroundImage;
  78342. private _thumbImage;
  78343. private _valueBarImage;
  78344. private _tempMeasure;
  78345. get displayThumb(): boolean;
  78346. set displayThumb(value: boolean);
  78347. /**
  78348. * Gets or sets the image used to render the background
  78349. */
  78350. get backgroundImage(): Image;
  78351. set backgroundImage(value: Image);
  78352. /**
  78353. * Gets or sets the image used to render the value bar
  78354. */
  78355. get valueBarImage(): Image;
  78356. set valueBarImage(value: Image);
  78357. /**
  78358. * Gets or sets the image used to render the thumb
  78359. */
  78360. get thumbImage(): Image;
  78361. set thumbImage(value: Image);
  78362. /**
  78363. * Creates a new ImageBasedSlider
  78364. * @param name defines the control name
  78365. */
  78366. constructor(name?: string | undefined);
  78367. protected _getTypeName(): string;
  78368. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78369. }
  78370. }
  78371. declare module BABYLON.GUI {
  78372. /**
  78373. * Forcing an export so that this code will execute
  78374. * @hidden
  78375. */
  78376. const name = "Statics";
  78377. }
  78378. declare module BABYLON.GUI {
  78379. /**
  78380. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78381. */
  78382. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78383. /**
  78384. * Define the instrumented AdvancedDynamicTexture.
  78385. */
  78386. texture: AdvancedDynamicTexture;
  78387. private _captureRenderTime;
  78388. private _renderTime;
  78389. private _captureLayoutTime;
  78390. private _layoutTime;
  78391. private _onBeginRenderObserver;
  78392. private _onEndRenderObserver;
  78393. private _onBeginLayoutObserver;
  78394. private _onEndLayoutObserver;
  78395. /**
  78396. * Gets the perf counter used to capture render time
  78397. */
  78398. get renderTimeCounter(): BABYLON.PerfCounter;
  78399. /**
  78400. * Gets the perf counter used to capture layout time
  78401. */
  78402. get layoutTimeCounter(): BABYLON.PerfCounter;
  78403. /**
  78404. * Enable or disable the render time capture
  78405. */
  78406. get captureRenderTime(): boolean;
  78407. set captureRenderTime(value: boolean);
  78408. /**
  78409. * Enable or disable the layout time capture
  78410. */
  78411. get captureLayoutTime(): boolean;
  78412. set captureLayoutTime(value: boolean);
  78413. /**
  78414. * Instantiates a new advanced dynamic texture instrumentation.
  78415. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78416. * @param texture Defines the AdvancedDynamicTexture to instrument
  78417. */
  78418. constructor(
  78419. /**
  78420. * Define the instrumented AdvancedDynamicTexture.
  78421. */
  78422. texture: AdvancedDynamicTexture);
  78423. /**
  78424. * Dispose and release associated resources.
  78425. */
  78426. dispose(): void;
  78427. }
  78428. }
  78429. declare module BABYLON.GUI {
  78430. /**
  78431. * Class used to load GUI via XML.
  78432. */
  78433. export class XmlLoader {
  78434. private _nodes;
  78435. private _nodeTypes;
  78436. private _isLoaded;
  78437. private _objectAttributes;
  78438. private _parentClass;
  78439. /**
  78440. * Create a new xml loader
  78441. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78442. */
  78443. constructor(parentClass?: null);
  78444. private _getChainElement;
  78445. private _getClassAttribute;
  78446. private _createGuiElement;
  78447. private _parseGrid;
  78448. private _parseElement;
  78449. private _prepareSourceElement;
  78450. private _parseElementsFromSource;
  78451. private _parseXml;
  78452. /**
  78453. * Gets if the loading has finished.
  78454. * @returns whether the loading has finished or not
  78455. */
  78456. isLoaded(): boolean;
  78457. /**
  78458. * Gets a loaded node / control by id.
  78459. * @param id the Controls id set in the xml
  78460. * @returns element of type Control
  78461. */
  78462. getNodeById(id: string): any;
  78463. /**
  78464. * Gets all loaded nodes / controls
  78465. * @returns Array of controls
  78466. */
  78467. getNodes(): any;
  78468. /**
  78469. * Initiates the xml layout loading
  78470. * @param xmlFile defines the xml layout to load
  78471. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78472. * @param callback defines the callback called on layout load.
  78473. */
  78474. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78475. }
  78476. }
  78477. declare module BABYLON.GUI {
  78478. /**
  78479. * Class used to create containers for controls
  78480. */
  78481. export class Container3D extends Control3D {
  78482. private _blockLayout;
  78483. /**
  78484. * Gets the list of child controls
  78485. */
  78486. protected _children: Control3D[];
  78487. /**
  78488. * Gets the list of child controls
  78489. */
  78490. get children(): Array<Control3D>;
  78491. /**
  78492. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78493. * This is helpful to optimize layout operation when adding multiple children in a row
  78494. */
  78495. get blockLayout(): boolean;
  78496. set blockLayout(value: boolean);
  78497. /**
  78498. * Creates a new container
  78499. * @param name defines the container name
  78500. */
  78501. constructor(name?: string);
  78502. /**
  78503. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78504. * @returns the current container
  78505. */
  78506. updateLayout(): Container3D;
  78507. /**
  78508. * Gets a boolean indicating if the given control is in the children of this control
  78509. * @param control defines the control to check
  78510. * @returns true if the control is in the child list
  78511. */
  78512. containsControl(control: Control3D): boolean;
  78513. /**
  78514. * Adds a control to the children of this control
  78515. * @param control defines the control to add
  78516. * @returns the current container
  78517. */
  78518. addControl(control: Control3D): Container3D;
  78519. /**
  78520. * This function will be called everytime a new control is added
  78521. */
  78522. protected _arrangeChildren(): void;
  78523. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78524. /**
  78525. * Removes a control from the children of this control
  78526. * @param control defines the control to remove
  78527. * @returns the current container
  78528. */
  78529. removeControl(control: Control3D): Container3D;
  78530. protected _getTypeName(): string;
  78531. /**
  78532. * Releases all associated resources
  78533. */
  78534. dispose(): void;
  78535. /** Control rotation will remain unchanged */
  78536. static readonly UNSET_ORIENTATION: number;
  78537. /** Control will rotate to make it look at sphere central axis */
  78538. static readonly FACEORIGIN_ORIENTATION: number;
  78539. /** Control will rotate to make it look back at sphere central axis */
  78540. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78541. /** Control will rotate to look at z axis (0, 0, 1) */
  78542. static readonly FACEFORWARD_ORIENTATION: number;
  78543. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78544. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78545. }
  78546. }
  78547. declare module BABYLON.GUI {
  78548. /**
  78549. * Class used to manage 3D user interface
  78550. * @see https://doc.babylonjs.com/how_to/gui3d
  78551. */
  78552. export class GUI3DManager implements BABYLON.IDisposable {
  78553. private _scene;
  78554. private _sceneDisposeObserver;
  78555. private _utilityLayer;
  78556. private _rootContainer;
  78557. private _pointerObserver;
  78558. private _pointerOutObserver;
  78559. /** @hidden */
  78560. _lastPickedControl: Control3D;
  78561. /** @hidden */
  78562. _lastControlOver: {
  78563. [pointerId: number]: Control3D;
  78564. };
  78565. /** @hidden */
  78566. _lastControlDown: {
  78567. [pointerId: number]: Control3D;
  78568. };
  78569. /**
  78570. * BABYLON.Observable raised when the point picked by the pointer events changed
  78571. */
  78572. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78573. /** @hidden */
  78574. _sharedMaterials: {
  78575. [key: string]: BABYLON.Material;
  78576. };
  78577. /** Gets the hosting scene */
  78578. get scene(): BABYLON.Scene;
  78579. /** Gets associated utility layer */
  78580. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78581. /**
  78582. * Creates a new GUI3DManager
  78583. * @param scene
  78584. */
  78585. constructor(scene?: BABYLON.Scene);
  78586. private _handlePointerOut;
  78587. private _doPicking;
  78588. /**
  78589. * Gets the root container
  78590. */
  78591. get rootContainer(): Container3D;
  78592. /**
  78593. * Gets a boolean indicating if the given control is in the root child list
  78594. * @param control defines the control to check
  78595. * @returns true if the control is in the root child list
  78596. */
  78597. containsControl(control: Control3D): boolean;
  78598. /**
  78599. * Adds a control to the root child list
  78600. * @param control defines the control to add
  78601. * @returns the current manager
  78602. */
  78603. addControl(control: Control3D): GUI3DManager;
  78604. /**
  78605. * Removes a control from the root child list
  78606. * @param control defines the control to remove
  78607. * @returns the current container
  78608. */
  78609. removeControl(control: Control3D): GUI3DManager;
  78610. /**
  78611. * Releases all associated resources
  78612. */
  78613. dispose(): void;
  78614. }
  78615. }
  78616. declare module BABYLON.GUI {
  78617. /**
  78618. * Class used to transport BABYLON.Vector3 information for pointer events
  78619. */
  78620. export class Vector3WithInfo extends BABYLON.Vector3 {
  78621. /** defines the current mouse button index */
  78622. buttonIndex: number;
  78623. /**
  78624. * Creates a new Vector3WithInfo
  78625. * @param source defines the vector3 data to transport
  78626. * @param buttonIndex defines the current mouse button index
  78627. */
  78628. constructor(source: BABYLON.Vector3,
  78629. /** defines the current mouse button index */
  78630. buttonIndex?: number);
  78631. }
  78632. }
  78633. declare module BABYLON.GUI {
  78634. /**
  78635. * Class used as base class for controls
  78636. */
  78637. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78638. /** Defines the control name */
  78639. name?: string | undefined;
  78640. /** @hidden */
  78641. _host: GUI3DManager;
  78642. private _node;
  78643. private _downCount;
  78644. private _enterCount;
  78645. private _downPointerIds;
  78646. private _isVisible;
  78647. /** Gets or sets the control position in world space */
  78648. get position(): BABYLON.Vector3;
  78649. set position(value: BABYLON.Vector3);
  78650. /** Gets or sets the control scaling in world space */
  78651. get scaling(): BABYLON.Vector3;
  78652. set scaling(value: BABYLON.Vector3);
  78653. /** Callback used to start pointer enter animation */
  78654. pointerEnterAnimation: () => void;
  78655. /** Callback used to start pointer out animation */
  78656. pointerOutAnimation: () => void;
  78657. /** Callback used to start pointer down animation */
  78658. pointerDownAnimation: () => void;
  78659. /** Callback used to start pointer up animation */
  78660. pointerUpAnimation: () => void;
  78661. /**
  78662. * An event triggered when the pointer move over the control
  78663. */
  78664. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78665. /**
  78666. * An event triggered when the pointer move out of the control
  78667. */
  78668. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78669. /**
  78670. * An event triggered when the pointer taps the control
  78671. */
  78672. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78673. /**
  78674. * An event triggered when pointer is up
  78675. */
  78676. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78677. /**
  78678. * An event triggered when a control is clicked on (with a mouse)
  78679. */
  78680. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78681. /**
  78682. * An event triggered when pointer enters the control
  78683. */
  78684. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78685. /**
  78686. * Gets or sets the parent container
  78687. */
  78688. parent: BABYLON.Nullable<Container3D>;
  78689. private _behaviors;
  78690. /**
  78691. * Gets the list of attached behaviors
  78692. * @see https://doc.babylonjs.com/features/behaviour
  78693. */
  78694. get behaviors(): BABYLON.Behavior<Control3D>[];
  78695. /**
  78696. * Attach a behavior to the control
  78697. * @see https://doc.babylonjs.com/features/behaviour
  78698. * @param behavior defines the behavior to attach
  78699. * @returns the current control
  78700. */
  78701. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78702. /**
  78703. * Remove an attached behavior
  78704. * @see https://doc.babylonjs.com/features/behaviour
  78705. * @param behavior defines the behavior to attach
  78706. * @returns the current control
  78707. */
  78708. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78709. /**
  78710. * Gets an attached behavior by name
  78711. * @param name defines the name of the behavior to look for
  78712. * @see https://doc.babylonjs.com/features/behaviour
  78713. * @returns null if behavior was not found else the requested behavior
  78714. */
  78715. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78716. /** Gets or sets a boolean indicating if the control is visible */
  78717. get isVisible(): boolean;
  78718. set isVisible(value: boolean);
  78719. /**
  78720. * Creates a new control
  78721. * @param name defines the control name
  78722. */
  78723. constructor(
  78724. /** Defines the control name */
  78725. name?: string | undefined);
  78726. /**
  78727. * Gets a string representing the class name
  78728. */
  78729. get typeName(): string;
  78730. /**
  78731. * Get the current class name of the control.
  78732. * @returns current class name
  78733. */
  78734. getClassName(): string;
  78735. protected _getTypeName(): string;
  78736. /**
  78737. * Gets the transform node used by this control
  78738. */
  78739. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78740. /**
  78741. * Gets the mesh used to render this control
  78742. */
  78743. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78744. /**
  78745. * Link the control as child of the given node
  78746. * @param node defines the node to link to. Use null to unlink the control
  78747. * @returns the current control
  78748. */
  78749. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78750. /** @hidden **/
  78751. _prepareNode(scene: BABYLON.Scene): void;
  78752. /**
  78753. * Node creation.
  78754. * Can be overriden by children
  78755. * @param scene defines the scene where the node must be attached
  78756. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78757. */
  78758. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78759. /**
  78760. * Affect a material to the given mesh
  78761. * @param mesh defines the mesh which will represent the control
  78762. */
  78763. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78764. /** @hidden */
  78765. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78766. /** @hidden */
  78767. _onPointerEnter(target: Control3D): boolean;
  78768. /** @hidden */
  78769. _onPointerOut(target: Control3D): void;
  78770. /** @hidden */
  78771. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78772. /** @hidden */
  78773. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78774. /** @hidden */
  78775. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78776. /** @hidden */
  78777. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78778. /** @hidden */
  78779. _disposeNode(): void;
  78780. /**
  78781. * Releases all associated resources
  78782. */
  78783. dispose(): void;
  78784. }
  78785. }
  78786. declare module BABYLON.GUI {
  78787. /**
  78788. * Class used as a root to all buttons
  78789. */
  78790. export class AbstractButton3D extends Control3D {
  78791. /**
  78792. * Creates a new button
  78793. * @param name defines the control name
  78794. */
  78795. constructor(name?: string);
  78796. protected _getTypeName(): string;
  78797. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78798. }
  78799. }
  78800. declare module BABYLON.GUI {
  78801. /**
  78802. * Class used to create a button in 3D
  78803. */
  78804. export class Button3D extends AbstractButton3D {
  78805. /** @hidden */
  78806. protected _currentMaterial: BABYLON.Material;
  78807. private _facadeTexture;
  78808. private _content;
  78809. private _contentResolution;
  78810. private _contentScaleRatio;
  78811. /**
  78812. * Gets or sets the texture resolution used to render content (512 by default)
  78813. */
  78814. get contentResolution(): BABYLON.int;
  78815. set contentResolution(value: BABYLON.int);
  78816. /**
  78817. * Gets or sets the texture scale ratio used to render content (2 by default)
  78818. */
  78819. get contentScaleRatio(): number;
  78820. set contentScaleRatio(value: number);
  78821. protected _disposeFacadeTexture(): void;
  78822. protected _resetContent(): void;
  78823. /**
  78824. * Creates a new button
  78825. * @param name defines the control name
  78826. */
  78827. constructor(name?: string);
  78828. /**
  78829. * Gets or sets the GUI 2D content used to display the button's facade
  78830. */
  78831. get content(): Control;
  78832. set content(value: Control);
  78833. /**
  78834. * Apply the facade texture (created from the content property).
  78835. * This function can be overloaded by child classes
  78836. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78837. */
  78838. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78839. protected _getTypeName(): string;
  78840. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78841. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78842. /**
  78843. * Releases all associated resources
  78844. */
  78845. dispose(): void;
  78846. }
  78847. }
  78848. declare module BABYLON.GUI {
  78849. /**
  78850. * Abstract class used to create a container panel deployed on the surface of a volume
  78851. */
  78852. export abstract class VolumeBasedPanel extends Container3D {
  78853. private _columns;
  78854. private _rows;
  78855. private _rowThenColum;
  78856. private _orientation;
  78857. protected _cellWidth: number;
  78858. protected _cellHeight: number;
  78859. /**
  78860. * Gets or sets the distance between elements
  78861. */
  78862. margin: number;
  78863. /**
  78864. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78865. * | Value | Type | Description |
  78866. * | ----- | ----------------------------------- | ----------- |
  78867. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78868. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78869. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78870. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78871. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78872. */
  78873. get orientation(): number;
  78874. set orientation(value: number);
  78875. /**
  78876. * Gets or sets the number of columns requested (10 by default).
  78877. * The panel will automatically compute the number of rows based on number of child controls.
  78878. */
  78879. get columns(): BABYLON.int;
  78880. set columns(value: BABYLON.int);
  78881. /**
  78882. * Gets or sets a the number of rows requested.
  78883. * The panel will automatically compute the number of columns based on number of child controls.
  78884. */
  78885. get rows(): BABYLON.int;
  78886. set rows(value: BABYLON.int);
  78887. /**
  78888. * Creates new VolumeBasedPanel
  78889. */
  78890. constructor();
  78891. protected _arrangeChildren(): void;
  78892. /** Child classes must implement this function to provide correct control positioning */
  78893. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78894. /** Child classes can implement this function to provide additional processing */
  78895. protected _finalProcessing(): void;
  78896. }
  78897. }
  78898. declare module BABYLON.GUI {
  78899. /**
  78900. * Class used to create a container panel deployed on the surface of a cylinder
  78901. */
  78902. export class CylinderPanel extends VolumeBasedPanel {
  78903. private _radius;
  78904. /**
  78905. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78906. */
  78907. get radius(): BABYLON.float;
  78908. set radius(value: BABYLON.float);
  78909. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78910. private _cylindricalMapping;
  78911. }
  78912. }
  78913. declare module BABYLON.GUI {
  78914. /** @hidden */
  78915. export var fluentVertexShader: {
  78916. name: string;
  78917. shader: string;
  78918. };
  78919. }
  78920. declare module BABYLON.GUI {
  78921. /** @hidden */
  78922. export var fluentPixelShader: {
  78923. name: string;
  78924. shader: string;
  78925. };
  78926. }
  78927. declare module BABYLON.GUI {
  78928. /** @hidden */
  78929. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78930. INNERGLOW: boolean;
  78931. BORDER: boolean;
  78932. HOVERLIGHT: boolean;
  78933. TEXTURE: boolean;
  78934. constructor();
  78935. }
  78936. /**
  78937. * Class used to render controls with fluent desgin
  78938. */
  78939. export class FluentMaterial extends BABYLON.PushMaterial {
  78940. /**
  78941. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78942. */
  78943. innerGlowColorIntensity: number;
  78944. /**
  78945. * Gets or sets the inner glow color (white by default)
  78946. */
  78947. innerGlowColor: BABYLON.Color3;
  78948. /**
  78949. * Gets or sets alpha value (default is 1.0)
  78950. */
  78951. alpha: number;
  78952. /**
  78953. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78954. */
  78955. albedoColor: BABYLON.Color3;
  78956. /**
  78957. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78958. */
  78959. renderBorders: boolean;
  78960. /**
  78961. * Gets or sets border width (default is 0.5)
  78962. */
  78963. borderWidth: number;
  78964. /**
  78965. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78966. */
  78967. edgeSmoothingValue: number;
  78968. /**
  78969. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78970. */
  78971. borderMinValue: number;
  78972. /**
  78973. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78974. */
  78975. renderHoverLight: boolean;
  78976. /**
  78977. * Gets or sets the radius used to render the hover light (default is 1.0)
  78978. */
  78979. hoverRadius: number;
  78980. /**
  78981. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78982. */
  78983. hoverColor: BABYLON.Color4;
  78984. /**
  78985. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78986. */
  78987. hoverPosition: BABYLON.Vector3;
  78988. private _albedoTexture;
  78989. /** Gets or sets the texture to use for albedo color */
  78990. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78991. /**
  78992. * Creates a new Fluent material
  78993. * @param name defines the name of the material
  78994. * @param scene defines the hosting scene
  78995. */
  78996. constructor(name: string, scene: BABYLON.Scene);
  78997. needAlphaBlending(): boolean;
  78998. needAlphaTesting(): boolean;
  78999. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79000. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79001. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79002. getActiveTextures(): BABYLON.BaseTexture[];
  79003. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79004. dispose(forceDisposeEffect?: boolean): void;
  79005. clone(name: string): FluentMaterial;
  79006. serialize(): any;
  79007. getClassName(): string;
  79008. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79009. }
  79010. }
  79011. declare module BABYLON.GUI {
  79012. /**
  79013. * Class used to create a holographic button in 3D
  79014. */
  79015. export class HolographicButton extends Button3D {
  79016. private _backPlate;
  79017. private _textPlate;
  79018. private _frontPlate;
  79019. private _text;
  79020. private _imageUrl;
  79021. private _shareMaterials;
  79022. private _frontMaterial;
  79023. private _backMaterial;
  79024. private _plateMaterial;
  79025. private _pickedPointObserver;
  79026. private _tooltipFade;
  79027. private _tooltipTextBlock;
  79028. private _tooltipTexture;
  79029. private _tooltipMesh;
  79030. private _tooltipHoverObserver;
  79031. private _tooltipOutObserver;
  79032. private _disposeTooltip;
  79033. /**
  79034. * Rendering ground id of all the mesh in the button
  79035. */
  79036. set renderingGroupId(id: number);
  79037. get renderingGroupId(): number;
  79038. /**
  79039. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79040. */
  79041. set tooltipText(text: BABYLON.Nullable<string>);
  79042. get tooltipText(): BABYLON.Nullable<string>;
  79043. /**
  79044. * Gets or sets text for the button
  79045. */
  79046. get text(): string;
  79047. set text(value: string);
  79048. /**
  79049. * Gets or sets the image url for the button
  79050. */
  79051. get imageUrl(): string;
  79052. set imageUrl(value: string);
  79053. /**
  79054. * Gets the back material used by this button
  79055. */
  79056. get backMaterial(): FluentMaterial;
  79057. /**
  79058. * Gets the front material used by this button
  79059. */
  79060. get frontMaterial(): FluentMaterial;
  79061. /**
  79062. * Gets the plate material used by this button
  79063. */
  79064. get plateMaterial(): BABYLON.StandardMaterial;
  79065. /**
  79066. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79067. */
  79068. get shareMaterials(): boolean;
  79069. /**
  79070. * Creates a new button
  79071. * @param name defines the control name
  79072. */
  79073. constructor(name?: string, shareMaterials?: boolean);
  79074. protected _getTypeName(): string;
  79075. private _rebuildContent;
  79076. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79077. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79078. private _createBackMaterial;
  79079. private _createFrontMaterial;
  79080. private _createPlateMaterial;
  79081. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  79082. /**
  79083. * Releases all associated resources
  79084. */
  79085. dispose(): void;
  79086. }
  79087. }
  79088. declare module BABYLON.GUI {
  79089. /**
  79090. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  79091. */
  79092. export class MeshButton3D extends Button3D {
  79093. /** @hidden */
  79094. protected _currentMesh: BABYLON.Mesh;
  79095. /**
  79096. * Creates a new 3D button based on a mesh
  79097. * @param mesh mesh to become a 3D button
  79098. * @param name defines the control name
  79099. */
  79100. constructor(mesh: BABYLON.Mesh, name?: string);
  79101. protected _getTypeName(): string;
  79102. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79103. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79104. }
  79105. }
  79106. declare module BABYLON.GUI {
  79107. /**
  79108. * Class used to create a container panel deployed on the surface of a plane
  79109. */
  79110. export class PlanePanel extends VolumeBasedPanel {
  79111. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79112. }
  79113. }
  79114. declare module BABYLON.GUI {
  79115. /**
  79116. * Class used to create a container panel where items get randomized planar mapping
  79117. */
  79118. export class ScatterPanel extends VolumeBasedPanel {
  79119. private _iteration;
  79120. /**
  79121. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  79122. */
  79123. get iteration(): BABYLON.float;
  79124. set iteration(value: BABYLON.float);
  79125. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79126. private _scatterMapping;
  79127. protected _finalProcessing(): void;
  79128. }
  79129. }
  79130. declare module BABYLON.GUI {
  79131. /**
  79132. * Class used to create a container panel deployed on the surface of a sphere
  79133. */
  79134. export class SpherePanel extends VolumeBasedPanel {
  79135. private _radius;
  79136. /**
  79137. * Gets or sets the radius of the sphere where to project controls (5 by default)
  79138. */
  79139. get radius(): BABYLON.float;
  79140. set radius(value: BABYLON.float);
  79141. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79142. private _sphericalMapping;
  79143. }
  79144. }
  79145. declare module BABYLON.GUI {
  79146. /**
  79147. * Class used to create a stack panel in 3D on XY plane
  79148. */
  79149. export class StackPanel3D extends Container3D {
  79150. private _isVertical;
  79151. /**
  79152. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  79153. */
  79154. get isVertical(): boolean;
  79155. set isVertical(value: boolean);
  79156. /**
  79157. * Gets or sets the distance between elements
  79158. */
  79159. margin: number;
  79160. /**
  79161. * Creates new StackPanel
  79162. * @param isVertical
  79163. */
  79164. constructor(isVertical?: boolean);
  79165. protected _arrangeChildren(): void;
  79166. }
  79167. }
  79168. declare module BABYLON {
  79169. /**
  79170. * Configuration for glTF validation
  79171. */
  79172. export interface IGLTFValidationConfiguration {
  79173. /**
  79174. * The url of the glTF validator.
  79175. */
  79176. url: string;
  79177. }
  79178. /**
  79179. * glTF validation
  79180. */
  79181. export class GLTFValidation {
  79182. /**
  79183. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  79184. */
  79185. static Configuration: IGLTFValidationConfiguration;
  79186. private static _LoadScriptPromise;
  79187. /**
  79188. * Validate a glTF asset using the glTF-Validator.
  79189. * @param data The JSON of a glTF or the array buffer of a binary glTF
  79190. * @param rootUrl The root url for the glTF
  79191. * @param fileName The file name for the glTF
  79192. * @param getExternalResource The callback to get external resources for the glTF validator
  79193. * @returns A promise that resolves with the glTF validation results once complete
  79194. */
  79195. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  79196. }
  79197. }
  79198. declare module BABYLON {
  79199. /**
  79200. * Mode that determines the coordinate system to use.
  79201. */
  79202. export enum GLTFLoaderCoordinateSystemMode {
  79203. /**
  79204. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  79205. */
  79206. AUTO = 0,
  79207. /**
  79208. * Sets the useRightHandedSystem flag on the scene.
  79209. */
  79210. FORCE_RIGHT_HANDED = 1
  79211. }
  79212. /**
  79213. * Mode that determines what animations will start.
  79214. */
  79215. export enum GLTFLoaderAnimationStartMode {
  79216. /**
  79217. * No animation will start.
  79218. */
  79219. NONE = 0,
  79220. /**
  79221. * The first animation will start.
  79222. */
  79223. FIRST = 1,
  79224. /**
  79225. * All animations will start.
  79226. */
  79227. ALL = 2
  79228. }
  79229. /**
  79230. * Interface that contains the data for the glTF asset.
  79231. */
  79232. export interface IGLTFLoaderData {
  79233. /**
  79234. * The object that represents the glTF JSON.
  79235. */
  79236. json: Object;
  79237. /**
  79238. * The BIN chunk of a binary glTF.
  79239. */
  79240. bin: Nullable<IDataBuffer>;
  79241. }
  79242. /**
  79243. * Interface for extending the loader.
  79244. */
  79245. export interface IGLTFLoaderExtension {
  79246. /**
  79247. * The name of this extension.
  79248. */
  79249. readonly name: string;
  79250. /**
  79251. * Defines whether this extension is enabled.
  79252. */
  79253. enabled: boolean;
  79254. /**
  79255. * Defines the order of this extension.
  79256. * The loader sorts the extensions using these values when loading.
  79257. */
  79258. order?: number;
  79259. }
  79260. /**
  79261. * Loader state.
  79262. */
  79263. export enum GLTFLoaderState {
  79264. /**
  79265. * The asset is loading.
  79266. */
  79267. LOADING = 0,
  79268. /**
  79269. * The asset is ready for rendering.
  79270. */
  79271. READY = 1,
  79272. /**
  79273. * The asset is completely loaded.
  79274. */
  79275. COMPLETE = 2
  79276. }
  79277. /** @hidden */
  79278. export interface IImportMeshAsyncOutput {
  79279. meshes: AbstractMesh[];
  79280. particleSystems: IParticleSystem[];
  79281. skeletons: Skeleton[];
  79282. animationGroups: AnimationGroup[];
  79283. lights: Light[];
  79284. transformNodes: TransformNode[];
  79285. }
  79286. /** @hidden */
  79287. export interface IGLTFLoader extends IDisposable {
  79288. readonly state: Nullable<GLTFLoaderState>;
  79289. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  79290. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79291. }
  79292. /**
  79293. * File loader for loading glTF files into a scene.
  79294. */
  79295. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79296. /** @hidden */
  79297. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79298. /** @hidden */
  79299. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79300. /**
  79301. * Raised when the asset has been parsed
  79302. */
  79303. onParsedObservable: Observable<IGLTFLoaderData>;
  79304. private _onParsedObserver;
  79305. /**
  79306. * Raised when the asset has been parsed
  79307. */
  79308. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79309. /**
  79310. * 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.
  79311. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79312. * Defaults to true.
  79313. * @hidden
  79314. */
  79315. static IncrementalLoading: boolean;
  79316. /**
  79317. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79318. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79319. * @hidden
  79320. */
  79321. static HomogeneousCoordinates: boolean;
  79322. /**
  79323. * The coordinate system mode. Defaults to AUTO.
  79324. */
  79325. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79326. /**
  79327. * The animation start mode. Defaults to FIRST.
  79328. */
  79329. animationStartMode: GLTFLoaderAnimationStartMode;
  79330. /**
  79331. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79332. */
  79333. compileMaterials: boolean;
  79334. /**
  79335. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79336. */
  79337. useClipPlane: boolean;
  79338. /**
  79339. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79340. */
  79341. compileShadowGenerators: boolean;
  79342. /**
  79343. * Defines if the Alpha blended materials are only applied as coverage.
  79344. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79345. * If true, no extra effects are applied to transparent pixels.
  79346. */
  79347. transparencyAsCoverage: boolean;
  79348. /**
  79349. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79350. * Enabling will disable offline support and glTF validator.
  79351. * Defaults to false.
  79352. */
  79353. useRangeRequests: boolean;
  79354. /**
  79355. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79356. */
  79357. createInstances: boolean;
  79358. /**
  79359. * 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.
  79360. */
  79361. alwaysComputeBoundingBox: boolean;
  79362. /**
  79363. * Function called before loading a url referenced by the asset.
  79364. */
  79365. preprocessUrlAsync: (url: string) => Promise<string>;
  79366. /**
  79367. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79368. */
  79369. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79370. private _onMeshLoadedObserver;
  79371. /**
  79372. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79373. */
  79374. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79375. /**
  79376. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79377. */
  79378. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79379. private _onTextureLoadedObserver;
  79380. /**
  79381. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79382. */
  79383. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79384. /**
  79385. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79386. */
  79387. readonly onMaterialLoadedObservable: Observable<Material>;
  79388. private _onMaterialLoadedObserver;
  79389. /**
  79390. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79391. */
  79392. set onMaterialLoaded(callback: (material: Material) => void);
  79393. /**
  79394. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79395. */
  79396. readonly onCameraLoadedObservable: Observable<Camera>;
  79397. private _onCameraLoadedObserver;
  79398. /**
  79399. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79400. */
  79401. set onCameraLoaded(callback: (camera: Camera) => void);
  79402. /**
  79403. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79404. * For assets with LODs, raised when all of the LODs are complete.
  79405. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79406. */
  79407. readonly onCompleteObservable: Observable<void>;
  79408. private _onCompleteObserver;
  79409. /**
  79410. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79411. * For assets with LODs, raised when all of the LODs are complete.
  79412. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79413. */
  79414. set onComplete(callback: () => void);
  79415. /**
  79416. * Observable raised when an error occurs.
  79417. */
  79418. readonly onErrorObservable: Observable<any>;
  79419. private _onErrorObserver;
  79420. /**
  79421. * Callback raised when an error occurs.
  79422. */
  79423. set onError(callback: (reason: any) => void);
  79424. /**
  79425. * Observable raised after the loader is disposed.
  79426. */
  79427. readonly onDisposeObservable: Observable<void>;
  79428. private _onDisposeObserver;
  79429. /**
  79430. * Callback raised after the loader is disposed.
  79431. */
  79432. set onDispose(callback: () => void);
  79433. /**
  79434. * Observable raised after a loader extension is created.
  79435. * Set additional options for a loader extension in this event.
  79436. */
  79437. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79438. private _onExtensionLoadedObserver;
  79439. /**
  79440. * Callback raised after a loader extension is created.
  79441. */
  79442. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79443. /**
  79444. * Defines if the loader logging is enabled.
  79445. */
  79446. get loggingEnabled(): boolean;
  79447. set loggingEnabled(value: boolean);
  79448. /**
  79449. * Defines if the loader should capture performance counters.
  79450. */
  79451. get capturePerformanceCounters(): boolean;
  79452. set capturePerformanceCounters(value: boolean);
  79453. /**
  79454. * Defines if the loader should validate the asset.
  79455. */
  79456. validate: boolean;
  79457. /**
  79458. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79459. */
  79460. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79461. private _onValidatedObserver;
  79462. /**
  79463. * Callback raised after a loader extension is created.
  79464. */
  79465. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79466. private _loader;
  79467. private _progressCallback?;
  79468. private _requests;
  79469. private static magicBase64Encoded;
  79470. /**
  79471. * Name of the loader ("gltf")
  79472. */
  79473. name: string;
  79474. /** @hidden */
  79475. extensions: ISceneLoaderPluginExtensions;
  79476. /**
  79477. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79478. */
  79479. dispose(): void;
  79480. /** @hidden */
  79481. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79482. /** @hidden */
  79483. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79484. /** @hidden */
  79485. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79486. meshes: AbstractMesh[];
  79487. particleSystems: IParticleSystem[];
  79488. skeletons: Skeleton[];
  79489. animationGroups: AnimationGroup[];
  79490. }>;
  79491. /** @hidden */
  79492. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79493. /** @hidden */
  79494. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79495. /** @hidden */
  79496. canDirectLoad(data: string): boolean;
  79497. /** @hidden */
  79498. directLoad(scene: Scene, data: string): Promise<any>;
  79499. /**
  79500. * The callback that allows custom handling of the root url based on the response url.
  79501. * @param rootUrl the original root url
  79502. * @param responseURL the response url if available
  79503. * @returns the new root url
  79504. */
  79505. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79506. /** @hidden */
  79507. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79508. /**
  79509. * The loader state or null if the loader is not active.
  79510. */
  79511. get loaderState(): Nullable<GLTFLoaderState>;
  79512. /**
  79513. * Returns a promise that resolves when the asset is completely loaded.
  79514. * @returns a promise that resolves when the asset is completely loaded.
  79515. */
  79516. whenCompleteAsync(): Promise<void>;
  79517. /** @hidden */
  79518. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79519. /** @hidden */
  79520. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79521. private _onProgress;
  79522. private _validate;
  79523. private _getLoader;
  79524. private _parseJson;
  79525. private _unpackBinaryAsync;
  79526. private _unpackBinaryV1Async;
  79527. private _unpackBinaryV2Async;
  79528. private static _parseVersion;
  79529. private static _compareVersion;
  79530. private static readonly _logSpaces;
  79531. private _logIndentLevel;
  79532. private _loggingEnabled;
  79533. /** @hidden */
  79534. _log: (message: string) => void;
  79535. /** @hidden */
  79536. _logOpen(message: string): void;
  79537. /** @hidden */
  79538. _logClose(): void;
  79539. private _logEnabled;
  79540. private _logDisabled;
  79541. private _capturePerformanceCounters;
  79542. /** @hidden */
  79543. _startPerformanceCounter: (counterName: string) => void;
  79544. /** @hidden */
  79545. _endPerformanceCounter: (counterName: string) => void;
  79546. private _startPerformanceCounterEnabled;
  79547. private _startPerformanceCounterDisabled;
  79548. private _endPerformanceCounterEnabled;
  79549. private _endPerformanceCounterDisabled;
  79550. }
  79551. }
  79552. declare module BABYLON.GLTF1 {
  79553. /**
  79554. * Enums
  79555. * @hidden
  79556. */
  79557. export enum EComponentType {
  79558. BYTE = 5120,
  79559. UNSIGNED_BYTE = 5121,
  79560. SHORT = 5122,
  79561. UNSIGNED_SHORT = 5123,
  79562. FLOAT = 5126
  79563. }
  79564. /** @hidden */
  79565. export enum EShaderType {
  79566. FRAGMENT = 35632,
  79567. VERTEX = 35633
  79568. }
  79569. /** @hidden */
  79570. export enum EParameterType {
  79571. BYTE = 5120,
  79572. UNSIGNED_BYTE = 5121,
  79573. SHORT = 5122,
  79574. UNSIGNED_SHORT = 5123,
  79575. INT = 5124,
  79576. UNSIGNED_INT = 5125,
  79577. FLOAT = 5126,
  79578. FLOAT_VEC2 = 35664,
  79579. FLOAT_VEC3 = 35665,
  79580. FLOAT_VEC4 = 35666,
  79581. INT_VEC2 = 35667,
  79582. INT_VEC3 = 35668,
  79583. INT_VEC4 = 35669,
  79584. BOOL = 35670,
  79585. BOOL_VEC2 = 35671,
  79586. BOOL_VEC3 = 35672,
  79587. BOOL_VEC4 = 35673,
  79588. FLOAT_MAT2 = 35674,
  79589. FLOAT_MAT3 = 35675,
  79590. FLOAT_MAT4 = 35676,
  79591. SAMPLER_2D = 35678
  79592. }
  79593. /** @hidden */
  79594. export enum ETextureWrapMode {
  79595. CLAMP_TO_EDGE = 33071,
  79596. MIRRORED_REPEAT = 33648,
  79597. REPEAT = 10497
  79598. }
  79599. /** @hidden */
  79600. export enum ETextureFilterType {
  79601. NEAREST = 9728,
  79602. LINEAR = 9728,
  79603. NEAREST_MIPMAP_NEAREST = 9984,
  79604. LINEAR_MIPMAP_NEAREST = 9985,
  79605. NEAREST_MIPMAP_LINEAR = 9986,
  79606. LINEAR_MIPMAP_LINEAR = 9987
  79607. }
  79608. /** @hidden */
  79609. export enum ETextureFormat {
  79610. ALPHA = 6406,
  79611. RGB = 6407,
  79612. RGBA = 6408,
  79613. LUMINANCE = 6409,
  79614. LUMINANCE_ALPHA = 6410
  79615. }
  79616. /** @hidden */
  79617. export enum ECullingType {
  79618. FRONT = 1028,
  79619. BACK = 1029,
  79620. FRONT_AND_BACK = 1032
  79621. }
  79622. /** @hidden */
  79623. export enum EBlendingFunction {
  79624. ZERO = 0,
  79625. ONE = 1,
  79626. SRC_COLOR = 768,
  79627. ONE_MINUS_SRC_COLOR = 769,
  79628. DST_COLOR = 774,
  79629. ONE_MINUS_DST_COLOR = 775,
  79630. SRC_ALPHA = 770,
  79631. ONE_MINUS_SRC_ALPHA = 771,
  79632. DST_ALPHA = 772,
  79633. ONE_MINUS_DST_ALPHA = 773,
  79634. CONSTANT_COLOR = 32769,
  79635. ONE_MINUS_CONSTANT_COLOR = 32770,
  79636. CONSTANT_ALPHA = 32771,
  79637. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79638. SRC_ALPHA_SATURATE = 776
  79639. }
  79640. /** @hidden */
  79641. export interface IGLTFProperty {
  79642. extensions?: {
  79643. [key: string]: any;
  79644. };
  79645. extras?: Object;
  79646. }
  79647. /** @hidden */
  79648. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79649. name?: string;
  79650. }
  79651. /** @hidden */
  79652. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79653. bufferView: string;
  79654. byteOffset: number;
  79655. byteStride: number;
  79656. count: number;
  79657. type: string;
  79658. componentType: EComponentType;
  79659. max?: number[];
  79660. min?: number[];
  79661. name?: string;
  79662. }
  79663. /** @hidden */
  79664. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79665. buffer: string;
  79666. byteOffset: number;
  79667. byteLength: number;
  79668. byteStride: number;
  79669. target?: number;
  79670. }
  79671. /** @hidden */
  79672. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79673. uri: string;
  79674. byteLength?: number;
  79675. type?: string;
  79676. }
  79677. /** @hidden */
  79678. export interface IGLTFShader extends IGLTFChildRootProperty {
  79679. uri: string;
  79680. type: EShaderType;
  79681. }
  79682. /** @hidden */
  79683. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79684. attributes: string[];
  79685. fragmentShader: string;
  79686. vertexShader: string;
  79687. }
  79688. /** @hidden */
  79689. export interface IGLTFTechniqueParameter {
  79690. type: number;
  79691. count?: number;
  79692. semantic?: string;
  79693. node?: string;
  79694. value?: number | boolean | string | Array<any>;
  79695. source?: string;
  79696. babylonValue?: any;
  79697. }
  79698. /** @hidden */
  79699. export interface IGLTFTechniqueCommonProfile {
  79700. lightingModel: string;
  79701. texcoordBindings: Object;
  79702. parameters?: Array<any>;
  79703. }
  79704. /** @hidden */
  79705. export interface IGLTFTechniqueStatesFunctions {
  79706. blendColor?: number[];
  79707. blendEquationSeparate?: number[];
  79708. blendFuncSeparate?: number[];
  79709. colorMask: boolean[];
  79710. cullFace: number[];
  79711. }
  79712. /** @hidden */
  79713. export interface IGLTFTechniqueStates {
  79714. enable: number[];
  79715. functions: IGLTFTechniqueStatesFunctions;
  79716. }
  79717. /** @hidden */
  79718. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79719. parameters: {
  79720. [key: string]: IGLTFTechniqueParameter;
  79721. };
  79722. program: string;
  79723. attributes: {
  79724. [key: string]: string;
  79725. };
  79726. uniforms: {
  79727. [key: string]: string;
  79728. };
  79729. states: IGLTFTechniqueStates;
  79730. }
  79731. /** @hidden */
  79732. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79733. technique?: string;
  79734. values: string[];
  79735. }
  79736. /** @hidden */
  79737. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79738. attributes: {
  79739. [key: string]: string;
  79740. };
  79741. indices: string;
  79742. material: string;
  79743. mode?: number;
  79744. }
  79745. /** @hidden */
  79746. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79747. primitives: IGLTFMeshPrimitive[];
  79748. }
  79749. /** @hidden */
  79750. export interface IGLTFImage extends IGLTFChildRootProperty {
  79751. uri: string;
  79752. }
  79753. /** @hidden */
  79754. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79755. magFilter?: number;
  79756. minFilter?: number;
  79757. wrapS?: number;
  79758. wrapT?: number;
  79759. }
  79760. /** @hidden */
  79761. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79762. sampler: string;
  79763. source: string;
  79764. format?: ETextureFormat;
  79765. internalFormat?: ETextureFormat;
  79766. target?: number;
  79767. type?: number;
  79768. babylonTexture?: Texture;
  79769. }
  79770. /** @hidden */
  79771. export interface IGLTFAmbienLight {
  79772. color?: number[];
  79773. }
  79774. /** @hidden */
  79775. export interface IGLTFDirectionalLight {
  79776. color?: number[];
  79777. }
  79778. /** @hidden */
  79779. export interface IGLTFPointLight {
  79780. color?: number[];
  79781. constantAttenuation?: number;
  79782. linearAttenuation?: number;
  79783. quadraticAttenuation?: number;
  79784. }
  79785. /** @hidden */
  79786. export interface IGLTFSpotLight {
  79787. color?: number[];
  79788. constantAttenuation?: number;
  79789. fallOfAngle?: number;
  79790. fallOffExponent?: number;
  79791. linearAttenuation?: number;
  79792. quadraticAttenuation?: number;
  79793. }
  79794. /** @hidden */
  79795. export interface IGLTFLight extends IGLTFChildRootProperty {
  79796. type: string;
  79797. }
  79798. /** @hidden */
  79799. export interface IGLTFCameraOrthographic {
  79800. xmag: number;
  79801. ymag: number;
  79802. zfar: number;
  79803. znear: number;
  79804. }
  79805. /** @hidden */
  79806. export interface IGLTFCameraPerspective {
  79807. aspectRatio: number;
  79808. yfov: number;
  79809. zfar: number;
  79810. znear: number;
  79811. }
  79812. /** @hidden */
  79813. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79814. type: string;
  79815. }
  79816. /** @hidden */
  79817. export interface IGLTFAnimationChannelTarget {
  79818. id: string;
  79819. path: string;
  79820. }
  79821. /** @hidden */
  79822. export interface IGLTFAnimationChannel {
  79823. sampler: string;
  79824. target: IGLTFAnimationChannelTarget;
  79825. }
  79826. /** @hidden */
  79827. export interface IGLTFAnimationSampler {
  79828. input: string;
  79829. output: string;
  79830. interpolation?: string;
  79831. }
  79832. /** @hidden */
  79833. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79834. channels?: IGLTFAnimationChannel[];
  79835. parameters?: {
  79836. [key: string]: string;
  79837. };
  79838. samplers?: {
  79839. [key: string]: IGLTFAnimationSampler;
  79840. };
  79841. }
  79842. /** @hidden */
  79843. export interface IGLTFNodeInstanceSkin {
  79844. skeletons: string[];
  79845. skin: string;
  79846. meshes: string[];
  79847. }
  79848. /** @hidden */
  79849. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79850. bindShapeMatrix: number[];
  79851. inverseBindMatrices: string;
  79852. jointNames: string[];
  79853. babylonSkeleton?: Skeleton;
  79854. }
  79855. /** @hidden */
  79856. export interface IGLTFNode extends IGLTFChildRootProperty {
  79857. camera?: string;
  79858. children: string[];
  79859. skin?: string;
  79860. jointName?: string;
  79861. light?: string;
  79862. matrix: number[];
  79863. mesh?: string;
  79864. meshes?: string[];
  79865. rotation?: number[];
  79866. scale?: number[];
  79867. translation?: number[];
  79868. babylonNode?: Node;
  79869. }
  79870. /** @hidden */
  79871. export interface IGLTFScene extends IGLTFChildRootProperty {
  79872. nodes: string[];
  79873. }
  79874. /** @hidden */
  79875. export interface IGLTFRuntime {
  79876. extensions: {
  79877. [key: string]: any;
  79878. };
  79879. accessors: {
  79880. [key: string]: IGLTFAccessor;
  79881. };
  79882. buffers: {
  79883. [key: string]: IGLTFBuffer;
  79884. };
  79885. bufferViews: {
  79886. [key: string]: IGLTFBufferView;
  79887. };
  79888. meshes: {
  79889. [key: string]: IGLTFMesh;
  79890. };
  79891. lights: {
  79892. [key: string]: IGLTFLight;
  79893. };
  79894. cameras: {
  79895. [key: string]: IGLTFCamera;
  79896. };
  79897. nodes: {
  79898. [key: string]: IGLTFNode;
  79899. };
  79900. images: {
  79901. [key: string]: IGLTFImage;
  79902. };
  79903. textures: {
  79904. [key: string]: IGLTFTexture;
  79905. };
  79906. shaders: {
  79907. [key: string]: IGLTFShader;
  79908. };
  79909. programs: {
  79910. [key: string]: IGLTFProgram;
  79911. };
  79912. samplers: {
  79913. [key: string]: IGLTFSampler;
  79914. };
  79915. techniques: {
  79916. [key: string]: IGLTFTechnique;
  79917. };
  79918. materials: {
  79919. [key: string]: IGLTFMaterial;
  79920. };
  79921. animations: {
  79922. [key: string]: IGLTFAnimation;
  79923. };
  79924. skins: {
  79925. [key: string]: IGLTFSkins;
  79926. };
  79927. currentScene?: Object;
  79928. scenes: {
  79929. [key: string]: IGLTFScene;
  79930. };
  79931. extensionsUsed: string[];
  79932. extensionsRequired?: string[];
  79933. buffersCount: number;
  79934. shaderscount: number;
  79935. scene: Scene;
  79936. rootUrl: string;
  79937. loadedBufferCount: number;
  79938. loadedBufferViews: {
  79939. [name: string]: ArrayBufferView;
  79940. };
  79941. loadedShaderCount: number;
  79942. importOnlyMeshes: boolean;
  79943. importMeshesNames?: string[];
  79944. dummyNodes: Node[];
  79945. forAssetContainer: boolean;
  79946. }
  79947. /** @hidden */
  79948. export interface INodeToRoot {
  79949. bone: Bone;
  79950. node: IGLTFNode;
  79951. id: string;
  79952. }
  79953. /** @hidden */
  79954. export interface IJointNode {
  79955. node: IGLTFNode;
  79956. id: string;
  79957. }
  79958. }
  79959. declare module BABYLON.GLTF1 {
  79960. /**
  79961. * Utils functions for GLTF
  79962. * @hidden
  79963. */
  79964. export class GLTFUtils {
  79965. /**
  79966. * Sets the given "parameter" matrix
  79967. * @param scene: the Scene object
  79968. * @param source: the source node where to pick the matrix
  79969. * @param parameter: the GLTF technique parameter
  79970. * @param uniformName: the name of the shader's uniform
  79971. * @param shaderMaterial: the shader material
  79972. */
  79973. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79974. /**
  79975. * Sets the given "parameter" matrix
  79976. * @param shaderMaterial: the shader material
  79977. * @param uniform: the name of the shader's uniform
  79978. * @param value: the value of the uniform
  79979. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79980. */
  79981. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79982. /**
  79983. * Returns the wrap mode of the texture
  79984. * @param mode: the mode value
  79985. */
  79986. static GetWrapMode(mode: number): number;
  79987. /**
  79988. * Returns the byte stride giving an accessor
  79989. * @param accessor: the GLTF accessor objet
  79990. */
  79991. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79992. /**
  79993. * Returns the texture filter mode giving a mode value
  79994. * @param mode: the filter mode value
  79995. */
  79996. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79997. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79998. /**
  79999. * Returns a buffer from its accessor
  80000. * @param gltfRuntime: the GLTF runtime
  80001. * @param accessor: the GLTF accessor
  80002. */
  80003. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80004. /**
  80005. * Decodes a buffer view into a string
  80006. * @param view: the buffer view
  80007. */
  80008. static DecodeBufferToText(view: ArrayBufferView): string;
  80009. /**
  80010. * Returns the default material of gltf. Related to
  80011. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80012. * @param scene: the Babylon.js scene
  80013. */
  80014. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80015. private static _DefaultMaterial;
  80016. }
  80017. }
  80018. declare module BABYLON.GLTF1 {
  80019. /**
  80020. * Implementation of the base glTF spec
  80021. * @hidden
  80022. */
  80023. export class GLTFLoaderBase {
  80024. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80025. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80026. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80027. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80028. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80029. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80030. }
  80031. /**
  80032. * glTF V1 Loader
  80033. * @hidden
  80034. */
  80035. export class GLTFLoader implements IGLTFLoader {
  80036. static Extensions: {
  80037. [name: string]: GLTFLoaderExtension;
  80038. };
  80039. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80040. state: Nullable<GLTFLoaderState>;
  80041. dispose(): void;
  80042. private _importMeshAsync;
  80043. /**
  80044. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80045. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80046. * @param scene the scene the meshes should be added to
  80047. * @param forAssetContainer defines if the entities must be stored in the scene
  80048. * @param data gltf data containing information of the meshes in a loaded file
  80049. * @param rootUrl root url to load from
  80050. * @param onProgress event that fires when loading progress has occured
  80051. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80052. */
  80053. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80054. private _loadAsync;
  80055. /**
  80056. * Imports all objects from a loaded gltf file and adds them to the scene
  80057. * @param scene the scene the objects should be added to
  80058. * @param data gltf data containing information of the meshes in a loaded file
  80059. * @param rootUrl root url to load from
  80060. * @param onProgress event that fires when loading progress has occured
  80061. * @returns a promise which completes when objects have been loaded to the scene
  80062. */
  80063. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80064. private _loadShadersAsync;
  80065. private _loadBuffersAsync;
  80066. private _createNodes;
  80067. }
  80068. /** @hidden */
  80069. export abstract class GLTFLoaderExtension {
  80070. private _name;
  80071. constructor(name: string);
  80072. get name(): string;
  80073. /**
  80074. * Defines an override for loading the runtime
  80075. * Return true to stop further extensions from loading the runtime
  80076. */
  80077. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  80078. /**
  80079. * Defines an onverride for creating gltf runtime
  80080. * Return true to stop further extensions from creating the runtime
  80081. */
  80082. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  80083. /**
  80084. * Defines an override for loading buffers
  80085. * Return true to stop further extensions from loading this buffer
  80086. */
  80087. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  80088. /**
  80089. * Defines an override for loading texture buffers
  80090. * Return true to stop further extensions from loading this texture data
  80091. */
  80092. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80093. /**
  80094. * Defines an override for creating textures
  80095. * Return true to stop further extensions from loading this texture
  80096. */
  80097. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  80098. /**
  80099. * Defines an override for loading shader strings
  80100. * Return true to stop further extensions from loading this shader data
  80101. */
  80102. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80103. /**
  80104. * Defines an override for loading materials
  80105. * Return true to stop further extensions from loading this material
  80106. */
  80107. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80108. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  80109. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  80110. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80111. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80112. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  80113. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80114. private static LoadTextureBufferAsync;
  80115. private static CreateTextureAsync;
  80116. private static ApplyExtensions;
  80117. }
  80118. }
  80119. declare module BABYLON.GLTF1 {
  80120. /** @hidden */
  80121. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  80122. private _bin;
  80123. constructor();
  80124. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  80125. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80126. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80127. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80128. }
  80129. }
  80130. declare module BABYLON.GLTF1 {
  80131. /** @hidden */
  80132. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  80133. constructor();
  80134. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  80135. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80136. private _loadTexture;
  80137. }
  80138. }
  80139. declare module BABYLON.GLTF2.Loader {
  80140. /**
  80141. * Loader interface with an index field.
  80142. */
  80143. export interface IArrayItem {
  80144. /**
  80145. * The index of this item in the array.
  80146. */
  80147. index: number;
  80148. }
  80149. /**
  80150. * Loader interface with additional members.
  80151. */
  80152. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  80153. /** @hidden */
  80154. _data?: Promise<ArrayBufferView>;
  80155. /** @hidden */
  80156. _babylonVertexBuffer?: Promise<VertexBuffer>;
  80157. }
  80158. /**
  80159. * Loader interface with additional members.
  80160. */
  80161. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  80162. }
  80163. /** @hidden */
  80164. export interface _IAnimationSamplerData {
  80165. input: Float32Array;
  80166. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  80167. output: Float32Array;
  80168. }
  80169. /**
  80170. * Loader interface with additional members.
  80171. */
  80172. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  80173. /** @hidden */
  80174. _data?: Promise<_IAnimationSamplerData>;
  80175. }
  80176. /**
  80177. * Loader interface with additional members.
  80178. */
  80179. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  80180. channels: IAnimationChannel[];
  80181. samplers: IAnimationSampler[];
  80182. /** @hidden */
  80183. _babylonAnimationGroup?: AnimationGroup;
  80184. }
  80185. /**
  80186. * Loader interface with additional members.
  80187. */
  80188. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  80189. /** @hidden */
  80190. _data?: Promise<ArrayBufferView>;
  80191. }
  80192. /**
  80193. * Loader interface with additional members.
  80194. */
  80195. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  80196. /** @hidden */
  80197. _data?: Promise<ArrayBufferView>;
  80198. /** @hidden */
  80199. _babylonBuffer?: Promise<Buffer>;
  80200. }
  80201. /**
  80202. * Loader interface with additional members.
  80203. */
  80204. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  80205. }
  80206. /**
  80207. * Loader interface with additional members.
  80208. */
  80209. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  80210. /** @hidden */
  80211. _data?: Promise<ArrayBufferView>;
  80212. }
  80213. /**
  80214. * Loader interface with additional members.
  80215. */
  80216. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  80217. }
  80218. /**
  80219. * Loader interface with additional members.
  80220. */
  80221. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  80222. }
  80223. /**
  80224. * Loader interface with additional members.
  80225. */
  80226. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  80227. baseColorTexture?: ITextureInfo;
  80228. metallicRoughnessTexture?: ITextureInfo;
  80229. }
  80230. /**
  80231. * Loader interface with additional members.
  80232. */
  80233. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  80234. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80235. normalTexture?: IMaterialNormalTextureInfo;
  80236. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80237. emissiveTexture?: ITextureInfo;
  80238. /** @hidden */
  80239. _data?: {
  80240. [babylonDrawMode: number]: {
  80241. babylonMaterial: Material;
  80242. babylonMeshes: AbstractMesh[];
  80243. promise: Promise<void>;
  80244. };
  80245. };
  80246. }
  80247. /**
  80248. * Loader interface with additional members.
  80249. */
  80250. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  80251. primitives: IMeshPrimitive[];
  80252. }
  80253. /**
  80254. * Loader interface with additional members.
  80255. */
  80256. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  80257. /** @hidden */
  80258. _instanceData?: {
  80259. babylonSourceMesh: Mesh;
  80260. promise: Promise<any>;
  80261. };
  80262. }
  80263. /**
  80264. * Loader interface with additional members.
  80265. */
  80266. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  80267. /**
  80268. * The parent glTF node.
  80269. */
  80270. parent?: INode;
  80271. /** @hidden */
  80272. _babylonTransformNode?: TransformNode;
  80273. /** @hidden */
  80274. _primitiveBabylonMeshes?: AbstractMesh[];
  80275. /** @hidden */
  80276. _babylonBones?: Bone[];
  80277. /** @hidden */
  80278. _numMorphTargets?: number;
  80279. }
  80280. /** @hidden */
  80281. export interface _ISamplerData {
  80282. noMipMaps: boolean;
  80283. samplingMode: number;
  80284. wrapU: number;
  80285. wrapV: number;
  80286. }
  80287. /**
  80288. * Loader interface with additional members.
  80289. */
  80290. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80291. /** @hidden */
  80292. _data?: _ISamplerData;
  80293. }
  80294. /**
  80295. * Loader interface with additional members.
  80296. */
  80297. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80298. }
  80299. /**
  80300. * Loader interface with additional members.
  80301. */
  80302. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80303. /** @hidden */
  80304. _data?: {
  80305. babylonSkeleton: Skeleton;
  80306. promise: Promise<void>;
  80307. };
  80308. }
  80309. /**
  80310. * Loader interface with additional members.
  80311. */
  80312. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80313. }
  80314. /**
  80315. * Loader interface with additional members.
  80316. */
  80317. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80318. }
  80319. /**
  80320. * Loader interface with additional members.
  80321. */
  80322. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80323. accessors?: IAccessor[];
  80324. animations?: IAnimation[];
  80325. buffers?: IBuffer[];
  80326. bufferViews?: IBufferView[];
  80327. cameras?: ICamera[];
  80328. images?: IImage[];
  80329. materials?: IMaterial[];
  80330. meshes?: IMesh[];
  80331. nodes?: INode[];
  80332. samplers?: ISampler[];
  80333. scenes?: IScene[];
  80334. skins?: ISkin[];
  80335. textures?: ITexture[];
  80336. }
  80337. }
  80338. declare module BABYLON.GLTF2 {
  80339. /**
  80340. * Interface for a glTF loader extension.
  80341. */
  80342. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80343. /**
  80344. * Called after the loader state changes to LOADING.
  80345. */
  80346. onLoading?(): void;
  80347. /**
  80348. * Called after the loader state changes to READY.
  80349. */
  80350. onReady?(): void;
  80351. /**
  80352. * Define this method to modify the default behavior when loading scenes.
  80353. * @param context The context when loading the asset
  80354. * @param scene The glTF scene property
  80355. * @returns A promise that resolves when the load is complete or null if not handled
  80356. */
  80357. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80358. /**
  80359. * Define this method to modify the default behavior when loading nodes.
  80360. * @param context The context when loading the asset
  80361. * @param node The glTF node property
  80362. * @param assign A function called synchronously after parsing the glTF properties
  80363. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80364. */
  80365. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80366. /**
  80367. * Define this method to modify the default behavior when loading cameras.
  80368. * @param context The context when loading the asset
  80369. * @param camera The glTF camera property
  80370. * @param assign A function called synchronously after parsing the glTF properties
  80371. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80372. */
  80373. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80374. /**
  80375. * @hidden
  80376. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80377. * @param context The context when loading the asset
  80378. * @param primitive The glTF mesh primitive property
  80379. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80380. */
  80381. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80382. /**
  80383. * @hidden
  80384. * Define this method to modify the default behavior when loading data for mesh primitives.
  80385. * @param context The context when loading the asset
  80386. * @param name The mesh name when loading the asset
  80387. * @param node The glTF node when loading the asset
  80388. * @param mesh The glTF mesh when loading the asset
  80389. * @param primitive The glTF mesh primitive property
  80390. * @param assign A function called synchronously after parsing the glTF properties
  80391. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80392. */
  80393. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80394. /**
  80395. * @hidden
  80396. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80397. * @param context The context when loading the asset
  80398. * @param material The glTF material property
  80399. * @param assign A function called synchronously after parsing the glTF properties
  80400. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80401. */
  80402. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80403. /**
  80404. * Define this method to modify the default behavior when creating materials.
  80405. * @param context The context when loading the asset
  80406. * @param material The glTF material property
  80407. * @param babylonDrawMode The draw mode for the Babylon material
  80408. * @returns The Babylon material or null if not handled
  80409. */
  80410. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80411. /**
  80412. * Define this method to modify the default behavior when loading material properties.
  80413. * @param context The context when loading the asset
  80414. * @param material The glTF material property
  80415. * @param babylonMaterial The Babylon material
  80416. * @returns A promise that resolves when the load is complete or null if not handled
  80417. */
  80418. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80419. /**
  80420. * Define this method to modify the default behavior when loading texture infos.
  80421. * @param context The context when loading the asset
  80422. * @param textureInfo The glTF texture info property
  80423. * @param assign A function called synchronously after parsing the glTF properties
  80424. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80425. */
  80426. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80427. /**
  80428. * @hidden
  80429. * Define this method to modify the default behavior when loading textures.
  80430. * @param context The context when loading the asset
  80431. * @param texture The glTF texture property
  80432. * @param assign A function called synchronously after parsing the glTF properties
  80433. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80434. */
  80435. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80436. /**
  80437. * Define this method to modify the default behavior when loading animations.
  80438. * @param context The context when loading the asset
  80439. * @param animation The glTF animation property
  80440. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80441. */
  80442. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80443. /**
  80444. * @hidden
  80445. * Define this method to modify the default behavior when loading skins.
  80446. * @param context The context when loading the asset
  80447. * @param node The glTF node property
  80448. * @param skin The glTF skin property
  80449. * @returns A promise that resolves when the load is complete or null if not handled
  80450. */
  80451. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80452. /**
  80453. * @hidden
  80454. * Define this method to modify the default behavior when loading uris.
  80455. * @param context The context when loading the asset
  80456. * @param property The glTF property associated with the uri
  80457. * @param uri The uri to load
  80458. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80459. */
  80460. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80461. /**
  80462. * Define this method to modify the default behavior when loading buffer views.
  80463. * @param context The context when loading the asset
  80464. * @param bufferView The glTF buffer view property
  80465. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80466. */
  80467. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80468. /**
  80469. * Define this method to modify the default behavior when loading buffers.
  80470. * @param context The context when loading the asset
  80471. * @param buffer The glTF buffer property
  80472. * @param byteOffset The byte offset to load
  80473. * @param byteLength The byte length to load
  80474. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80475. */
  80476. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80477. }
  80478. }
  80479. declare module BABYLON.GLTF2 {
  80480. /**
  80481. * Helper class for working with arrays when loading the glTF asset
  80482. */
  80483. export class ArrayItem {
  80484. /**
  80485. * Gets an item from the given array.
  80486. * @param context The context when loading the asset
  80487. * @param array The array to get the item from
  80488. * @param index The index to the array
  80489. * @returns The array item
  80490. */
  80491. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80492. /**
  80493. * Assign an `index` field to each item of the given array.
  80494. * @param array The array of items
  80495. */
  80496. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80497. }
  80498. /**
  80499. * The glTF 2.0 loader
  80500. */
  80501. export class GLTFLoader implements IGLTFLoader {
  80502. /** @hidden */
  80503. _completePromises: Promise<any>[];
  80504. /** @hidden */
  80505. _forAssetContainer: boolean;
  80506. /** Storage */
  80507. _babylonLights: Light[];
  80508. /** @hidden */
  80509. _disableInstancedMesh: number;
  80510. private _disposed;
  80511. private _parent;
  80512. private _state;
  80513. private _extensions;
  80514. private _rootUrl;
  80515. private _fileName;
  80516. private _uniqueRootUrl;
  80517. private _gltf;
  80518. private _bin;
  80519. private _babylonScene;
  80520. private _rootBabylonMesh;
  80521. private _defaultBabylonMaterialData;
  80522. private static _RegisteredExtensions;
  80523. /**
  80524. * The default glTF sampler.
  80525. */
  80526. static readonly DefaultSampler: ISampler;
  80527. /**
  80528. * Registers a loader extension.
  80529. * @param name The name of the loader extension.
  80530. * @param factory The factory function that creates the loader extension.
  80531. */
  80532. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80533. /**
  80534. * Unregisters a loader extension.
  80535. * @param name The name of the loader extension.
  80536. * @returns A boolean indicating whether the extension has been unregistered
  80537. */
  80538. static UnregisterExtension(name: string): boolean;
  80539. /**
  80540. * The loader state.
  80541. */
  80542. get state(): Nullable<GLTFLoaderState>;
  80543. /**
  80544. * The object that represents the glTF JSON.
  80545. */
  80546. get gltf(): IGLTF;
  80547. /**
  80548. * The BIN chunk of a binary glTF.
  80549. */
  80550. get bin(): Nullable<IDataBuffer>;
  80551. /**
  80552. * The parent file loader.
  80553. */
  80554. get parent(): GLTFFileLoader;
  80555. /**
  80556. * The Babylon scene when loading the asset.
  80557. */
  80558. get babylonScene(): Scene;
  80559. /**
  80560. * The root Babylon mesh when loading the asset.
  80561. */
  80562. get rootBabylonMesh(): Mesh;
  80563. /** @hidden */
  80564. constructor(parent: GLTFFileLoader);
  80565. /** @hidden */
  80566. dispose(): void;
  80567. /** @hidden */
  80568. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80569. /** @hidden */
  80570. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80571. private _loadAsync;
  80572. private _loadData;
  80573. private _setupData;
  80574. private _loadExtensions;
  80575. private _checkExtensions;
  80576. private _setState;
  80577. private _createRootNode;
  80578. /**
  80579. * Loads a glTF scene.
  80580. * @param context The context when loading the asset
  80581. * @param scene The glTF scene property
  80582. * @returns A promise that resolves when the load is complete
  80583. */
  80584. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80585. private _forEachPrimitive;
  80586. private _getMeshes;
  80587. private _getTransformNodes;
  80588. private _getSkeletons;
  80589. private _getAnimationGroups;
  80590. private _startAnimations;
  80591. /**
  80592. * Loads a glTF node.
  80593. * @param context The context when loading the asset
  80594. * @param node The glTF node property
  80595. * @param assign A function called synchronously after parsing the glTF properties
  80596. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80597. */
  80598. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80599. private _loadMeshAsync;
  80600. /**
  80601. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80602. * @param context The context when loading the asset
  80603. * @param name The mesh name when loading the asset
  80604. * @param node The glTF node when loading the asset
  80605. * @param mesh The glTF mesh when loading the asset
  80606. * @param primitive The glTF mesh primitive property
  80607. * @param assign A function called synchronously after parsing the glTF properties
  80608. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80609. */
  80610. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80611. private _loadVertexDataAsync;
  80612. private _createMorphTargets;
  80613. private _loadMorphTargetsAsync;
  80614. private _loadMorphTargetVertexDataAsync;
  80615. private static _LoadTransform;
  80616. private _loadSkinAsync;
  80617. private _loadBones;
  80618. private _loadBone;
  80619. private _loadSkinInverseBindMatricesDataAsync;
  80620. private _updateBoneMatrices;
  80621. private _getNodeMatrix;
  80622. /**
  80623. * Loads a glTF camera.
  80624. * @param context The context when loading the asset
  80625. * @param camera The glTF camera property
  80626. * @param assign A function called synchronously after parsing the glTF properties
  80627. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80628. */
  80629. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80630. private _loadAnimationsAsync;
  80631. /**
  80632. * Loads a glTF animation.
  80633. * @param context The context when loading the asset
  80634. * @param animation The glTF animation property
  80635. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80636. */
  80637. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80638. /**
  80639. * @hidden Loads a glTF animation channel.
  80640. * @param context The context when loading the asset
  80641. * @param animationContext The context of the animation when loading the asset
  80642. * @param animation The glTF animation property
  80643. * @param channel The glTF animation channel property
  80644. * @param babylonAnimationGroup The babylon animation group property
  80645. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80646. * @returns A void promise when the channel load is complete
  80647. */
  80648. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80649. private _loadAnimationSamplerAsync;
  80650. private _loadBufferAsync;
  80651. /**
  80652. * Loads a glTF buffer view.
  80653. * @param context The context when loading the asset
  80654. * @param bufferView The glTF buffer view property
  80655. * @returns A promise that resolves with the loaded data when the load is complete
  80656. */
  80657. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80658. private _loadAccessorAsync;
  80659. /** @hidden */
  80660. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80661. private _loadIndicesAccessorAsync;
  80662. private _loadVertexBufferViewAsync;
  80663. private _loadVertexAccessorAsync;
  80664. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80665. /** @hidden */
  80666. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80667. private _createDefaultMaterial;
  80668. /**
  80669. * Creates a Babylon material from a glTF material.
  80670. * @param context The context when loading the asset
  80671. * @param material The glTF material property
  80672. * @param babylonDrawMode The draw mode for the Babylon material
  80673. * @returns The Babylon material
  80674. */
  80675. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80676. /**
  80677. * Loads properties from a glTF material into a Babylon material.
  80678. * @param context The context when loading the asset
  80679. * @param material The glTF material property
  80680. * @param babylonMaterial The Babylon material
  80681. * @returns A promise that resolves when the load is complete
  80682. */
  80683. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80684. /**
  80685. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80686. * @param context The context when loading the asset
  80687. * @param material The glTF material property
  80688. * @param babylonMaterial The Babylon material
  80689. * @returns A promise that resolves when the load is complete
  80690. */
  80691. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80692. /**
  80693. * Loads the alpha properties from a glTF material into a Babylon material.
  80694. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80695. * @param context The context when loading the asset
  80696. * @param material The glTF material property
  80697. * @param babylonMaterial The Babylon material
  80698. */
  80699. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80700. /**
  80701. * Loads a glTF texture info.
  80702. * @param context The context when loading the asset
  80703. * @param textureInfo The glTF texture info property
  80704. * @param assign A function called synchronously after parsing the glTF properties
  80705. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80706. */
  80707. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80708. /** @hidden */
  80709. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80710. /** @hidden */
  80711. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80712. private _loadSampler;
  80713. /**
  80714. * Loads a glTF image.
  80715. * @param context The context when loading the asset
  80716. * @param image The glTF image property
  80717. * @returns A promise that resolves with the loaded data when the load is complete
  80718. */
  80719. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80720. /**
  80721. * Loads a glTF uri.
  80722. * @param context The context when loading the asset
  80723. * @param property The glTF property associated with the uri
  80724. * @param uri The base64 or relative uri
  80725. * @returns A promise that resolves with the loaded data when the load is complete
  80726. */
  80727. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80728. /**
  80729. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80730. * @param babylonObject the Babylon object with metadata
  80731. * @param pointer the JSON pointer
  80732. */
  80733. static AddPointerMetadata(babylonObject: {
  80734. metadata: any;
  80735. }, pointer: string): void;
  80736. private static _GetTextureWrapMode;
  80737. private static _GetTextureSamplingMode;
  80738. private static _GetTypedArrayConstructor;
  80739. private static _GetTypedArray;
  80740. private static _GetNumComponents;
  80741. private static _ValidateUri;
  80742. /** @hidden */
  80743. static _GetDrawMode(context: string, mode: number | undefined): number;
  80744. private _compileMaterialsAsync;
  80745. private _compileShadowGeneratorsAsync;
  80746. private _forEachExtensions;
  80747. private _applyExtensions;
  80748. private _extensionsOnLoading;
  80749. private _extensionsOnReady;
  80750. private _extensionsLoadSceneAsync;
  80751. private _extensionsLoadNodeAsync;
  80752. private _extensionsLoadCameraAsync;
  80753. private _extensionsLoadVertexDataAsync;
  80754. private _extensionsLoadMeshPrimitiveAsync;
  80755. private _extensionsLoadMaterialAsync;
  80756. private _extensionsCreateMaterial;
  80757. private _extensionsLoadMaterialPropertiesAsync;
  80758. private _extensionsLoadTextureInfoAsync;
  80759. private _extensionsLoadTextureAsync;
  80760. private _extensionsLoadAnimationAsync;
  80761. private _extensionsLoadSkinAsync;
  80762. private _extensionsLoadUriAsync;
  80763. private _extensionsLoadBufferViewAsync;
  80764. private _extensionsLoadBufferAsync;
  80765. /**
  80766. * Helper method called by a loader extension to load an glTF extension.
  80767. * @param context The context when loading the asset
  80768. * @param property The glTF property to load the extension from
  80769. * @param extensionName The name of the extension to load
  80770. * @param actionAsync The action to run
  80771. * @returns The promise returned by actionAsync or null if the extension does not exist
  80772. */
  80773. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80774. /**
  80775. * Helper method called by a loader extension to load a glTF extra.
  80776. * @param context The context when loading the asset
  80777. * @param property The glTF property to load the extra from
  80778. * @param extensionName The name of the extension to load
  80779. * @param actionAsync The action to run
  80780. * @returns The promise returned by actionAsync or null if the extra does not exist
  80781. */
  80782. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80783. /**
  80784. * Checks for presence of an extension.
  80785. * @param name The name of the extension to check
  80786. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80787. */
  80788. isExtensionUsed(name: string): boolean;
  80789. /**
  80790. * Increments the indentation level and logs a message.
  80791. * @param message The message to log
  80792. */
  80793. logOpen(message: string): void;
  80794. /**
  80795. * Decrements the indentation level.
  80796. */
  80797. logClose(): void;
  80798. /**
  80799. * Logs a message
  80800. * @param message The message to log
  80801. */
  80802. log(message: string): void;
  80803. /**
  80804. * Starts a performance counter.
  80805. * @param counterName The name of the performance counter
  80806. */
  80807. startPerformanceCounter(counterName: string): void;
  80808. /**
  80809. * Ends a performance counter.
  80810. * @param counterName The name of the performance counter
  80811. */
  80812. endPerformanceCounter(counterName: string): void;
  80813. }
  80814. }
  80815. declare module BABYLON.GLTF2.Loader.Extensions {
  80816. /** @hidden */
  80817. interface IEXTLightsImageBased_LightImageBased {
  80818. _babylonTexture?: BaseTexture;
  80819. _loaded?: Promise<void>;
  80820. }
  80821. /**
  80822. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80823. */
  80824. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80825. /**
  80826. * The name of this extension.
  80827. */
  80828. readonly name: string;
  80829. /**
  80830. * Defines whether this extension is enabled.
  80831. */
  80832. enabled: boolean;
  80833. private _loader;
  80834. private _lights?;
  80835. /** @hidden */
  80836. constructor(loader: GLTFLoader);
  80837. /** @hidden */
  80838. dispose(): void;
  80839. /** @hidden */
  80840. onLoading(): void;
  80841. /** @hidden */
  80842. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80843. private _loadLightAsync;
  80844. }
  80845. }
  80846. declare module BABYLON.GLTF2.Loader.Extensions {
  80847. /**
  80848. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80849. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80850. * !!! Experimental Extension Subject to Changes !!!
  80851. */
  80852. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80853. /**
  80854. * The name of this extension.
  80855. */
  80856. readonly name: string;
  80857. /**
  80858. * Defines whether this extension is enabled.
  80859. */
  80860. enabled: boolean;
  80861. private _loader;
  80862. /** @hidden */
  80863. constructor(loader: GLTFLoader);
  80864. /** @hidden */
  80865. dispose(): void;
  80866. /** @hidden */
  80867. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80868. }
  80869. }
  80870. declare module BABYLON.GLTF2.Loader.Extensions {
  80871. /**
  80872. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80873. */
  80874. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80875. /**
  80876. * The name of this extension.
  80877. */
  80878. readonly name: string;
  80879. /**
  80880. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80881. */
  80882. dracoCompression?: DracoCompression;
  80883. /**
  80884. * Defines whether this extension is enabled.
  80885. */
  80886. enabled: boolean;
  80887. private _loader;
  80888. /** @hidden */
  80889. constructor(loader: GLTFLoader);
  80890. /** @hidden */
  80891. dispose(): void;
  80892. /** @hidden */
  80893. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80894. }
  80895. }
  80896. declare module BABYLON.GLTF2.Loader.Extensions {
  80897. /**
  80898. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80899. */
  80900. export class KHR_lights implements IGLTFLoaderExtension {
  80901. /**
  80902. * The name of this extension.
  80903. */
  80904. readonly name: string;
  80905. /**
  80906. * Defines whether this extension is enabled.
  80907. */
  80908. enabled: boolean;
  80909. private _loader;
  80910. private _lights?;
  80911. /** @hidden */
  80912. constructor(loader: GLTFLoader);
  80913. /** @hidden */
  80914. dispose(): void;
  80915. /** @hidden */
  80916. onLoading(): void;
  80917. /** @hidden */
  80918. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80919. }
  80920. }
  80921. declare module BABYLON.GLTF2.Loader.Extensions {
  80922. /**
  80923. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80924. */
  80925. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80926. /**
  80927. * The name of this extension.
  80928. */
  80929. readonly name: string;
  80930. /**
  80931. * Defines whether this extension is enabled.
  80932. */
  80933. enabled: boolean;
  80934. /**
  80935. * Defines a number that determines the order the extensions are applied.
  80936. */
  80937. order: number;
  80938. private _loader;
  80939. /** @hidden */
  80940. constructor(loader: GLTFLoader);
  80941. /** @hidden */
  80942. dispose(): void;
  80943. /** @hidden */
  80944. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80945. private _loadSpecularGlossinessPropertiesAsync;
  80946. }
  80947. }
  80948. declare module BABYLON.GLTF2.Loader.Extensions {
  80949. /**
  80950. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80951. */
  80952. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80953. /**
  80954. * The name of this extension.
  80955. */
  80956. readonly name: string;
  80957. /**
  80958. * Defines whether this extension is enabled.
  80959. */
  80960. enabled: boolean;
  80961. /**
  80962. * Defines a number that determines the order the extensions are applied.
  80963. */
  80964. order: number;
  80965. private _loader;
  80966. /** @hidden */
  80967. constructor(loader: GLTFLoader);
  80968. /** @hidden */
  80969. dispose(): void;
  80970. /** @hidden */
  80971. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80972. private _loadUnlitPropertiesAsync;
  80973. }
  80974. }
  80975. declare module BABYLON.GLTF2.Loader.Extensions {
  80976. /**
  80977. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80978. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80979. * !!! Experimental Extension Subject to Changes !!!
  80980. */
  80981. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80982. /**
  80983. * The name of this extension.
  80984. */
  80985. readonly name: string;
  80986. /**
  80987. * Defines whether this extension is enabled.
  80988. */
  80989. enabled: boolean;
  80990. /**
  80991. * Defines a number that determines the order the extensions are applied.
  80992. */
  80993. order: number;
  80994. private _loader;
  80995. /** @hidden */
  80996. constructor(loader: GLTFLoader);
  80997. /** @hidden */
  80998. dispose(): void;
  80999. /** @hidden */
  81000. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81001. private _loadClearCoatPropertiesAsync;
  81002. }
  81003. }
  81004. declare module BABYLON.GLTF2.Loader.Extensions {
  81005. /**
  81006. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81007. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81008. * !!! Experimental Extension Subject to Changes !!!
  81009. */
  81010. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81011. /**
  81012. * The name of this extension.
  81013. */
  81014. readonly name: string;
  81015. /**
  81016. * Defines whether this extension is enabled.
  81017. */
  81018. enabled: boolean;
  81019. /**
  81020. * Defines a number that determines the order the extensions are applied.
  81021. */
  81022. order: number;
  81023. private _loader;
  81024. /** @hidden */
  81025. constructor(loader: GLTFLoader);
  81026. /** @hidden */
  81027. dispose(): void;
  81028. /** @hidden */
  81029. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81030. private _loadSheenPropertiesAsync;
  81031. }
  81032. }
  81033. declare module BABYLON.GLTF2.Loader.Extensions {
  81034. /**
  81035. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81036. * !!! Experimental Extension Subject to Changes !!!
  81037. */
  81038. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81039. /**
  81040. * The name of this extension.
  81041. */
  81042. readonly name: string;
  81043. /**
  81044. * Defines whether this extension is enabled.
  81045. */
  81046. enabled: boolean;
  81047. /**
  81048. * Defines a number that determines the order the extensions are applied.
  81049. */
  81050. order: number;
  81051. private _loader;
  81052. /** @hidden */
  81053. constructor(loader: GLTFLoader);
  81054. /** @hidden */
  81055. dispose(): void;
  81056. /** @hidden */
  81057. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81058. private _loadSpecularPropertiesAsync;
  81059. }
  81060. }
  81061. declare module BABYLON.GLTF2.Loader.Extensions {
  81062. /**
  81063. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  81064. * !!! Experimental Extension Subject to Changes !!!
  81065. */
  81066. export class KHR_materials_ior implements IGLTFLoaderExtension {
  81067. /**
  81068. * Default ior Value from the spec.
  81069. */
  81070. private static readonly _DEFAULT_IOR;
  81071. /**
  81072. * The name of this extension.
  81073. */
  81074. readonly name: string;
  81075. /**
  81076. * Defines whether this extension is enabled.
  81077. */
  81078. enabled: boolean;
  81079. /**
  81080. * Defines a number that determines the order the extensions are applied.
  81081. */
  81082. order: number;
  81083. private _loader;
  81084. /** @hidden */
  81085. constructor(loader: GLTFLoader);
  81086. /** @hidden */
  81087. dispose(): void;
  81088. /** @hidden */
  81089. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81090. private _loadIorPropertiesAsync;
  81091. }
  81092. }
  81093. declare module BABYLON.GLTF2.Loader.Extensions {
  81094. /**
  81095. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  81096. * !!! Experimental Extension Subject to Changes !!!
  81097. */
  81098. export class KHR_materials_variants implements IGLTFLoaderExtension {
  81099. /**
  81100. * The name of this extension.
  81101. */
  81102. readonly name: string;
  81103. /**
  81104. * Defines whether this extension is enabled.
  81105. */
  81106. enabled: boolean;
  81107. private _loader;
  81108. /** @hidden */
  81109. constructor(loader: GLTFLoader);
  81110. /** @hidden */
  81111. dispose(): void;
  81112. /**
  81113. * Gets the list of available variant tag names for this asset.
  81114. * @param rootMesh The glTF root mesh
  81115. * @returns the list of all the variant names for this model
  81116. */
  81117. static GetAvailableVariants(rootMesh: Mesh): string[];
  81118. /**
  81119. * Gets the list of available variant tag names for this asset.
  81120. * @param rootMesh The glTF root mesh
  81121. * @returns the list of all the variant names for this model
  81122. */
  81123. getAvailableVariants(rootMesh: Mesh): string[];
  81124. /**
  81125. * Select a variant given a variant tag name or a list of variant tag names.
  81126. * @param rootMesh The glTF root mesh
  81127. * @param variantName The variant name(s) to select.
  81128. */
  81129. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81130. /**
  81131. * Select a variant given a variant tag name or a list of variant tag names.
  81132. * @param rootMesh The glTF root mesh
  81133. * @param variantName The variant name(s) to select.
  81134. */
  81135. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81136. /**
  81137. * Reset back to the original before selecting a variant.
  81138. * @param rootMesh The glTF root mesh
  81139. */
  81140. static Reset(rootMesh: Mesh): void;
  81141. /**
  81142. * Reset back to the original before selecting a variant.
  81143. * @param rootMesh The glTF root mesh
  81144. */
  81145. reset(rootMesh: Mesh): void;
  81146. /**
  81147. * Gets the last selected variant tag name(s) or null if original.
  81148. * @param rootMesh The glTF root mesh
  81149. * @returns The selected variant tag name(s).
  81150. */
  81151. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81152. /**
  81153. * Gets the last selected variant tag name(s) or null if original.
  81154. * @param rootMesh The glTF root mesh
  81155. * @returns The selected variant tag name(s).
  81156. */
  81157. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81158. private static _GetExtensionMetadata;
  81159. /** @hidden */
  81160. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81161. }
  81162. }
  81163. declare module BABYLON.GLTF2.Loader.Extensions {
  81164. /**
  81165. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  81166. * !!! Experimental Extension Subject to Changes !!!
  81167. */
  81168. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  81169. /**
  81170. * The name of this extension.
  81171. */
  81172. readonly name: string;
  81173. /**
  81174. * Defines whether this extension is enabled.
  81175. */
  81176. enabled: boolean;
  81177. /**
  81178. * Defines a number that determines the order the extensions are applied.
  81179. */
  81180. order: number;
  81181. private _loader;
  81182. /** @hidden */
  81183. constructor(loader: GLTFLoader);
  81184. /** @hidden */
  81185. dispose(): void;
  81186. /** @hidden */
  81187. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81188. private _loadTransparentPropertiesAsync;
  81189. }
  81190. }
  81191. declare module BABYLON.GLTF2.Loader.Extensions {
  81192. /**
  81193. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  81194. */
  81195. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  81196. /**
  81197. * The name of this extension.
  81198. */
  81199. readonly name: string;
  81200. /**
  81201. * Defines whether this extension is enabled.
  81202. */
  81203. enabled: boolean;
  81204. /** @hidden */
  81205. constructor(loader: GLTFLoader);
  81206. /** @hidden */
  81207. dispose(): void;
  81208. }
  81209. }
  81210. declare module BABYLON.GLTF2.Loader.Extensions {
  81211. /**
  81212. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  81213. * !!! Experimental Extension Subject to Changes !!!
  81214. */
  81215. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  81216. /** The name of this extension. */
  81217. readonly name: string;
  81218. /** Defines whether this extension is enabled. */
  81219. enabled: boolean;
  81220. private _loader;
  81221. /** @hidden */
  81222. constructor(loader: GLTFLoader);
  81223. /** @hidden */
  81224. dispose(): void;
  81225. /** @hidden */
  81226. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81227. }
  81228. }
  81229. declare module BABYLON.GLTF2.Loader.Extensions {
  81230. /**
  81231. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  81232. */
  81233. export class KHR_texture_transform implements IGLTFLoaderExtension {
  81234. /**
  81235. * The name of this extension.
  81236. */
  81237. readonly name: string;
  81238. /**
  81239. * Defines whether this extension is enabled.
  81240. */
  81241. enabled: boolean;
  81242. private _loader;
  81243. /** @hidden */
  81244. constructor(loader: GLTFLoader);
  81245. /** @hidden */
  81246. dispose(): void;
  81247. /** @hidden */
  81248. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81249. }
  81250. }
  81251. declare module BABYLON.GLTF2.Loader.Extensions {
  81252. /**
  81253. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  81254. * !!! Experimental Extension Subject to Changes !!!
  81255. */
  81256. export class KHR_xmp implements IGLTFLoaderExtension {
  81257. /**
  81258. * The name of this extension.
  81259. */
  81260. readonly name: string;
  81261. /**
  81262. * Defines whether this extension is enabled.
  81263. */
  81264. enabled: boolean;
  81265. /**
  81266. * Defines a number that determines the order the extensions are applied.
  81267. */
  81268. order: number;
  81269. private _loader;
  81270. /** @hidden */
  81271. constructor(loader: GLTFLoader);
  81272. /** @hidden */
  81273. dispose(): void;
  81274. /**
  81275. * Called after the loader state changes to LOADING.
  81276. */
  81277. onLoading(): void;
  81278. }
  81279. }
  81280. declare module BABYLON.GLTF2.Loader.Extensions {
  81281. /**
  81282. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  81283. */
  81284. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  81285. /**
  81286. * The name of this extension.
  81287. */
  81288. readonly name: string;
  81289. /**
  81290. * Defines whether this extension is enabled.
  81291. */
  81292. enabled: boolean;
  81293. private _loader;
  81294. private _clips;
  81295. private _emitters;
  81296. /** @hidden */
  81297. constructor(loader: GLTFLoader);
  81298. /** @hidden */
  81299. dispose(): void;
  81300. /** @hidden */
  81301. onLoading(): void;
  81302. /** @hidden */
  81303. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81304. /** @hidden */
  81305. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81306. /** @hidden */
  81307. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81308. private _loadClipAsync;
  81309. private _loadEmitterAsync;
  81310. private _getEventAction;
  81311. private _loadAnimationEventAsync;
  81312. }
  81313. }
  81314. declare module BABYLON.GLTF2.Loader.Extensions {
  81315. /**
  81316. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81317. */
  81318. export class MSFT_lod implements IGLTFLoaderExtension {
  81319. /**
  81320. * The name of this extension.
  81321. */
  81322. readonly name: string;
  81323. /**
  81324. * Defines whether this extension is enabled.
  81325. */
  81326. enabled: boolean;
  81327. /**
  81328. * Defines a number that determines the order the extensions are applied.
  81329. */
  81330. order: number;
  81331. /**
  81332. * Maximum number of LODs to load, starting from the lowest LOD.
  81333. */
  81334. maxLODsToLoad: number;
  81335. /**
  81336. * Observable raised when all node LODs of one level are loaded.
  81337. * The event data is the index of the loaded LOD starting from zero.
  81338. * Dispose the loader to cancel the loading of the next level of LODs.
  81339. */
  81340. onNodeLODsLoadedObservable: Observable<number>;
  81341. /**
  81342. * Observable raised when all material LODs of one level are loaded.
  81343. * The event data is the index of the loaded LOD starting from zero.
  81344. * Dispose the loader to cancel the loading of the next level of LODs.
  81345. */
  81346. onMaterialLODsLoadedObservable: Observable<number>;
  81347. private _loader;
  81348. private _bufferLODs;
  81349. private _nodeIndexLOD;
  81350. private _nodeSignalLODs;
  81351. private _nodePromiseLODs;
  81352. private _nodeBufferLODs;
  81353. private _materialIndexLOD;
  81354. private _materialSignalLODs;
  81355. private _materialPromiseLODs;
  81356. private _materialBufferLODs;
  81357. /** @hidden */
  81358. constructor(loader: GLTFLoader);
  81359. /** @hidden */
  81360. dispose(): void;
  81361. /** @hidden */
  81362. onReady(): void;
  81363. /** @hidden */
  81364. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81365. /** @hidden */
  81366. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81367. /** @hidden */
  81368. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81369. /** @hidden */
  81370. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81371. /** @hidden */
  81372. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81373. private _loadBufferLOD;
  81374. /**
  81375. * Gets an array of LOD properties from lowest to highest.
  81376. */
  81377. private _getLODs;
  81378. private _disposeTransformNode;
  81379. private _disposeMaterials;
  81380. }
  81381. }
  81382. declare module BABYLON.GLTF2.Loader.Extensions {
  81383. /** @hidden */
  81384. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81385. readonly name: string;
  81386. enabled: boolean;
  81387. private _loader;
  81388. constructor(loader: GLTFLoader);
  81389. dispose(): void;
  81390. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81391. }
  81392. }
  81393. declare module BABYLON.GLTF2.Loader.Extensions {
  81394. /** @hidden */
  81395. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81396. readonly name: string;
  81397. enabled: boolean;
  81398. private _loader;
  81399. constructor(loader: GLTFLoader);
  81400. dispose(): void;
  81401. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81402. }
  81403. }
  81404. declare module BABYLON.GLTF2.Loader.Extensions {
  81405. /**
  81406. * Store glTF extras (if present) in BJS objects' metadata
  81407. */
  81408. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81409. /**
  81410. * The name of this extension.
  81411. */
  81412. readonly name: string;
  81413. /**
  81414. * Defines whether this extension is enabled.
  81415. */
  81416. enabled: boolean;
  81417. private _loader;
  81418. private _assignExtras;
  81419. /** @hidden */
  81420. constructor(loader: GLTFLoader);
  81421. /** @hidden */
  81422. dispose(): void;
  81423. /** @hidden */
  81424. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81425. /** @hidden */
  81426. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81427. /** @hidden */
  81428. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81429. }
  81430. }
  81431. declare module BABYLON {
  81432. /**
  81433. * Class reading and parsing the MTL file bundled with the obj file.
  81434. */
  81435. export class MTLFileLoader {
  81436. /**
  81437. * Invert Y-Axis of referenced textures on load
  81438. */
  81439. static INVERT_TEXTURE_Y: boolean;
  81440. /**
  81441. * All material loaded from the mtl will be set here
  81442. */
  81443. materials: StandardMaterial[];
  81444. /**
  81445. * This function will read the mtl file and create each material described inside
  81446. * This function could be improve by adding :
  81447. * -some component missing (Ni, Tf...)
  81448. * -including the specific options available
  81449. *
  81450. * @param scene defines the scene the material will be created in
  81451. * @param data defines the mtl data to parse
  81452. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81453. * @param forAssetContainer defines if the material should be registered in the scene
  81454. */
  81455. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81456. /**
  81457. * Gets the texture for the material.
  81458. *
  81459. * If the material is imported from input file,
  81460. * We sanitize the url to ensure it takes the textre from aside the material.
  81461. *
  81462. * @param rootUrl The root url to load from
  81463. * @param value The value stored in the mtl
  81464. * @return The Texture
  81465. */
  81466. private static _getTexture;
  81467. }
  81468. }
  81469. declare module BABYLON {
  81470. /**
  81471. * Options for loading OBJ/MTL files
  81472. */
  81473. type MeshLoadOptions = {
  81474. /**
  81475. * Defines if UVs are optimized by default during load.
  81476. */
  81477. OptimizeWithUV: boolean;
  81478. /**
  81479. * Defines custom scaling of UV coordinates of loaded meshes.
  81480. */
  81481. UVScaling: Vector2;
  81482. /**
  81483. * Invert model on y-axis (does a model scaling inversion)
  81484. */
  81485. InvertY: boolean;
  81486. /**
  81487. * Invert Y-Axis of referenced textures on load
  81488. */
  81489. InvertTextureY: boolean;
  81490. /**
  81491. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81492. */
  81493. ImportVertexColors: boolean;
  81494. /**
  81495. * Compute the normals for the model, even if normals are present in the file.
  81496. */
  81497. ComputeNormals: boolean;
  81498. /**
  81499. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81500. */
  81501. SkipMaterials: boolean;
  81502. /**
  81503. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81504. */
  81505. MaterialLoadingFailsSilently: boolean;
  81506. };
  81507. /**
  81508. * OBJ file type loader.
  81509. * This is a babylon scene loader plugin.
  81510. */
  81511. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81512. /**
  81513. * Defines if UVs are optimized by default during load.
  81514. */
  81515. static OPTIMIZE_WITH_UV: boolean;
  81516. /**
  81517. * Invert model on y-axis (does a model scaling inversion)
  81518. */
  81519. static INVERT_Y: boolean;
  81520. /**
  81521. * Invert Y-Axis of referenced textures on load
  81522. */
  81523. static get INVERT_TEXTURE_Y(): boolean;
  81524. static set INVERT_TEXTURE_Y(value: boolean);
  81525. /**
  81526. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81527. */
  81528. static IMPORT_VERTEX_COLORS: boolean;
  81529. /**
  81530. * Compute the normals for the model, even if normals are present in the file.
  81531. */
  81532. static COMPUTE_NORMALS: boolean;
  81533. /**
  81534. * Defines custom scaling of UV coordinates of loaded meshes.
  81535. */
  81536. static UV_SCALING: Vector2;
  81537. /**
  81538. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81539. */
  81540. static SKIP_MATERIALS: boolean;
  81541. /**
  81542. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81543. *
  81544. * Defaults to true for backwards compatibility.
  81545. */
  81546. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81547. /**
  81548. * Defines the name of the plugin.
  81549. */
  81550. name: string;
  81551. /**
  81552. * Defines the extension the plugin is able to load.
  81553. */
  81554. extensions: string;
  81555. /** @hidden */
  81556. obj: RegExp;
  81557. /** @hidden */
  81558. group: RegExp;
  81559. /** @hidden */
  81560. mtllib: RegExp;
  81561. /** @hidden */
  81562. usemtl: RegExp;
  81563. /** @hidden */
  81564. smooth: RegExp;
  81565. /** @hidden */
  81566. vertexPattern: RegExp;
  81567. /** @hidden */
  81568. normalPattern: RegExp;
  81569. /** @hidden */
  81570. uvPattern: RegExp;
  81571. /** @hidden */
  81572. facePattern1: RegExp;
  81573. /** @hidden */
  81574. facePattern2: RegExp;
  81575. /** @hidden */
  81576. facePattern3: RegExp;
  81577. /** @hidden */
  81578. facePattern4: RegExp;
  81579. /** @hidden */
  81580. facePattern5: RegExp;
  81581. private _forAssetContainer;
  81582. private _meshLoadOptions;
  81583. /**
  81584. * Creates loader for .OBJ files
  81585. *
  81586. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81587. */
  81588. constructor(meshLoadOptions?: MeshLoadOptions);
  81589. private static get currentMeshLoadOptions();
  81590. /**
  81591. * Calls synchronously the MTL file attached to this obj.
  81592. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81593. * Without this function materials are not displayed in the first frame (but displayed after).
  81594. * In consequence it is impossible to get material information in your HTML file
  81595. *
  81596. * @param url The URL of the MTL file
  81597. * @param rootUrl
  81598. * @param onSuccess Callback function to be called when the MTL file is loaded
  81599. * @private
  81600. */
  81601. private _loadMTL;
  81602. /**
  81603. * Instantiates a OBJ file loader plugin.
  81604. * @returns the created plugin
  81605. */
  81606. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81607. /**
  81608. * If the data string can be loaded directly.
  81609. *
  81610. * @param data string containing the file data
  81611. * @returns if the data can be loaded directly
  81612. */
  81613. canDirectLoad(data: string): boolean;
  81614. /**
  81615. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81616. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81617. * @param scene the scene the meshes should be added to
  81618. * @param data the OBJ data to load
  81619. * @param rootUrl root url to load from
  81620. * @param onProgress event that fires when loading progress has occured
  81621. * @param fileName Defines the name of the file to load
  81622. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81623. */
  81624. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81625. meshes: AbstractMesh[];
  81626. particleSystems: IParticleSystem[];
  81627. skeletons: Skeleton[];
  81628. animationGroups: AnimationGroup[];
  81629. }>;
  81630. /**
  81631. * Imports all objects from the loaded OBJ data and adds them to the scene
  81632. * @param scene the scene the objects should be added to
  81633. * @param data the OBJ data to load
  81634. * @param rootUrl root url to load from
  81635. * @param onProgress event that fires when loading progress has occured
  81636. * @param fileName Defines the name of the file to load
  81637. * @returns a promise which completes when objects have been loaded to the scene
  81638. */
  81639. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81640. /**
  81641. * Load into an asset container.
  81642. * @param scene The scene to load into
  81643. * @param data The data to import
  81644. * @param rootUrl The root url for scene and resources
  81645. * @param onProgress The callback when the load progresses
  81646. * @param fileName Defines the name of the file to load
  81647. * @returns The loaded asset container
  81648. */
  81649. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81650. /**
  81651. * Read the OBJ file and create an Array of meshes.
  81652. * Each mesh contains all information given by the OBJ and the MTL file.
  81653. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81654. *
  81655. * @param meshesNames
  81656. * @param scene Scene The scene where are displayed the data
  81657. * @param data String The content of the obj file
  81658. * @param rootUrl String The path to the folder
  81659. * @returns Array<AbstractMesh>
  81660. * @private
  81661. */
  81662. private _parseSolid;
  81663. }
  81664. }
  81665. declare module BABYLON {
  81666. /**
  81667. * STL file type loader.
  81668. * This is a babylon scene loader plugin.
  81669. */
  81670. export class STLFileLoader implements ISceneLoaderPlugin {
  81671. /** @hidden */
  81672. solidPattern: RegExp;
  81673. /** @hidden */
  81674. facetsPattern: RegExp;
  81675. /** @hidden */
  81676. normalPattern: RegExp;
  81677. /** @hidden */
  81678. vertexPattern: RegExp;
  81679. /**
  81680. * Defines the name of the plugin.
  81681. */
  81682. name: string;
  81683. /**
  81684. * Defines the extensions the stl loader is able to load.
  81685. * force data to come in as an ArrayBuffer
  81686. * we'll convert to string if it looks like it's an ASCII .stl
  81687. */
  81688. extensions: ISceneLoaderPluginExtensions;
  81689. /**
  81690. * Import meshes into a scene.
  81691. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81692. * @param scene The scene to import into
  81693. * @param data The data to import
  81694. * @param rootUrl The root url for scene and resources
  81695. * @param meshes The meshes array to import into
  81696. * @param particleSystems The particle systems array to import into
  81697. * @param skeletons The skeletons array to import into
  81698. * @param onError The callback when import fails
  81699. * @returns True if successful or false otherwise
  81700. */
  81701. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81702. /**
  81703. * Load into a scene.
  81704. * @param scene The scene to load into
  81705. * @param data The data to import
  81706. * @param rootUrl The root url for scene and resources
  81707. * @param onError The callback when import fails
  81708. * @returns true if successful or false otherwise
  81709. */
  81710. load(scene: Scene, data: any, rootUrl: string): boolean;
  81711. /**
  81712. * Load into an asset container.
  81713. * @param scene The scene to load into
  81714. * @param data The data to import
  81715. * @param rootUrl The root url for scene and resources
  81716. * @param onError The callback when import fails
  81717. * @returns The loaded asset container
  81718. */
  81719. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81720. private _isBinary;
  81721. private _parseBinary;
  81722. private _parseASCII;
  81723. }
  81724. }
  81725. declare module BABYLON {
  81726. /**
  81727. * Class for generating OBJ data from a Babylon scene.
  81728. */
  81729. export class OBJExport {
  81730. /**
  81731. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81732. * @param mesh defines the list of meshes to serialize
  81733. * @param materials defines if materials should be exported
  81734. * @param matlibname defines the name of the associated mtl file
  81735. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81736. * @returns the OBJ content
  81737. */
  81738. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81739. /**
  81740. * Exports the material(s) of a mesh in .MTL file format (text)
  81741. * @param mesh defines the mesh to extract the material from
  81742. * @returns the mtl content
  81743. */
  81744. static MTL(mesh: Mesh): string;
  81745. }
  81746. }
  81747. declare module BABYLON {
  81748. /** @hidden */
  81749. export var __IGLTFExporterExtension: number;
  81750. /**
  81751. * Interface for extending the exporter
  81752. * @hidden
  81753. */
  81754. export interface IGLTFExporterExtension {
  81755. /**
  81756. * The name of this extension
  81757. */
  81758. readonly name: string;
  81759. /**
  81760. * Defines whether this extension is enabled
  81761. */
  81762. enabled: boolean;
  81763. /**
  81764. * Defines whether this extension is required
  81765. */
  81766. required: boolean;
  81767. }
  81768. }
  81769. declare module BABYLON.GLTF2.Exporter {
  81770. /** @hidden */
  81771. export var __IGLTFExporterExtensionV2: number;
  81772. /**
  81773. * Interface for a glTF exporter extension
  81774. * @hidden
  81775. */
  81776. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81777. /**
  81778. * Define this method to modify the default behavior before exporting a texture
  81779. * @param context The context when loading the asset
  81780. * @param babylonTexture The Babylon.js texture
  81781. * @param mimeType The mime-type of the generated image
  81782. * @returns A promise that resolves with the exported texture
  81783. */
  81784. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81785. /**
  81786. * Define this method to get notified when a texture info is created
  81787. * @param context The context when loading the asset
  81788. * @param textureInfo The glTF texture info
  81789. * @param babylonTexture The Babylon.js texture
  81790. */
  81791. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81792. /**
  81793. * Define this method to modify the default behavior when exporting texture info
  81794. * @param context The context when loading the asset
  81795. * @param meshPrimitive glTF mesh primitive
  81796. * @param babylonSubMesh Babylon submesh
  81797. * @param binaryWriter glTF serializer binary writer instance
  81798. * @returns nullable IMeshPrimitive promise
  81799. */
  81800. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81801. /**
  81802. * Define this method to modify the default behavior when exporting a node
  81803. * @param context The context when exporting the node
  81804. * @param node glTF node
  81805. * @param babylonNode BabylonJS node
  81806. * @returns nullable INode promise
  81807. */
  81808. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81809. [key: number]: number;
  81810. }): Promise<Nullable<INode>>;
  81811. /**
  81812. * Define this method to modify the default behavior when exporting a material
  81813. * @param material glTF material
  81814. * @param babylonMaterial BabylonJS material
  81815. * @returns nullable IMaterial promise
  81816. */
  81817. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81818. /**
  81819. * Define this method to return additional textures to export from a material
  81820. * @param material glTF material
  81821. * @param babylonMaterial BabylonJS material
  81822. * @returns List of textures
  81823. */
  81824. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81825. /** Gets a boolean indicating that this extension was used */
  81826. wasUsed: boolean;
  81827. /** Gets a boolean indicating that this extension is required for the file to work */
  81828. required: boolean;
  81829. /**
  81830. * Called after the exporter state changes to EXPORTING
  81831. */
  81832. onExporting?(): void;
  81833. }
  81834. }
  81835. declare module BABYLON.GLTF2.Exporter {
  81836. /**
  81837. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81838. * @hidden
  81839. */
  81840. export class _GLTFMaterialExporter {
  81841. /**
  81842. * Represents the dielectric specular values for R, G and B
  81843. */
  81844. private static readonly _DielectricSpecular;
  81845. /**
  81846. * Allows the maximum specular power to be defined for material calculations
  81847. */
  81848. private static readonly _MaxSpecularPower;
  81849. /**
  81850. * Mapping to store textures
  81851. */
  81852. private _textureMap;
  81853. /**
  81854. * Numeric tolerance value
  81855. */
  81856. private static readonly _Epsilon;
  81857. /**
  81858. * Reference to the glTF Exporter
  81859. */
  81860. private _exporter;
  81861. constructor(exporter: _Exporter);
  81862. /**
  81863. * Specifies if two colors are approximately equal in value
  81864. * @param color1 first color to compare to
  81865. * @param color2 second color to compare to
  81866. * @param epsilon threshold value
  81867. */
  81868. private static FuzzyEquals;
  81869. /**
  81870. * Gets the materials from a Babylon scene and converts them to glTF materials
  81871. * @param scene babylonjs scene
  81872. * @param mimeType texture mime type
  81873. * @param images array of images
  81874. * @param textures array of textures
  81875. * @param materials array of materials
  81876. * @param imageData mapping of texture names to base64 textures
  81877. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81878. */
  81879. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81880. /**
  81881. * Makes a copy of the glTF material without the texture parameters
  81882. * @param originalMaterial original glTF material
  81883. * @returns glTF material without texture parameters
  81884. */
  81885. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81886. /**
  81887. * Specifies if the material has any texture parameters present
  81888. * @param material glTF Material
  81889. * @returns boolean specifying if texture parameters are present
  81890. */
  81891. _hasTexturesPresent(material: IMaterial): boolean;
  81892. /**
  81893. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81894. * @param babylonStandardMaterial
  81895. * @returns glTF Metallic Roughness Material representation
  81896. */
  81897. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81898. /**
  81899. * Computes the metallic factor
  81900. * @param diffuse diffused value
  81901. * @param specular specular value
  81902. * @param oneMinusSpecularStrength one minus the specular strength
  81903. * @returns metallic value
  81904. */
  81905. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81906. /**
  81907. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81908. * @param glTFMaterial glTF material
  81909. * @param babylonMaterial Babylon material
  81910. */
  81911. private static _SetAlphaMode;
  81912. /**
  81913. * Converts a Babylon Standard Material to a glTF Material
  81914. * @param babylonStandardMaterial BJS Standard Material
  81915. * @param mimeType mime type to use for the textures
  81916. * @param images array of glTF image interfaces
  81917. * @param textures array of glTF texture interfaces
  81918. * @param materials array of glTF material interfaces
  81919. * @param imageData map of image file name to data
  81920. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81921. */
  81922. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81923. private _finishMaterial;
  81924. /**
  81925. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81926. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81927. * @param mimeType mime type to use for the textures
  81928. * @param images array of glTF image interfaces
  81929. * @param textures array of glTF texture interfaces
  81930. * @param materials array of glTF material interfaces
  81931. * @param imageData map of image file name to data
  81932. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81933. */
  81934. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81935. /**
  81936. * Converts an image typed array buffer to a base64 image
  81937. * @param buffer typed array buffer
  81938. * @param width width of the image
  81939. * @param height height of the image
  81940. * @param mimeType mimetype of the image
  81941. * @returns base64 image string
  81942. */
  81943. private _createBase64FromCanvasAsync;
  81944. /**
  81945. * Generates a white texture based on the specified width and height
  81946. * @param width width of the texture in pixels
  81947. * @param height height of the texture in pixels
  81948. * @param scene babylonjs scene
  81949. * @returns white texture
  81950. */
  81951. private _createWhiteTexture;
  81952. /**
  81953. * 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
  81954. * @param texture1 first texture to resize
  81955. * @param texture2 second texture to resize
  81956. * @param scene babylonjs scene
  81957. * @returns resized textures or null
  81958. */
  81959. private _resizeTexturesToSameDimensions;
  81960. /**
  81961. * Converts an array of pixels to a Float32Array
  81962. * Throws an error if the pixel format is not supported
  81963. * @param pixels - array buffer containing pixel values
  81964. * @returns Float32 of pixels
  81965. */
  81966. private _convertPixelArrayToFloat32;
  81967. /**
  81968. * Convert Specular Glossiness Textures to Metallic Roughness
  81969. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81970. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81971. * @param diffuseTexture texture used to store diffuse information
  81972. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81973. * @param factors specular glossiness material factors
  81974. * @param mimeType the mime type to use for the texture
  81975. * @returns pbr metallic roughness interface or null
  81976. */
  81977. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81978. /**
  81979. * Converts specular glossiness material properties to metallic roughness
  81980. * @param specularGlossiness interface with specular glossiness material properties
  81981. * @returns interface with metallic roughness material properties
  81982. */
  81983. private _convertSpecularGlossinessToMetallicRoughness;
  81984. /**
  81985. * Calculates the surface reflectance, independent of lighting conditions
  81986. * @param color Color source to calculate brightness from
  81987. * @returns number representing the perceived brightness, or zero if color is undefined
  81988. */
  81989. private _getPerceivedBrightness;
  81990. /**
  81991. * Returns the maximum color component value
  81992. * @param color
  81993. * @returns maximum color component value, or zero if color is null or undefined
  81994. */
  81995. private _getMaxComponent;
  81996. /**
  81997. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81998. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81999. * @param mimeType mime type to use for the textures
  82000. * @param images array of glTF image interfaces
  82001. * @param textures array of glTF texture interfaces
  82002. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82003. * @param imageData map of image file name to data
  82004. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82005. * @returns glTF PBR Metallic Roughness factors
  82006. */
  82007. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82008. private _getGLTFTextureSampler;
  82009. private _getGLTFTextureWrapMode;
  82010. private _getGLTFTextureWrapModesSampler;
  82011. /**
  82012. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82013. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82014. * @param mimeType mime type to use for the textures
  82015. * @param images array of glTF image interfaces
  82016. * @param textures array of glTF texture interfaces
  82017. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82018. * @param imageData map of image file name to data
  82019. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82020. * @returns glTF PBR Metallic Roughness factors
  82021. */
  82022. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82023. /**
  82024. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82025. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82026. * @param mimeType mime type to use for the textures
  82027. * @param images array of glTF image interfaces
  82028. * @param textures array of glTF texture interfaces
  82029. * @param materials array of glTF material interfaces
  82030. * @param imageData map of image file name to data
  82031. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82032. */
  82033. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82034. private setMetallicRoughnessPbrMaterial;
  82035. private getPixelsFromTexture;
  82036. /**
  82037. * Extracts a texture from a Babylon texture into file data and glTF data
  82038. * @param babylonTexture Babylon texture to extract
  82039. * @param mimeType Mime Type of the babylonTexture
  82040. * @return glTF texture info, or null if the texture format is not supported
  82041. */
  82042. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82043. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82044. /**
  82045. * Builds a texture from base64 string
  82046. * @param base64Texture base64 texture string
  82047. * @param baseTextureName Name to use for the texture
  82048. * @param mimeType image mime type for the texture
  82049. * @param images array of images
  82050. * @param textures array of textures
  82051. * @param imageData map of image data
  82052. * @returns glTF texture info, or null if the texture format is not supported
  82053. */
  82054. private _getTextureInfoFromBase64;
  82055. }
  82056. }
  82057. declare module BABYLON {
  82058. /**
  82059. * Class for holding and downloading glTF file data
  82060. */
  82061. export class GLTFData {
  82062. /**
  82063. * Object which contains the file name as the key and its data as the value
  82064. */
  82065. glTFFiles: {
  82066. [fileName: string]: string | Blob;
  82067. };
  82068. /**
  82069. * Initializes the glTF file object
  82070. */
  82071. constructor();
  82072. /**
  82073. * Downloads the glTF data as files based on their names and data
  82074. */
  82075. downloadFiles(): void;
  82076. }
  82077. }
  82078. declare module BABYLON {
  82079. /**
  82080. * Holds a collection of exporter options and parameters
  82081. */
  82082. export interface IExportOptions {
  82083. /**
  82084. * Function which indicates whether a babylon node should be exported or not
  82085. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  82086. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  82087. */
  82088. shouldExportNode?(node: Node): boolean;
  82089. /**
  82090. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  82091. * @param metadata source metadata to read from
  82092. * @returns the data to store to glTF node extras
  82093. */
  82094. metadataSelector?(metadata: any): any;
  82095. /**
  82096. * The sample rate to bake animation curves
  82097. */
  82098. animationSampleRate?: number;
  82099. /**
  82100. * Begin serialization without waiting for the scene to be ready
  82101. */
  82102. exportWithoutWaitingForScene?: boolean;
  82103. /**
  82104. * Indicates if coordinate system swapping root nodes should be included in export
  82105. */
  82106. includeCoordinateSystemConversionNodes?: boolean;
  82107. }
  82108. /**
  82109. * Class for generating glTF data from a Babylon scene.
  82110. */
  82111. export class GLTF2Export {
  82112. /**
  82113. * Exports the geometry of the scene to .gltf file format asynchronously
  82114. * @param scene Babylon scene with scene hierarchy information
  82115. * @param filePrefix File prefix to use when generating the glTF file
  82116. * @param options Exporter options
  82117. * @returns Returns an object with a .gltf file and associates texture names
  82118. * as keys and their data and paths as values
  82119. */
  82120. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82121. private static _PreExportAsync;
  82122. private static _PostExportAsync;
  82123. /**
  82124. * Exports the geometry of the scene to .glb file format asychronously
  82125. * @param scene Babylon scene with scene hierarchy information
  82126. * @param filePrefix File prefix to use when generating glb file
  82127. * @param options Exporter options
  82128. * @returns Returns an object with a .glb filename as key and data as value
  82129. */
  82130. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82131. }
  82132. }
  82133. declare module BABYLON.GLTF2.Exporter {
  82134. /**
  82135. * @hidden
  82136. */
  82137. export class _GLTFUtilities {
  82138. /**
  82139. * Creates a buffer view based on the supplied arguments
  82140. * @param bufferIndex index value of the specified buffer
  82141. * @param byteOffset byte offset value
  82142. * @param byteLength byte length of the bufferView
  82143. * @param byteStride byte distance between conequential elements
  82144. * @param name name of the buffer view
  82145. * @returns bufferView for glTF
  82146. */
  82147. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  82148. /**
  82149. * Creates an accessor based on the supplied arguments
  82150. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  82151. * @param name The name of the accessor
  82152. * @param type The type of the accessor
  82153. * @param componentType The datatype of components in the attribute
  82154. * @param count The number of attributes referenced by this accessor
  82155. * @param byteOffset The offset relative to the start of the bufferView in bytes
  82156. * @param min Minimum value of each component in this attribute
  82157. * @param max Maximum value of each component in this attribute
  82158. * @returns accessor for glTF
  82159. */
  82160. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  82161. /**
  82162. * Calculates the minimum and maximum values of an array of position floats
  82163. * @param positions Positions array of a mesh
  82164. * @param vertexStart Starting vertex offset to calculate min and max values
  82165. * @param vertexCount Number of vertices to check for min and max values
  82166. * @returns min number array and max number array
  82167. */
  82168. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  82169. min: number[];
  82170. max: number[];
  82171. };
  82172. /**
  82173. * Converts a new right-handed Vector3
  82174. * @param vector vector3 array
  82175. * @returns right-handed Vector3
  82176. */
  82177. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  82178. /**
  82179. * Converts a Vector3 to right-handed
  82180. * @param vector Vector3 to convert to right-handed
  82181. */
  82182. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  82183. /**
  82184. * Converts a three element number array to right-handed
  82185. * @param vector number array to convert to right-handed
  82186. */
  82187. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  82188. /**
  82189. * Converts a new right-handed Vector3
  82190. * @param vector vector3 array
  82191. * @returns right-handed Vector3
  82192. */
  82193. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  82194. /**
  82195. * Converts a Vector3 to right-handed
  82196. * @param vector Vector3 to convert to right-handed
  82197. */
  82198. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  82199. /**
  82200. * Converts a three element number array to right-handed
  82201. * @param vector number array to convert to right-handed
  82202. */
  82203. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  82204. /**
  82205. * Converts a Vector4 to right-handed
  82206. * @param vector Vector4 to convert to right-handed
  82207. */
  82208. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  82209. /**
  82210. * Converts a Vector4 to right-handed
  82211. * @param vector Vector4 to convert to right-handed
  82212. */
  82213. static _GetRightHandedArray4FromRef(vector: number[]): void;
  82214. /**
  82215. * Converts a Quaternion to right-handed
  82216. * @param quaternion Source quaternion to convert to right-handed
  82217. */
  82218. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  82219. /**
  82220. * Converts a Quaternion to right-handed
  82221. * @param quaternion Source quaternion to convert to right-handed
  82222. */
  82223. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  82224. static _NormalizeTangentFromRef(tangent: Vector4): void;
  82225. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  82226. }
  82227. }
  82228. declare module BABYLON.GLTF2.Exporter {
  82229. /**
  82230. * Converts Babylon Scene into glTF 2.0.
  82231. * @hidden
  82232. */
  82233. export class _Exporter {
  82234. /**
  82235. * Stores the glTF to export
  82236. */
  82237. _glTF: IGLTF;
  82238. /**
  82239. * Stores all generated buffer views, which represents views into the main glTF buffer data
  82240. */
  82241. _bufferViews: IBufferView[];
  82242. /**
  82243. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  82244. */
  82245. _accessors: IAccessor[];
  82246. /**
  82247. * Stores all the generated nodes, which contains transform and/or mesh information per node
  82248. */
  82249. _nodes: INode[];
  82250. /**
  82251. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  82252. */
  82253. private _scenes;
  82254. /**
  82255. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  82256. */
  82257. private _meshes;
  82258. /**
  82259. * Stores all the generated material information, which represents the appearance of each primitive
  82260. */
  82261. _materials: IMaterial[];
  82262. _materialMap: {
  82263. [materialID: number]: number;
  82264. };
  82265. /**
  82266. * Stores all the generated texture information, which is referenced by glTF materials
  82267. */
  82268. _textures: ITexture[];
  82269. /**
  82270. * Stores all the generated image information, which is referenced by glTF textures
  82271. */
  82272. _images: IImage[];
  82273. /**
  82274. * Stores all the texture samplers
  82275. */
  82276. _samplers: ISampler[];
  82277. /**
  82278. * Stores all the generated glTF skins
  82279. */
  82280. _skins: ISkin[];
  82281. /**
  82282. * Stores all the generated animation samplers, which is referenced by glTF animations
  82283. */
  82284. /**
  82285. * Stores the animations for glTF models
  82286. */
  82287. private _animations;
  82288. /**
  82289. * Stores the total amount of bytes stored in the glTF buffer
  82290. */
  82291. private _totalByteLength;
  82292. /**
  82293. * Stores a reference to the Babylon scene containing the source geometry and material information
  82294. */
  82295. _babylonScene: Scene;
  82296. /**
  82297. * Stores a map of the image data, where the key is the file name and the value
  82298. * is the image data
  82299. */
  82300. _imageData: {
  82301. [fileName: string]: {
  82302. data: Uint8Array;
  82303. mimeType: ImageMimeType;
  82304. };
  82305. };
  82306. /**
  82307. * Stores a map of the unique id of a node to its index in the node array
  82308. */
  82309. _nodeMap: {
  82310. [key: number]: number;
  82311. };
  82312. /**
  82313. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82314. */
  82315. _convertToRightHandedSystem: boolean;
  82316. /**
  82317. * Specifies if a Babylon node should be converted to right-handed on export
  82318. */
  82319. _convertToRightHandedSystemMap: {
  82320. [nodeId: number]: boolean;
  82321. };
  82322. _includeCoordinateSystemConversionNodes: boolean;
  82323. /**
  82324. * Baked animation sample rate
  82325. */
  82326. private _animationSampleRate;
  82327. private _options;
  82328. private _localEngine;
  82329. _glTFMaterialExporter: _GLTFMaterialExporter;
  82330. private _extensions;
  82331. private static _ExtensionNames;
  82332. private static _ExtensionFactories;
  82333. private _applyExtension;
  82334. private _applyExtensions;
  82335. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82336. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82337. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82338. [key: number]: number;
  82339. }): Promise<Nullable<INode>>;
  82340. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82341. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82342. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82343. private _forEachExtensions;
  82344. private _extensionsOnExporting;
  82345. /**
  82346. * Load glTF serializer extensions
  82347. */
  82348. private _loadExtensions;
  82349. /**
  82350. * Creates a glTF Exporter instance, which can accept optional exporter options
  82351. * @param babylonScene Babylon scene object
  82352. * @param options Options to modify the behavior of the exporter
  82353. */
  82354. constructor(babylonScene: Scene, options?: IExportOptions);
  82355. dispose(): void;
  82356. /**
  82357. * Registers a glTF exporter extension
  82358. * @param name Name of the extension to export
  82359. * @param factory The factory function that creates the exporter extension
  82360. */
  82361. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82362. /**
  82363. * Un-registers an exporter extension
  82364. * @param name The name fo the exporter extension
  82365. * @returns A boolean indicating whether the extension has been un-registered
  82366. */
  82367. static UnregisterExtension(name: string): boolean;
  82368. /**
  82369. * Lazy load a local engine
  82370. */
  82371. _getLocalEngine(): Engine;
  82372. private reorderIndicesBasedOnPrimitiveMode;
  82373. /**
  82374. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82375. * clock-wise during export to glTF
  82376. * @param submesh BabylonJS submesh
  82377. * @param primitiveMode Primitive mode of the mesh
  82378. * @param sideOrientation the winding order of the submesh
  82379. * @param vertexBufferKind The type of vertex attribute
  82380. * @param meshAttributeArray The vertex attribute data
  82381. * @param byteOffset The offset to the binary data
  82382. * @param binaryWriter The binary data for the glTF file
  82383. * @param convertToRightHandedSystem Converts the values to right-handed
  82384. */
  82385. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82386. /**
  82387. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82388. * clock-wise during export to glTF
  82389. * @param submesh BabylonJS submesh
  82390. * @param primitiveMode Primitive mode of the mesh
  82391. * @param sideOrientation the winding order of the submesh
  82392. * @param vertexBufferKind The type of vertex attribute
  82393. * @param meshAttributeArray The vertex attribute data
  82394. * @param byteOffset The offset to the binary data
  82395. * @param binaryWriter The binary data for the glTF file
  82396. * @param convertToRightHandedSystem Converts the values to right-handed
  82397. */
  82398. private reorderTriangleFillMode;
  82399. /**
  82400. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82401. * clock-wise during export to glTF
  82402. * @param submesh BabylonJS submesh
  82403. * @param primitiveMode Primitive mode of the mesh
  82404. * @param sideOrientation the winding order of the submesh
  82405. * @param vertexBufferKind The type of vertex attribute
  82406. * @param meshAttributeArray The vertex attribute data
  82407. * @param byteOffset The offset to the binary data
  82408. * @param binaryWriter The binary data for the glTF file
  82409. * @param convertToRightHandedSystem Converts the values to right-handed
  82410. */
  82411. private reorderTriangleStripDrawMode;
  82412. /**
  82413. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82414. * clock-wise during export to glTF
  82415. * @param submesh BabylonJS submesh
  82416. * @param primitiveMode Primitive mode of the mesh
  82417. * @param sideOrientation the winding order of the submesh
  82418. * @param vertexBufferKind The type of vertex attribute
  82419. * @param meshAttributeArray The vertex attribute data
  82420. * @param byteOffset The offset to the binary data
  82421. * @param binaryWriter The binary data for the glTF file
  82422. * @param convertToRightHandedSystem Converts the values to right-handed
  82423. */
  82424. private reorderTriangleFanMode;
  82425. /**
  82426. * Writes the vertex attribute data to binary
  82427. * @param vertices The vertices to write to the binary writer
  82428. * @param byteOffset The offset into the binary writer to overwrite binary data
  82429. * @param vertexAttributeKind The vertex attribute type
  82430. * @param meshAttributeArray The vertex attribute data
  82431. * @param binaryWriter The writer containing the binary data
  82432. * @param convertToRightHandedSystem Converts the values to right-handed
  82433. */
  82434. private writeVertexAttributeData;
  82435. /**
  82436. * Writes mesh attribute data to a data buffer
  82437. * Returns the bytelength of the data
  82438. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82439. * @param meshAttributeArray Array containing the attribute data
  82440. * @param byteStride Specifies the space between data
  82441. * @param binaryWriter The buffer to write the binary data to
  82442. * @param convertToRightHandedSystem Converts the values to right-handed
  82443. */
  82444. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  82445. /**
  82446. * Generates glTF json data
  82447. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82448. * @param glTFPrefix Text to use when prefixing a glTF file
  82449. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82450. * @returns json data as string
  82451. */
  82452. private generateJSON;
  82453. /**
  82454. * Generates data for .gltf and .bin files based on the glTF prefix string
  82455. * @param glTFPrefix Text to use when prefixing a glTF file
  82456. * @param dispose Dispose the exporter
  82457. * @returns GLTFData with glTF file data
  82458. */
  82459. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82460. /**
  82461. * Creates a binary buffer for glTF
  82462. * @returns array buffer for binary data
  82463. */
  82464. private _generateBinaryAsync;
  82465. /**
  82466. * Pads the number to a multiple of 4
  82467. * @param num number to pad
  82468. * @returns padded number
  82469. */
  82470. private _getPadding;
  82471. /**
  82472. * @hidden
  82473. */
  82474. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82475. /**
  82476. * Sets the TRS for each node
  82477. * @param node glTF Node for storing the transformation data
  82478. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82479. * @param convertToRightHandedSystem Converts the values to right-handed
  82480. */
  82481. private setNodeTransformation;
  82482. private getVertexBufferFromMesh;
  82483. /**
  82484. * Creates a bufferview based on the vertices type for the Babylon mesh
  82485. * @param kind Indicates the type of vertices data
  82486. * @param componentType Indicates the numerical type used to store the data
  82487. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82488. * @param binaryWriter The buffer to write the bufferview data to
  82489. * @param convertToRightHandedSystem Converts the values to right-handed
  82490. */
  82491. private createBufferViewKind;
  82492. /**
  82493. * The primitive mode of the Babylon mesh
  82494. * @param babylonMesh The BabylonJS mesh
  82495. */
  82496. private getMeshPrimitiveMode;
  82497. /**
  82498. * Sets the primitive mode of the glTF mesh primitive
  82499. * @param meshPrimitive glTF mesh primitive
  82500. * @param primitiveMode The primitive mode
  82501. */
  82502. private setPrimitiveMode;
  82503. /**
  82504. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82505. * @param meshPrimitive glTF mesh primitive
  82506. * @param attributeKind vertex attribute
  82507. * @returns boolean specifying if uv coordinates are present
  82508. */
  82509. private setAttributeKind;
  82510. /**
  82511. * Sets data for the primitive attributes of each submesh
  82512. * @param mesh glTF Mesh object to store the primitive attribute information
  82513. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82514. * @param binaryWriter Buffer to write the attribute data to
  82515. * @param convertToRightHandedSystem Converts the values to right-handed
  82516. */
  82517. private setPrimitiveAttributesAsync;
  82518. /**
  82519. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82520. * @param node The node to check
  82521. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82522. */
  82523. private isBabylonCoordinateSystemConvertingNode;
  82524. /**
  82525. * Creates a glTF scene based on the array of meshes
  82526. * Returns the the total byte offset
  82527. * @param babylonScene Babylon scene to get the mesh data from
  82528. * @param binaryWriter Buffer to write binary data to
  82529. */
  82530. private createSceneAsync;
  82531. /**
  82532. * Creates a mapping of Node unique id to node index and handles animations
  82533. * @param babylonScene Babylon Scene
  82534. * @param nodes Babylon transform nodes
  82535. * @param binaryWriter Buffer to write binary data to
  82536. * @returns Node mapping of unique id to index
  82537. */
  82538. private createNodeMapAndAnimationsAsync;
  82539. /**
  82540. * Creates a glTF node from a Babylon mesh
  82541. * @param babylonMesh Source Babylon mesh
  82542. * @param binaryWriter Buffer for storing geometry data
  82543. * @param convertToRightHandedSystem Converts the values to right-handed
  82544. * @param nodeMap Node mapping of unique id to glTF node index
  82545. * @returns glTF node
  82546. */
  82547. private createNodeAsync;
  82548. /**
  82549. * Creates a glTF skin from a Babylon skeleton
  82550. * @param babylonScene Babylon Scene
  82551. * @param nodes Babylon transform nodes
  82552. * @param binaryWriter Buffer to write binary data to
  82553. * @returns Node mapping of unique id to index
  82554. */
  82555. private createSkinsAsync;
  82556. }
  82557. /**
  82558. * @hidden
  82559. *
  82560. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82561. */
  82562. export class _BinaryWriter {
  82563. /**
  82564. * Array buffer which stores all binary data
  82565. */
  82566. private _arrayBuffer;
  82567. /**
  82568. * View of the array buffer
  82569. */
  82570. private _dataView;
  82571. /**
  82572. * byte offset of data in array buffer
  82573. */
  82574. private _byteOffset;
  82575. /**
  82576. * Initialize binary writer with an initial byte length
  82577. * @param byteLength Initial byte length of the array buffer
  82578. */
  82579. constructor(byteLength: number);
  82580. /**
  82581. * Resize the array buffer to the specified byte length
  82582. * @param byteLength
  82583. */
  82584. private resizeBuffer;
  82585. /**
  82586. * Get an array buffer with the length of the byte offset
  82587. * @returns ArrayBuffer resized to the byte offset
  82588. */
  82589. getArrayBuffer(): ArrayBuffer;
  82590. /**
  82591. * Get the byte offset of the array buffer
  82592. * @returns byte offset
  82593. */
  82594. getByteOffset(): number;
  82595. /**
  82596. * Stores an UInt8 in the array buffer
  82597. * @param entry
  82598. * @param byteOffset If defined, specifies where to set the value as an offset.
  82599. */
  82600. setUInt8(entry: number, byteOffset?: number): void;
  82601. /**
  82602. * Stores an UInt16 in the array buffer
  82603. * @param entry
  82604. * @param byteOffset If defined, specifies where to set the value as an offset.
  82605. */
  82606. setUInt16(entry: number, byteOffset?: number): void;
  82607. /**
  82608. * Gets an UInt32 in the array buffer
  82609. * @param entry
  82610. * @param byteOffset If defined, specifies where to set the value as an offset.
  82611. */
  82612. getUInt32(byteOffset: number): number;
  82613. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82614. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82615. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82616. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82617. /**
  82618. * Stores a Float32 in the array buffer
  82619. * @param entry
  82620. */
  82621. setFloat32(entry: number, byteOffset?: number): void;
  82622. /**
  82623. * Stores an UInt32 in the array buffer
  82624. * @param entry
  82625. * @param byteOffset If defined, specifies where to set the value as an offset.
  82626. */
  82627. setUInt32(entry: number, byteOffset?: number): void;
  82628. }
  82629. }
  82630. declare module BABYLON.GLTF2.Exporter {
  82631. /**
  82632. * @hidden
  82633. * Interface to store animation data.
  82634. */
  82635. export interface _IAnimationData {
  82636. /**
  82637. * Keyframe data.
  82638. */
  82639. inputs: number[];
  82640. /**
  82641. * Value data.
  82642. */
  82643. outputs: number[][];
  82644. /**
  82645. * Animation interpolation data.
  82646. */
  82647. samplerInterpolation: AnimationSamplerInterpolation;
  82648. /**
  82649. * Minimum keyframe value.
  82650. */
  82651. inputsMin: number;
  82652. /**
  82653. * Maximum keyframe value.
  82654. */
  82655. inputsMax: number;
  82656. }
  82657. /**
  82658. * @hidden
  82659. */
  82660. export interface _IAnimationInfo {
  82661. /**
  82662. * The target channel for the animation
  82663. */
  82664. animationChannelTargetPath: AnimationChannelTargetPath;
  82665. /**
  82666. * The glTF accessor type for the data.
  82667. */
  82668. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82669. /**
  82670. * Specifies if quaternions should be used.
  82671. */
  82672. useQuaternion: boolean;
  82673. }
  82674. /**
  82675. * @hidden
  82676. * Utility class for generating glTF animation data from BabylonJS.
  82677. */
  82678. export class _GLTFAnimation {
  82679. /**
  82680. * @ignore
  82681. *
  82682. * Creates glTF channel animation from BabylonJS animation.
  82683. * @param babylonTransformNode - BabylonJS mesh.
  82684. * @param animation - animation.
  82685. * @param animationChannelTargetPath - The target animation channel.
  82686. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82687. * @param useQuaternion - Specifies if quaternions are used.
  82688. * @returns nullable IAnimationData
  82689. */
  82690. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82691. private static _DeduceAnimationInfo;
  82692. /**
  82693. * @ignore
  82694. * Create node animations from the transform node animations
  82695. * @param babylonNode
  82696. * @param runtimeGLTFAnimation
  82697. * @param idleGLTFAnimations
  82698. * @param nodeMap
  82699. * @param nodes
  82700. * @param binaryWriter
  82701. * @param bufferViews
  82702. * @param accessors
  82703. * @param convertToRightHandedSystem
  82704. * @param animationSampleRate
  82705. */
  82706. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82707. [key: number]: number;
  82708. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82709. /**
  82710. * @ignore
  82711. * Create node animations from the animation groups
  82712. * @param babylonScene
  82713. * @param glTFAnimations
  82714. * @param nodeMap
  82715. * @param nodes
  82716. * @param binaryWriter
  82717. * @param bufferViews
  82718. * @param accessors
  82719. * @param convertToRightHandedSystemMap
  82720. * @param animationSampleRate
  82721. */
  82722. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82723. [key: number]: number;
  82724. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82725. [nodeId: number]: boolean;
  82726. }, animationSampleRate: number): void;
  82727. private static AddAnimation;
  82728. /**
  82729. * Create a baked animation
  82730. * @param babylonTransformNode BabylonJS mesh
  82731. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82732. * @param animationChannelTargetPath animation target channel
  82733. * @param minFrame minimum animation frame
  82734. * @param maxFrame maximum animation frame
  82735. * @param fps frames per second of the animation
  82736. * @param inputs input key frames of the animation
  82737. * @param outputs output key frame data of the animation
  82738. * @param convertToRightHandedSystem converts the values to right-handed
  82739. * @param useQuaternion specifies if quaternions should be used
  82740. */
  82741. private static _CreateBakedAnimation;
  82742. private static _ConvertFactorToVector3OrQuaternion;
  82743. private static _SetInterpolatedValue;
  82744. /**
  82745. * Creates linear animation from the animation key frames
  82746. * @param babylonTransformNode BabylonJS mesh
  82747. * @param animation BabylonJS animation
  82748. * @param animationChannelTargetPath The target animation channel
  82749. * @param frameDelta The difference between the last and first frame of the animation
  82750. * @param inputs Array to store the key frame times
  82751. * @param outputs Array to store the key frame data
  82752. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82753. * @param useQuaternion Specifies if quaternions are used in the animation
  82754. */
  82755. private static _CreateLinearOrStepAnimation;
  82756. /**
  82757. * Creates cubic spline animation from the animation key frames
  82758. * @param babylonTransformNode BabylonJS mesh
  82759. * @param animation BabylonJS animation
  82760. * @param animationChannelTargetPath The target animation channel
  82761. * @param frameDelta The difference between the last and first frame of the animation
  82762. * @param inputs Array to store the key frame times
  82763. * @param outputs Array to store the key frame data
  82764. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82765. * @param useQuaternion Specifies if quaternions are used in the animation
  82766. */
  82767. private static _CreateCubicSplineAnimation;
  82768. private static _GetBasePositionRotationOrScale;
  82769. /**
  82770. * Adds a key frame value
  82771. * @param keyFrame
  82772. * @param animation
  82773. * @param outputs
  82774. * @param animationChannelTargetPath
  82775. * @param basePositionRotationOrScale
  82776. * @param convertToRightHandedSystem
  82777. * @param useQuaternion
  82778. */
  82779. private static _AddKeyframeValue;
  82780. /**
  82781. * Determine the interpolation based on the key frames
  82782. * @param keyFrames
  82783. * @param animationChannelTargetPath
  82784. * @param useQuaternion
  82785. */
  82786. private static _DeduceInterpolation;
  82787. /**
  82788. * Adds an input tangent or output tangent to the output data
  82789. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82790. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82791. * @param outputs The animation data by keyframe
  82792. * @param animationChannelTargetPath The target animation channel
  82793. * @param interpolation The interpolation type
  82794. * @param keyFrame The key frame with the animation data
  82795. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82796. * @param useQuaternion Specifies if quaternions are used
  82797. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82798. */
  82799. private static AddSplineTangent;
  82800. /**
  82801. * Get the minimum and maximum key frames' frame values
  82802. * @param keyFrames animation key frames
  82803. * @returns the minimum and maximum key frame value
  82804. */
  82805. private static calculateMinMaxKeyFrames;
  82806. }
  82807. }
  82808. declare module BABYLON.GLTF2.Exporter {
  82809. /** @hidden */
  82810. export var textureTransformPixelShader: {
  82811. name: string;
  82812. shader: string;
  82813. };
  82814. }
  82815. declare module BABYLON.GLTF2.Exporter.Extensions {
  82816. /**
  82817. * @hidden
  82818. */
  82819. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82820. private _recordedTextures;
  82821. /** Name of this extension */
  82822. readonly name: string;
  82823. /** Defines whether this extension is enabled */
  82824. enabled: boolean;
  82825. /** Defines whether this extension is required */
  82826. required: boolean;
  82827. /** Reference to the glTF exporter */
  82828. private _wasUsed;
  82829. constructor(exporter: _Exporter);
  82830. dispose(): void;
  82831. /** @hidden */
  82832. get wasUsed(): boolean;
  82833. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82834. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82835. /**
  82836. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82837. * @param babylonTexture
  82838. * @param offset
  82839. * @param rotation
  82840. * @param scale
  82841. * @param scene
  82842. */
  82843. private _textureTransformTextureAsync;
  82844. }
  82845. }
  82846. declare module BABYLON.GLTF2.Exporter.Extensions {
  82847. /**
  82848. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82849. */
  82850. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82851. /** The name of this extension. */
  82852. readonly name: string;
  82853. /** Defines whether this extension is enabled. */
  82854. enabled: boolean;
  82855. /** Defines whether this extension is required */
  82856. required: boolean;
  82857. /** Reference to the glTF exporter */
  82858. private _exporter;
  82859. private _lights;
  82860. /** @hidden */
  82861. constructor(exporter: _Exporter);
  82862. /** @hidden */
  82863. dispose(): void;
  82864. /** @hidden */
  82865. get wasUsed(): boolean;
  82866. /** @hidden */
  82867. onExporting(): void;
  82868. /**
  82869. * Define this method to modify the default behavior when exporting a node
  82870. * @param context The context when exporting the node
  82871. * @param node glTF node
  82872. * @param babylonNode BabylonJS node
  82873. * @param nodeMap Node mapping of unique id to glTF node index
  82874. * @returns nullable INode promise
  82875. */
  82876. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82877. [key: number]: number;
  82878. }): Promise<Nullable<INode>>;
  82879. }
  82880. }
  82881. declare module BABYLON.GLTF2.Exporter.Extensions {
  82882. /**
  82883. * @hidden
  82884. */
  82885. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82886. /** Name of this extension */
  82887. readonly name: string;
  82888. /** Defines whether this extension is enabled */
  82889. enabled: boolean;
  82890. /** Defines whether this extension is required */
  82891. required: boolean;
  82892. /** Reference to the glTF exporter */
  82893. private _textureInfos;
  82894. private _exportedTextures;
  82895. private _wasUsed;
  82896. constructor(exporter: _Exporter);
  82897. dispose(): void;
  82898. /** @hidden */
  82899. get wasUsed(): boolean;
  82900. private _getTextureIndex;
  82901. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82902. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82903. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82904. }
  82905. }
  82906. declare module BABYLON.GLTF2.Exporter.Extensions {
  82907. /**
  82908. * @hidden
  82909. */
  82910. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  82911. /** Name of this extension */
  82912. readonly name: string;
  82913. /** Defines whether this extension is enabled */
  82914. enabled: boolean;
  82915. /** Defines whether this extension is required */
  82916. required: boolean;
  82917. private _wasUsed;
  82918. constructor(exporter: _Exporter);
  82919. /** @hidden */
  82920. get wasUsed(): boolean;
  82921. dispose(): void;
  82922. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82923. }
  82924. }
  82925. declare module BABYLON {
  82926. /**
  82927. * Class for generating STL data from a Babylon scene.
  82928. */
  82929. export class STLExport {
  82930. /**
  82931. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82932. * @param meshes list defines the mesh to serialize
  82933. * @param download triggers the automatic download of the file.
  82934. * @param fileName changes the downloads fileName.
  82935. * @param binary changes the STL to a binary type.
  82936. * @param isLittleEndian toggle for binary type exporter.
  82937. * @returns the STL as UTF8 string
  82938. */
  82939. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82940. }
  82941. }
  82942. declare module "babylonjs-gltf2interface" {
  82943. export = BABYLON.GLTF2;
  82944. }
  82945. /**
  82946. * Module for glTF 2.0 Interface
  82947. */
  82948. declare module BABYLON.GLTF2 {
  82949. /**
  82950. * The datatype of the components in the attribute
  82951. */
  82952. const enum AccessorComponentType {
  82953. /**
  82954. * Byte
  82955. */
  82956. BYTE = 5120,
  82957. /**
  82958. * Unsigned Byte
  82959. */
  82960. UNSIGNED_BYTE = 5121,
  82961. /**
  82962. * Short
  82963. */
  82964. SHORT = 5122,
  82965. /**
  82966. * Unsigned Short
  82967. */
  82968. UNSIGNED_SHORT = 5123,
  82969. /**
  82970. * Unsigned Int
  82971. */
  82972. UNSIGNED_INT = 5125,
  82973. /**
  82974. * Float
  82975. */
  82976. FLOAT = 5126,
  82977. }
  82978. /**
  82979. * Specifies if the attirbute is a scalar, vector, or matrix
  82980. */
  82981. const enum AccessorType {
  82982. /**
  82983. * Scalar
  82984. */
  82985. SCALAR = "SCALAR",
  82986. /**
  82987. * Vector2
  82988. */
  82989. VEC2 = "VEC2",
  82990. /**
  82991. * Vector3
  82992. */
  82993. VEC3 = "VEC3",
  82994. /**
  82995. * Vector4
  82996. */
  82997. VEC4 = "VEC4",
  82998. /**
  82999. * Matrix2x2
  83000. */
  83001. MAT2 = "MAT2",
  83002. /**
  83003. * Matrix3x3
  83004. */
  83005. MAT3 = "MAT3",
  83006. /**
  83007. * Matrix4x4
  83008. */
  83009. MAT4 = "MAT4",
  83010. }
  83011. /**
  83012. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83013. */
  83014. const enum AnimationChannelTargetPath {
  83015. /**
  83016. * Translation
  83017. */
  83018. TRANSLATION = "translation",
  83019. /**
  83020. * Rotation
  83021. */
  83022. ROTATION = "rotation",
  83023. /**
  83024. * Scale
  83025. */
  83026. SCALE = "scale",
  83027. /**
  83028. * Weights
  83029. */
  83030. WEIGHTS = "weights",
  83031. }
  83032. /**
  83033. * Interpolation algorithm
  83034. */
  83035. const enum AnimationSamplerInterpolation {
  83036. /**
  83037. * The animated values are linearly interpolated between keyframes
  83038. */
  83039. LINEAR = "LINEAR",
  83040. /**
  83041. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  83042. */
  83043. STEP = "STEP",
  83044. /**
  83045. * The animation's interpolation is computed using a cubic spline with specified tangents
  83046. */
  83047. CUBICSPLINE = "CUBICSPLINE",
  83048. }
  83049. /**
  83050. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83051. */
  83052. const enum CameraType {
  83053. /**
  83054. * A perspective camera containing properties to create a perspective projection matrix
  83055. */
  83056. PERSPECTIVE = "perspective",
  83057. /**
  83058. * An orthographic camera containing properties to create an orthographic projection matrix
  83059. */
  83060. ORTHOGRAPHIC = "orthographic",
  83061. }
  83062. /**
  83063. * The mime-type of the image
  83064. */
  83065. const enum ImageMimeType {
  83066. /**
  83067. * JPEG Mime-type
  83068. */
  83069. JPEG = "image/jpeg",
  83070. /**
  83071. * PNG Mime-type
  83072. */
  83073. PNG = "image/png",
  83074. }
  83075. /**
  83076. * The alpha rendering mode of the material
  83077. */
  83078. const enum MaterialAlphaMode {
  83079. /**
  83080. * The alpha value is ignored and the rendered output is fully opaque
  83081. */
  83082. OPAQUE = "OPAQUE",
  83083. /**
  83084. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  83085. */
  83086. MASK = "MASK",
  83087. /**
  83088. * 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)
  83089. */
  83090. BLEND = "BLEND",
  83091. }
  83092. /**
  83093. * The type of the primitives to render
  83094. */
  83095. const enum MeshPrimitiveMode {
  83096. /**
  83097. * Points
  83098. */
  83099. POINTS = 0,
  83100. /**
  83101. * Lines
  83102. */
  83103. LINES = 1,
  83104. /**
  83105. * Line Loop
  83106. */
  83107. LINE_LOOP = 2,
  83108. /**
  83109. * Line Strip
  83110. */
  83111. LINE_STRIP = 3,
  83112. /**
  83113. * Triangles
  83114. */
  83115. TRIANGLES = 4,
  83116. /**
  83117. * Triangle Strip
  83118. */
  83119. TRIANGLE_STRIP = 5,
  83120. /**
  83121. * Triangle Fan
  83122. */
  83123. TRIANGLE_FAN = 6,
  83124. }
  83125. /**
  83126. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83127. */
  83128. const enum TextureMagFilter {
  83129. /**
  83130. * Nearest
  83131. */
  83132. NEAREST = 9728,
  83133. /**
  83134. * Linear
  83135. */
  83136. LINEAR = 9729,
  83137. }
  83138. /**
  83139. * Minification filter. All valid values correspond to WebGL enums
  83140. */
  83141. const enum TextureMinFilter {
  83142. /**
  83143. * Nearest
  83144. */
  83145. NEAREST = 9728,
  83146. /**
  83147. * Linear
  83148. */
  83149. LINEAR = 9729,
  83150. /**
  83151. * Nearest Mip-Map Nearest
  83152. */
  83153. NEAREST_MIPMAP_NEAREST = 9984,
  83154. /**
  83155. * Linear Mipmap Nearest
  83156. */
  83157. LINEAR_MIPMAP_NEAREST = 9985,
  83158. /**
  83159. * Nearest Mipmap Linear
  83160. */
  83161. NEAREST_MIPMAP_LINEAR = 9986,
  83162. /**
  83163. * Linear Mipmap Linear
  83164. */
  83165. LINEAR_MIPMAP_LINEAR = 9987,
  83166. }
  83167. /**
  83168. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83169. */
  83170. const enum TextureWrapMode {
  83171. /**
  83172. * Clamp to Edge
  83173. */
  83174. CLAMP_TO_EDGE = 33071,
  83175. /**
  83176. * Mirrored Repeat
  83177. */
  83178. MIRRORED_REPEAT = 33648,
  83179. /**
  83180. * Repeat
  83181. */
  83182. REPEAT = 10497,
  83183. }
  83184. /**
  83185. * glTF Property
  83186. */
  83187. interface IProperty {
  83188. /**
  83189. * Dictionary object with extension-specific objects
  83190. */
  83191. extensions?: {
  83192. [key: string]: any;
  83193. };
  83194. /**
  83195. * Application-Specific data
  83196. */
  83197. extras?: any;
  83198. }
  83199. /**
  83200. * glTF Child of Root Property
  83201. */
  83202. interface IChildRootProperty extends IProperty {
  83203. /**
  83204. * The user-defined name of this object
  83205. */
  83206. name?: string;
  83207. }
  83208. /**
  83209. * Indices of those attributes that deviate from their initialization value
  83210. */
  83211. interface IAccessorSparseIndices extends IProperty {
  83212. /**
  83213. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83214. */
  83215. bufferView: number;
  83216. /**
  83217. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83218. */
  83219. byteOffset?: number;
  83220. /**
  83221. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  83222. */
  83223. componentType: AccessorComponentType;
  83224. }
  83225. /**
  83226. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  83227. */
  83228. interface IAccessorSparseValues extends IProperty {
  83229. /**
  83230. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83231. */
  83232. bufferView: number;
  83233. /**
  83234. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83235. */
  83236. byteOffset?: number;
  83237. }
  83238. /**
  83239. * Sparse storage of attributes that deviate from their initialization value
  83240. */
  83241. interface IAccessorSparse extends IProperty {
  83242. /**
  83243. * The number of attributes encoded in this sparse accessor
  83244. */
  83245. count: number;
  83246. /**
  83247. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  83248. */
  83249. indices: IAccessorSparseIndices;
  83250. /**
  83251. * 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
  83252. */
  83253. values: IAccessorSparseValues;
  83254. }
  83255. /**
  83256. * 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
  83257. */
  83258. interface IAccessor extends IChildRootProperty {
  83259. /**
  83260. * The index of the bufferview
  83261. */
  83262. bufferView?: number;
  83263. /**
  83264. * The offset relative to the start of the bufferView in bytes
  83265. */
  83266. byteOffset?: number;
  83267. /**
  83268. * The datatype of components in the attribute
  83269. */
  83270. componentType: AccessorComponentType;
  83271. /**
  83272. * Specifies whether integer data values should be normalized
  83273. */
  83274. normalized?: boolean;
  83275. /**
  83276. * The number of attributes referenced by this accessor
  83277. */
  83278. count: number;
  83279. /**
  83280. * Specifies if the attribute is a scalar, vector, or matrix
  83281. */
  83282. type: AccessorType;
  83283. /**
  83284. * Maximum value of each component in this attribute
  83285. */
  83286. max?: number[];
  83287. /**
  83288. * Minimum value of each component in this attribute
  83289. */
  83290. min?: number[];
  83291. /**
  83292. * Sparse storage of attributes that deviate from their initialization value
  83293. */
  83294. sparse?: IAccessorSparse;
  83295. }
  83296. /**
  83297. * Targets an animation's sampler at a node's property
  83298. */
  83299. interface IAnimationChannel extends IProperty {
  83300. /**
  83301. * The index of a sampler in this animation used to compute the value for the target
  83302. */
  83303. sampler: number;
  83304. /**
  83305. * The index of the node and TRS property to target
  83306. */
  83307. target: IAnimationChannelTarget;
  83308. }
  83309. /**
  83310. * The index of the node and TRS property that an animation channel targets
  83311. */
  83312. interface IAnimationChannelTarget extends IProperty {
  83313. /**
  83314. * The index of the node to target
  83315. */
  83316. node: number;
  83317. /**
  83318. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83319. */
  83320. path: AnimationChannelTargetPath;
  83321. }
  83322. /**
  83323. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83324. */
  83325. interface IAnimationSampler extends IProperty {
  83326. /**
  83327. * The index of an accessor containing keyframe input values, e.g., time
  83328. */
  83329. input: number;
  83330. /**
  83331. * Interpolation algorithm
  83332. */
  83333. interpolation?: AnimationSamplerInterpolation;
  83334. /**
  83335. * The index of an accessor, containing keyframe output values
  83336. */
  83337. output: number;
  83338. }
  83339. /**
  83340. * A keyframe animation
  83341. */
  83342. interface IAnimation extends IChildRootProperty {
  83343. /**
  83344. * An array of channels, each of which targets an animation's sampler at a node's property
  83345. */
  83346. channels: IAnimationChannel[];
  83347. /**
  83348. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83349. */
  83350. samplers: IAnimationSampler[];
  83351. }
  83352. /**
  83353. * Metadata about the glTF asset
  83354. */
  83355. interface IAsset extends IChildRootProperty {
  83356. /**
  83357. * A copyright message suitable for display to credit the content creator
  83358. */
  83359. copyright?: string;
  83360. /**
  83361. * Tool that generated this glTF model. Useful for debugging
  83362. */
  83363. generator?: string;
  83364. /**
  83365. * The glTF version that this asset targets
  83366. */
  83367. version: string;
  83368. /**
  83369. * The minimum glTF version that this asset targets
  83370. */
  83371. minVersion?: string;
  83372. }
  83373. /**
  83374. * A buffer points to binary geometry, animation, or skins
  83375. */
  83376. interface IBuffer extends IChildRootProperty {
  83377. /**
  83378. * 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
  83379. */
  83380. uri?: string;
  83381. /**
  83382. * The length of the buffer in bytes
  83383. */
  83384. byteLength: number;
  83385. }
  83386. /**
  83387. * A view into a buffer generally representing a subset of the buffer
  83388. */
  83389. interface IBufferView extends IChildRootProperty {
  83390. /**
  83391. * The index of the buffer
  83392. */
  83393. buffer: number;
  83394. /**
  83395. * The offset into the buffer in bytes
  83396. */
  83397. byteOffset?: number;
  83398. /**
  83399. * The lenth of the bufferView in bytes
  83400. */
  83401. byteLength: number;
  83402. /**
  83403. * The stride, in bytes
  83404. */
  83405. byteStride?: number;
  83406. }
  83407. /**
  83408. * An orthographic camera containing properties to create an orthographic projection matrix
  83409. */
  83410. interface ICameraOrthographic extends IProperty {
  83411. /**
  83412. * The floating-point horizontal magnification of the view. Must not be zero
  83413. */
  83414. xmag: number;
  83415. /**
  83416. * The floating-point vertical magnification of the view. Must not be zero
  83417. */
  83418. ymag: number;
  83419. /**
  83420. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83421. */
  83422. zfar: number;
  83423. /**
  83424. * The floating-point distance to the near clipping plane
  83425. */
  83426. znear: number;
  83427. }
  83428. /**
  83429. * A perspective camera containing properties to create a perspective projection matrix
  83430. */
  83431. interface ICameraPerspective extends IProperty {
  83432. /**
  83433. * The floating-point aspect ratio of the field of view
  83434. */
  83435. aspectRatio?: number;
  83436. /**
  83437. * The floating-point vertical field of view in radians
  83438. */
  83439. yfov: number;
  83440. /**
  83441. * The floating-point distance to the far clipping plane
  83442. */
  83443. zfar?: number;
  83444. /**
  83445. * The floating-point distance to the near clipping plane
  83446. */
  83447. znear: number;
  83448. }
  83449. /**
  83450. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83451. */
  83452. interface ICamera extends IChildRootProperty {
  83453. /**
  83454. * An orthographic camera containing properties to create an orthographic projection matrix
  83455. */
  83456. orthographic?: ICameraOrthographic;
  83457. /**
  83458. * A perspective camera containing properties to create a perspective projection matrix
  83459. */
  83460. perspective?: ICameraPerspective;
  83461. /**
  83462. * Specifies if the camera uses a perspective or orthographic projection
  83463. */
  83464. type: CameraType;
  83465. }
  83466. /**
  83467. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83468. */
  83469. interface IImage extends IChildRootProperty {
  83470. /**
  83471. * 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
  83472. */
  83473. uri?: string;
  83474. /**
  83475. * The image's MIME type
  83476. */
  83477. mimeType?: ImageMimeType;
  83478. /**
  83479. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83480. */
  83481. bufferView?: number;
  83482. }
  83483. /**
  83484. * Material Normal Texture Info
  83485. */
  83486. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83487. /**
  83488. * The scalar multiplier applied to each normal vector of the normal texture
  83489. */
  83490. scale?: number;
  83491. }
  83492. /**
  83493. * Material Occlusion Texture Info
  83494. */
  83495. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83496. /**
  83497. * A scalar multiplier controlling the amount of occlusion applied
  83498. */
  83499. strength?: number;
  83500. }
  83501. /**
  83502. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83503. */
  83504. interface IMaterialPbrMetallicRoughness {
  83505. /**
  83506. * The material's base color factor
  83507. */
  83508. baseColorFactor?: number[];
  83509. /**
  83510. * The base color texture
  83511. */
  83512. baseColorTexture?: ITextureInfo;
  83513. /**
  83514. * The metalness of the material
  83515. */
  83516. metallicFactor?: number;
  83517. /**
  83518. * The roughness of the material
  83519. */
  83520. roughnessFactor?: number;
  83521. /**
  83522. * The metallic-roughness texture
  83523. */
  83524. metallicRoughnessTexture?: ITextureInfo;
  83525. }
  83526. /**
  83527. * The material appearance of a primitive
  83528. */
  83529. interface IMaterial extends IChildRootProperty {
  83530. /**
  83531. * 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
  83532. */
  83533. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83534. /**
  83535. * The normal map texture
  83536. */
  83537. normalTexture?: IMaterialNormalTextureInfo;
  83538. /**
  83539. * The occlusion map texture
  83540. */
  83541. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83542. /**
  83543. * The emissive map texture
  83544. */
  83545. emissiveTexture?: ITextureInfo;
  83546. /**
  83547. * 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
  83548. */
  83549. emissiveFactor?: number[];
  83550. /**
  83551. * The alpha rendering mode of the material
  83552. */
  83553. alphaMode?: MaterialAlphaMode;
  83554. /**
  83555. * The alpha cutoff value of the material
  83556. */
  83557. alphaCutoff?: number;
  83558. /**
  83559. * Specifies whether the material is double sided
  83560. */
  83561. doubleSided?: boolean;
  83562. }
  83563. /**
  83564. * Geometry to be rendered with the given material
  83565. */
  83566. interface IMeshPrimitive extends IProperty {
  83567. /**
  83568. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83569. */
  83570. attributes: {
  83571. [name: string]: number;
  83572. };
  83573. /**
  83574. * The index of the accessor that contains the indices
  83575. */
  83576. indices?: number;
  83577. /**
  83578. * The index of the material to apply to this primitive when rendering
  83579. */
  83580. material?: number;
  83581. /**
  83582. * The type of primitives to render. All valid values correspond to WebGL enums
  83583. */
  83584. mode?: MeshPrimitiveMode;
  83585. /**
  83586. * 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
  83587. */
  83588. targets?: {
  83589. [name: string]: number;
  83590. }[];
  83591. }
  83592. /**
  83593. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83594. */
  83595. interface IMesh extends IChildRootProperty {
  83596. /**
  83597. * An array of primitives, each defining geometry to be rendered with a material
  83598. */
  83599. primitives: IMeshPrimitive[];
  83600. /**
  83601. * Array of weights to be applied to the Morph Targets
  83602. */
  83603. weights?: number[];
  83604. }
  83605. /**
  83606. * A node in the node hierarchy
  83607. */
  83608. interface INode extends IChildRootProperty {
  83609. /**
  83610. * The index of the camera referenced by this node
  83611. */
  83612. camera?: number;
  83613. /**
  83614. * The indices of this node's children
  83615. */
  83616. children?: number[];
  83617. /**
  83618. * The index of the skin referenced by this node
  83619. */
  83620. skin?: number;
  83621. /**
  83622. * A floating-point 4x4 transformation matrix stored in column-major order
  83623. */
  83624. matrix?: number[];
  83625. /**
  83626. * The index of the mesh in this node
  83627. */
  83628. mesh?: number;
  83629. /**
  83630. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83631. */
  83632. rotation?: number[];
  83633. /**
  83634. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83635. */
  83636. scale?: number[];
  83637. /**
  83638. * The node's translation along the x, y, and z axes
  83639. */
  83640. translation?: number[];
  83641. /**
  83642. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83643. */
  83644. weights?: number[];
  83645. }
  83646. /**
  83647. * Texture sampler properties for filtering and wrapping modes
  83648. */
  83649. interface ISampler extends IChildRootProperty {
  83650. /**
  83651. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83652. */
  83653. magFilter?: TextureMagFilter;
  83654. /**
  83655. * Minification filter. All valid values correspond to WebGL enums
  83656. */
  83657. minFilter?: TextureMinFilter;
  83658. /**
  83659. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83660. */
  83661. wrapS?: TextureWrapMode;
  83662. /**
  83663. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83664. */
  83665. wrapT?: TextureWrapMode;
  83666. }
  83667. /**
  83668. * The root nodes of a scene
  83669. */
  83670. interface IScene extends IChildRootProperty {
  83671. /**
  83672. * The indices of each root node
  83673. */
  83674. nodes: number[];
  83675. }
  83676. /**
  83677. * Joints and matrices defining a skin
  83678. */
  83679. interface ISkin extends IChildRootProperty {
  83680. /**
  83681. * 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
  83682. */
  83683. inverseBindMatrices?: number;
  83684. /**
  83685. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83686. */
  83687. skeleton?: number;
  83688. /**
  83689. * 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)
  83690. */
  83691. joints: number[];
  83692. }
  83693. /**
  83694. * A texture and its sampler
  83695. */
  83696. interface ITexture extends IChildRootProperty {
  83697. /**
  83698. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83699. */
  83700. sampler?: number;
  83701. /**
  83702. * The index of the image used by this texture
  83703. */
  83704. source: number;
  83705. }
  83706. /**
  83707. * Reference to a texture
  83708. */
  83709. interface ITextureInfo extends IProperty {
  83710. /**
  83711. * The index of the texture
  83712. */
  83713. index: number;
  83714. /**
  83715. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83716. */
  83717. texCoord?: number;
  83718. }
  83719. /**
  83720. * The root object for a glTF asset
  83721. */
  83722. interface IGLTF extends IProperty {
  83723. /**
  83724. * An array of accessors. An accessor is a typed view into a bufferView
  83725. */
  83726. accessors?: IAccessor[];
  83727. /**
  83728. * An array of keyframe animations
  83729. */
  83730. animations?: IAnimation[];
  83731. /**
  83732. * Metadata about the glTF asset
  83733. */
  83734. asset: IAsset;
  83735. /**
  83736. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83737. */
  83738. buffers?: IBuffer[];
  83739. /**
  83740. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83741. */
  83742. bufferViews?: IBufferView[];
  83743. /**
  83744. * An array of cameras
  83745. */
  83746. cameras?: ICamera[];
  83747. /**
  83748. * Names of glTF extensions used somewhere in this asset
  83749. */
  83750. extensionsUsed?: string[];
  83751. /**
  83752. * Names of glTF extensions required to properly load this asset
  83753. */
  83754. extensionsRequired?: string[];
  83755. /**
  83756. * An array of images. An image defines data used to create a texture
  83757. */
  83758. images?: IImage[];
  83759. /**
  83760. * An array of materials. A material defines the appearance of a primitive
  83761. */
  83762. materials?: IMaterial[];
  83763. /**
  83764. * An array of meshes. A mesh is a set of primitives to be rendered
  83765. */
  83766. meshes?: IMesh[];
  83767. /**
  83768. * An array of nodes
  83769. */
  83770. nodes?: INode[];
  83771. /**
  83772. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83773. */
  83774. samplers?: ISampler[];
  83775. /**
  83776. * The index of the default scene
  83777. */
  83778. scene?: number;
  83779. /**
  83780. * An array of scenes
  83781. */
  83782. scenes?: IScene[];
  83783. /**
  83784. * An array of skins. A skin is defined by joints and matrices
  83785. */
  83786. skins?: ISkin[];
  83787. /**
  83788. * An array of textures
  83789. */
  83790. textures?: ITexture[];
  83791. }
  83792. /**
  83793. * The glTF validation results
  83794. * @ignore
  83795. */
  83796. interface IGLTFValidationResults {
  83797. info: {
  83798. generator: string;
  83799. hasAnimations: boolean;
  83800. hasDefaultScene: boolean;
  83801. hasMaterials: boolean;
  83802. hasMorphTargets: boolean;
  83803. hasSkins: boolean;
  83804. hasTextures: boolean;
  83805. maxAttributesUsed: number;
  83806. primitivesCount: number
  83807. };
  83808. issues: {
  83809. messages: Array<string>;
  83810. numErrors: number;
  83811. numHints: number;
  83812. numInfos: number;
  83813. numWarnings: number;
  83814. truncated: boolean
  83815. };
  83816. mimeType: string;
  83817. uri: string;
  83818. validatedAt: string;
  83819. validatorVersion: string;
  83820. }
  83821. /**
  83822. * The glTF validation options
  83823. */
  83824. interface IGLTFValidationOptions {
  83825. /** Uri to use */
  83826. uri?: string;
  83827. /** Function used to load external resources */
  83828. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83829. /** Boolean indicating that we need to validate accessor data */
  83830. validateAccessorData?: boolean;
  83831. /** max number of issues allowed */
  83832. maxIssues?: number;
  83833. /** Ignored issues */
  83834. ignoredIssues?: Array<string>;
  83835. /** Value to override severy settings */
  83836. severityOverrides?: Object;
  83837. }
  83838. /**
  83839. * The glTF validator object
  83840. * @ignore
  83841. */
  83842. interface IGLTFValidator {
  83843. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83844. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83845. }
  83846. /**
  83847. * Interfaces from the EXT_lights_image_based extension
  83848. */
  83849. /** @hidden */
  83850. interface IEXTLightsImageBased_LightReferenceImageBased {
  83851. light: number;
  83852. }
  83853. /** @hidden */
  83854. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  83855. intensity: number;
  83856. rotation: number[];
  83857. specularImageSize: number;
  83858. specularImages: number[][];
  83859. irradianceCoefficients: number[][];
  83860. }
  83861. /** @hidden */
  83862. interface IEXTLightsImageBased {
  83863. lights: IEXTLightsImageBased_LightImageBased[];
  83864. }
  83865. /**
  83866. * Interfaces from the EXT_mesh_gpu_instancing extension
  83867. * !!! Experimental Extension Subject to Changes !!!
  83868. */
  83869. /** @hidden */
  83870. interface IEXTMeshGpuInstancing {
  83871. mesh?: number;
  83872. attributes: { [name: string]: number };
  83873. }
  83874. /**
  83875. * Interfaces from the KHR_draco_mesh_compression extension
  83876. */
  83877. /** @hidden */
  83878. interface IKHRDracoMeshCompression {
  83879. bufferView: number;
  83880. attributes: { [name: string]: number };
  83881. }
  83882. /**
  83883. * Interfaces from the KHR_lights_punctual extension
  83884. */
  83885. /** @hidden */
  83886. const enum IKHRLightsPunctual_LightType {
  83887. DIRECTIONAL = "directional",
  83888. POINT = "point",
  83889. SPOT = "spot"
  83890. }
  83891. /** @hidden */
  83892. interface IKHRLightsPunctual_LightReference {
  83893. light: number;
  83894. }
  83895. /** @hidden */
  83896. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  83897. type: IKHRLightsPunctual_LightType;
  83898. color?: number[];
  83899. intensity?: number;
  83900. range?: number;
  83901. spot?: {
  83902. innerConeAngle?: number;
  83903. outerConeAngle?: number;
  83904. };
  83905. }
  83906. /** @hidden */
  83907. interface IKHRLightsPunctual {
  83908. lights: IKHRLightsPunctual_Light[];
  83909. }
  83910. /**
  83911. * Interfaces from the KHR_materials_clearcoat extension
  83912. * !!! Experimental Extension Subject to Changes !!!
  83913. */
  83914. /** @hidden */
  83915. interface IKHRMaterialsClearcoat {
  83916. clearcoatFactor: number;
  83917. clearcoatTexture: ITextureInfo;
  83918. clearcoatRoughnessFactor: number;
  83919. clearcoatRoughnessTexture: ITextureInfo;
  83920. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  83921. }
  83922. /**
  83923. * Interfaces from the KHR_materials_ior extension
  83924. * !!! Experimental Extension Subject to Changes !!!
  83925. */
  83926. /** @hidden */
  83927. interface IKHRMaterialsIor {
  83928. ior: number;
  83929. }
  83930. /**
  83931. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  83932. */
  83933. /** @hidden */
  83934. interface IKHRMaterialsPbrSpecularGlossiness {
  83935. diffuseFactor: number[];
  83936. diffuseTexture: ITextureInfo;
  83937. specularFactor: number[];
  83938. glossinessFactor: number;
  83939. specularGlossinessTexture: ITextureInfo;
  83940. }
  83941. /**
  83942. * Interfaces from the KHR_materials_sheen extension
  83943. * !!! Experimental Extension Subject to Changes !!!
  83944. */
  83945. /** @hidden */
  83946. interface IKHRMaterialsSheen {
  83947. sheenColorFactor?: number[];
  83948. sheenTexture?: ITextureInfo;
  83949. sheenRoughnessFactor?: number;
  83950. }
  83951. /**
  83952. * Interfaces from the KHR_materials_specular extension
  83953. * !!! Experimental Extension Subject to Changes !!!
  83954. */
  83955. /** @hidden */
  83956. interface IKHRMaterialsSpecular {
  83957. specularFactor: number;
  83958. specularColorFactor: number[];
  83959. specularTexture: ITextureInfo;
  83960. }
  83961. /**
  83962. * Interfaces from the KHR_materials_transmission extension
  83963. * !!! Experimental Extension Subject to Changes !!!
  83964. */
  83965. /** @hidden */
  83966. interface IKHRMaterialsTransmission {
  83967. transmissionFactor?: number;
  83968. transmissionTexture?: ITextureInfo;
  83969. }
  83970. /**
  83971. * Interfaces from the KHR_materials_variants extension
  83972. * !!! Experimental Extension Subject to Changes !!!
  83973. */
  83974. /** @hidden */
  83975. interface IKHRMaterialVariants_Mapping {
  83976. tags: string[];
  83977. material: number;
  83978. }
  83979. /** @hidden */
  83980. interface IKHRMaterialVariants {
  83981. mapping: IKHRMaterialVariants_Mapping[];
  83982. }
  83983. /**
  83984. * Interfaces from the KHR_texture_basisu extension
  83985. * !!! Experimental Extension Subject to Changes !!!
  83986. */
  83987. /** @hidden */
  83988. interface IKHRTextureBasisU {
  83989. source: number;
  83990. }
  83991. /**
  83992. * Interfaces from the KHR_texture_transform extension
  83993. */
  83994. /** @hidden */
  83995. interface IKHRTextureTransform {
  83996. offset?: number[];
  83997. rotation?: number;
  83998. scale?: number[];
  83999. texCoord?: number;
  84000. }
  84001. /**
  84002. * Interfaces from the KHR_xmp extension
  84003. * !!! Experimental Extension Subject to Changes !!!
  84004. */
  84005. /** @hidden */
  84006. interface IKHRXmp_Data {
  84007. [key: string]: unknown;
  84008. }
  84009. /** @hidden */
  84010. interface IKHRXmp_Gltf {
  84011. packets: IKHRXmp_Data[];
  84012. }
  84013. /** @hidden */
  84014. interface IKHRXmp_Node {
  84015. packet: number;
  84016. }
  84017. /**
  84018. * Interfaces from the MSFT_audio_emitter extension
  84019. */
  84020. /** @hidden */
  84021. interface IMSFTAudioEmitter_ClipReference {
  84022. clip: number;
  84023. weight?: number;
  84024. }
  84025. /** @hidden */
  84026. interface IMSFTAudioEmitter_EmittersReference {
  84027. emitters: number[];
  84028. }
  84029. /** @hidden */
  84030. const enum IMSFTAudioEmitter_DistanceModel {
  84031. linear = "linear",
  84032. inverse = "inverse",
  84033. exponential = "exponential",
  84034. }
  84035. /** @hidden */
  84036. interface IMSFTAudioEmitter_Emitter {
  84037. name?: string;
  84038. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  84039. refDistance?: number;
  84040. maxDistance?: number;
  84041. rolloffFactor?: number;
  84042. innerAngle?: number;
  84043. outerAngle?: number;
  84044. loop?: boolean;
  84045. volume?: number;
  84046. clips: IMSFTAudioEmitter_ClipReference[];
  84047. }
  84048. /** @hidden */
  84049. const enum IMSFTAudioEmitter_AudioMimeType {
  84050. WAV = "audio/wav",
  84051. }
  84052. /** @hidden */
  84053. interface IMSFTAudioEmitter_Clip extends IProperty {
  84054. uri?: string;
  84055. bufferView?: number;
  84056. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  84057. }
  84058. /** @hidden */
  84059. const enum IMSFTAudioEmitter_AnimationEventAction {
  84060. play = "play",
  84061. pause = "pause",
  84062. stop = "stop",
  84063. }
  84064. /** @hidden */
  84065. interface IMSFTAudioEmitter_AnimationEvent {
  84066. action: IMSFTAudioEmitter_AnimationEventAction;
  84067. emitter: number;
  84068. time: number;
  84069. startOffset?: number;
  84070. }
  84071. /**
  84072. * Interfaces from the MSFT_lod extension
  84073. */
  84074. /** @hidden */
  84075. interface IMSFTLOD {
  84076. ids: number[];
  84077. }
  84078. }
  84079. declare module BABYLON {
  84080. /** @hidden */
  84081. export var cellPixelShader: {
  84082. name: string;
  84083. shader: string;
  84084. };
  84085. }
  84086. declare module BABYLON {
  84087. /** @hidden */
  84088. export var cellVertexShader: {
  84089. name: string;
  84090. shader: string;
  84091. };
  84092. }
  84093. declare module BABYLON {
  84094. export class CellMaterial extends BABYLON.PushMaterial {
  84095. private _diffuseTexture;
  84096. diffuseTexture: BABYLON.BaseTexture;
  84097. diffuseColor: BABYLON.Color3;
  84098. _computeHighLevel: boolean;
  84099. computeHighLevel: boolean;
  84100. private _disableLighting;
  84101. disableLighting: boolean;
  84102. private _maxSimultaneousLights;
  84103. maxSimultaneousLights: number;
  84104. constructor(name: string, scene: BABYLON.Scene);
  84105. needAlphaBlending(): boolean;
  84106. needAlphaTesting(): boolean;
  84107. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84108. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84109. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84110. getAnimatables(): BABYLON.IAnimatable[];
  84111. getActiveTextures(): BABYLON.BaseTexture[];
  84112. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84113. dispose(forceDisposeEffect?: boolean): void;
  84114. getClassName(): string;
  84115. clone(name: string): CellMaterial;
  84116. serialize(): any;
  84117. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  84118. }
  84119. }
  84120. declare module BABYLON {
  84121. export class CustomShaderStructure {
  84122. FragmentStore: string;
  84123. VertexStore: string;
  84124. constructor();
  84125. }
  84126. export class ShaderSpecialParts {
  84127. constructor();
  84128. Fragment_Begin: string;
  84129. Fragment_Definitions: string;
  84130. Fragment_MainBegin: string;
  84131. Fragment_Custom_Diffuse: string;
  84132. Fragment_Before_Lights: string;
  84133. Fragment_Before_Fog: string;
  84134. Fragment_Custom_Alpha: string;
  84135. Fragment_Before_FragColor: string;
  84136. Vertex_Begin: string;
  84137. Vertex_Definitions: string;
  84138. Vertex_MainBegin: string;
  84139. Vertex_Before_PositionUpdated: string;
  84140. Vertex_Before_NormalUpdated: string;
  84141. Vertex_After_WorldPosComputed: string;
  84142. Vertex_MainEnd: string;
  84143. }
  84144. export class CustomMaterial extends BABYLON.StandardMaterial {
  84145. static ShaderIndexer: number;
  84146. CustomParts: ShaderSpecialParts;
  84147. _isCreatedShader: boolean;
  84148. _createdShaderName: string;
  84149. _customUniform: string[];
  84150. _newUniforms: string[];
  84151. _newUniformInstances: {
  84152. [name: string]: any;
  84153. };
  84154. _newSamplerInstances: {
  84155. [name: string]: BABYLON.Texture;
  84156. };
  84157. _customAttributes: string[];
  84158. FragmentShader: string;
  84159. VertexShader: string;
  84160. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84161. ReviewUniform(name: string, arr: string[]): string[];
  84162. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84163. constructor(name: string, scene: BABYLON.Scene);
  84164. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  84165. AddAttribute(name: string): CustomMaterial;
  84166. Fragment_Begin(shaderPart: string): CustomMaterial;
  84167. Fragment_Definitions(shaderPart: string): CustomMaterial;
  84168. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  84169. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  84170. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  84171. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  84172. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  84173. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  84174. Vertex_Begin(shaderPart: string): CustomMaterial;
  84175. Vertex_Definitions(shaderPart: string): CustomMaterial;
  84176. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  84177. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  84178. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  84179. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  84180. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  84181. }
  84182. }
  84183. declare module BABYLON {
  84184. export class ShaderAlebdoParts {
  84185. constructor();
  84186. Fragment_Begin: string;
  84187. Fragment_Definitions: string;
  84188. Fragment_MainBegin: string;
  84189. Fragment_Custom_Albedo: string;
  84190. Fragment_Before_Lights: string;
  84191. Fragment_Custom_MetallicRoughness: string;
  84192. Fragment_Custom_MicroSurface: string;
  84193. Fragment_Before_Fog: string;
  84194. Fragment_Custom_Alpha: string;
  84195. Fragment_Before_FragColor: string;
  84196. Vertex_Begin: string;
  84197. Vertex_Definitions: string;
  84198. Vertex_MainBegin: string;
  84199. Vertex_Before_PositionUpdated: string;
  84200. Vertex_Before_NormalUpdated: string;
  84201. Vertex_After_WorldPosComputed: string;
  84202. Vertex_MainEnd: string;
  84203. }
  84204. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  84205. static ShaderIndexer: number;
  84206. CustomParts: ShaderAlebdoParts;
  84207. _isCreatedShader: boolean;
  84208. _createdShaderName: string;
  84209. _customUniform: string[];
  84210. _newUniforms: string[];
  84211. _newUniformInstances: {
  84212. [name: string]: any;
  84213. };
  84214. _newSamplerInstances: {
  84215. [name: string]: BABYLON.Texture;
  84216. };
  84217. _customAttributes: string[];
  84218. FragmentShader: string;
  84219. VertexShader: string;
  84220. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84221. ReviewUniform(name: string, arr: string[]): string[];
  84222. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84223. constructor(name: string, scene: BABYLON.Scene);
  84224. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  84225. AddAttribute(name: string): PBRCustomMaterial;
  84226. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  84227. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  84228. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  84229. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  84230. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  84231. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  84232. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  84233. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  84234. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  84235. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  84236. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  84237. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  84238. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  84239. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  84240. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  84241. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  84242. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  84243. }
  84244. }
  84245. declare module BABYLON {
  84246. /** @hidden */
  84247. export var firePixelShader: {
  84248. name: string;
  84249. shader: string;
  84250. };
  84251. }
  84252. declare module BABYLON {
  84253. /** @hidden */
  84254. export var fireVertexShader: {
  84255. name: string;
  84256. shader: string;
  84257. };
  84258. }
  84259. declare module BABYLON {
  84260. export class FireMaterial extends BABYLON.PushMaterial {
  84261. private _diffuseTexture;
  84262. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84263. private _distortionTexture;
  84264. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84265. private _opacityTexture;
  84266. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84267. diffuseColor: BABYLON.Color3;
  84268. speed: number;
  84269. private _scaledDiffuse;
  84270. private _lastTime;
  84271. constructor(name: string, scene: BABYLON.Scene);
  84272. needAlphaBlending(): boolean;
  84273. needAlphaTesting(): boolean;
  84274. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84275. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84276. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84277. getAnimatables(): BABYLON.IAnimatable[];
  84278. getActiveTextures(): BABYLON.BaseTexture[];
  84279. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84280. getClassName(): string;
  84281. dispose(forceDisposeEffect?: boolean): void;
  84282. clone(name: string): FireMaterial;
  84283. serialize(): any;
  84284. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  84285. }
  84286. }
  84287. declare module BABYLON {
  84288. /** @hidden */
  84289. export var furPixelShader: {
  84290. name: string;
  84291. shader: string;
  84292. };
  84293. }
  84294. declare module BABYLON {
  84295. /** @hidden */
  84296. export var furVertexShader: {
  84297. name: string;
  84298. shader: string;
  84299. };
  84300. }
  84301. declare module BABYLON {
  84302. export class FurMaterial extends BABYLON.PushMaterial {
  84303. private _diffuseTexture;
  84304. diffuseTexture: BABYLON.BaseTexture;
  84305. private _heightTexture;
  84306. heightTexture: BABYLON.BaseTexture;
  84307. diffuseColor: BABYLON.Color3;
  84308. furLength: number;
  84309. furAngle: number;
  84310. furColor: BABYLON.Color3;
  84311. furOffset: number;
  84312. furSpacing: number;
  84313. furGravity: BABYLON.Vector3;
  84314. furSpeed: number;
  84315. furDensity: number;
  84316. furOcclusion: number;
  84317. furTexture: BABYLON.DynamicTexture;
  84318. private _disableLighting;
  84319. disableLighting: boolean;
  84320. private _maxSimultaneousLights;
  84321. maxSimultaneousLights: number;
  84322. highLevelFur: boolean;
  84323. _meshes: BABYLON.AbstractMesh[];
  84324. private _furTime;
  84325. constructor(name: string, scene: BABYLON.Scene);
  84326. get furTime(): number;
  84327. set furTime(furTime: number);
  84328. needAlphaBlending(): boolean;
  84329. needAlphaTesting(): boolean;
  84330. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84331. updateFur(): void;
  84332. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84333. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84334. getAnimatables(): BABYLON.IAnimatable[];
  84335. getActiveTextures(): BABYLON.BaseTexture[];
  84336. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84337. dispose(forceDisposeEffect?: boolean): void;
  84338. clone(name: string): FurMaterial;
  84339. serialize(): any;
  84340. getClassName(): string;
  84341. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84342. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84343. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84344. }
  84345. }
  84346. declare module BABYLON {
  84347. /** @hidden */
  84348. export var gradientPixelShader: {
  84349. name: string;
  84350. shader: string;
  84351. };
  84352. }
  84353. declare module BABYLON {
  84354. /** @hidden */
  84355. export var gradientVertexShader: {
  84356. name: string;
  84357. shader: string;
  84358. };
  84359. }
  84360. declare module BABYLON {
  84361. export class GradientMaterial extends BABYLON.PushMaterial {
  84362. private _maxSimultaneousLights;
  84363. maxSimultaneousLights: number;
  84364. topColor: BABYLON.Color3;
  84365. topColorAlpha: number;
  84366. bottomColor: BABYLON.Color3;
  84367. bottomColorAlpha: number;
  84368. offset: number;
  84369. scale: number;
  84370. smoothness: number;
  84371. private _disableLighting;
  84372. disableLighting: boolean;
  84373. constructor(name: string, scene: BABYLON.Scene);
  84374. needAlphaBlending(): boolean;
  84375. needAlphaTesting(): boolean;
  84376. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84377. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84378. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84379. getAnimatables(): BABYLON.IAnimatable[];
  84380. dispose(forceDisposeEffect?: boolean): void;
  84381. clone(name: string): GradientMaterial;
  84382. serialize(): any;
  84383. getClassName(): string;
  84384. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84385. }
  84386. }
  84387. declare module BABYLON {
  84388. /** @hidden */
  84389. export var gridPixelShader: {
  84390. name: string;
  84391. shader: string;
  84392. };
  84393. }
  84394. declare module BABYLON {
  84395. /** @hidden */
  84396. export var gridVertexShader: {
  84397. name: string;
  84398. shader: string;
  84399. };
  84400. }
  84401. declare module BABYLON {
  84402. /**
  84403. * The grid materials allows you to wrap any shape with a grid.
  84404. * Colors are customizable.
  84405. */
  84406. export class GridMaterial extends BABYLON.PushMaterial {
  84407. /**
  84408. * Main color of the grid (e.g. between lines)
  84409. */
  84410. mainColor: BABYLON.Color3;
  84411. /**
  84412. * Color of the grid lines.
  84413. */
  84414. lineColor: BABYLON.Color3;
  84415. /**
  84416. * The scale of the grid compared to unit.
  84417. */
  84418. gridRatio: number;
  84419. /**
  84420. * Allows setting an offset for the grid lines.
  84421. */
  84422. gridOffset: BABYLON.Vector3;
  84423. /**
  84424. * The frequency of thicker lines.
  84425. */
  84426. majorUnitFrequency: number;
  84427. /**
  84428. * The visibility of minor units in the grid.
  84429. */
  84430. minorUnitVisibility: number;
  84431. /**
  84432. * The grid opacity outside of the lines.
  84433. */
  84434. opacity: number;
  84435. /**
  84436. * Determine RBG output is premultiplied by alpha value.
  84437. */
  84438. preMultiplyAlpha: boolean;
  84439. private _opacityTexture;
  84440. opacityTexture: BABYLON.BaseTexture;
  84441. private _gridControl;
  84442. /**
  84443. * constructor
  84444. * @param name The name given to the material in order to identify it afterwards.
  84445. * @param scene The scene the material is used in.
  84446. */
  84447. constructor(name: string, scene: BABYLON.Scene);
  84448. /**
  84449. * Returns wehter or not the grid requires alpha blending.
  84450. */
  84451. needAlphaBlending(): boolean;
  84452. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84453. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84454. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84455. /**
  84456. * Dispose the material and its associated resources.
  84457. * @param forceDisposeEffect will also dispose the used effect when true
  84458. */
  84459. dispose(forceDisposeEffect?: boolean): void;
  84460. clone(name: string): GridMaterial;
  84461. serialize(): any;
  84462. getClassName(): string;
  84463. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84464. }
  84465. }
  84466. declare module BABYLON {
  84467. /** @hidden */
  84468. export var lavaPixelShader: {
  84469. name: string;
  84470. shader: string;
  84471. };
  84472. }
  84473. declare module BABYLON {
  84474. /** @hidden */
  84475. export var lavaVertexShader: {
  84476. name: string;
  84477. shader: string;
  84478. };
  84479. }
  84480. declare module BABYLON {
  84481. export class LavaMaterial extends BABYLON.PushMaterial {
  84482. private _diffuseTexture;
  84483. diffuseTexture: BABYLON.BaseTexture;
  84484. noiseTexture: BABYLON.BaseTexture;
  84485. fogColor: BABYLON.Color3;
  84486. speed: number;
  84487. movingSpeed: number;
  84488. lowFrequencySpeed: number;
  84489. fogDensity: number;
  84490. private _lastTime;
  84491. diffuseColor: BABYLON.Color3;
  84492. private _disableLighting;
  84493. disableLighting: boolean;
  84494. private _unlit;
  84495. unlit: boolean;
  84496. private _maxSimultaneousLights;
  84497. maxSimultaneousLights: number;
  84498. private _scaledDiffuse;
  84499. constructor(name: string, scene: BABYLON.Scene);
  84500. needAlphaBlending(): boolean;
  84501. needAlphaTesting(): boolean;
  84502. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84503. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84504. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84505. getAnimatables(): BABYLON.IAnimatable[];
  84506. getActiveTextures(): BABYLON.BaseTexture[];
  84507. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84508. dispose(forceDisposeEffect?: boolean): void;
  84509. clone(name: string): LavaMaterial;
  84510. serialize(): any;
  84511. getClassName(): string;
  84512. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84513. }
  84514. }
  84515. declare module BABYLON {
  84516. /** @hidden */
  84517. export var mixPixelShader: {
  84518. name: string;
  84519. shader: string;
  84520. };
  84521. }
  84522. declare module BABYLON {
  84523. /** @hidden */
  84524. export var mixVertexShader: {
  84525. name: string;
  84526. shader: string;
  84527. };
  84528. }
  84529. declare module BABYLON {
  84530. export class MixMaterial extends BABYLON.PushMaterial {
  84531. /**
  84532. * Mix textures
  84533. */
  84534. private _mixTexture1;
  84535. mixTexture1: BABYLON.BaseTexture;
  84536. private _mixTexture2;
  84537. mixTexture2: BABYLON.BaseTexture;
  84538. /**
  84539. * Diffuse textures
  84540. */
  84541. private _diffuseTexture1;
  84542. diffuseTexture1: BABYLON.Texture;
  84543. private _diffuseTexture2;
  84544. diffuseTexture2: BABYLON.Texture;
  84545. private _diffuseTexture3;
  84546. diffuseTexture3: BABYLON.Texture;
  84547. private _diffuseTexture4;
  84548. diffuseTexture4: BABYLON.Texture;
  84549. private _diffuseTexture5;
  84550. diffuseTexture5: BABYLON.Texture;
  84551. private _diffuseTexture6;
  84552. diffuseTexture6: BABYLON.Texture;
  84553. private _diffuseTexture7;
  84554. diffuseTexture7: BABYLON.Texture;
  84555. private _diffuseTexture8;
  84556. diffuseTexture8: BABYLON.Texture;
  84557. /**
  84558. * Uniforms
  84559. */
  84560. diffuseColor: BABYLON.Color3;
  84561. specularColor: BABYLON.Color3;
  84562. specularPower: number;
  84563. private _disableLighting;
  84564. disableLighting: boolean;
  84565. private _maxSimultaneousLights;
  84566. maxSimultaneousLights: number;
  84567. constructor(name: string, scene: BABYLON.Scene);
  84568. needAlphaBlending(): boolean;
  84569. needAlphaTesting(): boolean;
  84570. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84571. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84572. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84573. getAnimatables(): BABYLON.IAnimatable[];
  84574. getActiveTextures(): BABYLON.BaseTexture[];
  84575. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84576. dispose(forceDisposeEffect?: boolean): void;
  84577. clone(name: string): MixMaterial;
  84578. serialize(): any;
  84579. getClassName(): string;
  84580. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84581. }
  84582. }
  84583. declare module BABYLON {
  84584. /** @hidden */
  84585. export var normalPixelShader: {
  84586. name: string;
  84587. shader: string;
  84588. };
  84589. }
  84590. declare module BABYLON {
  84591. /** @hidden */
  84592. export var normalVertexShader: {
  84593. name: string;
  84594. shader: string;
  84595. };
  84596. }
  84597. declare module BABYLON {
  84598. export class NormalMaterial extends BABYLON.PushMaterial {
  84599. private _diffuseTexture;
  84600. diffuseTexture: BABYLON.BaseTexture;
  84601. diffuseColor: BABYLON.Color3;
  84602. private _disableLighting;
  84603. disableLighting: boolean;
  84604. private _maxSimultaneousLights;
  84605. maxSimultaneousLights: number;
  84606. constructor(name: string, scene: BABYLON.Scene);
  84607. needAlphaBlending(): boolean;
  84608. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84609. needAlphaTesting(): boolean;
  84610. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84611. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84612. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84613. getAnimatables(): BABYLON.IAnimatable[];
  84614. getActiveTextures(): BABYLON.BaseTexture[];
  84615. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84616. dispose(forceDisposeEffect?: boolean): void;
  84617. clone(name: string): NormalMaterial;
  84618. serialize(): any;
  84619. getClassName(): string;
  84620. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84621. }
  84622. }
  84623. declare module BABYLON {
  84624. /** @hidden */
  84625. export var shadowOnlyPixelShader: {
  84626. name: string;
  84627. shader: string;
  84628. };
  84629. }
  84630. declare module BABYLON {
  84631. /** @hidden */
  84632. export var shadowOnlyVertexShader: {
  84633. name: string;
  84634. shader: string;
  84635. };
  84636. }
  84637. declare module BABYLON {
  84638. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84639. private _activeLight;
  84640. private _needAlphaBlending;
  84641. constructor(name: string, scene: BABYLON.Scene);
  84642. shadowColor: BABYLON.Color3;
  84643. needAlphaBlending(): boolean;
  84644. needAlphaTesting(): boolean;
  84645. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84646. get activeLight(): BABYLON.IShadowLight;
  84647. set activeLight(light: BABYLON.IShadowLight);
  84648. private _getFirstShadowLightForMesh;
  84649. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84650. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84651. clone(name: string): ShadowOnlyMaterial;
  84652. serialize(): any;
  84653. getClassName(): string;
  84654. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84655. }
  84656. }
  84657. declare module BABYLON {
  84658. /** @hidden */
  84659. export var simplePixelShader: {
  84660. name: string;
  84661. shader: string;
  84662. };
  84663. }
  84664. declare module BABYLON {
  84665. /** @hidden */
  84666. export var simpleVertexShader: {
  84667. name: string;
  84668. shader: string;
  84669. };
  84670. }
  84671. declare module BABYLON {
  84672. export class SimpleMaterial extends BABYLON.PushMaterial {
  84673. private _diffuseTexture;
  84674. diffuseTexture: BABYLON.BaseTexture;
  84675. diffuseColor: BABYLON.Color3;
  84676. private _disableLighting;
  84677. disableLighting: boolean;
  84678. private _maxSimultaneousLights;
  84679. maxSimultaneousLights: number;
  84680. constructor(name: string, scene: BABYLON.Scene);
  84681. needAlphaBlending(): boolean;
  84682. needAlphaTesting(): boolean;
  84683. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84684. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84685. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84686. getAnimatables(): BABYLON.IAnimatable[];
  84687. getActiveTextures(): BABYLON.BaseTexture[];
  84688. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84689. dispose(forceDisposeEffect?: boolean): void;
  84690. clone(name: string): SimpleMaterial;
  84691. serialize(): any;
  84692. getClassName(): string;
  84693. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84694. }
  84695. }
  84696. declare module BABYLON {
  84697. /** @hidden */
  84698. export var skyPixelShader: {
  84699. name: string;
  84700. shader: string;
  84701. };
  84702. }
  84703. declare module BABYLON {
  84704. /** @hidden */
  84705. export var skyVertexShader: {
  84706. name: string;
  84707. shader: string;
  84708. };
  84709. }
  84710. declare module BABYLON {
  84711. /**
  84712. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84713. * @see https://doc.babylonjs.com/extensions/sky
  84714. */
  84715. export class SkyMaterial extends BABYLON.PushMaterial {
  84716. /**
  84717. * Defines the overall luminance of sky in interval ]0, 1[.
  84718. */
  84719. luminance: number;
  84720. /**
  84721. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84722. */
  84723. turbidity: number;
  84724. /**
  84725. * Defines the sky appearance (light intensity).
  84726. */
  84727. rayleigh: number;
  84728. /**
  84729. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84730. */
  84731. mieCoefficient: number;
  84732. /**
  84733. * Defines the amount of haze particles following the Mie scattering theory.
  84734. */
  84735. mieDirectionalG: number;
  84736. /**
  84737. * Defines the distance of the sun according to the active scene camera.
  84738. */
  84739. distance: number;
  84740. /**
  84741. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84742. * "inclined".
  84743. */
  84744. inclination: number;
  84745. /**
  84746. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84747. * an object direction and a reference direction.
  84748. */
  84749. azimuth: number;
  84750. /**
  84751. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84752. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84753. */
  84754. sunPosition: BABYLON.Vector3;
  84755. /**
  84756. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84757. * .sunPosition property.
  84758. */
  84759. useSunPosition: boolean;
  84760. /**
  84761. * Defines an offset vector used to get a horizon offset.
  84762. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84763. */
  84764. cameraOffset: BABYLON.Vector3;
  84765. private _cameraPosition;
  84766. /**
  84767. * Instantiates a new sky material.
  84768. * This material allows to create dynamic and texture free
  84769. * effects for skyboxes by taking care of the atmosphere state.
  84770. * @see https://doc.babylonjs.com/extensions/sky
  84771. * @param name Define the name of the material in the scene
  84772. * @param scene Define the scene the material belong to
  84773. */
  84774. constructor(name: string, scene: BABYLON.Scene);
  84775. /**
  84776. * Specifies if the material will require alpha blending
  84777. * @returns a boolean specifying if alpha blending is needed
  84778. */
  84779. needAlphaBlending(): boolean;
  84780. /**
  84781. * Specifies if this material should be rendered in alpha test mode
  84782. * @returns false as the sky material doesn't need alpha testing.
  84783. */
  84784. needAlphaTesting(): boolean;
  84785. /**
  84786. * Get the texture used for alpha test purpose.
  84787. * @returns null as the sky material has no texture.
  84788. */
  84789. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84790. /**
  84791. * Get if the submesh is ready to be used and all its information available.
  84792. * Child classes can use it to update shaders
  84793. * @param mesh defines the mesh to check
  84794. * @param subMesh defines which submesh to check
  84795. * @param useInstances specifies that instances should be used
  84796. * @returns a boolean indicating that the submesh is ready or not
  84797. */
  84798. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84799. /**
  84800. * Binds the submesh to this material by preparing the effect and shader to draw
  84801. * @param world defines the world transformation matrix
  84802. * @param mesh defines the mesh containing the submesh
  84803. * @param subMesh defines the submesh to bind the material to
  84804. */
  84805. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84806. /**
  84807. * Get the list of animatables in the material.
  84808. * @returns the list of animatables object used in the material
  84809. */
  84810. getAnimatables(): BABYLON.IAnimatable[];
  84811. /**
  84812. * Disposes the material
  84813. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84814. */
  84815. dispose(forceDisposeEffect?: boolean): void;
  84816. /**
  84817. * Makes a duplicate of the material, and gives it a new name
  84818. * @param name defines the new name for the duplicated material
  84819. * @returns the cloned material
  84820. */
  84821. clone(name: string): SkyMaterial;
  84822. /**
  84823. * Serializes this material in a JSON representation
  84824. * @returns the serialized material object
  84825. */
  84826. serialize(): any;
  84827. /**
  84828. * Gets the current class name of the material e.g. "SkyMaterial"
  84829. * Mainly use in serialization.
  84830. * @returns the class name
  84831. */
  84832. getClassName(): string;
  84833. /**
  84834. * Creates a sky material from parsed material data
  84835. * @param source defines the JSON representation of the material
  84836. * @param scene defines the hosting scene
  84837. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84838. * @returns a new sky material
  84839. */
  84840. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84841. }
  84842. }
  84843. declare module BABYLON {
  84844. /** @hidden */
  84845. export var terrainPixelShader: {
  84846. name: string;
  84847. shader: string;
  84848. };
  84849. }
  84850. declare module BABYLON {
  84851. /** @hidden */
  84852. export var terrainVertexShader: {
  84853. name: string;
  84854. shader: string;
  84855. };
  84856. }
  84857. declare module BABYLON {
  84858. export class TerrainMaterial extends BABYLON.PushMaterial {
  84859. private _mixTexture;
  84860. mixTexture: BABYLON.BaseTexture;
  84861. private _diffuseTexture1;
  84862. diffuseTexture1: BABYLON.Texture;
  84863. private _diffuseTexture2;
  84864. diffuseTexture2: BABYLON.Texture;
  84865. private _diffuseTexture3;
  84866. diffuseTexture3: BABYLON.Texture;
  84867. private _bumpTexture1;
  84868. bumpTexture1: BABYLON.Texture;
  84869. private _bumpTexture2;
  84870. bumpTexture2: BABYLON.Texture;
  84871. private _bumpTexture3;
  84872. bumpTexture3: BABYLON.Texture;
  84873. diffuseColor: BABYLON.Color3;
  84874. specularColor: BABYLON.Color3;
  84875. specularPower: number;
  84876. private _disableLighting;
  84877. disableLighting: boolean;
  84878. private _maxSimultaneousLights;
  84879. maxSimultaneousLights: number;
  84880. constructor(name: string, scene: BABYLON.Scene);
  84881. needAlphaBlending(): boolean;
  84882. needAlphaTesting(): boolean;
  84883. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84884. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84885. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84886. getAnimatables(): BABYLON.IAnimatable[];
  84887. getActiveTextures(): BABYLON.BaseTexture[];
  84888. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84889. dispose(forceDisposeEffect?: boolean): void;
  84890. clone(name: string): TerrainMaterial;
  84891. serialize(): any;
  84892. getClassName(): string;
  84893. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84894. }
  84895. }
  84896. declare module BABYLON {
  84897. /** @hidden */
  84898. export var triplanarPixelShader: {
  84899. name: string;
  84900. shader: string;
  84901. };
  84902. }
  84903. declare module BABYLON {
  84904. /** @hidden */
  84905. export var triplanarVertexShader: {
  84906. name: string;
  84907. shader: string;
  84908. };
  84909. }
  84910. declare module BABYLON {
  84911. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84912. mixTexture: BABYLON.BaseTexture;
  84913. private _diffuseTextureX;
  84914. diffuseTextureX: BABYLON.BaseTexture;
  84915. private _diffuseTextureY;
  84916. diffuseTextureY: BABYLON.BaseTexture;
  84917. private _diffuseTextureZ;
  84918. diffuseTextureZ: BABYLON.BaseTexture;
  84919. private _normalTextureX;
  84920. normalTextureX: BABYLON.BaseTexture;
  84921. private _normalTextureY;
  84922. normalTextureY: BABYLON.BaseTexture;
  84923. private _normalTextureZ;
  84924. normalTextureZ: BABYLON.BaseTexture;
  84925. tileSize: number;
  84926. diffuseColor: BABYLON.Color3;
  84927. specularColor: BABYLON.Color3;
  84928. specularPower: number;
  84929. private _disableLighting;
  84930. disableLighting: boolean;
  84931. private _maxSimultaneousLights;
  84932. maxSimultaneousLights: number;
  84933. constructor(name: string, scene: BABYLON.Scene);
  84934. needAlphaBlending(): boolean;
  84935. needAlphaTesting(): boolean;
  84936. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84937. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84938. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84939. getAnimatables(): BABYLON.IAnimatable[];
  84940. getActiveTextures(): BABYLON.BaseTexture[];
  84941. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84942. dispose(forceDisposeEffect?: boolean): void;
  84943. clone(name: string): TriPlanarMaterial;
  84944. serialize(): any;
  84945. getClassName(): string;
  84946. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84947. }
  84948. }
  84949. declare module BABYLON {
  84950. /** @hidden */
  84951. export var waterPixelShader: {
  84952. name: string;
  84953. shader: string;
  84954. };
  84955. }
  84956. declare module BABYLON {
  84957. /** @hidden */
  84958. export var waterVertexShader: {
  84959. name: string;
  84960. shader: string;
  84961. };
  84962. }
  84963. declare module BABYLON {
  84964. export class WaterMaterial extends BABYLON.PushMaterial {
  84965. renderTargetSize: BABYLON.Vector2;
  84966. private _bumpTexture;
  84967. bumpTexture: BABYLON.BaseTexture;
  84968. diffuseColor: BABYLON.Color3;
  84969. specularColor: BABYLON.Color3;
  84970. specularPower: number;
  84971. private _disableLighting;
  84972. disableLighting: boolean;
  84973. private _maxSimultaneousLights;
  84974. maxSimultaneousLights: number;
  84975. /**
  84976. * @param {number}: Represents the wind force
  84977. */
  84978. windForce: number;
  84979. /**
  84980. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84981. */
  84982. windDirection: BABYLON.Vector2;
  84983. /**
  84984. * @param {number}: Wave height, represents the height of the waves
  84985. */
  84986. waveHeight: number;
  84987. /**
  84988. * @param {number}: Bump height, represents the bump height related to the bump map
  84989. */
  84990. bumpHeight: number;
  84991. /**
  84992. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84993. */
  84994. private _bumpSuperimpose;
  84995. bumpSuperimpose: boolean;
  84996. /**
  84997. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  84998. */
  84999. private _fresnelSeparate;
  85000. fresnelSeparate: boolean;
  85001. /**
  85002. * @param {boolean}: bump Waves modify the reflection.
  85003. */
  85004. private _bumpAffectsReflection;
  85005. bumpAffectsReflection: boolean;
  85006. /**
  85007. * @param {number}: The water color blended with the refraction (near)
  85008. */
  85009. waterColor: BABYLON.Color3;
  85010. /**
  85011. * @param {number}: The blend factor related to the water color
  85012. */
  85013. colorBlendFactor: number;
  85014. /**
  85015. * @param {number}: The water color blended with the reflection (far)
  85016. */
  85017. waterColor2: BABYLON.Color3;
  85018. /**
  85019. * @param {number}: The blend factor related to the water color (reflection, far)
  85020. */
  85021. colorBlendFactor2: number;
  85022. /**
  85023. * @param {number}: Represents the maximum length of a wave
  85024. */
  85025. waveLength: number;
  85026. /**
  85027. * @param {number}: Defines the waves speed
  85028. */
  85029. waveSpeed: number;
  85030. /**
  85031. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  85032. * will avoid calculating useless pixels in the pixel shader of the water material.
  85033. */
  85034. disableClipPlane: boolean;
  85035. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  85036. private _mesh;
  85037. private _refractionRTT;
  85038. private _reflectionRTT;
  85039. private _reflectionTransform;
  85040. private _lastTime;
  85041. private _lastDeltaTime;
  85042. private _useLogarithmicDepth;
  85043. private _waitingRenderList;
  85044. private _imageProcessingConfiguration;
  85045. private _imageProcessingObserver;
  85046. /**
  85047. * Gets a boolean indicating that current material needs to register RTT
  85048. */
  85049. get hasRenderTargetTextures(): boolean;
  85050. /**
  85051. * Constructor
  85052. */
  85053. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  85054. get useLogarithmicDepth(): boolean;
  85055. set useLogarithmicDepth(value: boolean);
  85056. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85057. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85058. addToRenderList(node: any): void;
  85059. enableRenderTargets(enable: boolean): void;
  85060. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  85061. get renderTargetsEnabled(): boolean;
  85062. needAlphaBlending(): boolean;
  85063. needAlphaTesting(): boolean;
  85064. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85065. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85066. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85067. private _createRenderTargets;
  85068. getAnimatables(): BABYLON.IAnimatable[];
  85069. getActiveTextures(): BABYLON.BaseTexture[];
  85070. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85071. dispose(forceDisposeEffect?: boolean): void;
  85072. clone(name: string): WaterMaterial;
  85073. serialize(): any;
  85074. getClassName(): string;
  85075. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  85076. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  85077. }
  85078. }
  85079. declare module BABYLON {
  85080. /** @hidden */
  85081. export var asciiartPixelShader: {
  85082. name: string;
  85083. shader: string;
  85084. };
  85085. }
  85086. declare module BABYLON {
  85087. /**
  85088. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  85089. *
  85090. * It basically takes care rendering the font front the given font size to a texture.
  85091. * This is used later on in the postprocess.
  85092. */
  85093. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  85094. private _font;
  85095. private _text;
  85096. private _charSize;
  85097. /**
  85098. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85099. */
  85100. get charSize(): number;
  85101. /**
  85102. * Create a new instance of the Ascii Art FontTexture class
  85103. * @param name the name of the texture
  85104. * @param font the font to use, use the W3C CSS notation
  85105. * @param text the caracter set to use in the rendering.
  85106. * @param scene the scene that owns the texture
  85107. */
  85108. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85109. /**
  85110. * Gets the max char width of a font.
  85111. * @param font the font to use, use the W3C CSS notation
  85112. * @return the max char width
  85113. */
  85114. private getFontWidth;
  85115. /**
  85116. * Gets the max char height of a font.
  85117. * @param font the font to use, use the W3C CSS notation
  85118. * @return the max char height
  85119. */
  85120. private getFontHeight;
  85121. /**
  85122. * Clones the current AsciiArtTexture.
  85123. * @return the clone of the texture.
  85124. */
  85125. clone(): AsciiArtFontTexture;
  85126. /**
  85127. * Parses a json object representing the texture and returns an instance of it.
  85128. * @param source the source JSON representation
  85129. * @param scene the scene to create the texture for
  85130. * @return the parsed texture
  85131. */
  85132. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  85133. }
  85134. /**
  85135. * Option available in the Ascii Art Post Process.
  85136. */
  85137. export interface IAsciiArtPostProcessOptions {
  85138. /**
  85139. * The font to use following the w3c font definition.
  85140. */
  85141. font?: string;
  85142. /**
  85143. * The character set to use in the postprocess.
  85144. */
  85145. characterSet?: string;
  85146. /**
  85147. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85148. * This number is defined between 0 and 1;
  85149. */
  85150. mixToTile?: number;
  85151. /**
  85152. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85153. * This number is defined between 0 and 1;
  85154. */
  85155. mixToNormal?: number;
  85156. }
  85157. /**
  85158. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  85159. *
  85160. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85161. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  85162. */
  85163. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  85164. /**
  85165. * The font texture used to render the char in the post process.
  85166. */
  85167. private _asciiArtFontTexture;
  85168. /**
  85169. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85170. * This number is defined between 0 and 1;
  85171. */
  85172. mixToTile: number;
  85173. /**
  85174. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85175. * This number is defined between 0 and 1;
  85176. */
  85177. mixToNormal: number;
  85178. /**
  85179. * Instantiates a new Ascii Art Post Process.
  85180. * @param name the name to give to the postprocess
  85181. * @camera the camera to apply the post process to.
  85182. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  85183. */
  85184. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  85185. }
  85186. }
  85187. declare module BABYLON {
  85188. /** @hidden */
  85189. export var digitalrainPixelShader: {
  85190. name: string;
  85191. shader: string;
  85192. };
  85193. }
  85194. declare module BABYLON {
  85195. /**
  85196. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  85197. *
  85198. * It basically takes care rendering the font front the given font size to a texture.
  85199. * This is used later on in the postprocess.
  85200. */
  85201. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  85202. private _font;
  85203. private _text;
  85204. private _charSize;
  85205. /**
  85206. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85207. */
  85208. get charSize(): number;
  85209. /**
  85210. * Create a new instance of the Digital Rain FontTexture class
  85211. * @param name the name of the texture
  85212. * @param font the font to use, use the W3C CSS notation
  85213. * @param text the caracter set to use in the rendering.
  85214. * @param scene the scene that owns the texture
  85215. */
  85216. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85217. /**
  85218. * Gets the max char width of a font.
  85219. * @param font the font to use, use the W3C CSS notation
  85220. * @return the max char width
  85221. */
  85222. private getFontWidth;
  85223. /**
  85224. * Gets the max char height of a font.
  85225. * @param font the font to use, use the W3C CSS notation
  85226. * @return the max char height
  85227. */
  85228. private getFontHeight;
  85229. /**
  85230. * Clones the current DigitalRainFontTexture.
  85231. * @return the clone of the texture.
  85232. */
  85233. clone(): DigitalRainFontTexture;
  85234. /**
  85235. * Parses a json object representing the texture and returns an instance of it.
  85236. * @param source the source JSON representation
  85237. * @param scene the scene to create the texture for
  85238. * @return the parsed texture
  85239. */
  85240. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  85241. }
  85242. /**
  85243. * Option available in the Digital Rain Post Process.
  85244. */
  85245. export interface IDigitalRainPostProcessOptions {
  85246. /**
  85247. * The font to use following the w3c font definition.
  85248. */
  85249. font?: string;
  85250. /**
  85251. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85252. * This number is defined between 0 and 1;
  85253. */
  85254. mixToTile?: number;
  85255. /**
  85256. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85257. * This number is defined between 0 and 1;
  85258. */
  85259. mixToNormal?: number;
  85260. }
  85261. /**
  85262. * DigitalRainPostProcess helps rendering everithing in digital rain.
  85263. *
  85264. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85265. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  85266. */
  85267. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  85268. /**
  85269. * The font texture used to render the char in the post process.
  85270. */
  85271. private _digitalRainFontTexture;
  85272. /**
  85273. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85274. * This number is defined between 0 and 1;
  85275. */
  85276. mixToTile: number;
  85277. /**
  85278. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85279. * This number is defined between 0 and 1;
  85280. */
  85281. mixToNormal: number;
  85282. /**
  85283. * Instantiates a new Digital Rain Post Process.
  85284. * @param name the name to give to the postprocess
  85285. * @camera the camera to apply the post process to.
  85286. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  85287. */
  85288. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  85289. }
  85290. }
  85291. declare module BABYLON {
  85292. /** @hidden */
  85293. export var brickProceduralTexturePixelShader: {
  85294. name: string;
  85295. shader: string;
  85296. };
  85297. }
  85298. declare module BABYLON {
  85299. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85300. private _numberOfBricksHeight;
  85301. private _numberOfBricksWidth;
  85302. private _jointColor;
  85303. private _brickColor;
  85304. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85305. updateShaderUniforms(): void;
  85306. get numberOfBricksHeight(): number;
  85307. set numberOfBricksHeight(value: number);
  85308. get numberOfBricksWidth(): number;
  85309. set numberOfBricksWidth(value: number);
  85310. get jointColor(): BABYLON.Color3;
  85311. set jointColor(value: BABYLON.Color3);
  85312. get brickColor(): BABYLON.Color3;
  85313. set brickColor(value: BABYLON.Color3);
  85314. /**
  85315. * Serializes this brick procedural texture
  85316. * @returns a serialized brick procedural texture object
  85317. */
  85318. serialize(): any;
  85319. /**
  85320. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85321. * @param parsedTexture defines parsed texture data
  85322. * @param scene defines the current scene
  85323. * @param rootUrl defines the root URL containing brick procedural texture information
  85324. * @returns a parsed Brick Procedural BABYLON.Texture
  85325. */
  85326. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85327. }
  85328. }
  85329. declare module BABYLON {
  85330. /** @hidden */
  85331. export var cloudProceduralTexturePixelShader: {
  85332. name: string;
  85333. shader: string;
  85334. };
  85335. }
  85336. declare module BABYLON {
  85337. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85338. private _skyColor;
  85339. private _cloudColor;
  85340. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85341. updateShaderUniforms(): void;
  85342. get skyColor(): BABYLON.Color4;
  85343. set skyColor(value: BABYLON.Color4);
  85344. get cloudColor(): BABYLON.Color4;
  85345. set cloudColor(value: BABYLON.Color4);
  85346. /**
  85347. * Serializes this cloud procedural texture
  85348. * @returns a serialized cloud procedural texture object
  85349. */
  85350. serialize(): any;
  85351. /**
  85352. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85353. * @param parsedTexture defines parsed texture data
  85354. * @param scene defines the current scene
  85355. * @param rootUrl defines the root URL containing cloud procedural texture information
  85356. * @returns a parsed Cloud Procedural BABYLON.Texture
  85357. */
  85358. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85359. }
  85360. }
  85361. declare module BABYLON {
  85362. /** @hidden */
  85363. export var fireProceduralTexturePixelShader: {
  85364. name: string;
  85365. shader: string;
  85366. };
  85367. }
  85368. declare module BABYLON {
  85369. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85370. private _time;
  85371. private _speed;
  85372. private _autoGenerateTime;
  85373. private _fireColors;
  85374. private _alphaThreshold;
  85375. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85376. updateShaderUniforms(): void;
  85377. render(useCameraPostProcess?: boolean): void;
  85378. static get PurpleFireColors(): BABYLON.Color3[];
  85379. static get GreenFireColors(): BABYLON.Color3[];
  85380. static get RedFireColors(): BABYLON.Color3[];
  85381. static get BlueFireColors(): BABYLON.Color3[];
  85382. get autoGenerateTime(): boolean;
  85383. set autoGenerateTime(value: boolean);
  85384. get fireColors(): BABYLON.Color3[];
  85385. set fireColors(value: BABYLON.Color3[]);
  85386. get time(): number;
  85387. set time(value: number);
  85388. get speed(): BABYLON.Vector2;
  85389. set speed(value: BABYLON.Vector2);
  85390. get alphaThreshold(): number;
  85391. set alphaThreshold(value: number);
  85392. /**
  85393. * Serializes this fire procedural texture
  85394. * @returns a serialized fire procedural texture object
  85395. */
  85396. serialize(): any;
  85397. /**
  85398. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85399. * @param parsedTexture defines parsed texture data
  85400. * @param scene defines the current scene
  85401. * @param rootUrl defines the root URL containing fire procedural texture information
  85402. * @returns a parsed Fire Procedural BABYLON.Texture
  85403. */
  85404. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85405. }
  85406. }
  85407. declare module BABYLON {
  85408. /** @hidden */
  85409. export var grassProceduralTexturePixelShader: {
  85410. name: string;
  85411. shader: string;
  85412. };
  85413. }
  85414. declare module BABYLON {
  85415. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85416. private _grassColors;
  85417. private _groundColor;
  85418. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85419. updateShaderUniforms(): void;
  85420. get grassColors(): BABYLON.Color3[];
  85421. set grassColors(value: BABYLON.Color3[]);
  85422. get groundColor(): BABYLON.Color3;
  85423. set groundColor(value: BABYLON.Color3);
  85424. /**
  85425. * Serializes this grass procedural texture
  85426. * @returns a serialized grass procedural texture object
  85427. */
  85428. serialize(): any;
  85429. /**
  85430. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85431. * @param parsedTexture defines parsed texture data
  85432. * @param scene defines the current scene
  85433. * @param rootUrl defines the root URL containing grass procedural texture information
  85434. * @returns a parsed Grass Procedural BABYLON.Texture
  85435. */
  85436. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85437. }
  85438. }
  85439. declare module BABYLON {
  85440. /** @hidden */
  85441. export var marbleProceduralTexturePixelShader: {
  85442. name: string;
  85443. shader: string;
  85444. };
  85445. }
  85446. declare module BABYLON {
  85447. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85448. private _numberOfTilesHeight;
  85449. private _numberOfTilesWidth;
  85450. private _amplitude;
  85451. private _jointColor;
  85452. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85453. updateShaderUniforms(): void;
  85454. get numberOfTilesHeight(): number;
  85455. set numberOfTilesHeight(value: number);
  85456. get amplitude(): number;
  85457. set amplitude(value: number);
  85458. get numberOfTilesWidth(): number;
  85459. set numberOfTilesWidth(value: number);
  85460. get jointColor(): BABYLON.Color3;
  85461. set jointColor(value: BABYLON.Color3);
  85462. /**
  85463. * Serializes this marble procedural texture
  85464. * @returns a serialized marble procedural texture object
  85465. */
  85466. serialize(): any;
  85467. /**
  85468. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85469. * @param parsedTexture defines parsed texture data
  85470. * @param scene defines the current scene
  85471. * @param rootUrl defines the root URL containing marble procedural texture information
  85472. * @returns a parsed Marble Procedural BABYLON.Texture
  85473. */
  85474. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85475. }
  85476. }
  85477. declare module BABYLON {
  85478. /** @hidden */
  85479. export var normalMapProceduralTexturePixelShader: {
  85480. name: string;
  85481. shader: string;
  85482. };
  85483. }
  85484. declare module BABYLON {
  85485. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85486. private _baseTexture;
  85487. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85488. updateShaderUniforms(): void;
  85489. render(useCameraPostProcess?: boolean): void;
  85490. resize(size: any, generateMipMaps: any): void;
  85491. get baseTexture(): BABYLON.Texture;
  85492. set baseTexture(texture: BABYLON.Texture);
  85493. /**
  85494. * Serializes this normal map procedural texture
  85495. * @returns a serialized normal map procedural texture object
  85496. */
  85497. serialize(): any;
  85498. /**
  85499. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85500. * @param parsedTexture defines parsed texture data
  85501. * @param scene defines the current scene
  85502. * @param rootUrl defines the root URL containing normal map procedural texture information
  85503. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85504. */
  85505. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85506. }
  85507. }
  85508. declare module BABYLON {
  85509. /** @hidden */
  85510. export var perlinNoiseProceduralTexturePixelShader: {
  85511. name: string;
  85512. shader: string;
  85513. };
  85514. }
  85515. declare module BABYLON {
  85516. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85517. time: number;
  85518. timeScale: number;
  85519. translationSpeed: number;
  85520. private _currentTranslation;
  85521. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85522. updateShaderUniforms(): void;
  85523. render(useCameraPostProcess?: boolean): void;
  85524. resize(size: any, generateMipMaps: any): void;
  85525. /**
  85526. * Serializes this perlin noise procedural texture
  85527. * @returns a serialized perlin noise procedural texture object
  85528. */
  85529. serialize(): any;
  85530. /**
  85531. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85532. * @param parsedTexture defines parsed texture data
  85533. * @param scene defines the current scene
  85534. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85535. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85536. */
  85537. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85538. }
  85539. }
  85540. declare module BABYLON {
  85541. /** @hidden */
  85542. export var roadProceduralTexturePixelShader: {
  85543. name: string;
  85544. shader: string;
  85545. };
  85546. }
  85547. declare module BABYLON {
  85548. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85549. private _roadColor;
  85550. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85551. updateShaderUniforms(): void;
  85552. get roadColor(): BABYLON.Color3;
  85553. set roadColor(value: BABYLON.Color3);
  85554. /**
  85555. * Serializes this road procedural texture
  85556. * @returns a serialized road procedural texture object
  85557. */
  85558. serialize(): any;
  85559. /**
  85560. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85561. * @param parsedTexture defines parsed texture data
  85562. * @param scene defines the current scene
  85563. * @param rootUrl defines the root URL containing road procedural texture information
  85564. * @returns a parsed Road Procedural BABYLON.Texture
  85565. */
  85566. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85567. }
  85568. }
  85569. declare module BABYLON {
  85570. /** @hidden */
  85571. export var starfieldProceduralTexturePixelShader: {
  85572. name: string;
  85573. shader: string;
  85574. };
  85575. }
  85576. declare module BABYLON {
  85577. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85578. private _time;
  85579. private _alpha;
  85580. private _beta;
  85581. private _zoom;
  85582. private _formuparam;
  85583. private _stepsize;
  85584. private _tile;
  85585. private _brightness;
  85586. private _darkmatter;
  85587. private _distfading;
  85588. private _saturation;
  85589. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85590. updateShaderUniforms(): void;
  85591. get time(): number;
  85592. set time(value: number);
  85593. get alpha(): number;
  85594. set alpha(value: number);
  85595. get beta(): number;
  85596. set beta(value: number);
  85597. get formuparam(): number;
  85598. set formuparam(value: number);
  85599. get stepsize(): number;
  85600. set stepsize(value: number);
  85601. get zoom(): number;
  85602. set zoom(value: number);
  85603. get tile(): number;
  85604. set tile(value: number);
  85605. get brightness(): number;
  85606. set brightness(value: number);
  85607. get darkmatter(): number;
  85608. set darkmatter(value: number);
  85609. get distfading(): number;
  85610. set distfading(value: number);
  85611. get saturation(): number;
  85612. set saturation(value: number);
  85613. /**
  85614. * Serializes this starfield procedural texture
  85615. * @returns a serialized starfield procedural texture object
  85616. */
  85617. serialize(): any;
  85618. /**
  85619. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85620. * @param parsedTexture defines parsed texture data
  85621. * @param scene defines the current scene
  85622. * @param rootUrl defines the root URL containing startfield procedural texture information
  85623. * @returns a parsed Starfield Procedural BABYLON.Texture
  85624. */
  85625. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85626. }
  85627. }
  85628. declare module BABYLON {
  85629. /** @hidden */
  85630. export var woodProceduralTexturePixelShader: {
  85631. name: string;
  85632. shader: string;
  85633. };
  85634. }
  85635. declare module BABYLON {
  85636. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85637. private _ampScale;
  85638. private _woodColor;
  85639. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85640. updateShaderUniforms(): void;
  85641. get ampScale(): number;
  85642. set ampScale(value: number);
  85643. get woodColor(): BABYLON.Color3;
  85644. set woodColor(value: BABYLON.Color3);
  85645. /**
  85646. * Serializes this wood procedural texture
  85647. * @returns a serialized wood procedural texture object
  85648. */
  85649. serialize(): any;
  85650. /**
  85651. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85652. * @param parsedTexture defines parsed texture data
  85653. * @param scene defines the current scene
  85654. * @param rootUrl defines the root URL containing wood procedural texture information
  85655. * @returns a parsed Wood Procedural BABYLON.Texture
  85656. */
  85657. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85658. }
  85659. }