documentation.d.ts 3.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4597. /**
  4598. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4599. * This function works in right handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4608. * This function works in right handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5120. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r?: number,
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g?: number,
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b?: number);
  5513. /**
  5514. * Creates a string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class IntersectionInfo {
  6822. bu: Nullable<number>;
  6823. bv: Nullable<number>;
  6824. distance: number;
  6825. faceId: number;
  6826. subMeshId: number;
  6827. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * Class used to store bounding sphere information
  6833. */
  6834. export class BoundingSphere {
  6835. /**
  6836. * Gets the center of the bounding sphere in local space
  6837. */
  6838. readonly center: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in local space
  6841. */
  6842. radius: number;
  6843. /**
  6844. * Gets the center of the bounding sphere in world space
  6845. */
  6846. readonly centerWorld: Vector3;
  6847. /**
  6848. * Radius of the bounding sphere in world space
  6849. */
  6850. radiusWorld: number;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * Creates a new bounding sphere
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding sphere by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingSphere;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding sphere is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding sphere center is in between the frustum planes.
  6896. * Used for optimistic fast inclusion.
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if the sphere center is in between the frustum planes
  6899. */
  6900. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding sphere
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding sphere
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Checks if two sphere intersct
  6909. * @param sphere0 sphere 0
  6910. * @param sphere1 sphere 1
  6911. * @returns true if the speres intersect
  6912. */
  6913. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Class used to store bounding box information
  6919. */
  6920. export class BoundingBox implements ICullable {
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in local space
  6923. */
  6924. readonly vectors: Vector3[];
  6925. /**
  6926. * Gets the center of the bounding box in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Gets the center of the bounding box in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Gets the extend size in local space
  6935. */
  6936. readonly extendSize: Vector3;
  6937. /**
  6938. * Gets the extend size in world space
  6939. */
  6940. readonly extendSizeWorld: Vector3;
  6941. /**
  6942. * Gets the OBB (object bounding box) directions
  6943. */
  6944. readonly directions: Vector3[];
  6945. /**
  6946. * Gets the 8 vectors representing the bounding box in world space
  6947. */
  6948. readonly vectorsWorld: Vector3[];
  6949. /**
  6950. * Gets the minimum vector in world space
  6951. */
  6952. readonly minimumWorld: Vector3;
  6953. /**
  6954. * Gets the maximum vector in world space
  6955. */
  6956. readonly maximumWorld: Vector3;
  6957. /**
  6958. * Gets the minimum vector in local space
  6959. */
  6960. readonly minimum: Vector3;
  6961. /**
  6962. * Gets the maximum vector in local space
  6963. */
  6964. readonly maximum: Vector3;
  6965. private _worldMatrix;
  6966. private static readonly TmpVector3;
  6967. /**
  6968. * @hidden
  6969. */
  6970. _tag: number;
  6971. /**
  6972. * Creates a new bounding box
  6973. * @param min defines the minimum vector (in local space)
  6974. * @param max defines the maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6978. /**
  6979. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6980. * @param min defines the new minimum vector (in local space)
  6981. * @param max defines the new maximum vector (in local space)
  6982. * @param worldMatrix defines the new world matrix
  6983. */
  6984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6985. /**
  6986. * Scale the current bounding box by applying a scale factor
  6987. * @param factor defines the scale factor to apply
  6988. * @returns the current bounding box
  6989. */
  6990. scale(factor: number): BoundingBox;
  6991. /**
  6992. * Gets the world matrix of the bounding box
  6993. * @returns a matrix
  6994. */
  6995. getWorldMatrix(): DeepImmutable<Matrix>;
  6996. /** @hidden */
  6997. _update(world: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Tests if the bounding box is intersecting the frustum planes
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if the bounding box is entirely inside the frustum planes
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if there is an inclusion
  7008. */
  7009. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding box
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding box
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Tests if the bounding box intersects with a bounding sphere
  7018. * @param sphere defines the sphere to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7022. /**
  7023. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7024. * @param min defines the min vector to use
  7025. * @param max defines the max vector to use
  7026. * @returns true if there is an intersection
  7027. */
  7028. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if two bounding boxes are intersections
  7031. * @param box0 defines the first box to test
  7032. * @param box1 defines the second box to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7036. /**
  7037. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7038. * @param minPoint defines the minimum vector of the bounding box
  7039. * @param maxPoint defines the maximum vector of the bounding box
  7040. * @param sphereCenter defines the sphere center
  7041. * @param sphereRadius defines the sphere radius
  7042. * @returns true if there is an intersection
  7043. */
  7044. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7045. /**
  7046. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7047. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @return true if there is an inclusion
  7050. */
  7051. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7054. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @return true if there is an intersection
  7057. */
  7058. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. }
  7060. }
  7061. declare module BABYLON {
  7062. /** @hidden */
  7063. export class Collider {
  7064. /** Define if a collision was found */
  7065. collisionFound: boolean;
  7066. /**
  7067. * Define last intersection point in local space
  7068. */
  7069. intersectionPoint: Vector3;
  7070. /**
  7071. * Define last collided mesh
  7072. */
  7073. collidedMesh: Nullable<AbstractMesh>;
  7074. private _collisionPoint;
  7075. private _planeIntersectionPoint;
  7076. private _tempVector;
  7077. private _tempVector2;
  7078. private _tempVector3;
  7079. private _tempVector4;
  7080. private _edge;
  7081. private _baseToVertex;
  7082. private _destinationPoint;
  7083. private _slidePlaneNormal;
  7084. private _displacementVector;
  7085. /** @hidden */
  7086. _radius: Vector3;
  7087. /** @hidden */
  7088. _retry: number;
  7089. private _velocity;
  7090. private _basePoint;
  7091. private _epsilon;
  7092. /** @hidden */
  7093. _velocityWorldLength: number;
  7094. /** @hidden */
  7095. _basePointWorld: Vector3;
  7096. private _velocityWorld;
  7097. private _normalizedVelocity;
  7098. /** @hidden */
  7099. _initialVelocity: Vector3;
  7100. /** @hidden */
  7101. _initialPosition: Vector3;
  7102. private _nearestDistance;
  7103. private _collisionMask;
  7104. get collisionMask(): number;
  7105. set collisionMask(mask: number);
  7106. /**
  7107. * Gets the plane normal used to compute the sliding response (in local space)
  7108. */
  7109. get slidePlaneNormal(): Vector3;
  7110. /** @hidden */
  7111. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7112. /** @hidden */
  7113. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7114. /** @hidden */
  7115. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */
  7117. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7118. /** @hidden */
  7119. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7120. /** @hidden */
  7121. _getResponse(pos: Vector3, vel: Vector3): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. /**
  7126. * Interface for cullable objects
  7127. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7128. */
  7129. export interface ICullable {
  7130. /**
  7131. * Checks if the object or part of the object is in the frustum
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isInFrustum(frustumPlanes: Plane[]): boolean;
  7136. /**
  7137. * Checks if a cullable object (mesh...) is in the camera frustum
  7138. * Unlike isInFrustum this cheks the full bounding box
  7139. * @param frustumPlanes Camera near/planes
  7140. * @returns true if the object is in frustum otherwise false
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7143. }
  7144. /**
  7145. * Info for a bounding data of a mesh
  7146. */
  7147. export class BoundingInfo implements ICullable {
  7148. /**
  7149. * Bounding box for the mesh
  7150. */
  7151. readonly boundingBox: BoundingBox;
  7152. /**
  7153. * Bounding sphere for the mesh
  7154. */
  7155. readonly boundingSphere: BoundingSphere;
  7156. private _isLocked;
  7157. private static readonly TmpVector3;
  7158. /**
  7159. * Constructs bounding info
  7160. * @param minimum min vector of the bounding box/sphere
  7161. * @param maximum max vector of the bounding box/sphere
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7165. /**
  7166. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7167. * @param min defines the new minimum vector (in local space)
  7168. * @param max defines the new maximum vector (in local space)
  7169. * @param worldMatrix defines the new world matrix
  7170. */
  7171. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7172. /**
  7173. * min vector of the bounding box/sphere
  7174. */
  7175. get minimum(): Vector3;
  7176. /**
  7177. * max vector of the bounding box/sphere
  7178. */
  7179. get maximum(): Vector3;
  7180. /**
  7181. * If the info is locked and won't be updated to avoid perf overhead
  7182. */
  7183. get isLocked(): boolean;
  7184. set isLocked(value: boolean);
  7185. /**
  7186. * Updates the bounding sphere and box
  7187. * @param world world matrix to be used to update
  7188. */
  7189. update(world: DeepImmutable<Matrix>): void;
  7190. /**
  7191. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7192. * @param center New center of the bounding info
  7193. * @param extend New extend of the bounding info
  7194. * @returns the current bounding info
  7195. */
  7196. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7197. /**
  7198. * Scale the current bounding info by applying a scale factor
  7199. * @param factor defines the scale factor to apply
  7200. * @returns the current bounding info
  7201. */
  7202. scale(factor: number): BoundingInfo;
  7203. /**
  7204. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7205. * @param frustumPlanes defines the frustum to test
  7206. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7207. * @returns true if the bounding info is in the frustum planes
  7208. */
  7209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7210. /**
  7211. * Gets the world distance between the min and max points of the bounding box
  7212. */
  7213. get diagonalLength(): number;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /** @hidden */
  7222. _checkCollision(collider: Collider): boolean;
  7223. /**
  7224. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7225. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7226. * @param point the point to check intersection with
  7227. * @returns if the point intersects
  7228. */
  7229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7230. /**
  7231. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7232. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7233. * @param boundingInfo the bounding info to check intersection with
  7234. * @param precise if the intersection should be done using OBB
  7235. * @returns if the bounding info intersects
  7236. */
  7237. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7238. }
  7239. }
  7240. declare module BABYLON {
  7241. /**
  7242. * Extracts minimum and maximum values from a list of indexed positions
  7243. * @param positions defines the positions to use
  7244. * @param indices defines the indices to the positions
  7245. * @param indexStart defines the start index
  7246. * @param indexCount defines the end index
  7247. * @param bias defines bias value to add to the result
  7248. * @return minimum and maximum values
  7249. */
  7250. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7251. minimum: Vector3;
  7252. maximum: Vector3;
  7253. };
  7254. /**
  7255. * Extracts minimum and maximum values from a list of positions
  7256. * @param positions defines the positions to use
  7257. * @param start defines the start index in the positions array
  7258. * @param count defines the number of positions to handle
  7259. * @param bias defines bias value to add to the result
  7260. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7261. * @return minimum and maximum values
  7262. */
  7263. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7264. minimum: Vector3;
  7265. maximum: Vector3;
  7266. };
  7267. }
  7268. declare module BABYLON {
  7269. /** @hidden */
  7270. export class WebGLDataBuffer extends DataBuffer {
  7271. private _buffer;
  7272. constructor(resource: WebGLBuffer);
  7273. get underlyingResource(): any;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /** @hidden */
  7278. export class WebGLPipelineContext implements IPipelineContext {
  7279. engine: ThinEngine;
  7280. program: Nullable<WebGLProgram>;
  7281. context?: WebGLRenderingContext;
  7282. vertexShader?: WebGLShader;
  7283. fragmentShader?: WebGLShader;
  7284. isParallelCompiled: boolean;
  7285. onCompiled?: () => void;
  7286. transformFeedback?: WebGLTransformFeedback | null;
  7287. vertexCompilationError: Nullable<string>;
  7288. fragmentCompilationError: Nullable<string>;
  7289. programLinkError: Nullable<string>;
  7290. programValidationError: Nullable<string>;
  7291. get isAsync(): boolean;
  7292. get isReady(): boolean;
  7293. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7294. _getVertexShaderCode(): string | null;
  7295. _getFragmentShaderCode(): string | null;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. interface ThinEngine {
  7300. /**
  7301. * Create an uniform buffer
  7302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7303. * @param elements defines the content of the uniform buffer
  7304. * @returns the webGL uniform buffer
  7305. */
  7306. createUniformBuffer(elements: FloatArray): DataBuffer;
  7307. /**
  7308. * Create a dynamic uniform buffer
  7309. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7310. * @param elements defines the content of the uniform buffer
  7311. * @returns the webGL uniform buffer
  7312. */
  7313. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7314. /**
  7315. * Update an existing uniform buffer
  7316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7317. * @param uniformBuffer defines the target uniform buffer
  7318. * @param elements defines the content to update
  7319. * @param offset defines the offset in the uniform buffer where update should start
  7320. * @param count defines the size of the data to update
  7321. */
  7322. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7323. /**
  7324. * Bind an uniform buffer to the current webGL context
  7325. * @param buffer defines the buffer to bind
  7326. */
  7327. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7328. /**
  7329. * Bind a buffer to the current webGL context at a given location
  7330. * @param buffer defines the buffer to bind
  7331. * @param location defines the index where to bind the buffer
  7332. */
  7333. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7334. /**
  7335. * Bind a specific block at a given index in a specific shader program
  7336. * @param pipelineContext defines the pipeline context to use
  7337. * @param blockName defines the block name
  7338. * @param index defines the index where to bind the block
  7339. */
  7340. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. */
  7354. export class UniformBuffer {
  7355. private _engine;
  7356. private _buffer;
  7357. private _data;
  7358. private _bufferData;
  7359. private _dynamic?;
  7360. private _uniformLocations;
  7361. private _uniformSizes;
  7362. private _uniformLocationPointer;
  7363. private _needSync;
  7364. private _noUBO;
  7365. private _currentEffect;
  7366. /** @hidden */
  7367. _alreadyBound: boolean;
  7368. private static _MAX_UNIFORM_SIZE;
  7369. private static _tempBuffer;
  7370. /**
  7371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7376. /**
  7377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7382. /**
  7383. * Lambda to Update a single float in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateFloat: (name: string, x: number) => void;
  7388. /**
  7389. * Lambda to Update a vec2 of float in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update a vec3 of float in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7400. /**
  7401. * Lambda to Update a vec4 of float in a uniform buffer.
  7402. * This is dynamic to allow compat with webgl 1 and 2.
  7403. * You will need to pass the name of the uniform as well as the value.
  7404. */
  7405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7406. /**
  7407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7408. * This is dynamic to allow compat with webgl 1 and 2.
  7409. * You will need to pass the name of the uniform as well as the value.
  7410. */
  7411. updateMatrix: (name: string, mat: Matrix) => void;
  7412. /**
  7413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7414. * This is dynamic to allow compat with webgl 1 and 2.
  7415. * You will need to pass the name of the uniform as well as the value.
  7416. */
  7417. updateVector3: (name: string, vector: Vector3) => void;
  7418. /**
  7419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7420. * This is dynamic to allow compat with webgl 1 and 2.
  7421. * You will need to pass the name of the uniform as well as the value.
  7422. */
  7423. updateVector4: (name: string, vector: Vector4) => void;
  7424. /**
  7425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7426. * This is dynamic to allow compat with webgl 1 and 2.
  7427. * You will need to pass the name of the uniform as well as the value.
  7428. */
  7429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7430. /**
  7431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7432. * This is dynamic to allow compat with webgl 1 and 2.
  7433. * You will need to pass the name of the uniform as well as the value.
  7434. */
  7435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7436. /**
  7437. * Instantiates a new Uniform buffer objects.
  7438. *
  7439. * Handles blocks of uniform on the GPU.
  7440. *
  7441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7442. *
  7443. * For more information, please refer to :
  7444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7445. * @param engine Define the engine the buffer is associated with
  7446. * @param data Define the data contained in the buffer
  7447. * @param dynamic Define if the buffer is updatable
  7448. */
  7449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7450. /**
  7451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7452. * or just falling back on setUniformXXX calls.
  7453. */
  7454. get useUbo(): boolean;
  7455. /**
  7456. * Indicates if the WebGL underlying uniform buffer is in sync
  7457. * with the javascript cache data.
  7458. */
  7459. get isSync(): boolean;
  7460. /**
  7461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7462. * Also, a dynamic UniformBuffer will disable cache verification and always
  7463. * update the underlying WebGL uniform buffer to the GPU.
  7464. * @returns if Dynamic, otherwise false
  7465. */
  7466. isDynamic(): boolean;
  7467. /**
  7468. * The data cache on JS side.
  7469. * @returns the underlying data as a float array
  7470. */
  7471. getData(): Float32Array;
  7472. /**
  7473. * The underlying WebGL Uniform buffer.
  7474. * @returns the webgl buffer
  7475. */
  7476. getBuffer(): Nullable<DataBuffer>;
  7477. /**
  7478. * std140 layout specifies how to align data within an UBO structure.
  7479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7480. * for specs.
  7481. */
  7482. private _fillAlignment;
  7483. /**
  7484. * Adds an uniform in the buffer.
  7485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7486. * for the layout to be correct !
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param size Data size, or data directly.
  7489. */
  7490. addUniform(name: string, size: number | number[]): void;
  7491. /**
  7492. * Adds a Matrix 4x4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param mat A 4x4 matrix.
  7495. */
  7496. addMatrix(name: string, mat: Matrix): void;
  7497. /**
  7498. * Adds a vec2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. * @param x Define the x component value of the vec2
  7501. * @param y Define the y component value of the vec2
  7502. */
  7503. addFloat2(name: string, x: number, y: number): void;
  7504. /**
  7505. * Adds a vec3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. * @param x Define the x component value of the vec3
  7508. * @param y Define the y component value of the vec3
  7509. * @param z Define the z component value of the vec3
  7510. */
  7511. addFloat3(name: string, x: number, y: number, z: number): void;
  7512. /**
  7513. * Adds a vec3 to the uniform buffer.
  7514. * @param name Name of the uniform, as used in the uniform block in the shader.
  7515. * @param color Define the vec3 from a Color
  7516. */
  7517. addColor3(name: string, color: Color3): void;
  7518. /**
  7519. * Adds a vec4 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param color Define the rgb components from a Color
  7522. * @param alpha Define the a component of the vec4
  7523. */
  7524. addColor4(name: string, color: Color3, alpha: number): void;
  7525. /**
  7526. * Adds a vec3 to the uniform buffer.
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param vector Define the vec3 components from a Vector
  7529. */
  7530. addVector3(name: string, vector: Vector3): void;
  7531. /**
  7532. * Adds a Matrix 3x3 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. */
  7535. addMatrix3x3(name: string): void;
  7536. /**
  7537. * Adds a Matrix 2x2 to the uniform buffer.
  7538. * @param name Name of the uniform, as used in the uniform block in the shader.
  7539. */
  7540. addMatrix2x2(name: string): void;
  7541. /**
  7542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7543. */
  7544. create(): void;
  7545. /** @hidden */
  7546. _rebuild(): void;
  7547. /**
  7548. * Updates the WebGL Uniform Buffer on the GPU.
  7549. * If the `dynamic` flag is set to true, no cache comparison is done.
  7550. * Otherwise, the buffer will be updated only if the cache differs.
  7551. */
  7552. update(): void;
  7553. /**
  7554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. * @param size Define the size of the data.
  7558. */
  7559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7560. private _valueCache;
  7561. private _cacheMatrix;
  7562. private _updateMatrix3x3ForUniform;
  7563. private _updateMatrix3x3ForEffect;
  7564. private _updateMatrix2x2ForEffect;
  7565. private _updateMatrix2x2ForUniform;
  7566. private _updateFloatForEffect;
  7567. private _updateFloatForUniform;
  7568. private _updateFloat2ForEffect;
  7569. private _updateFloat2ForUniform;
  7570. private _updateFloat3ForEffect;
  7571. private _updateFloat3ForUniform;
  7572. private _updateFloat4ForEffect;
  7573. private _updateFloat4ForUniform;
  7574. private _updateMatrixForEffect;
  7575. private _updateMatrixForUniform;
  7576. private _updateVector3ForEffect;
  7577. private _updateVector3ForUniform;
  7578. private _updateVector4ForEffect;
  7579. private _updateVector4ForUniform;
  7580. private _updateColor3ForEffect;
  7581. private _updateColor3ForUniform;
  7582. private _updateColor4ForEffect;
  7583. private _updateColor4ForUniform;
  7584. /**
  7585. * Sets a sampler uniform on the effect.
  7586. * @param name Define the name of the sampler.
  7587. * @param texture Define the texture to set in the sampler
  7588. */
  7589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7590. /**
  7591. * Directly updates the value of the uniform in the cache AND on the GPU.
  7592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7593. * @param data Define the flattened data
  7594. */
  7595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7596. /**
  7597. * Binds this uniform buffer to an effect.
  7598. * @param effect Define the effect to bind the buffer to
  7599. * @param name Name of the uniform block in the shader.
  7600. */
  7601. bindToEffect(effect: Effect, name: string): void;
  7602. /**
  7603. * Disposes the uniform buffer.
  7604. */
  7605. dispose(): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Enum that determines the text-wrapping mode to use.
  7611. */
  7612. export enum InspectableType {
  7613. /**
  7614. * Checkbox for booleans
  7615. */
  7616. Checkbox = 0,
  7617. /**
  7618. * Sliders for numbers
  7619. */
  7620. Slider = 1,
  7621. /**
  7622. * Vector3
  7623. */
  7624. Vector3 = 2,
  7625. /**
  7626. * Quaternions
  7627. */
  7628. Quaternion = 3,
  7629. /**
  7630. * Color3
  7631. */
  7632. Color3 = 4,
  7633. /**
  7634. * String
  7635. */
  7636. String = 5
  7637. }
  7638. /**
  7639. * Interface used to define custom inspectable properties.
  7640. * This interface is used by the inspector to display custom property grids
  7641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7642. */
  7643. export interface IInspectable {
  7644. /**
  7645. * Gets the label to display
  7646. */
  7647. label: string;
  7648. /**
  7649. * Gets the name of the property to edit
  7650. */
  7651. propertyName: string;
  7652. /**
  7653. * Gets the type of the editor to use
  7654. */
  7655. type: InspectableType;
  7656. /**
  7657. * Gets the minimum value of the property when using in "slider" mode
  7658. */
  7659. min?: number;
  7660. /**
  7661. * Gets the maximum value of the property when using in "slider" mode
  7662. */
  7663. max?: number;
  7664. /**
  7665. * Gets the setp to use when using in "slider" mode
  7666. */
  7667. step?: number;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class used to provide helper for timing
  7673. */
  7674. export class TimingTools {
  7675. /**
  7676. * Polyfill for setImmediate
  7677. * @param action defines the action to execute after the current execution block
  7678. */
  7679. static SetImmediate(action: () => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * Class used to enable instatition of objects by class name
  7685. */
  7686. export class InstantiationTools {
  7687. /**
  7688. * Use this object to register external classes like custom textures or material
  7689. * to allow the laoders to instantiate them
  7690. */
  7691. static RegisteredExternalClasses: {
  7692. [key: string]: Object;
  7693. };
  7694. /**
  7695. * Tries to instantiate a new object from a given class name
  7696. * @param className defines the class name to instantiate
  7697. * @returns the new object or null if the system was not able to do the instantiation
  7698. */
  7699. static Instantiate(className: string): any;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Define options used to create a depth texture
  7705. */
  7706. export class DepthTextureCreationOptions {
  7707. /** Specifies whether or not a stencil should be allocated in the texture */
  7708. generateStencil?: boolean;
  7709. /** Specifies whether or not bilinear filtering is enable on the texture */
  7710. bilinearFiltering?: boolean;
  7711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7712. comparisonFunction?: number;
  7713. /** Specifies if the created texture is a cube texture */
  7714. isCube?: boolean;
  7715. }
  7716. }
  7717. declare module BABYLON {
  7718. interface ThinEngine {
  7719. /**
  7720. * Creates a depth stencil cube texture.
  7721. * This is only available in WebGL 2.
  7722. * @param size The size of face edge in the cube texture.
  7723. * @param options The options defining the cube texture.
  7724. * @returns The cube texture
  7725. */
  7726. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7741. * @returns the cube texture as an InternalTexture
  7742. */
  7743. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7744. /**
  7745. * Creates a cube texture
  7746. * @param rootUrl defines the url where the files to load is located
  7747. * @param scene defines the current scene
  7748. * @param files defines the list of files to load (1 per face)
  7749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7750. * @param onLoad defines an optional callback raised when the texture is loaded
  7751. * @param onError defines an optional callback raised if there is an issue to load the texture
  7752. * @param format defines the format of the data
  7753. * @param forcedExtension defines the extension to use to pick the right loader
  7754. * @returns the cube texture as an InternalTexture
  7755. */
  7756. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7757. /**
  7758. * Creates a cube texture
  7759. * @param rootUrl defines the url where the files to load is located
  7760. * @param scene defines the current scene
  7761. * @param files defines the list of files to load (1 per face)
  7762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7763. * @param onLoad defines an optional callback raised when the texture is loaded
  7764. * @param onError defines an optional callback raised if there is an issue to load the texture
  7765. * @param format defines the format of the data
  7766. * @param forcedExtension defines the extension to use to pick the right loader
  7767. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7770. * @returns the cube texture as an InternalTexture
  7771. */
  7772. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7773. /** @hidden */
  7774. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7775. /** @hidden */
  7776. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7779. /** @hidden */
  7780. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /**
  7782. * @hidden
  7783. */
  7784. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Class for creating a cube texture
  7790. */
  7791. export class CubeTexture extends BaseTexture {
  7792. private _delayedOnLoad;
  7793. /**
  7794. * Observable triggered once the texture has been loaded.
  7795. */
  7796. onLoadObservable: Observable<CubeTexture>;
  7797. /**
  7798. * The url of the texture
  7799. */
  7800. url: string;
  7801. /**
  7802. * Gets or sets the center of the bounding box associated with the cube texture.
  7803. * It must define where the camera used to render the texture was set
  7804. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. boundingBoxPosition: Vector3;
  7807. private _boundingBoxSize;
  7808. /**
  7809. * Gets or sets the size of the bounding box associated with the cube texture
  7810. * When defined, the cubemap will switch to local mode
  7811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7812. * @example https://www.babylonjs-playground.com/#RNASML
  7813. */
  7814. set boundingBoxSize(value: Vector3);
  7815. /**
  7816. * Returns the bounding box size
  7817. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7818. */
  7819. get boundingBoxSize(): Vector3;
  7820. protected _rotationY: number;
  7821. /**
  7822. * Sets texture matrix rotation angle around Y axis in radians.
  7823. */
  7824. set rotationY(value: number);
  7825. /**
  7826. * Gets texture matrix rotation angle around Y axis radians.
  7827. */
  7828. get rotationY(): number;
  7829. /**
  7830. * Are mip maps generated for this texture or not.
  7831. */
  7832. get noMipmap(): boolean;
  7833. private _noMipmap;
  7834. private _files;
  7835. protected _forcedExtension: Nullable<string>;
  7836. private _extensions;
  7837. private _textureMatrix;
  7838. private _format;
  7839. private _createPolynomials;
  7840. /**
  7841. * Creates a cube texture from an array of image urls
  7842. * @param files defines an array of image urls
  7843. * @param scene defines the hosting scene
  7844. * @param noMipmap specifies if mip maps are not used
  7845. * @returns a cube texture
  7846. */
  7847. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7848. /**
  7849. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7850. * @param url defines the url of the prefiltered texture
  7851. * @param scene defines the scene the texture is attached to
  7852. * @param forcedExtension defines the extension of the file if different from the url
  7853. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7854. * @return the prefiltered texture
  7855. */
  7856. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7857. /**
  7858. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7859. * as prefiltered data.
  7860. * @param rootUrl defines the url of the texture or the root name of the six images
  7861. * @param null defines the scene or engine the texture is attached to
  7862. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7863. * @param noMipmap defines if mipmaps should be created or not
  7864. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7865. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7866. * @param onError defines a callback triggered in case of error during load
  7867. * @param format defines the internal format to use for the texture once loaded
  7868. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7869. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7870. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7873. * @return the cube texture
  7874. */
  7875. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7876. /**
  7877. * Get the current class name of the texture useful for serialization or dynamic coding.
  7878. * @returns "CubeTexture"
  7879. */
  7880. getClassName(): string;
  7881. /**
  7882. * Update the url (and optional buffer) of this texture if url was null during construction.
  7883. * @param url the url of the texture
  7884. * @param forcedExtension defines the extension to use
  7885. * @param onLoad callback called when the texture is loaded (defaults to null)
  7886. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7887. */
  7888. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7889. /**
  7890. * Delays loading of the cube texture
  7891. * @param forcedExtension defines the extension to use
  7892. */
  7893. delayLoad(forcedExtension?: string): void;
  7894. /**
  7895. * Returns the reflection texture matrix
  7896. * @returns the reflection texture matrix
  7897. */
  7898. getReflectionTextureMatrix(): Matrix;
  7899. /**
  7900. * Sets the reflection texture matrix
  7901. * @param value Reflection texture matrix
  7902. */
  7903. setReflectionTextureMatrix(value: Matrix): void;
  7904. /**
  7905. * Parses text to create a cube texture
  7906. * @param parsedTexture define the serialized text to read from
  7907. * @param scene defines the hosting scene
  7908. * @param rootUrl defines the root url of the cube texture
  7909. * @returns a cube texture
  7910. */
  7911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7912. /**
  7913. * Makes a clone, or deep copy, of the cube texture
  7914. * @returns a new cube texture
  7915. */
  7916. clone(): CubeTexture;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * Manages the defines for the Material
  7922. */
  7923. export class MaterialDefines {
  7924. /** @hidden */
  7925. protected _keys: string[];
  7926. private _isDirty;
  7927. /** @hidden */
  7928. _renderId: number;
  7929. /** @hidden */
  7930. _areLightsDirty: boolean;
  7931. /** @hidden */
  7932. _areLightsDisposed: boolean;
  7933. /** @hidden */
  7934. _areAttributesDirty: boolean;
  7935. /** @hidden */
  7936. _areTexturesDirty: boolean;
  7937. /** @hidden */
  7938. _areFresnelDirty: boolean;
  7939. /** @hidden */
  7940. _areMiscDirty: boolean;
  7941. /** @hidden */
  7942. _areImageProcessingDirty: boolean;
  7943. /** @hidden */
  7944. _normals: boolean;
  7945. /** @hidden */
  7946. _uvs: boolean;
  7947. /** @hidden */
  7948. _needNormals: boolean;
  7949. /** @hidden */
  7950. _needUVs: boolean;
  7951. [id: string]: any;
  7952. /**
  7953. * Specifies if the material needs to be re-calculated
  7954. */
  7955. get isDirty(): boolean;
  7956. /**
  7957. * Marks the material to indicate that it has been re-calculated
  7958. */
  7959. markAsProcessed(): void;
  7960. /**
  7961. * Marks the material to indicate that it needs to be re-calculated
  7962. */
  7963. markAsUnprocessed(): void;
  7964. /**
  7965. * Marks the material to indicate all of its defines need to be re-calculated
  7966. */
  7967. markAllAsDirty(): void;
  7968. /**
  7969. * Marks the material to indicate that image processing needs to be re-calculated
  7970. */
  7971. markAsImageProcessingDirty(): void;
  7972. /**
  7973. * Marks the material to indicate the lights need to be re-calculated
  7974. * @param disposed Defines whether the light is dirty due to dispose or not
  7975. */
  7976. markAsLightDirty(disposed?: boolean): void;
  7977. /**
  7978. * Marks the attribute state as changed
  7979. */
  7980. markAsAttributesDirty(): void;
  7981. /**
  7982. * Marks the texture state as changed
  7983. */
  7984. markAsTexturesDirty(): void;
  7985. /**
  7986. * Marks the fresnel state as changed
  7987. */
  7988. markAsFresnelDirty(): void;
  7989. /**
  7990. * Marks the misc state as changed
  7991. */
  7992. markAsMiscDirty(): void;
  7993. /**
  7994. * Rebuilds the material defines
  7995. */
  7996. rebuild(): void;
  7997. /**
  7998. * Specifies if two material defines are equal
  7999. * @param other - A material define instance to compare to
  8000. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8001. */
  8002. isEqual(other: MaterialDefines): boolean;
  8003. /**
  8004. * Clones this instance's defines to another instance
  8005. * @param other - material defines to clone values to
  8006. */
  8007. cloneTo(other: MaterialDefines): void;
  8008. /**
  8009. * Resets the material define values
  8010. */
  8011. reset(): void;
  8012. /**
  8013. * Converts the material define values to a string
  8014. * @returns - String of material define information
  8015. */
  8016. toString(): string;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8023. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8025. */
  8026. export class ColorCurves {
  8027. private _dirty;
  8028. private _tempColor;
  8029. private _globalCurve;
  8030. private _highlightsCurve;
  8031. private _midtonesCurve;
  8032. private _shadowsCurve;
  8033. private _positiveCurve;
  8034. private _negativeCurve;
  8035. private _globalHue;
  8036. private _globalDensity;
  8037. private _globalSaturation;
  8038. private _globalExposure;
  8039. /**
  8040. * Gets the global Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. get globalHue(): number;
  8044. /**
  8045. * Sets the global Hue value.
  8046. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8047. */
  8048. set globalHue(value: number);
  8049. /**
  8050. * Gets the global Density value.
  8051. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. get globalDensity(): number;
  8055. /**
  8056. * Sets the global Density value.
  8057. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. set globalDensity(value: number);
  8061. /**
  8062. * Gets the global Saturation value.
  8063. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8064. */
  8065. get globalSaturation(): number;
  8066. /**
  8067. * Sets the global Saturation value.
  8068. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8069. */
  8070. set globalSaturation(value: number);
  8071. /**
  8072. * Gets the global Exposure value.
  8073. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8074. */
  8075. get globalExposure(): number;
  8076. /**
  8077. * Sets the global Exposure value.
  8078. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8079. */
  8080. set globalExposure(value: number);
  8081. private _highlightsHue;
  8082. private _highlightsDensity;
  8083. private _highlightsSaturation;
  8084. private _highlightsExposure;
  8085. /**
  8086. * Gets the highlights Hue value.
  8087. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8088. */
  8089. get highlightsHue(): number;
  8090. /**
  8091. * Sets the highlights Hue value.
  8092. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8093. */
  8094. set highlightsHue(value: number);
  8095. /**
  8096. * Gets the highlights Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. get highlightsDensity(): number;
  8101. /**
  8102. * Sets the highlights Density value.
  8103. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. set highlightsDensity(value: number);
  8107. /**
  8108. * Gets the highlights Saturation value.
  8109. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8110. */
  8111. get highlightsSaturation(): number;
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8115. */
  8116. set highlightsSaturation(value: number);
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8120. */
  8121. get highlightsExposure(): number;
  8122. /**
  8123. * Sets the highlights Exposure value.
  8124. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8125. */
  8126. set highlightsExposure(value: number);
  8127. private _midtonesHue;
  8128. private _midtonesDensity;
  8129. private _midtonesSaturation;
  8130. private _midtonesExposure;
  8131. /**
  8132. * Gets the midtones Hue value.
  8133. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8134. */
  8135. get midtonesHue(): number;
  8136. /**
  8137. * Sets the midtones Hue value.
  8138. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8139. */
  8140. set midtonesHue(value: number);
  8141. /**
  8142. * Gets the midtones Density value.
  8143. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. get midtonesDensity(): number;
  8147. /**
  8148. * Sets the midtones Density value.
  8149. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8150. * Values less than zero provide a filter of opposite hue.
  8151. */
  8152. set midtonesDensity(value: number);
  8153. /**
  8154. * Gets the midtones Saturation value.
  8155. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8156. */
  8157. get midtonesSaturation(): number;
  8158. /**
  8159. * Sets the midtones Saturation value.
  8160. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8161. */
  8162. set midtonesSaturation(value: number);
  8163. /**
  8164. * Gets the midtones Exposure value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8166. */
  8167. get midtonesExposure(): number;
  8168. /**
  8169. * Sets the midtones Exposure value.
  8170. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8171. */
  8172. set midtonesExposure(value: number);
  8173. private _shadowsHue;
  8174. private _shadowsDensity;
  8175. private _shadowsSaturation;
  8176. private _shadowsExposure;
  8177. /**
  8178. * Gets the shadows Hue value.
  8179. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8180. */
  8181. get shadowsHue(): number;
  8182. /**
  8183. * Sets the shadows Hue value.
  8184. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8185. */
  8186. set shadowsHue(value: number);
  8187. /**
  8188. * Gets the shadows Density value.
  8189. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get shadowsDensity(): number;
  8193. /**
  8194. * Sets the shadows Density value.
  8195. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set shadowsDensity(value: number);
  8199. /**
  8200. * Gets the shadows Saturation value.
  8201. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8202. */
  8203. get shadowsSaturation(): number;
  8204. /**
  8205. * Sets the shadows Saturation value.
  8206. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8207. */
  8208. set shadowsSaturation(value: number);
  8209. /**
  8210. * Gets the shadows Exposure value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8212. */
  8213. get shadowsExposure(): number;
  8214. /**
  8215. * Sets the shadows Exposure value.
  8216. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8217. */
  8218. set shadowsExposure(value: number);
  8219. /**
  8220. * Returns the class name
  8221. * @returns The class name
  8222. */
  8223. getClassName(): string;
  8224. /**
  8225. * Binds the color curves to the shader.
  8226. * @param colorCurves The color curve to bind
  8227. * @param effect The effect to bind to
  8228. * @param positiveUniform The positive uniform shader parameter
  8229. * @param neutralUniform The neutral uniform shader parameter
  8230. * @param negativeUniform The negative uniform shader parameter
  8231. */
  8232. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8233. /**
  8234. * Prepare the list of uniforms associated with the ColorCurves effects.
  8235. * @param uniformsList The list of uniforms used in the effect
  8236. */
  8237. static PrepareUniforms(uniformsList: string[]): void;
  8238. /**
  8239. * Returns color grading data based on a hue, density, saturation and exposure value.
  8240. * @param filterHue The hue of the color filter.
  8241. * @param filterDensity The density of the color filter.
  8242. * @param saturation The saturation.
  8243. * @param exposure The exposure.
  8244. * @param result The result data container.
  8245. */
  8246. private getColorGradingDataToRef;
  8247. /**
  8248. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8249. * @param value The input slider value in range [-100,100].
  8250. * @returns Adjusted value.
  8251. */
  8252. private static applyColorGradingSliderNonlinear;
  8253. /**
  8254. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8255. * @param hue The hue (H) input.
  8256. * @param saturation The saturation (S) input.
  8257. * @param brightness The brightness (B) input.
  8258. * @result An RGBA color represented as Vector4.
  8259. */
  8260. private static fromHSBToRef;
  8261. /**
  8262. * Returns a value clamped between min and max
  8263. * @param value The value to clamp
  8264. * @param min The minimum of value
  8265. * @param max The maximum of value
  8266. * @returns The clamped value.
  8267. */
  8268. private static clamp;
  8269. /**
  8270. * Clones the current color curve instance.
  8271. * @return The cloned curves
  8272. */
  8273. clone(): ColorCurves;
  8274. /**
  8275. * Serializes the current color curve instance to a json representation.
  8276. * @return a JSON representation
  8277. */
  8278. serialize(): any;
  8279. /**
  8280. * Parses the color curve from a json representation.
  8281. * @param source the JSON source to parse
  8282. * @return The parsed curves
  8283. */
  8284. static Parse(source: any): ColorCurves;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /**
  8289. * Interface to follow in your material defines to integrate easily the
  8290. * Image proccessing functions.
  8291. * @hidden
  8292. */
  8293. export interface IImageProcessingConfigurationDefines {
  8294. IMAGEPROCESSING: boolean;
  8295. VIGNETTE: boolean;
  8296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8297. VIGNETTEBLENDMODEOPAQUE: boolean;
  8298. TONEMAPPING: boolean;
  8299. TONEMAPPING_ACES: boolean;
  8300. CONTRAST: boolean;
  8301. EXPOSURE: boolean;
  8302. COLORCURVES: boolean;
  8303. COLORGRADING: boolean;
  8304. COLORGRADING3D: boolean;
  8305. SAMPLER3DGREENDEPTH: boolean;
  8306. SAMPLER3DBGRMAP: boolean;
  8307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8308. }
  8309. /**
  8310. * @hidden
  8311. */
  8312. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. EXPOSURE: boolean;
  8327. constructor();
  8328. }
  8329. /**
  8330. * This groups together the common properties used for image processing either in direct forward pass
  8331. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8332. * or not.
  8333. */
  8334. export class ImageProcessingConfiguration {
  8335. /**
  8336. * Default tone mapping applied in BabylonJS.
  8337. */
  8338. static readonly TONEMAPPING_STANDARD: number;
  8339. /**
  8340. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8341. * to other engines rendering to increase portability.
  8342. */
  8343. static readonly TONEMAPPING_ACES: number;
  8344. /**
  8345. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8346. */
  8347. colorCurves: Nullable<ColorCurves>;
  8348. private _colorCurvesEnabled;
  8349. /**
  8350. * Gets wether the color curves effect is enabled.
  8351. */
  8352. get colorCurvesEnabled(): boolean;
  8353. /**
  8354. * Sets wether the color curves effect is enabled.
  8355. */
  8356. set colorCurvesEnabled(value: boolean);
  8357. private _colorGradingTexture;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. get colorGradingTexture(): Nullable<BaseTexture>;
  8362. /**
  8363. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8364. */
  8365. set colorGradingTexture(value: Nullable<BaseTexture>);
  8366. private _colorGradingEnabled;
  8367. /**
  8368. * Gets wether the color grading effect is enabled.
  8369. */
  8370. get colorGradingEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color grading effect is enabled.
  8373. */
  8374. set colorGradingEnabled(value: boolean);
  8375. private _colorGradingWithGreenDepth;
  8376. /**
  8377. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. get colorGradingWithGreenDepth(): boolean;
  8380. /**
  8381. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8382. */
  8383. set colorGradingWithGreenDepth(value: boolean);
  8384. private _colorGradingBGR;
  8385. /**
  8386. * Gets wether the color grading texture contains BGR values.
  8387. */
  8388. get colorGradingBGR(): boolean;
  8389. /**
  8390. * Sets wether the color grading texture contains BGR values.
  8391. */
  8392. set colorGradingBGR(value: boolean);
  8393. /** @hidden */
  8394. _exposure: number;
  8395. /**
  8396. * Gets the Exposure used in the effect.
  8397. */
  8398. get exposure(): number;
  8399. /**
  8400. * Sets the Exposure used in the effect.
  8401. */
  8402. set exposure(value: number);
  8403. private _toneMappingEnabled;
  8404. /**
  8405. * Gets wether the tone mapping effect is enabled.
  8406. */
  8407. get toneMappingEnabled(): boolean;
  8408. /**
  8409. * Sets wether the tone mapping effect is enabled.
  8410. */
  8411. set toneMappingEnabled(value: boolean);
  8412. private _toneMappingType;
  8413. /**
  8414. * Gets the type of tone mapping effect.
  8415. */
  8416. get toneMappingType(): number;
  8417. /**
  8418. * Sets the type of tone mapping effect used in BabylonJS.
  8419. */
  8420. set toneMappingType(value: number);
  8421. protected _contrast: number;
  8422. /**
  8423. * Gets the contrast used in the effect.
  8424. */
  8425. get contrast(): number;
  8426. /**
  8427. * Sets the contrast used in the effect.
  8428. */
  8429. set contrast(value: number);
  8430. /**
  8431. * Vignette stretch size.
  8432. */
  8433. vignetteStretch: number;
  8434. /**
  8435. * Vignette centre X Offset.
  8436. */
  8437. vignetteCentreX: number;
  8438. /**
  8439. * Vignette centre Y Offset.
  8440. */
  8441. vignetteCentreY: number;
  8442. /**
  8443. * Vignette weight or intensity of the vignette effect.
  8444. */
  8445. vignetteWeight: number;
  8446. /**
  8447. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8448. * if vignetteEnabled is set to true.
  8449. */
  8450. vignetteColor: Color4;
  8451. /**
  8452. * Camera field of view used by the Vignette effect.
  8453. */
  8454. vignetteCameraFov: number;
  8455. private _vignetteBlendMode;
  8456. /**
  8457. * Gets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. get vignetteBlendMode(): number;
  8460. /**
  8461. * Sets the vignette blend mode allowing different kind of effect.
  8462. */
  8463. set vignetteBlendMode(value: number);
  8464. private _vignetteEnabled;
  8465. /**
  8466. * Gets wether the vignette effect is enabled.
  8467. */
  8468. get vignetteEnabled(): boolean;
  8469. /**
  8470. * Sets wether the vignette effect is enabled.
  8471. */
  8472. set vignetteEnabled(value: boolean);
  8473. private _applyByPostProcess;
  8474. /**
  8475. * Gets wether the image processing is applied through a post process or not.
  8476. */
  8477. get applyByPostProcess(): boolean;
  8478. /**
  8479. * Sets wether the image processing is applied through a post process or not.
  8480. */
  8481. set applyByPostProcess(value: boolean);
  8482. private _isEnabled;
  8483. /**
  8484. * Gets wether the image processing is enabled or not.
  8485. */
  8486. get isEnabled(): boolean;
  8487. /**
  8488. * Sets wether the image processing is enabled or not.
  8489. */
  8490. set isEnabled(value: boolean);
  8491. /**
  8492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8493. */
  8494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8495. /**
  8496. * Method called each time the image processing information changes requires to recompile the effect.
  8497. */
  8498. protected _updateParameters(): void;
  8499. /**
  8500. * Gets the current class name.
  8501. * @return "ImageProcessingConfiguration"
  8502. */
  8503. getClassName(): string;
  8504. /**
  8505. * Prepare the list of uniforms associated with the Image Processing effects.
  8506. * @param uniforms The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of samplers associated with the Image Processing effects.
  8512. * @param samplersList The list of uniforms used in the effect
  8513. * @param defines the list of defines currently in use
  8514. */
  8515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8516. /**
  8517. * Prepare the list of defines associated to the shader.
  8518. * @param defines the list of defines to complete
  8519. * @param forPostProcess Define if we are currently in post process mode or not
  8520. */
  8521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8522. /**
  8523. * Returns true if all the image processing information are ready.
  8524. * @returns True if ready, otherwise, false
  8525. */
  8526. isReady(): boolean;
  8527. /**
  8528. * Binds the image processing to the shader.
  8529. * @param effect The effect to bind to
  8530. * @param overrideAspectRatio Override the aspect ratio of the effect
  8531. */
  8532. bind(effect: Effect, overrideAspectRatio?: number): void;
  8533. /**
  8534. * Clones the current image processing instance.
  8535. * @return The cloned image processing
  8536. */
  8537. clone(): ImageProcessingConfiguration;
  8538. /**
  8539. * Serializes the current image processing instance to a json representation.
  8540. * @return a JSON representation
  8541. */
  8542. serialize(): any;
  8543. /**
  8544. * Parses the image processing from a json representation.
  8545. * @param source the JSON source to parse
  8546. * @return The parsed image processing
  8547. */
  8548. static Parse(source: any): ImageProcessingConfiguration;
  8549. private static _VIGNETTEMODE_MULTIPLY;
  8550. private static _VIGNETTEMODE_OPAQUE;
  8551. /**
  8552. * Used to apply the vignette as a mix with the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_MULTIPLY(): number;
  8555. /**
  8556. * Used to apply the vignette as a replacement of the pixel color.
  8557. */
  8558. static get VIGNETTEMODE_OPAQUE(): number;
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /** @hidden */
  8563. export var postprocessVertexShader: {
  8564. name: string;
  8565. shader: string;
  8566. };
  8567. }
  8568. declare module BABYLON {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /**
  8603. * Defines the kind of connection point for node based material
  8604. */
  8605. export enum NodeMaterialBlockConnectionPointTypes {
  8606. /** Float */
  8607. Float = 1,
  8608. /** Int */
  8609. Int = 2,
  8610. /** Vector2 */
  8611. Vector2 = 4,
  8612. /** Vector3 */
  8613. Vector3 = 8,
  8614. /** Vector4 */
  8615. Vector4 = 16,
  8616. /** Color3 */
  8617. Color3 = 32,
  8618. /** Color4 */
  8619. Color4 = 64,
  8620. /** Matrix */
  8621. Matrix = 128,
  8622. /** Custom object */
  8623. Object = 256,
  8624. /** Detect type based on connection */
  8625. AutoDetect = 1024,
  8626. /** Output type that will be defined by input type */
  8627. BasedOnInput = 2048
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * Enum used to define the target of a block
  8633. */
  8634. export enum NodeMaterialBlockTargets {
  8635. /** Vertex shader */
  8636. Vertex = 1,
  8637. /** Fragment shader */
  8638. Fragment = 2,
  8639. /** Neutral */
  8640. Neutral = 4,
  8641. /** Vertex and Fragment */
  8642. VertexAndFragment = 3
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8648. */
  8649. export enum NodeMaterialBlockConnectionPointMode {
  8650. /** Value is an uniform */
  8651. Uniform = 0,
  8652. /** Value is a mesh attribute */
  8653. Attribute = 1,
  8654. /** Value is a varying between vertex and fragment shaders */
  8655. Varying = 2,
  8656. /** Mode is undefined */
  8657. Undefined = 3
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Enum used to define system values e.g. values automatically provided by the system
  8663. */
  8664. export enum NodeMaterialSystemValues {
  8665. /** World */
  8666. World = 1,
  8667. /** View */
  8668. View = 2,
  8669. /** Projection */
  8670. Projection = 3,
  8671. /** ViewProjection */
  8672. ViewProjection = 4,
  8673. /** WorldView */
  8674. WorldView = 5,
  8675. /** WorldViewProjection */
  8676. WorldViewProjection = 6,
  8677. /** CameraPosition */
  8678. CameraPosition = 7,
  8679. /** Fog Color */
  8680. FogColor = 8,
  8681. /** Delta time */
  8682. DeltaTime = 9
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /** Defines supported spaces */
  8687. export enum Space {
  8688. /** Local (object) space */
  8689. LOCAL = 0,
  8690. /** World space */
  8691. WORLD = 1,
  8692. /** Bone space */
  8693. BONE = 2
  8694. }
  8695. /** Defines the 3 main axes */
  8696. export class Axis {
  8697. /** X axis */
  8698. static X: Vector3;
  8699. /** Y axis */
  8700. static Y: Vector3;
  8701. /** Z axis */
  8702. static Z: Vector3;
  8703. }
  8704. }
  8705. declare module BABYLON {
  8706. /**
  8707. * Represents a camera frustum
  8708. */
  8709. export class Frustum {
  8710. /**
  8711. * Gets the planes representing the frustum
  8712. * @param transform matrix to be applied to the returned planes
  8713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8714. */
  8715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8716. /**
  8717. * Gets the near frustum plane transformed by the transform matrix
  8718. * @param transform transformation matrix to be applied to the resulting frustum plane
  8719. * @param frustumPlane the resuling frustum plane
  8720. */
  8721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8722. /**
  8723. * Gets the far frustum plane transformed by the transform matrix
  8724. * @param transform transformation matrix to be applied to the resulting frustum plane
  8725. * @param frustumPlane the resuling frustum plane
  8726. */
  8727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8728. /**
  8729. * Gets the left frustum plane transformed by the transform matrix
  8730. * @param transform transformation matrix to be applied to the resulting frustum plane
  8731. * @param frustumPlane the resuling frustum plane
  8732. */
  8733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8734. /**
  8735. * Gets the right frustum plane transformed by the transform matrix
  8736. * @param transform transformation matrix to be applied to the resulting frustum plane
  8737. * @param frustumPlane the resuling frustum plane
  8738. */
  8739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8740. /**
  8741. * Gets the top frustum plane transformed by the transform matrix
  8742. * @param transform transformation matrix to be applied to the resulting frustum plane
  8743. * @param frustumPlane the resuling frustum plane
  8744. */
  8745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8746. /**
  8747. * Gets the bottom frustum plane transformed by the transform matrix
  8748. * @param transform transformation matrix to be applied to the resulting frustum plane
  8749. * @param frustumPlane the resuling frustum plane
  8750. */
  8751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8752. /**
  8753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8754. * @param transform transformation matrix to be applied to the resulting frustum planes
  8755. * @param frustumPlanes the resuling frustum planes
  8756. */
  8757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Interface for the size containing width and height
  8763. */
  8764. export interface ISize {
  8765. /**
  8766. * Width
  8767. */
  8768. width: number;
  8769. /**
  8770. * Heighht
  8771. */
  8772. height: number;
  8773. }
  8774. /**
  8775. * Size containing widht and height
  8776. */
  8777. export class Size implements ISize {
  8778. /**
  8779. * Width
  8780. */
  8781. width: number;
  8782. /**
  8783. * Height
  8784. */
  8785. height: number;
  8786. /**
  8787. * Creates a Size object from the given width and height (floats).
  8788. * @param width width of the new size
  8789. * @param height height of the new size
  8790. */
  8791. constructor(width: number, height: number);
  8792. /**
  8793. * Returns a string with the Size width and height
  8794. * @returns a string with the Size width and height
  8795. */
  8796. toString(): string;
  8797. /**
  8798. * "Size"
  8799. * @returns the string "Size"
  8800. */
  8801. getClassName(): string;
  8802. /**
  8803. * Returns the Size hash code.
  8804. * @returns a hash code for a unique width and height
  8805. */
  8806. getHashCode(): number;
  8807. /**
  8808. * Updates the current size from the given one.
  8809. * @param src the given size
  8810. */
  8811. copyFrom(src: Size): void;
  8812. /**
  8813. * Updates in place the current Size from the given floats.
  8814. * @param width width of the new size
  8815. * @param height height of the new size
  8816. * @returns the updated Size.
  8817. */
  8818. copyFromFloats(width: number, height: number): Size;
  8819. /**
  8820. * Updates in place the current Size from the given floats.
  8821. * @param width width to set
  8822. * @param height height to set
  8823. * @returns the updated Size.
  8824. */
  8825. set(width: number, height: number): Size;
  8826. /**
  8827. * Multiplies the width and height by numbers
  8828. * @param w factor to multiple the width by
  8829. * @param h factor to multiple the height by
  8830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8831. */
  8832. multiplyByFloats(w: number, h: number): Size;
  8833. /**
  8834. * Clones the size
  8835. * @returns a new Size copied from the given one.
  8836. */
  8837. clone(): Size;
  8838. /**
  8839. * True if the current Size and the given one width and height are strictly equal.
  8840. * @param other the other size to compare against
  8841. * @returns True if the current Size and the given one width and height are strictly equal.
  8842. */
  8843. equals(other: Size): boolean;
  8844. /**
  8845. * The surface of the Size : width * height (float).
  8846. */
  8847. get surface(): number;
  8848. /**
  8849. * Create a new size of zero
  8850. * @returns a new Size set to (0.0, 0.0)
  8851. */
  8852. static Zero(): Size;
  8853. /**
  8854. * Sums the width and height of two sizes
  8855. * @param otherSize size to add to this size
  8856. * @returns a new Size set as the addition result of the current Size and the given one.
  8857. */
  8858. add(otherSize: Size): Size;
  8859. /**
  8860. * Subtracts the width and height of two
  8861. * @param otherSize size to subtract to this size
  8862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8863. */
  8864. subtract(otherSize: Size): Size;
  8865. /**
  8866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8867. * @param start starting size to lerp between
  8868. * @param end end size to lerp between
  8869. * @param amount amount to lerp between the start and end values
  8870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8871. */
  8872. static Lerp(start: Size, end: Size, amount: number): Size;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * Contains position and normal vectors for a vertex
  8878. */
  8879. export class PositionNormalVertex {
  8880. /** the position of the vertex (defaut: 0,0,0) */
  8881. position: Vector3;
  8882. /** the normal of the vertex (defaut: 0,1,0) */
  8883. normal: Vector3;
  8884. /**
  8885. * Creates a PositionNormalVertex
  8886. * @param position the position of the vertex (defaut: 0,0,0)
  8887. * @param normal the normal of the vertex (defaut: 0,1,0)
  8888. */
  8889. constructor(
  8890. /** the position of the vertex (defaut: 0,0,0) */
  8891. position?: Vector3,
  8892. /** the normal of the vertex (defaut: 0,1,0) */
  8893. normal?: Vector3);
  8894. /**
  8895. * Clones the PositionNormalVertex
  8896. * @returns the cloned PositionNormalVertex
  8897. */
  8898. clone(): PositionNormalVertex;
  8899. }
  8900. /**
  8901. * Contains position, normal and uv vectors for a vertex
  8902. */
  8903. export class PositionNormalTextureVertex {
  8904. /** the position of the vertex (defaut: 0,0,0) */
  8905. position: Vector3;
  8906. /** the normal of the vertex (defaut: 0,1,0) */
  8907. normal: Vector3;
  8908. /** the uv of the vertex (default: 0,0) */
  8909. uv: Vector2;
  8910. /**
  8911. * Creates a PositionNormalTextureVertex
  8912. * @param position the position of the vertex (defaut: 0,0,0)
  8913. * @param normal the normal of the vertex (defaut: 0,1,0)
  8914. * @param uv the uv of the vertex (default: 0,0)
  8915. */
  8916. constructor(
  8917. /** the position of the vertex (defaut: 0,0,0) */
  8918. position?: Vector3,
  8919. /** the normal of the vertex (defaut: 0,1,0) */
  8920. normal?: Vector3,
  8921. /** the uv of the vertex (default: 0,0) */
  8922. uv?: Vector2);
  8923. /**
  8924. * Clones the PositionNormalTextureVertex
  8925. * @returns the cloned PositionNormalTextureVertex
  8926. */
  8927. clone(): PositionNormalTextureVertex;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Enum defining the type of animations supported by InputBlock
  8933. */
  8934. export enum AnimatedInputBlockTypes {
  8935. /** No animation */
  8936. None = 0,
  8937. /** Time based animation. Will only work for floats */
  8938. Time = 1
  8939. }
  8940. }
  8941. declare module BABYLON {
  8942. /**
  8943. * Interface describing all the common properties and methods a shadow light needs to implement.
  8944. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8945. * as well as binding the different shadow properties to the effects.
  8946. */
  8947. export interface IShadowLight extends Light {
  8948. /**
  8949. * The light id in the scene (used in scene.findLighById for instance)
  8950. */
  8951. id: string;
  8952. /**
  8953. * The position the shdow will be casted from.
  8954. */
  8955. position: Vector3;
  8956. /**
  8957. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8958. */
  8959. direction: Vector3;
  8960. /**
  8961. * The transformed position. Position of the light in world space taking parenting in account.
  8962. */
  8963. transformedPosition: Vector3;
  8964. /**
  8965. * The transformed direction. Direction of the light in world space taking parenting in account.
  8966. */
  8967. transformedDirection: Vector3;
  8968. /**
  8969. * The friendly name of the light in the scene.
  8970. */
  8971. name: string;
  8972. /**
  8973. * Defines the shadow projection clipping minimum z value.
  8974. */
  8975. shadowMinZ: number;
  8976. /**
  8977. * Defines the shadow projection clipping maximum z value.
  8978. */
  8979. shadowMaxZ: number;
  8980. /**
  8981. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8982. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8983. */
  8984. computeTransformedInformation(): boolean;
  8985. /**
  8986. * Gets the scene the light belongs to.
  8987. * @returns The scene
  8988. */
  8989. getScene(): Scene;
  8990. /**
  8991. * Callback defining a custom Projection Matrix Builder.
  8992. * This can be used to override the default projection matrix computation.
  8993. */
  8994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8995. /**
  8996. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8997. * @param matrix The materix to updated with the projection information
  8998. * @param viewMatrix The transform matrix of the light
  8999. * @param renderList The list of mesh to render in the map
  9000. * @returns The current light
  9001. */
  9002. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9003. /**
  9004. * Gets the current depth scale used in ESM.
  9005. * @returns The scale
  9006. */
  9007. getDepthScale(): number;
  9008. /**
  9009. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9010. * @returns true if a cube texture needs to be use
  9011. */
  9012. needCube(): boolean;
  9013. /**
  9014. * Detects if the projection matrix requires to be recomputed this frame.
  9015. * @returns true if it requires to be recomputed otherwise, false.
  9016. */
  9017. needProjectionMatrixCompute(): boolean;
  9018. /**
  9019. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9020. */
  9021. forceProjectionMatrixCompute(): void;
  9022. /**
  9023. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9026. */
  9027. getShadowDirection(faceIndex?: number): Vector3;
  9028. /**
  9029. * Gets the minZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the min for
  9031. * @returns the depth min z
  9032. */
  9033. getDepthMinZ(activeCamera: Camera): number;
  9034. /**
  9035. * Gets the maxZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the max for
  9037. * @returns the depth max z
  9038. */
  9039. getDepthMaxZ(activeCamera: Camera): number;
  9040. }
  9041. /**
  9042. * Base implementation IShadowLight
  9043. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9044. */
  9045. export abstract class ShadowLight extends Light implements IShadowLight {
  9046. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9047. protected _position: Vector3;
  9048. protected _setPosition(value: Vector3): void;
  9049. /**
  9050. * Sets the position the shadow will be casted from. Also use as the light position for both
  9051. * point and spot lights.
  9052. */
  9053. get position(): Vector3;
  9054. /**
  9055. * Sets the position the shadow will be casted from. Also use as the light position for both
  9056. * point and spot lights.
  9057. */
  9058. set position(value: Vector3);
  9059. protected _direction: Vector3;
  9060. protected _setDirection(value: Vector3): void;
  9061. /**
  9062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9063. * Also use as the light direction on spot and directional lights.
  9064. */
  9065. get direction(): Vector3;
  9066. /**
  9067. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9068. * Also use as the light direction on spot and directional lights.
  9069. */
  9070. set direction(value: Vector3);
  9071. protected _shadowMinZ: number;
  9072. /**
  9073. * Gets the shadow projection clipping minimum z value.
  9074. */
  9075. get shadowMinZ(): number;
  9076. /**
  9077. * Sets the shadow projection clipping minimum z value.
  9078. */
  9079. set shadowMinZ(value: number);
  9080. protected _shadowMaxZ: number;
  9081. /**
  9082. * Sets the shadow projection clipping maximum z value.
  9083. */
  9084. get shadowMaxZ(): number;
  9085. /**
  9086. * Gets the shadow projection clipping maximum z value.
  9087. */
  9088. set shadowMaxZ(value: number);
  9089. /**
  9090. * Callback defining a custom Projection Matrix Builder.
  9091. * This can be used to override the default projection matrix computation.
  9092. */
  9093. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9094. /**
  9095. * The transformed position. Position of the light in world space taking parenting in account.
  9096. */
  9097. transformedPosition: Vector3;
  9098. /**
  9099. * The transformed direction. Direction of the light in world space taking parenting in account.
  9100. */
  9101. transformedDirection: Vector3;
  9102. private _needProjectionMatrixCompute;
  9103. /**
  9104. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9105. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9106. */
  9107. computeTransformedInformation(): boolean;
  9108. /**
  9109. * Return the depth scale used for the shadow map.
  9110. * @returns the depth scale.
  9111. */
  9112. getDepthScale(): number;
  9113. /**
  9114. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9115. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9116. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9117. */
  9118. getShadowDirection(faceIndex?: number): Vector3;
  9119. /**
  9120. * Returns the ShadowLight absolute position in the World.
  9121. * @returns the position vector in world space
  9122. */
  9123. getAbsolutePosition(): Vector3;
  9124. /**
  9125. * Sets the ShadowLight direction toward the passed target.
  9126. * @param target The point to target in local space
  9127. * @returns the updated ShadowLight direction
  9128. */
  9129. setDirectionToTarget(target: Vector3): Vector3;
  9130. /**
  9131. * Returns the light rotation in euler definition.
  9132. * @returns the x y z rotation in local space.
  9133. */
  9134. getRotation(): Vector3;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /** @hidden */
  9150. _initCache(): void;
  9151. /** @hidden */
  9152. _isSynchronized(): boolean;
  9153. /**
  9154. * Computes the world matrix of the node
  9155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9156. * @returns the world matrix
  9157. */
  9158. computeWorldMatrix(force?: boolean): Matrix;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. /**
  9172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9173. * @param matrix The materix to updated with the projection information
  9174. * @param viewMatrix The transform matrix of the light
  9175. * @param renderList The list of mesh to render in the map
  9176. * @returns The current light
  9177. */
  9178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var packingFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var bayerDitherFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var shadowMapFragmentDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var clipPlaneFragmentDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var clipPlaneFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapFragment: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var bonesDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var morphTargetsVertexGlobalDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var instancesDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var helperFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapVertexDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneVertexDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var instancesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var bonesVertex: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var shadowMapVertexNormalBias: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var shadowMapVertexMetric: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var clipPlaneVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var shadowMapVertexShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var depthBoxBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapFragmentSoftTransparentShadow: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9345. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9346. */
  9347. export class EffectFallbacks implements IEffectFallbacks {
  9348. private _defines;
  9349. private _currentRank;
  9350. private _maxRank;
  9351. private _mesh;
  9352. /**
  9353. * Removes the fallback from the bound mesh.
  9354. */
  9355. unBindMesh(): void;
  9356. /**
  9357. * Adds a fallback on the specified property.
  9358. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9359. * @param define The name of the define in the shader
  9360. */
  9361. addFallback(rank: number, define: string): void;
  9362. /**
  9363. * Sets the mesh to use CPU skinning when needing to fallback.
  9364. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9365. * @param mesh The mesh to use the fallbacks.
  9366. */
  9367. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9368. /**
  9369. * Checks to see if more fallbacks are still availible.
  9370. */
  9371. get hasMoreFallbacks(): boolean;
  9372. /**
  9373. * Removes the defines that should be removed when falling back.
  9374. * @param currentDefines defines the current define statements for the shader.
  9375. * @param effect defines the current effect we try to compile
  9376. * @returns The resulting defines with defines of the current rank removed.
  9377. */
  9378. reduce(currentDefines: string, effect: Effect): string;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Interface used to define Action
  9384. */
  9385. export interface IAction {
  9386. /**
  9387. * Trigger for the action
  9388. */
  9389. trigger: number;
  9390. /** Options of the trigger */
  9391. triggerOptions: any;
  9392. /**
  9393. * Gets the trigger parameters
  9394. * @returns the trigger parameters
  9395. */
  9396. getTriggerParameter(): any;
  9397. /**
  9398. * Internal only - executes current action event
  9399. * @hidden
  9400. */
  9401. _executeCurrent(evt?: ActionEvent): void;
  9402. /**
  9403. * Serialize placeholder for child classes
  9404. * @param parent of child
  9405. * @returns the serialized object
  9406. */
  9407. serialize(parent: any): any;
  9408. /**
  9409. * Internal only
  9410. * @hidden
  9411. */
  9412. _prepare(): void;
  9413. /**
  9414. * Internal only - manager for action
  9415. * @hidden
  9416. */
  9417. _actionManager: AbstractActionManager;
  9418. /**
  9419. * Adds action to chain of actions, may be a DoNothingAction
  9420. * @param action defines the next action to execute
  9421. * @returns The action passed in
  9422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9423. */
  9424. then(action: IAction): IAction;
  9425. }
  9426. /**
  9427. * The action to be carried out following a trigger
  9428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9429. */
  9430. export class Action implements IAction {
  9431. /** the trigger, with or without parameters, for the action */
  9432. triggerOptions: any;
  9433. /**
  9434. * Trigger for the action
  9435. */
  9436. trigger: number;
  9437. /**
  9438. * Internal only - manager for action
  9439. * @hidden
  9440. */
  9441. _actionManager: ActionManager;
  9442. private _nextActiveAction;
  9443. private _child;
  9444. private _condition?;
  9445. private _triggerParameter;
  9446. /**
  9447. * An event triggered prior to action being executed.
  9448. */
  9449. onBeforeExecuteObservable: Observable<Action>;
  9450. /**
  9451. * Creates a new Action
  9452. * @param triggerOptions the trigger, with or without parameters, for the action
  9453. * @param condition an optional determinant of action
  9454. */
  9455. constructor(
  9456. /** the trigger, with or without parameters, for the action */
  9457. triggerOptions: any, condition?: Condition);
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Gets the trigger parameters
  9465. * @returns the trigger parameters
  9466. */
  9467. getTriggerParameter(): any;
  9468. /**
  9469. * Internal only - executes current action event
  9470. * @hidden
  9471. */
  9472. _executeCurrent(evt?: ActionEvent): void;
  9473. /**
  9474. * Execute placeholder for child classes
  9475. * @param evt optional action event
  9476. */
  9477. execute(evt?: ActionEvent): void;
  9478. /**
  9479. * Skips to next active action
  9480. */
  9481. skipToNextActiveAction(): void;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: Action): Action;
  9489. /**
  9490. * Internal only
  9491. * @hidden
  9492. */
  9493. _getProperty(propertyPath: string): string;
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _getEffectiveTarget(target: any, propertyPath: string): any;
  9499. /**
  9500. * Serialize placeholder for child classes
  9501. * @param parent of child
  9502. * @returns the serialized object
  9503. */
  9504. serialize(parent: any): any;
  9505. /**
  9506. * Internal only called by serialize
  9507. * @hidden
  9508. */
  9509. protected _serialize(serializedAction: any, parent?: any): any;
  9510. /**
  9511. * Internal only
  9512. * @hidden
  9513. */
  9514. static _SerializeValueAsString: (value: any) => string;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. static _GetTargetProperty: (target: Scene | Node) => {
  9520. name: string;
  9521. targetType: string;
  9522. value: string;
  9523. };
  9524. }
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * A Condition applied to an Action
  9529. */
  9530. export class Condition {
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. _evaluationId: number;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. _currentResult: boolean;
  9546. /**
  9547. * Creates a new Condition
  9548. * @param actionManager the manager of the action the condition is applied to
  9549. */
  9550. constructor(actionManager: ActionManager);
  9551. /**
  9552. * Check if the current condition is valid
  9553. * @returns a boolean
  9554. */
  9555. isValid(): boolean;
  9556. /**
  9557. * Internal only
  9558. * @hidden
  9559. */
  9560. _getProperty(propertyPath: string): string;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getEffectiveTarget(target: any, propertyPath: string): any;
  9566. /**
  9567. * Serialize placeholder for child classes
  9568. * @returns the serialized object
  9569. */
  9570. serialize(): any;
  9571. /**
  9572. * Internal only
  9573. * @hidden
  9574. */
  9575. protected _serialize(serializedCondition: any): any;
  9576. }
  9577. /**
  9578. * Defines specific conditional operators as extensions of Condition
  9579. */
  9580. export class ValueCondition extends Condition {
  9581. /** path to specify the property of the target the conditional operator uses */
  9582. propertyPath: string;
  9583. /** the value compared by the conditional operator against the current value of the property */
  9584. value: any;
  9585. /** the conditional operator, default ValueCondition.IsEqual */
  9586. operator: number;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. private static _IsEqual;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. private static _IsDifferent;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. private static _IsGreater;
  9602. /**
  9603. * Internal only
  9604. * @hidden
  9605. */
  9606. private static _IsLesser;
  9607. /**
  9608. * returns the number for IsEqual
  9609. */
  9610. static get IsEqual(): number;
  9611. /**
  9612. * Returns the number for IsDifferent
  9613. */
  9614. static get IsDifferent(): number;
  9615. /**
  9616. * Returns the number for IsGreater
  9617. */
  9618. static get IsGreater(): number;
  9619. /**
  9620. * Returns the number for IsLesser
  9621. */
  9622. static get IsLesser(): number;
  9623. /**
  9624. * Internal only The action manager for the condition
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private _target;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private _effectiveTarget;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private _property;
  9643. /**
  9644. * Creates a new ValueCondition
  9645. * @param actionManager manager for the action the condition applies to
  9646. * @param target for the action
  9647. * @param propertyPath path to specify the property of the target the conditional operator uses
  9648. * @param value the value compared by the conditional operator against the current value of the property
  9649. * @param operator the conditional operator, default ValueCondition.IsEqual
  9650. */
  9651. constructor(actionManager: ActionManager, target: any,
  9652. /** path to specify the property of the target the conditional operator uses */
  9653. propertyPath: string,
  9654. /** the value compared by the conditional operator against the current value of the property */
  9655. value: any,
  9656. /** the conditional operator, default ValueCondition.IsEqual */
  9657. operator?: number);
  9658. /**
  9659. * Compares the given value with the property value for the specified conditional operator
  9660. * @returns the result of the comparison
  9661. */
  9662. isValid(): boolean;
  9663. /**
  9664. * Serialize the ValueCondition into a JSON compatible object
  9665. * @returns serialization object
  9666. */
  9667. serialize(): any;
  9668. /**
  9669. * Gets the name of the conditional operator for the ValueCondition
  9670. * @param operator the conditional operator
  9671. * @returns the name
  9672. */
  9673. static GetOperatorName(operator: number): string;
  9674. }
  9675. /**
  9676. * Defines a predicate condition as an extension of Condition
  9677. */
  9678. export class PredicateCondition extends Condition {
  9679. /** defines the predicate function used to validate the condition */
  9680. predicate: () => boolean;
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Creates a new PredicateCondition
  9688. * @param actionManager manager for the action the condition applies to
  9689. * @param predicate defines the predicate function used to validate the condition
  9690. */
  9691. constructor(actionManager: ActionManager,
  9692. /** defines the predicate function used to validate the condition */
  9693. predicate: () => boolean);
  9694. /**
  9695. * @returns the validity of the predicate condition
  9696. */
  9697. isValid(): boolean;
  9698. }
  9699. /**
  9700. * Defines a state condition as an extension of Condition
  9701. */
  9702. export class StateCondition extends Condition {
  9703. /** Value to compare with target state */
  9704. value: string;
  9705. /**
  9706. * Internal only - manager for action
  9707. * @hidden
  9708. */
  9709. _actionManager: ActionManager;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. private _target;
  9715. /**
  9716. * Creates a new StateCondition
  9717. * @param actionManager manager for the action the condition applies to
  9718. * @param target of the condition
  9719. * @param value to compare with target state
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** Value to compare with target state */
  9723. value: string);
  9724. /**
  9725. * Gets a boolean indicating if the current condition is met
  9726. * @returns the validity of the state
  9727. */
  9728. isValid(): boolean;
  9729. /**
  9730. * Serialize the StateCondition into a JSON compatible object
  9731. * @returns serialization object
  9732. */
  9733. serialize(): any;
  9734. }
  9735. }
  9736. declare module BABYLON {
  9737. /**
  9738. * This defines an action responsible to toggle a boolean once triggered.
  9739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9740. */
  9741. export class SwitchBooleanAction extends Action {
  9742. /**
  9743. * The path to the boolean property in the target object
  9744. */
  9745. propertyPath: string;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the boolean
  9753. * @param propertyPath defines the path to the boolean property in the target object
  9754. * @param condition defines the trigger related conditions
  9755. */
  9756. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9757. /** @hidden */
  9758. _prepare(): void;
  9759. /**
  9760. * Execute the action toggle the boolean value.
  9761. */
  9762. execute(): void;
  9763. /**
  9764. * Serializes the actions and its related information.
  9765. * @param parent defines the object to serialize in
  9766. * @returns the serialized object
  9767. */
  9768. serialize(parent: any): any;
  9769. }
  9770. /**
  9771. * This defines an action responsible to set a the state field of the target
  9772. * to a desired value once triggered.
  9773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9774. */
  9775. export class SetStateAction extends Action {
  9776. /**
  9777. * The value to store in the state field.
  9778. */
  9779. value: string;
  9780. private _target;
  9781. /**
  9782. * Instantiate the action
  9783. * @param triggerOptions defines the trigger options
  9784. * @param target defines the object containing the state property
  9785. * @param value defines the value to store in the state field
  9786. * @param condition defines the trigger related conditions
  9787. */
  9788. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9789. /**
  9790. * Execute the action and store the value on the target state property.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to set a property of the target
  9802. * to a desired value once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SetValueAction extends Action {
  9806. /**
  9807. * The path of the property to set in the target.
  9808. */
  9809. propertyPath: string;
  9810. /**
  9811. * The value to set in the property
  9812. */
  9813. value: any;
  9814. private _target;
  9815. private _effectiveTarget;
  9816. private _property;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the property
  9821. * @param propertyPath defines the path of the property to set in the target
  9822. * @param value defines the value to set in the property
  9823. * @param condition defines the trigger related conditions
  9824. */
  9825. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9826. /** @hidden */
  9827. _prepare(): void;
  9828. /**
  9829. * Execute the action and set the targetted property to the desired value.
  9830. */
  9831. execute(): void;
  9832. /**
  9833. * Serializes the actions and its related information.
  9834. * @param parent defines the object to serialize in
  9835. * @returns the serialized object
  9836. */
  9837. serialize(parent: any): any;
  9838. }
  9839. /**
  9840. * This defines an action responsible to increment the target value
  9841. * to a desired value once triggered.
  9842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9843. */
  9844. export class IncrementValueAction extends Action {
  9845. /**
  9846. * The path of the property to increment in the target.
  9847. */
  9848. propertyPath: string;
  9849. /**
  9850. * The value we should increment the property by.
  9851. */
  9852. value: any;
  9853. private _target;
  9854. private _effectiveTarget;
  9855. private _property;
  9856. /**
  9857. * Instantiate the action
  9858. * @param triggerOptions defines the trigger options
  9859. * @param target defines the object containing the property
  9860. * @param propertyPath defines the path of the property to increment in the target
  9861. * @param value defines the value value we should increment the property by
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9865. /** @hidden */
  9866. _prepare(): void;
  9867. /**
  9868. * Execute the action and increment the target of the value amount.
  9869. */
  9870. execute(): void;
  9871. /**
  9872. * Serializes the actions and its related information.
  9873. * @param parent defines the object to serialize in
  9874. * @returns the serialized object
  9875. */
  9876. serialize(parent: any): any;
  9877. }
  9878. /**
  9879. * This defines an action responsible to start an animation once triggered.
  9880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class PlayAnimationAction extends Action {
  9883. /**
  9884. * Where the animation should start (animation frame)
  9885. */
  9886. from: number;
  9887. /**
  9888. * Where the animation should stop (animation frame)
  9889. */
  9890. to: number;
  9891. /**
  9892. * Define if the animation should loop or stop after the first play.
  9893. */
  9894. loop?: boolean;
  9895. private _target;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the target animation or animation name
  9900. * @param from defines from where the animation should start (animation frame)
  9901. * @param end defines where the animation should stop (animation frame)
  9902. * @param loop defines if the animation should loop or stop after the first play
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and play the animation.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to stop an animation once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class StopAnimationAction extends Action {
  9924. private _target;
  9925. /**
  9926. * Instantiate the action
  9927. * @param triggerOptions defines the trigger options
  9928. * @param target defines the target animation or animation name
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and stop the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible that does nothing once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class DoNothingAction extends Action {
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions?: any, condition?: Condition);
  9956. /**
  9957. * Execute the action and do nothing.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. /**
  9968. * This defines an action responsible to trigger several actions once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class CombineAction extends Action {
  9972. /**
  9973. * The list of aggregated animations to run.
  9974. */
  9975. children: Action[];
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param children defines the list of aggregated animations to run
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and executes all the aggregated actions.
  9987. */
  9988. execute(evt: ActionEvent): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to run code (external event) once triggered.
  9998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class ExecuteCodeAction extends Action {
  10001. /**
  10002. * The callback function to run.
  10003. */
  10004. func: (evt: ActionEvent) => void;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param func defines the callback function to run
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10012. /**
  10013. * Execute the action and run the attached code.
  10014. */
  10015. execute(evt: ActionEvent): void;
  10016. }
  10017. /**
  10018. * This defines an action responsible to set the parent property of the target once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetParentAction extends Action {
  10022. private _parent;
  10023. private _target;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param target defines the target containing the parent property
  10028. * @param parent defines from where the animation should start (animation frame)
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the parent property.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10051. */
  10052. export class ActionManager extends AbstractActionManager {
  10053. /**
  10054. * Nothing
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10056. */
  10057. static readonly NothingTrigger: number;
  10058. /**
  10059. * On pick
  10060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10061. */
  10062. static readonly OnPickTrigger: number;
  10063. /**
  10064. * On left pick
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10066. */
  10067. static readonly OnLeftPickTrigger: number;
  10068. /**
  10069. * On right pick
  10070. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10071. */
  10072. static readonly OnRightPickTrigger: number;
  10073. /**
  10074. * On center pick
  10075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10076. */
  10077. static readonly OnCenterPickTrigger: number;
  10078. /**
  10079. * On pick down
  10080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10081. */
  10082. static readonly OnPickDownTrigger: number;
  10083. /**
  10084. * On double pick
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10086. */
  10087. static readonly OnDoublePickTrigger: number;
  10088. /**
  10089. * On pick up
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10091. */
  10092. static readonly OnPickUpTrigger: number;
  10093. /**
  10094. * On pick out.
  10095. * This trigger will only be raised if you also declared a OnPickDown
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickOutTrigger: number;
  10099. /**
  10100. * On long press
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLongPressTrigger: number;
  10104. /**
  10105. * On pointer over
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPointerOverTrigger: number;
  10109. /**
  10110. * On pointer out
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnPointerOutTrigger: number;
  10114. /**
  10115. * On every frame
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnEveryFrameTrigger: number;
  10119. /**
  10120. * On intersection enter
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnIntersectionEnterTrigger: number;
  10124. /**
  10125. * On intersection exit
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnIntersectionExitTrigger: number;
  10129. /**
  10130. * On key down
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10132. */
  10133. static readonly OnKeyDownTrigger: number;
  10134. /**
  10135. * On key up
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnKeyUpTrigger: number;
  10139. private _scene;
  10140. /**
  10141. * Creates a new action manager
  10142. * @param scene defines the hosting scene
  10143. */
  10144. constructor(scene: Scene);
  10145. /**
  10146. * Releases all associated resources
  10147. */
  10148. dispose(): void;
  10149. /**
  10150. * Gets hosting scene
  10151. * @returns the hosting scene
  10152. */
  10153. getScene(): Scene;
  10154. /**
  10155. * Does this action manager handles actions of any of the given triggers
  10156. * @param triggers defines the triggers to be tested
  10157. * @return a boolean indicating whether one (or more) of the triggers is handled
  10158. */
  10159. hasSpecificTriggers(triggers: number[]): boolean;
  10160. /**
  10161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10162. * speed.
  10163. * @param triggerA defines the trigger to be tested
  10164. * @param triggerB defines the trigger to be tested
  10165. * @return a boolean indicating whether one (or more) of the triggers is handled
  10166. */
  10167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10168. /**
  10169. * Does this action manager handles actions of a given trigger
  10170. * @param trigger defines the trigger to be tested
  10171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10172. * @return whether the trigger is handled
  10173. */
  10174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10175. /**
  10176. * Does this action manager has pointer triggers
  10177. */
  10178. get hasPointerTriggers(): boolean;
  10179. /**
  10180. * Does this action manager has pick triggers
  10181. */
  10182. get hasPickTriggers(): boolean;
  10183. /**
  10184. * Registers an action to this action manager
  10185. * @param action defines the action to be registered
  10186. * @return the action amended (prepared) after registration
  10187. */
  10188. registerAction(action: IAction): Nullable<IAction>;
  10189. /**
  10190. * Unregisters an action to this action manager
  10191. * @param action defines the action to be unregistered
  10192. * @return a boolean indicating whether the action has been unregistered
  10193. */
  10194. unregisterAction(action: IAction): Boolean;
  10195. /**
  10196. * Process a specific trigger
  10197. * @param trigger defines the trigger to process
  10198. * @param evt defines the event details to be processed
  10199. */
  10200. processTrigger(trigger: number, evt?: IActionEvent): void;
  10201. /** @hidden */
  10202. _getEffectiveTarget(target: any, propertyPath: string): any;
  10203. /** @hidden */
  10204. _getProperty(propertyPath: string): string;
  10205. /**
  10206. * Serialize this manager to a JSON object
  10207. * @param name defines the property name to store this manager
  10208. * @returns a JSON representation of this manager
  10209. */
  10210. serialize(name: string): any;
  10211. /**
  10212. * Creates a new ActionManager from a JSON data
  10213. * @param parsedActions defines the JSON data to read from
  10214. * @param object defines the hosting mesh
  10215. * @param scene defines the hosting scene
  10216. */
  10217. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10218. /**
  10219. * Get a trigger name by index
  10220. * @param trigger defines the trigger index
  10221. * @returns a trigger name
  10222. */
  10223. static GetTriggerName(trigger: number): string;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Class used to represent a sprite
  10229. * @see https://doc.babylonjs.com/babylon101/sprites
  10230. */
  10231. export class Sprite implements IAnimatable {
  10232. /** defines the name */
  10233. name: string;
  10234. /** Gets or sets the current world position */
  10235. position: Vector3;
  10236. /** Gets or sets the main color */
  10237. color: Color4;
  10238. /** Gets or sets the width */
  10239. width: number;
  10240. /** Gets or sets the height */
  10241. height: number;
  10242. /** Gets or sets rotation angle */
  10243. angle: number;
  10244. /** Gets or sets the cell index in the sprite sheet */
  10245. cellIndex: number;
  10246. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10247. cellRef: string;
  10248. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10249. invertU: boolean;
  10250. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10251. invertV: boolean;
  10252. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10253. disposeWhenFinishedAnimating: boolean;
  10254. /** Gets the list of attached animations */
  10255. animations: Nullable<Array<Animation>>;
  10256. /** Gets or sets a boolean indicating if the sprite can be picked */
  10257. isPickable: boolean;
  10258. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10259. useAlphaForPicking: boolean;
  10260. /** @hidden */
  10261. _xOffset: number;
  10262. /** @hidden */
  10263. _yOffset: number;
  10264. /** @hidden */
  10265. _xSize: number;
  10266. /** @hidden */
  10267. _ySize: number;
  10268. /**
  10269. * Gets or sets the associated action manager
  10270. */
  10271. actionManager: Nullable<ActionManager>;
  10272. /**
  10273. * An event triggered when the control has been disposed
  10274. */
  10275. onDisposeObservable: Observable<Sprite>;
  10276. private _animationStarted;
  10277. private _loopAnimation;
  10278. private _fromIndex;
  10279. private _toIndex;
  10280. private _delay;
  10281. private _direction;
  10282. private _manager;
  10283. private _time;
  10284. private _onAnimationEnd;
  10285. /**
  10286. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10287. */
  10288. isVisible: boolean;
  10289. /**
  10290. * Gets or sets the sprite size
  10291. */
  10292. get size(): number;
  10293. set size(value: number);
  10294. /**
  10295. * Returns a boolean indicating if the animation is started
  10296. */
  10297. get animationStarted(): boolean;
  10298. /**
  10299. * Gets or sets the unique id of the sprite
  10300. */
  10301. uniqueId: number;
  10302. /**
  10303. * Gets the manager of this sprite
  10304. */
  10305. get manager(): ISpriteManager;
  10306. /**
  10307. * Creates a new Sprite
  10308. * @param name defines the name
  10309. * @param manager defines the manager
  10310. */
  10311. constructor(
  10312. /** defines the name */
  10313. name: string, manager: ISpriteManager);
  10314. /**
  10315. * Returns the string "Sprite"
  10316. * @returns "Sprite"
  10317. */
  10318. getClassName(): string;
  10319. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10320. get fromIndex(): number;
  10321. set fromIndex(value: number);
  10322. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10323. get toIndex(): number;
  10324. set toIndex(value: number);
  10325. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10326. get loopAnimation(): boolean;
  10327. set loopAnimation(value: boolean);
  10328. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10329. get delay(): number;
  10330. set delay(value: number);
  10331. /**
  10332. * Starts an animation
  10333. * @param from defines the initial key
  10334. * @param to defines the end key
  10335. * @param loop defines if the animation must loop
  10336. * @param delay defines the start delay (in ms)
  10337. * @param onAnimationEnd defines a callback to call when animation ends
  10338. */
  10339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10340. /** Stops current animation (if any) */
  10341. stopAnimation(): void;
  10342. /** @hidden */
  10343. _animate(deltaTime: number): void;
  10344. /** Release associated resources */
  10345. dispose(): void;
  10346. /**
  10347. * Serializes the sprite to a JSON object
  10348. * @returns the JSON object
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Parses a JSON object to create a new sprite
  10353. * @param parsedSprite The JSON object to parse
  10354. * @param manager defines the hosting manager
  10355. * @returns the new sprite
  10356. */
  10357. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * Information about the result of picking within a scene
  10363. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10364. */
  10365. export class PickingInfo {
  10366. /** @hidden */
  10367. _pickingUnavailable: boolean;
  10368. /**
  10369. * If the pick collided with an object
  10370. */
  10371. hit: boolean;
  10372. /**
  10373. * Distance away where the pick collided
  10374. */
  10375. distance: number;
  10376. /**
  10377. * The location of pick collision
  10378. */
  10379. pickedPoint: Nullable<Vector3>;
  10380. /**
  10381. * The mesh corresponding the the pick collision
  10382. */
  10383. pickedMesh: Nullable<AbstractMesh>;
  10384. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10385. bu: number;
  10386. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10387. bv: number;
  10388. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10389. faceId: number;
  10390. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10391. subMeshFaceId: number;
  10392. /** Id of the the submesh that was picked */
  10393. subMeshId: number;
  10394. /** If a sprite was picked, this will be the sprite the pick collided with */
  10395. pickedSprite: Nullable<Sprite>;
  10396. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10397. thinInstanceIndex: number;
  10398. /**
  10399. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10400. */
  10401. originMesh: Nullable<AbstractMesh>;
  10402. /**
  10403. * The ray that was used to perform the picking.
  10404. */
  10405. ray: Nullable<Ray>;
  10406. /**
  10407. * Gets the normal correspodning to the face the pick collided with
  10408. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10409. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10410. * @returns The normal correspodning to the face the pick collided with
  10411. */
  10412. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10413. /**
  10414. * Gets the texture coordinates of where the pick occured
  10415. * @returns the vector containing the coordnates of the texture
  10416. */
  10417. getTextureCoordinates(): Nullable<Vector2>;
  10418. }
  10419. }
  10420. declare module BABYLON {
  10421. /**
  10422. * Class representing a ray with position and direction
  10423. */
  10424. export class Ray {
  10425. /** origin point */
  10426. origin: Vector3;
  10427. /** direction */
  10428. direction: Vector3;
  10429. /** length of the ray */
  10430. length: number;
  10431. private static readonly _TmpVector3;
  10432. private _tmpRay;
  10433. /**
  10434. * Creates a new ray
  10435. * @param origin origin point
  10436. * @param direction direction
  10437. * @param length length of the ray
  10438. */
  10439. constructor(
  10440. /** origin point */
  10441. origin: Vector3,
  10442. /** direction */
  10443. direction: Vector3,
  10444. /** length of the ray */
  10445. length?: number);
  10446. /**
  10447. * Checks if the ray intersects a box
  10448. * This does not account for the ray lenght by design to improve perfs.
  10449. * @param minimum bound of the box
  10450. * @param maximum bound of the box
  10451. * @param intersectionTreshold extra extend to be added to the box in all direction
  10452. * @returns if the box was hit
  10453. */
  10454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10455. /**
  10456. * Checks if the ray intersects a box
  10457. * This does not account for the ray lenght by design to improve perfs.
  10458. * @param box the bounding box to check
  10459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10460. * @returns if the box was hit
  10461. */
  10462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10463. /**
  10464. * If the ray hits a sphere
  10465. * @param sphere the bounding sphere to check
  10466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10467. * @returns true if it hits the sphere
  10468. */
  10469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10470. /**
  10471. * If the ray hits a triange
  10472. * @param vertex0 triangle vertex
  10473. * @param vertex1 triangle vertex
  10474. * @param vertex2 triangle vertex
  10475. * @returns intersection information if hit
  10476. */
  10477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10478. /**
  10479. * Checks if ray intersects a plane
  10480. * @param plane the plane to check
  10481. * @returns the distance away it was hit
  10482. */
  10483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10484. /**
  10485. * Calculate the intercept of a ray on a given axis
  10486. * @param axis to check 'x' | 'y' | 'z'
  10487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10489. */
  10490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10491. /**
  10492. * Checks if ray intersects a mesh
  10493. * @param mesh the mesh to check
  10494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10495. * @returns picking info of the intersecton
  10496. */
  10497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10498. /**
  10499. * Checks if ray intersects a mesh
  10500. * @param meshes the meshes to check
  10501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10502. * @param results array to store result in
  10503. * @returns Array of picking infos
  10504. */
  10505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10506. private _comparePickingInfo;
  10507. private static smallnum;
  10508. private static rayl;
  10509. /**
  10510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10511. * @param sega the first point of the segment to test the intersection against
  10512. * @param segb the second point of the segment to test the intersection against
  10513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10515. */
  10516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10517. /**
  10518. * Update the ray from viewport position
  10519. * @param x position
  10520. * @param y y position
  10521. * @param viewportWidth viewport width
  10522. * @param viewportHeight viewport height
  10523. * @param world world matrix
  10524. * @param view view matrix
  10525. * @param projection projection matrix
  10526. * @returns this ray updated
  10527. */
  10528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10529. /**
  10530. * Creates a ray with origin and direction of 0,0,0
  10531. * @returns the new ray
  10532. */
  10533. static Zero(): Ray;
  10534. /**
  10535. * Creates a new ray from screen space and viewport
  10536. * @param x position
  10537. * @param y y position
  10538. * @param viewportWidth viewport width
  10539. * @param viewportHeight viewport height
  10540. * @param world world matrix
  10541. * @param view view matrix
  10542. * @param projection projection matrix
  10543. * @returns new ray
  10544. */
  10545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10546. /**
  10547. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10548. * transformed to the given world matrix.
  10549. * @param origin The origin point
  10550. * @param end The end point
  10551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10552. * @returns the new ray
  10553. */
  10554. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10555. /**
  10556. * Transforms a ray by a matrix
  10557. * @param ray ray to transform
  10558. * @param matrix matrix to apply
  10559. * @returns the resulting new ray
  10560. */
  10561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10562. /**
  10563. * Transforms a ray by a matrix
  10564. * @param ray ray to transform
  10565. * @param matrix matrix to apply
  10566. * @param result ray to store result in
  10567. */
  10568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10569. /**
  10570. * Unproject a ray from screen space to object space
  10571. * @param sourceX defines the screen space x coordinate to use
  10572. * @param sourceY defines the screen space y coordinate to use
  10573. * @param viewportWidth defines the current width of the viewport
  10574. * @param viewportHeight defines the current height of the viewport
  10575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10576. * @param view defines the view matrix to use
  10577. * @param projection defines the projection matrix to use
  10578. */
  10579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10580. }
  10581. /**
  10582. * Type used to define predicate used to select faces when a mesh intersection is detected
  10583. */
  10584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10585. interface Scene {
  10586. /** @hidden */
  10587. _tempPickingRay: Nullable<Ray>;
  10588. /** @hidden */
  10589. _cachedRayForTransform: Ray;
  10590. /** @hidden */
  10591. _pickWithRayInverseMatrix: Matrix;
  10592. /** @hidden */
  10593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10594. /** @hidden */
  10595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10596. /** @hidden */
  10597. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. /**
  10602. * Groups all the scene component constants in one place to ease maintenance.
  10603. * @hidden
  10604. */
  10605. export class SceneComponentConstants {
  10606. static readonly NAME_EFFECTLAYER: string;
  10607. static readonly NAME_LAYER: string;
  10608. static readonly NAME_LENSFLARESYSTEM: string;
  10609. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10610. static readonly NAME_PARTICLESYSTEM: string;
  10611. static readonly NAME_GAMEPAD: string;
  10612. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10613. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10614. static readonly NAME_PREPASSRENDERER: string;
  10615. static readonly NAME_DEPTHRENDERER: string;
  10616. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10617. static readonly NAME_SPRITE: string;
  10618. static readonly NAME_OUTLINERENDERER: string;
  10619. static readonly NAME_PROCEDURALTEXTURE: string;
  10620. static readonly NAME_SHADOWGENERATOR: string;
  10621. static readonly NAME_OCTREE: string;
  10622. static readonly NAME_PHYSICSENGINE: string;
  10623. static readonly NAME_AUDIO: string;
  10624. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10625. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10626. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10627. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10628. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10629. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10630. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10631. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10632. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10633. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10634. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10635. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10636. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10637. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10638. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10639. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10640. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10643. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10644. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10645. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10646. static readonly STEP_AFTERRENDER_AUDIO: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10649. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10650. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10651. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10652. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10653. static readonly STEP_POINTERMOVE_SPRITE: number;
  10654. static readonly STEP_POINTERDOWN_SPRITE: number;
  10655. static readonly STEP_POINTERUP_SPRITE: number;
  10656. }
  10657. /**
  10658. * This represents a scene component.
  10659. *
  10660. * This is used to decouple the dependency the scene is having on the different workloads like
  10661. * layers, post processes...
  10662. */
  10663. export interface ISceneComponent {
  10664. /**
  10665. * The name of the component. Each component must have a unique name.
  10666. */
  10667. name: string;
  10668. /**
  10669. * The scene the component belongs to.
  10670. */
  10671. scene: Scene;
  10672. /**
  10673. * Register the component to one instance of a scene.
  10674. */
  10675. register(): void;
  10676. /**
  10677. * Rebuilds the elements related to this component in case of
  10678. * context lost for instance.
  10679. */
  10680. rebuild(): void;
  10681. /**
  10682. * Disposes the component and the associated ressources.
  10683. */
  10684. dispose(): void;
  10685. }
  10686. /**
  10687. * This represents a SERIALIZABLE scene component.
  10688. *
  10689. * This extends Scene Component to add Serialization methods on top.
  10690. */
  10691. export interface ISceneSerializableComponent extends ISceneComponent {
  10692. /**
  10693. * Adds all the elements from the container to the scene
  10694. * @param container the container holding the elements
  10695. */
  10696. addFromContainer(container: AbstractScene): void;
  10697. /**
  10698. * Removes all the elements in the container from the scene
  10699. * @param container contains the elements to remove
  10700. * @param dispose if the removed element should be disposed (default: false)
  10701. */
  10702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10703. /**
  10704. * Serializes the component data to the specified json object
  10705. * @param serializationObject The object to serialize to
  10706. */
  10707. serialize(serializationObject: any): void;
  10708. }
  10709. /**
  10710. * Strong typing of a Mesh related stage step action
  10711. */
  10712. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10713. /**
  10714. * Strong typing of a Evaluate Sub Mesh related stage step action
  10715. */
  10716. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10717. /**
  10718. * Strong typing of a Active Mesh related stage step action
  10719. */
  10720. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10721. /**
  10722. * Strong typing of a Camera related stage step action
  10723. */
  10724. export type CameraStageAction = (camera: Camera) => void;
  10725. /**
  10726. * Strong typing of a Camera Frame buffer related stage step action
  10727. */
  10728. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10729. /**
  10730. * Strong typing of a Render Target related stage step action
  10731. */
  10732. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10733. /**
  10734. * Strong typing of a RenderingGroup related stage step action
  10735. */
  10736. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10737. /**
  10738. * Strong typing of a Mesh Render related stage step action
  10739. */
  10740. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10741. /**
  10742. * Strong typing of a simple stage step action
  10743. */
  10744. export type SimpleStageAction = () => void;
  10745. /**
  10746. * Strong typing of a render target action.
  10747. */
  10748. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10749. /**
  10750. * Strong typing of a pointer move action.
  10751. */
  10752. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10753. /**
  10754. * Strong typing of a pointer up/down action.
  10755. */
  10756. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10757. /**
  10758. * Representation of a stage in the scene (Basically a list of ordered steps)
  10759. * @hidden
  10760. */
  10761. export class Stage<T extends Function> extends Array<{
  10762. index: number;
  10763. component: ISceneComponent;
  10764. action: T;
  10765. }> {
  10766. /**
  10767. * Hide ctor from the rest of the world.
  10768. * @param items The items to add.
  10769. */
  10770. private constructor();
  10771. /**
  10772. * Creates a new Stage.
  10773. * @returns A new instance of a Stage
  10774. */
  10775. static Create<T extends Function>(): Stage<T>;
  10776. /**
  10777. * Registers a step in an ordered way in the targeted stage.
  10778. * @param index Defines the position to register the step in
  10779. * @param component Defines the component attached to the step
  10780. * @param action Defines the action to launch during the step
  10781. */
  10782. registerStep(index: number, component: ISceneComponent, action: T): void;
  10783. /**
  10784. * Clears all the steps from the stage.
  10785. */
  10786. clear(): void;
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. interface Scene {
  10791. /** @hidden */
  10792. _pointerOverSprite: Nullable<Sprite>;
  10793. /** @hidden */
  10794. _pickedDownSprite: Nullable<Sprite>;
  10795. /** @hidden */
  10796. _tempSpritePickingRay: Nullable<Ray>;
  10797. /**
  10798. * All of the sprite managers added to this scene
  10799. * @see https://doc.babylonjs.com/babylon101/sprites
  10800. */
  10801. spriteManagers: Array<ISpriteManager>;
  10802. /**
  10803. * An event triggered when sprites rendering is about to start
  10804. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10805. */
  10806. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10807. /**
  10808. * An event triggered when sprites rendering is done
  10809. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10810. */
  10811. onAfterSpritesRenderingObservable: Observable<Scene>;
  10812. /** @hidden */
  10813. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10814. /** Launch a ray to try to pick a sprite in the scene
  10815. * @param x position on screen
  10816. * @param y position on screen
  10817. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10819. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10820. * @returns a PickingInfo
  10821. */
  10822. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10823. /** Use the given ray to pick a sprite in the scene
  10824. * @param ray The ray (in world space) to use to pick meshes
  10825. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10827. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10828. * @returns a PickingInfo
  10829. */
  10830. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10831. /** @hidden */
  10832. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10833. /** Launch a ray to try to pick sprites in the scene
  10834. * @param x position on screen
  10835. * @param y position on screen
  10836. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10837. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10838. * @returns a PickingInfo array
  10839. */
  10840. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10841. /** Use the given ray to pick sprites in the scene
  10842. * @param ray The ray (in world space) to use to pick meshes
  10843. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /**
  10849. * Force the sprite under the pointer
  10850. * @param sprite defines the sprite to use
  10851. */
  10852. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10853. /**
  10854. * Gets the sprite under the pointer
  10855. * @returns a Sprite or null if no sprite is under the pointer
  10856. */
  10857. getPointerOverSprite(): Nullable<Sprite>;
  10858. }
  10859. /**
  10860. * Defines the sprite scene component responsible to manage sprites
  10861. * in a given scene.
  10862. */
  10863. export class SpriteSceneComponent implements ISceneComponent {
  10864. /**
  10865. * The component name helpfull to identify the component in the list of scene components.
  10866. */
  10867. readonly name: string;
  10868. /**
  10869. * The scene the component belongs to.
  10870. */
  10871. scene: Scene;
  10872. /** @hidden */
  10873. private _spritePredicate;
  10874. /**
  10875. * Creates a new instance of the component for the given scene
  10876. * @param scene Defines the scene to register the component in
  10877. */
  10878. constructor(scene: Scene);
  10879. /**
  10880. * Registers the component in a given scene
  10881. */
  10882. register(): void;
  10883. /**
  10884. * Rebuilds the elements related to this component in case of
  10885. * context lost for instance.
  10886. */
  10887. rebuild(): void;
  10888. /**
  10889. * Disposes the component and the associated ressources.
  10890. */
  10891. dispose(): void;
  10892. private _pickSpriteButKeepRay;
  10893. private _pointerMove;
  10894. private _pointerDown;
  10895. private _pointerUp;
  10896. }
  10897. }
  10898. declare module BABYLON {
  10899. /** @hidden */
  10900. export var fogFragmentDeclaration: {
  10901. name: string;
  10902. shader: string;
  10903. };
  10904. }
  10905. declare module BABYLON {
  10906. /** @hidden */
  10907. export var fogFragment: {
  10908. name: string;
  10909. shader: string;
  10910. };
  10911. }
  10912. declare module BABYLON {
  10913. /** @hidden */
  10914. export var spritesPixelShader: {
  10915. name: string;
  10916. shader: string;
  10917. };
  10918. }
  10919. declare module BABYLON {
  10920. /** @hidden */
  10921. export var fogVertexDeclaration: {
  10922. name: string;
  10923. shader: string;
  10924. };
  10925. }
  10926. declare module BABYLON {
  10927. /** @hidden */
  10928. export var spritesVertexShader: {
  10929. name: string;
  10930. shader: string;
  10931. };
  10932. }
  10933. declare module BABYLON {
  10934. /**
  10935. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10936. */
  10937. export interface ISpriteManager extends IDisposable {
  10938. /**
  10939. * Gets manager's name
  10940. */
  10941. name: string;
  10942. /**
  10943. * Restricts the camera to viewing objects with the same layerMask.
  10944. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10945. */
  10946. layerMask: number;
  10947. /**
  10948. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10949. */
  10950. isPickable: boolean;
  10951. /**
  10952. * Gets the hosting scene
  10953. */
  10954. scene: Scene;
  10955. /**
  10956. * Specifies the rendering group id for this mesh (0 by default)
  10957. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10958. */
  10959. renderingGroupId: number;
  10960. /**
  10961. * Defines the list of sprites managed by the manager.
  10962. */
  10963. sprites: Array<Sprite>;
  10964. /**
  10965. * Gets or sets the spritesheet texture
  10966. */
  10967. texture: Texture;
  10968. /** Defines the default width of a cell in the spritesheet */
  10969. cellWidth: number;
  10970. /** Defines the default height of a cell in the spritesheet */
  10971. cellHeight: number;
  10972. /**
  10973. * Tests the intersection of a sprite with a specific ray.
  10974. * @param ray The ray we are sending to test the collision
  10975. * @param camera The camera space we are sending rays in
  10976. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10977. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10978. * @returns picking info or null.
  10979. */
  10980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10981. /**
  10982. * Intersects the sprites with a ray
  10983. * @param ray defines the ray to intersect with
  10984. * @param camera defines the current active camera
  10985. * @param predicate defines a predicate used to select candidate sprites
  10986. * @returns null if no hit or a PickingInfo array
  10987. */
  10988. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10989. /**
  10990. * Renders the list of sprites on screen.
  10991. */
  10992. render(): void;
  10993. }
  10994. /**
  10995. * Class used to manage multiple sprites on the same spritesheet
  10996. * @see https://doc.babylonjs.com/babylon101/sprites
  10997. */
  10998. export class SpriteManager implements ISpriteManager {
  10999. /** defines the manager's name */
  11000. name: string;
  11001. /** Define the Url to load snippets */
  11002. static SnippetUrl: string;
  11003. /** Snippet ID if the manager was created from the snippet server */
  11004. snippetId: string;
  11005. /** Gets the list of sprites */
  11006. sprites: Sprite[];
  11007. /** Gets or sets the rendering group id (0 by default) */
  11008. renderingGroupId: number;
  11009. /** Gets or sets camera layer mask */
  11010. layerMask: number;
  11011. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11012. fogEnabled: boolean;
  11013. /** Gets or sets a boolean indicating if the sprites are pickable */
  11014. isPickable: boolean;
  11015. /** Defines the default width of a cell in the spritesheet */
  11016. cellWidth: number;
  11017. /** Defines the default height of a cell in the spritesheet */
  11018. cellHeight: number;
  11019. /** Associative array from JSON sprite data file */
  11020. private _cellData;
  11021. /** Array of sprite names from JSON sprite data file */
  11022. private _spriteMap;
  11023. /** True when packed cell data from JSON file is ready*/
  11024. private _packedAndReady;
  11025. private _textureContent;
  11026. private _useInstancing;
  11027. /**
  11028. * An event triggered when the manager is disposed.
  11029. */
  11030. onDisposeObservable: Observable<SpriteManager>;
  11031. private _onDisposeObserver;
  11032. /**
  11033. * Callback called when the manager is disposed
  11034. */
  11035. set onDispose(callback: () => void);
  11036. private _capacity;
  11037. private _fromPacked;
  11038. private _spriteTexture;
  11039. private _epsilon;
  11040. private _scene;
  11041. private _vertexData;
  11042. private _buffer;
  11043. private _vertexBuffers;
  11044. private _spriteBuffer;
  11045. private _indexBuffer;
  11046. private _effectBase;
  11047. private _effectFog;
  11048. private _vertexBufferSize;
  11049. /**
  11050. * Gets or sets the unique id of the sprite
  11051. */
  11052. uniqueId: number;
  11053. /**
  11054. * Gets the array of sprites
  11055. */
  11056. get children(): Sprite[];
  11057. /**
  11058. * Gets the hosting scene
  11059. */
  11060. get scene(): Scene;
  11061. /**
  11062. * Gets the capacity of the manager
  11063. */
  11064. get capacity(): number;
  11065. /**
  11066. * Gets or sets the spritesheet texture
  11067. */
  11068. get texture(): Texture;
  11069. set texture(value: Texture);
  11070. private _blendMode;
  11071. /**
  11072. * Blend mode use to render the particle, it can be any of
  11073. * the static Constants.ALPHA_x properties provided in this class.
  11074. * Default value is Constants.ALPHA_COMBINE
  11075. */
  11076. get blendMode(): number;
  11077. set blendMode(blendMode: number);
  11078. /** Disables writing to the depth buffer when rendering the sprites.
  11079. * It can be handy to disable depth writing when using textures without alpha channel
  11080. * and setting some specific blend modes.
  11081. */
  11082. disableDepthWrite: boolean;
  11083. /**
  11084. * Creates a new sprite manager
  11085. * @param name defines the manager's name
  11086. * @param imgUrl defines the sprite sheet url
  11087. * @param capacity defines the maximum allowed number of sprites
  11088. * @param cellSize defines the size of a sprite cell
  11089. * @param scene defines the hosting scene
  11090. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11091. * @param samplingMode defines the smapling mode to use with spritesheet
  11092. * @param fromPacked set to false; do not alter
  11093. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11094. */
  11095. constructor(
  11096. /** defines the manager's name */
  11097. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11098. /**
  11099. * Returns the string "SpriteManager"
  11100. * @returns "SpriteManager"
  11101. */
  11102. getClassName(): string;
  11103. private _makePacked;
  11104. private _appendSpriteVertex;
  11105. private _checkTextureAlpha;
  11106. /**
  11107. * Intersects the sprites with a ray
  11108. * @param ray defines the ray to intersect with
  11109. * @param camera defines the current active camera
  11110. * @param predicate defines a predicate used to select candidate sprites
  11111. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11112. * @returns null if no hit or a PickingInfo
  11113. */
  11114. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11115. /**
  11116. * Intersects the sprites with a ray
  11117. * @param ray defines the ray to intersect with
  11118. * @param camera defines the current active camera
  11119. * @param predicate defines a predicate used to select candidate sprites
  11120. * @returns null if no hit or a PickingInfo array
  11121. */
  11122. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11123. /**
  11124. * Render all child sprites
  11125. */
  11126. render(): void;
  11127. /**
  11128. * Release associated resources
  11129. */
  11130. dispose(): void;
  11131. /**
  11132. * Serializes the sprite manager to a JSON object
  11133. * @param serializeTexture defines if the texture must be serialized as well
  11134. * @returns the JSON object
  11135. */
  11136. serialize(serializeTexture?: boolean): any;
  11137. /**
  11138. * Parses a JSON object to create a new sprite manager.
  11139. * @param parsedManager The JSON object to parse
  11140. * @param scene The scene to create the sprite managerin
  11141. * @param rootUrl The root url to use to load external dependencies like texture
  11142. * @returns the new sprite manager
  11143. */
  11144. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11145. /**
  11146. * Creates a sprite manager from a snippet saved in a remote file
  11147. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11148. * @param url defines the url to load from
  11149. * @param scene defines the hosting scene
  11150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11151. * @returns a promise that will resolve to the new sprite manager
  11152. */
  11153. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11154. /**
  11155. * Creates a sprite manager from a snippet saved by the sprite editor
  11156. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11157. * @param scene defines the hosting scene
  11158. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11159. * @returns a promise that will resolve to the new sprite manager
  11160. */
  11161. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11162. }
  11163. }
  11164. declare module BABYLON {
  11165. /** Interface used by value gradients (color, factor, ...) */
  11166. export interface IValueGradient {
  11167. /**
  11168. * Gets or sets the gradient value (between 0 and 1)
  11169. */
  11170. gradient: number;
  11171. }
  11172. /** Class used to store color4 gradient */
  11173. export class ColorGradient implements IValueGradient {
  11174. /**
  11175. * Gets or sets the gradient value (between 0 and 1)
  11176. */
  11177. gradient: number;
  11178. /**
  11179. * Gets or sets first associated color
  11180. */
  11181. color1: Color4;
  11182. /**
  11183. * Gets or sets second associated color
  11184. */
  11185. color2?: Color4 | undefined;
  11186. /**
  11187. * Creates a new color4 gradient
  11188. * @param gradient gets or sets the gradient value (between 0 and 1)
  11189. * @param color1 gets or sets first associated color
  11190. * @param color2 gets or sets first second color
  11191. */
  11192. constructor(
  11193. /**
  11194. * Gets or sets the gradient value (between 0 and 1)
  11195. */
  11196. gradient: number,
  11197. /**
  11198. * Gets or sets first associated color
  11199. */
  11200. color1: Color4,
  11201. /**
  11202. * Gets or sets second associated color
  11203. */
  11204. color2?: Color4 | undefined);
  11205. /**
  11206. * Will get a color picked randomly between color1 and color2.
  11207. * If color2 is undefined then color1 will be used
  11208. * @param result defines the target Color4 to store the result in
  11209. */
  11210. getColorToRef(result: Color4): void;
  11211. }
  11212. /** Class used to store color 3 gradient */
  11213. export class Color3Gradient implements IValueGradient {
  11214. /**
  11215. * Gets or sets the gradient value (between 0 and 1)
  11216. */
  11217. gradient: number;
  11218. /**
  11219. * Gets or sets the associated color
  11220. */
  11221. color: Color3;
  11222. /**
  11223. * Creates a new color3 gradient
  11224. * @param gradient gets or sets the gradient value (between 0 and 1)
  11225. * @param color gets or sets associated color
  11226. */
  11227. constructor(
  11228. /**
  11229. * Gets or sets the gradient value (between 0 and 1)
  11230. */
  11231. gradient: number,
  11232. /**
  11233. * Gets or sets the associated color
  11234. */
  11235. color: Color3);
  11236. }
  11237. /** Class used to store factor gradient */
  11238. export class FactorGradient implements IValueGradient {
  11239. /**
  11240. * Gets or sets the gradient value (between 0 and 1)
  11241. */
  11242. gradient: number;
  11243. /**
  11244. * Gets or sets first associated factor
  11245. */
  11246. factor1: number;
  11247. /**
  11248. * Gets or sets second associated factor
  11249. */
  11250. factor2?: number | undefined;
  11251. /**
  11252. * Creates a new factor gradient
  11253. * @param gradient gets or sets the gradient value (between 0 and 1)
  11254. * @param factor1 gets or sets first associated factor
  11255. * @param factor2 gets or sets second associated factor
  11256. */
  11257. constructor(
  11258. /**
  11259. * Gets or sets the gradient value (between 0 and 1)
  11260. */
  11261. gradient: number,
  11262. /**
  11263. * Gets or sets first associated factor
  11264. */
  11265. factor1: number,
  11266. /**
  11267. * Gets or sets second associated factor
  11268. */
  11269. factor2?: number | undefined);
  11270. /**
  11271. * Will get a number picked randomly between factor1 and factor2.
  11272. * If factor2 is undefined then factor1 will be used
  11273. * @returns the picked number
  11274. */
  11275. getFactor(): number;
  11276. }
  11277. /**
  11278. * Helper used to simplify some generic gradient tasks
  11279. */
  11280. export class GradientHelper {
  11281. /**
  11282. * Gets the current gradient from an array of IValueGradient
  11283. * @param ratio defines the current ratio to get
  11284. * @param gradients defines the array of IValueGradient
  11285. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11286. */
  11287. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11288. }
  11289. }
  11290. declare module BABYLON {
  11291. interface ThinEngine {
  11292. /**
  11293. * Creates a raw texture
  11294. * @param data defines the data to store in the texture
  11295. * @param width defines the width of the texture
  11296. * @param height defines the height of the texture
  11297. * @param format defines the format of the data
  11298. * @param generateMipMaps defines if the engine should generate the mip levels
  11299. * @param invertY defines if data must be stored with Y axis inverted
  11300. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11301. * @param compression defines the compression used (null by default)
  11302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11303. * @returns the raw texture inside an InternalTexture
  11304. */
  11305. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11306. /**
  11307. * Update a raw texture
  11308. * @param texture defines the texture to update
  11309. * @param data defines the data to store in the texture
  11310. * @param format defines the format of the data
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. */
  11313. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11314. /**
  11315. * Update a raw texture
  11316. * @param texture defines the texture to update
  11317. * @param data defines the data to store in the texture
  11318. * @param format defines the format of the data
  11319. * @param invertY defines if data must be stored with Y axis inverted
  11320. * @param compression defines the compression used (null by default)
  11321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11322. */
  11323. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11324. /**
  11325. * Creates a new raw cube texture
  11326. * @param data defines the array of data to use to create each face
  11327. * @param size defines the size of the textures
  11328. * @param format defines the format of the data
  11329. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11330. * @param generateMipMaps defines if the engine should generate the mip levels
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11333. * @param compression defines the compression used (null by default)
  11334. * @returns the cube texture as an InternalTexture
  11335. */
  11336. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11337. /**
  11338. * Update a raw cube texture
  11339. * @param texture defines the texture to udpdate
  11340. * @param data defines the data to store
  11341. * @param format defines the data format
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. * @param invertY defines if data must be stored with Y axis inverted
  11344. */
  11345. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11346. /**
  11347. * Update a raw cube texture
  11348. * @param texture defines the texture to udpdate
  11349. * @param data defines the data to store
  11350. * @param format defines the data format
  11351. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param compression defines the compression used (null by default)
  11354. */
  11355. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11356. /**
  11357. * Update a raw cube texture
  11358. * @param texture defines the texture to udpdate
  11359. * @param data defines the data to store
  11360. * @param format defines the data format
  11361. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11362. * @param invertY defines if data must be stored with Y axis inverted
  11363. * @param compression defines the compression used (null by default)
  11364. * @param level defines which level of the texture to update
  11365. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11367. /**
  11368. * Creates a new raw cube texture from a specified url
  11369. * @param url defines the url where the data is located
  11370. * @param scene defines the current scene
  11371. * @param size defines the size of the textures
  11372. * @param format defines the format of the data
  11373. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11374. * @param noMipmap defines if the engine should avoid generating the mip levels
  11375. * @param callback defines a callback used to extract texture data from loaded data
  11376. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11377. * @param onLoad defines a callback called when texture is loaded
  11378. * @param onError defines a callback called if there is an error
  11379. * @returns the cube texture as an InternalTexture
  11380. */
  11381. 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;
  11382. /**
  11383. * Creates a new raw cube texture from a specified url
  11384. * @param url defines the url where the data is located
  11385. * @param scene defines the current scene
  11386. * @param size defines the size of the textures
  11387. * @param format defines the format of the data
  11388. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11389. * @param noMipmap defines if the engine should avoid generating the mip levels
  11390. * @param callback defines a callback used to extract texture data from loaded data
  11391. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11392. * @param onLoad defines a callback called when texture is loaded
  11393. * @param onError defines a callback called if there is an error
  11394. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11395. * @param invertY defines if data must be stored with Y axis inverted
  11396. * @returns the cube texture as an InternalTexture
  11397. */
  11398. 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;
  11399. /**
  11400. * Creates a new raw 3D texture
  11401. * @param data defines the data used to create the texture
  11402. * @param width defines the width of the texture
  11403. * @param height defines the height of the texture
  11404. * @param depth defines the depth of the texture
  11405. * @param format defines the format of the texture
  11406. * @param generateMipMaps defines if the engine must generate mip levels
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11409. * @param compression defines the compressed used (can be null)
  11410. * @param textureType defines the compressed used (can be null)
  11411. * @returns a new raw 3D texture (stored in an InternalTexture)
  11412. */
  11413. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11414. /**
  11415. * Update a raw 3D texture
  11416. * @param texture defines the texture to update
  11417. * @param data defines the data to store
  11418. * @param format defines the data format
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. */
  11421. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11422. /**
  11423. * Update a raw 3D texture
  11424. * @param texture defines the texture to update
  11425. * @param data defines the data to store
  11426. * @param format defines the data format
  11427. * @param invertY defines if data must be stored with Y axis inverted
  11428. * @param compression defines the used compression (can be null)
  11429. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11430. */
  11431. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11432. /**
  11433. * Creates a new raw 2D array texture
  11434. * @param data defines the data used to create the texture
  11435. * @param width defines the width of the texture
  11436. * @param height defines the height of the texture
  11437. * @param depth defines the number of layers of the texture
  11438. * @param format defines the format of the texture
  11439. * @param generateMipMaps defines if the engine must generate mip levels
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11442. * @param compression defines the compressed used (can be null)
  11443. * @param textureType defines the compressed used (can be null)
  11444. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11445. */
  11446. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11447. /**
  11448. * Update a raw 2D array texture
  11449. * @param texture defines the texture to update
  11450. * @param data defines the data to store
  11451. * @param format defines the data format
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. */
  11454. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11455. /**
  11456. * Update a raw 2D array texture
  11457. * @param texture defines the texture to update
  11458. * @param data defines the data to store
  11459. * @param format defines the data format
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @param compression defines the used compression (can be null)
  11462. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11463. */
  11464. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11465. }
  11466. }
  11467. declare module BABYLON {
  11468. /**
  11469. * Raw texture can help creating a texture directly from an array of data.
  11470. * This can be super useful if you either get the data from an uncompressed source or
  11471. * if you wish to create your texture pixel by pixel.
  11472. */
  11473. export class RawTexture extends Texture {
  11474. /**
  11475. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11476. */
  11477. format: number;
  11478. /**
  11479. * Instantiates a new RawTexture.
  11480. * Raw texture can help creating a texture directly from an array of data.
  11481. * This can be super useful if you either get the data from an uncompressed source or
  11482. * if you wish to create your texture pixel by pixel.
  11483. * @param data define the array of data to use to create the texture
  11484. * @param width define the width of the texture
  11485. * @param height define the height of the texture
  11486. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11487. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11488. * @param generateMipMaps define whether mip maps should be generated or not
  11489. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11490. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11491. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11492. */
  11493. constructor(data: ArrayBufferView, width: number, height: number,
  11494. /**
  11495. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11496. */
  11497. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11498. /**
  11499. * Updates the texture underlying data.
  11500. * @param data Define the new data of the texture
  11501. */
  11502. update(data: ArrayBufferView): void;
  11503. /**
  11504. * Creates a luminance texture from some data.
  11505. * @param data Define the texture data
  11506. * @param width Define the width of the texture
  11507. * @param height Define the height of the texture
  11508. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @returns the luminance texture
  11513. */
  11514. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11515. /**
  11516. * Creates a luminance alpha texture from some data.
  11517. * @param data Define the texture data
  11518. * @param width Define the width of the texture
  11519. * @param height Define the height of the texture
  11520. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11524. * @returns the luminance alpha texture
  11525. */
  11526. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11527. /**
  11528. * Creates an alpha texture from some data.
  11529. * @param data Define the texture data
  11530. * @param width Define the width of the texture
  11531. * @param height Define the height of the texture
  11532. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11536. * @returns the alpha texture
  11537. */
  11538. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11539. /**
  11540. * Creates a RGB texture from some data.
  11541. * @param data Define the texture data
  11542. * @param width Define the width of the texture
  11543. * @param height Define the height of the texture
  11544. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11548. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11549. * @returns the RGB alpha texture
  11550. */
  11551. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11552. /**
  11553. * Creates a RGBA texture from some data.
  11554. * @param data Define the texture data
  11555. * @param width Define the width of the texture
  11556. * @param height Define the height of the texture
  11557. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11558. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11559. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11560. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11561. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11562. * @returns the RGBA texture
  11563. */
  11564. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11565. /**
  11566. * Creates a R texture from some data.
  11567. * @param data Define the texture data
  11568. * @param width Define the width of the texture
  11569. * @param height Define the height of the texture
  11570. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11574. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11575. * @returns the R texture
  11576. */
  11577. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11578. }
  11579. }
  11580. declare module BABYLON {
  11581. interface AbstractScene {
  11582. /**
  11583. * The list of procedural textures added to the scene
  11584. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11585. */
  11586. proceduralTextures: Array<ProceduralTexture>;
  11587. }
  11588. /**
  11589. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11590. * in a given scene.
  11591. */
  11592. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11593. /**
  11594. * The component name helpfull to identify the component in the list of scene components.
  11595. */
  11596. readonly name: string;
  11597. /**
  11598. * The scene the component belongs to.
  11599. */
  11600. scene: Scene;
  11601. /**
  11602. * Creates a new instance of the component for the given scene
  11603. * @param scene Defines the scene to register the component in
  11604. */
  11605. constructor(scene: Scene);
  11606. /**
  11607. * Registers the component in a given scene
  11608. */
  11609. register(): void;
  11610. /**
  11611. * Rebuilds the elements related to this component in case of
  11612. * context lost for instance.
  11613. */
  11614. rebuild(): void;
  11615. /**
  11616. * Disposes the component and the associated ressources.
  11617. */
  11618. dispose(): void;
  11619. private _beforeClear;
  11620. }
  11621. }
  11622. declare module BABYLON {
  11623. interface ThinEngine {
  11624. /**
  11625. * Creates a new render target cube texture
  11626. * @param size defines the size of the texture
  11627. * @param options defines the options used to create the texture
  11628. * @returns a new render target cube texture stored in an InternalTexture
  11629. */
  11630. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11631. }
  11632. }
  11633. declare module BABYLON {
  11634. /** @hidden */
  11635. export var proceduralVertexShader: {
  11636. name: string;
  11637. shader: string;
  11638. };
  11639. }
  11640. declare module BABYLON {
  11641. /**
  11642. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11643. * This is the base class of any Procedural texture and contains most of the shareable code.
  11644. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11645. */
  11646. export class ProceduralTexture extends Texture {
  11647. isCube: boolean;
  11648. /**
  11649. * Define if the texture is enabled or not (disabled texture will not render)
  11650. */
  11651. isEnabled: boolean;
  11652. /**
  11653. * Define if the texture must be cleared before rendering (default is true)
  11654. */
  11655. autoClear: boolean;
  11656. /**
  11657. * Callback called when the texture is generated
  11658. */
  11659. onGenerated: () => void;
  11660. /**
  11661. * Event raised when the texture is generated
  11662. */
  11663. onGeneratedObservable: Observable<ProceduralTexture>;
  11664. /** @hidden */
  11665. _generateMipMaps: boolean;
  11666. /** @hidden **/
  11667. _effect: Effect;
  11668. /** @hidden */
  11669. _textures: {
  11670. [key: string]: Texture;
  11671. };
  11672. /** @hidden */
  11673. protected _fallbackTexture: Nullable<Texture>;
  11674. private _size;
  11675. private _currentRefreshId;
  11676. private _frameId;
  11677. private _refreshRate;
  11678. private _vertexBuffers;
  11679. private _indexBuffer;
  11680. private _uniforms;
  11681. private _samplers;
  11682. private _fragment;
  11683. private _floats;
  11684. private _ints;
  11685. private _floatsArrays;
  11686. private _colors3;
  11687. private _colors4;
  11688. private _vectors2;
  11689. private _vectors3;
  11690. private _matrices;
  11691. private _fallbackTextureUsed;
  11692. private _fullEngine;
  11693. private _cachedDefines;
  11694. private _contentUpdateId;
  11695. private _contentData;
  11696. /**
  11697. * Instantiates a new procedural texture.
  11698. * 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.
  11699. * This is the base class of any Procedural texture and contains most of the shareable code.
  11700. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11701. * @param name Define the name of the texture
  11702. * @param size Define the size of the texture to create
  11703. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11704. * @param scene Define the scene the texture belongs to
  11705. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11706. * @param generateMipMaps Define if the texture should creates mip maps or not
  11707. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11708. */
  11709. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11710. /**
  11711. * The effect that is created when initializing the post process.
  11712. * @returns The created effect corresponding the the postprocess.
  11713. */
  11714. getEffect(): Effect;
  11715. /**
  11716. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11717. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11718. */
  11719. getContent(): Nullable<ArrayBufferView>;
  11720. private _createIndexBuffer;
  11721. /** @hidden */
  11722. _rebuild(): void;
  11723. /**
  11724. * Resets the texture in order to recreate its associated resources.
  11725. * This can be called in case of context loss
  11726. */
  11727. reset(): void;
  11728. protected _getDefines(): string;
  11729. /**
  11730. * Is the texture ready to be used ? (rendered at least once)
  11731. * @returns true if ready, otherwise, false.
  11732. */
  11733. isReady(): boolean;
  11734. /**
  11735. * Resets the refresh counter of the texture and start bak from scratch.
  11736. * Could be useful to regenerate the texture if it is setup to render only once.
  11737. */
  11738. resetRefreshCounter(): void;
  11739. /**
  11740. * Set the fragment shader to use in order to render the texture.
  11741. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11742. */
  11743. setFragment(fragment: any): void;
  11744. /**
  11745. * Define the refresh rate of the texture or the rendering frequency.
  11746. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11747. */
  11748. get refreshRate(): number;
  11749. set refreshRate(value: number);
  11750. /** @hidden */
  11751. _shouldRender(): boolean;
  11752. /**
  11753. * Get the size the texture is rendering at.
  11754. * @returns the size (texture is always squared)
  11755. */
  11756. getRenderSize(): number;
  11757. /**
  11758. * Resize the texture to new value.
  11759. * @param size Define the new size the texture should have
  11760. * @param generateMipMaps Define whether the new texture should create mip maps
  11761. */
  11762. resize(size: number, generateMipMaps: boolean): void;
  11763. private _checkUniform;
  11764. /**
  11765. * Set a texture in the shader program used to render.
  11766. * @param name Define the name of the uniform samplers as defined in the shader
  11767. * @param texture Define the texture to bind to this sampler
  11768. * @return the texture itself allowing "fluent" like uniform updates
  11769. */
  11770. setTexture(name: string, texture: Texture): ProceduralTexture;
  11771. /**
  11772. * Set a float 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. setFloat(name: string, value: number): ProceduralTexture;
  11778. /**
  11779. * Set a int 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. setInt(name: string, value: number): ProceduralTexture;
  11785. /**
  11786. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ProceduralTexture;
  11792. /**
  11793. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  11799. /**
  11800. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ProceduralTexture;
  11806. /**
  11807. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  11813. /**
  11814. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  11820. /**
  11821. * Set a mat4 in the shader from a MAtrix.
  11822. * @param name Define the name of the uniform as defined in the shader
  11823. * @param value Define the value to give to the uniform
  11824. * @return the texture itself allowing "fluent" like uniform updates
  11825. */
  11826. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11827. /**
  11828. * Render the texture to its associated render target.
  11829. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11830. */
  11831. render(useCameraPostProcess?: boolean): void;
  11832. /**
  11833. * Clone the texture.
  11834. * @returns the cloned texture
  11835. */
  11836. clone(): ProceduralTexture;
  11837. /**
  11838. * Dispose the texture and release its asoociated resources.
  11839. */
  11840. dispose(): void;
  11841. }
  11842. }
  11843. declare module BABYLON {
  11844. /**
  11845. * This represents the base class for particle system in Babylon.
  11846. * 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.
  11847. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11848. * @example https://doc.babylonjs.com/babylon101/particles
  11849. */
  11850. export class BaseParticleSystem {
  11851. /**
  11852. * Source color is added to the destination color without alpha affecting the result
  11853. */
  11854. static BLENDMODE_ONEONE: number;
  11855. /**
  11856. * Blend current color and particle color using particle’s alpha
  11857. */
  11858. static BLENDMODE_STANDARD: number;
  11859. /**
  11860. * Add current color and particle color multiplied by particle’s alpha
  11861. */
  11862. static BLENDMODE_ADD: number;
  11863. /**
  11864. * Multiply current color with particle color
  11865. */
  11866. static BLENDMODE_MULTIPLY: number;
  11867. /**
  11868. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11869. */
  11870. static BLENDMODE_MULTIPLYADD: number;
  11871. /**
  11872. * List of animations used by the particle system.
  11873. */
  11874. animations: Animation[];
  11875. /**
  11876. * Gets or sets the unique id of the particle system
  11877. */
  11878. uniqueId: number;
  11879. /**
  11880. * The id of the Particle system.
  11881. */
  11882. id: string;
  11883. /**
  11884. * The friendly name of the Particle system.
  11885. */
  11886. name: string;
  11887. /**
  11888. * Snippet ID if the particle system was created from the snippet server
  11889. */
  11890. snippetId: string;
  11891. /**
  11892. * The rendering group used by the Particle system to chose when to render.
  11893. */
  11894. renderingGroupId: number;
  11895. /**
  11896. * The emitter represents the Mesh or position we are attaching the particle system to.
  11897. */
  11898. emitter: Nullable<AbstractMesh | Vector3>;
  11899. /**
  11900. * The maximum number of particles to emit per frame
  11901. */
  11902. emitRate: number;
  11903. /**
  11904. * If you want to launch only a few particles at once, that can be done, as well.
  11905. */
  11906. manualEmitCount: number;
  11907. /**
  11908. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11909. */
  11910. updateSpeed: number;
  11911. /**
  11912. * The amount of time the particle system is running (depends of the overall update speed).
  11913. */
  11914. targetStopDuration: number;
  11915. /**
  11916. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11917. */
  11918. disposeOnStop: boolean;
  11919. /**
  11920. * Minimum power of emitting particles.
  11921. */
  11922. minEmitPower: number;
  11923. /**
  11924. * Maximum power of emitting particles.
  11925. */
  11926. maxEmitPower: number;
  11927. /**
  11928. * Minimum life time of emitting particles.
  11929. */
  11930. minLifeTime: number;
  11931. /**
  11932. * Maximum life time of emitting particles.
  11933. */
  11934. maxLifeTime: number;
  11935. /**
  11936. * Minimum Size of emitting particles.
  11937. */
  11938. minSize: number;
  11939. /**
  11940. * Maximum Size of emitting particles.
  11941. */
  11942. maxSize: number;
  11943. /**
  11944. * Minimum scale of emitting particles on X axis.
  11945. */
  11946. minScaleX: number;
  11947. /**
  11948. * Maximum scale of emitting particles on X axis.
  11949. */
  11950. maxScaleX: number;
  11951. /**
  11952. * Minimum scale of emitting particles on Y axis.
  11953. */
  11954. minScaleY: number;
  11955. /**
  11956. * Maximum scale of emitting particles on Y axis.
  11957. */
  11958. maxScaleY: number;
  11959. /**
  11960. * Gets or sets the minimal initial rotation in radians.
  11961. */
  11962. minInitialRotation: number;
  11963. /**
  11964. * Gets or sets the maximal initial rotation in radians.
  11965. */
  11966. maxInitialRotation: number;
  11967. /**
  11968. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11969. */
  11970. minAngularSpeed: number;
  11971. /**
  11972. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11973. */
  11974. maxAngularSpeed: number;
  11975. /**
  11976. * The texture used to render each particle. (this can be a spritesheet)
  11977. */
  11978. particleTexture: Nullable<Texture>;
  11979. /**
  11980. * The layer mask we are rendering the particles through.
  11981. */
  11982. layerMask: number;
  11983. /**
  11984. * This can help using your own shader to render the particle system.
  11985. * The according effect will be created
  11986. */
  11987. customShader: any;
  11988. /**
  11989. * By default particle system starts as soon as they are created. This prevents the
  11990. * automatic start to happen and let you decide when to start emitting particles.
  11991. */
  11992. preventAutoStart: boolean;
  11993. private _noiseTexture;
  11994. /**
  11995. * Gets or sets a texture used to add random noise to particle positions
  11996. */
  11997. get noiseTexture(): Nullable<ProceduralTexture>;
  11998. set noiseTexture(value: Nullable<ProceduralTexture>);
  11999. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12000. noiseStrength: Vector3;
  12001. /**
  12002. * Callback triggered when the particle animation is ending.
  12003. */
  12004. onAnimationEnd: Nullable<() => void>;
  12005. /**
  12006. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12007. */
  12008. blendMode: number;
  12009. /**
  12010. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12011. * to override the particles.
  12012. */
  12013. forceDepthWrite: boolean;
  12014. /** 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 */
  12015. preWarmCycles: number;
  12016. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12017. preWarmStepOffset: number;
  12018. /**
  12019. * 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)
  12020. */
  12021. spriteCellChangeSpeed: number;
  12022. /**
  12023. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12024. */
  12025. startSpriteCellID: number;
  12026. /**
  12027. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12028. */
  12029. endSpriteCellID: number;
  12030. /**
  12031. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12032. */
  12033. spriteCellWidth: number;
  12034. /**
  12035. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12036. */
  12037. spriteCellHeight: number;
  12038. /**
  12039. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12040. */
  12041. spriteRandomStartCell: boolean;
  12042. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12043. translationPivot: Vector2;
  12044. /** @hidden */
  12045. protected _isAnimationSheetEnabled: boolean;
  12046. /**
  12047. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12048. */
  12049. beginAnimationOnStart: boolean;
  12050. /**
  12051. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12052. */
  12053. beginAnimationFrom: number;
  12054. /**
  12055. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12056. */
  12057. beginAnimationTo: number;
  12058. /**
  12059. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12060. */
  12061. beginAnimationLoop: boolean;
  12062. /**
  12063. * Gets or sets a world offset applied to all particles
  12064. */
  12065. worldOffset: Vector3;
  12066. /**
  12067. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12068. */
  12069. get isAnimationSheetEnabled(): boolean;
  12070. set isAnimationSheetEnabled(value: boolean);
  12071. /**
  12072. * Get hosting scene
  12073. * @returns the scene
  12074. */
  12075. getScene(): Nullable<Scene>;
  12076. /**
  12077. * You can use gravity if you want to give an orientation to your particles.
  12078. */
  12079. gravity: Vector3;
  12080. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12081. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12082. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12083. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12084. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12085. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12086. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12087. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12088. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12089. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12090. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12091. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12092. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12093. /**
  12094. * Defines the delay in milliseconds before starting the system (0 by default)
  12095. */
  12096. startDelay: number;
  12097. /**
  12098. * Gets the current list of drag gradients.
  12099. * You must use addDragGradient and removeDragGradient to udpate this list
  12100. * @returns the list of drag gradients
  12101. */
  12102. getDragGradients(): Nullable<Array<FactorGradient>>;
  12103. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12104. limitVelocityDamping: number;
  12105. /**
  12106. * Gets the current list of limit velocity gradients.
  12107. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12108. * @returns the list of limit velocity gradients
  12109. */
  12110. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12111. /**
  12112. * Gets the current list of color gradients.
  12113. * You must use addColorGradient and removeColorGradient to udpate this list
  12114. * @returns the list of color gradients
  12115. */
  12116. getColorGradients(): Nullable<Array<ColorGradient>>;
  12117. /**
  12118. * Gets the current list of size gradients.
  12119. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12120. * @returns the list of size gradients
  12121. */
  12122. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12123. /**
  12124. * Gets the current list of color remap gradients.
  12125. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12126. * @returns the list of color remap gradients
  12127. */
  12128. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12129. /**
  12130. * Gets the current list of alpha remap gradients.
  12131. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12132. * @returns the list of alpha remap gradients
  12133. */
  12134. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12135. /**
  12136. * Gets the current list of life time gradients.
  12137. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12138. * @returns the list of life time gradients
  12139. */
  12140. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12141. /**
  12142. * Gets the current list of angular speed gradients.
  12143. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12144. * @returns the list of angular speed gradients
  12145. */
  12146. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12147. /**
  12148. * Gets the current list of velocity gradients.
  12149. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12150. * @returns the list of velocity gradients
  12151. */
  12152. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12153. /**
  12154. * Gets the current list of start size gradients.
  12155. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12156. * @returns the list of start size gradients
  12157. */
  12158. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12159. /**
  12160. * Gets the current list of emit rate gradients.
  12161. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12162. * @returns the list of emit rate gradients
  12163. */
  12164. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12165. /**
  12166. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12167. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12168. */
  12169. get direction1(): Vector3;
  12170. set direction1(value: Vector3);
  12171. /**
  12172. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12173. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12174. */
  12175. get direction2(): Vector3;
  12176. set direction2(value: Vector3);
  12177. /**
  12178. * 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.
  12179. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12180. */
  12181. get minEmitBox(): Vector3;
  12182. set minEmitBox(value: Vector3);
  12183. /**
  12184. * 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.
  12185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12186. */
  12187. get maxEmitBox(): Vector3;
  12188. set maxEmitBox(value: Vector3);
  12189. /**
  12190. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12191. */
  12192. color1: Color4;
  12193. /**
  12194. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12195. */
  12196. color2: Color4;
  12197. /**
  12198. * Color the particle will have at the end of its lifetime
  12199. */
  12200. colorDead: Color4;
  12201. /**
  12202. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12203. */
  12204. textureMask: Color4;
  12205. /**
  12206. * The particle emitter type defines the emitter used by the particle system.
  12207. * It can be for example box, sphere, or cone...
  12208. */
  12209. particleEmitterType: IParticleEmitterType;
  12210. /** @hidden */
  12211. _isSubEmitter: boolean;
  12212. /**
  12213. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12214. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12215. */
  12216. billboardMode: number;
  12217. protected _isBillboardBased: boolean;
  12218. /**
  12219. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12220. */
  12221. get isBillboardBased(): boolean;
  12222. set isBillboardBased(value: boolean);
  12223. /**
  12224. * The scene the particle system belongs to.
  12225. */
  12226. protected _scene: Nullable<Scene>;
  12227. /**
  12228. * The engine the particle system belongs to.
  12229. */
  12230. protected _engine: ThinEngine;
  12231. /**
  12232. * Local cache of defines for image processing.
  12233. */
  12234. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12235. /**
  12236. * Default configuration related to image processing available in the standard Material.
  12237. */
  12238. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12239. /**
  12240. * Gets the image processing configuration used either in this material.
  12241. */
  12242. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12243. /**
  12244. * Sets the Default image processing configuration used either in the this material.
  12245. *
  12246. * If sets to null, the scene one is in use.
  12247. */
  12248. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12249. /**
  12250. * Attaches a new image processing configuration to the Standard Material.
  12251. * @param configuration
  12252. */
  12253. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12254. /** @hidden */
  12255. protected _reset(): void;
  12256. /** @hidden */
  12257. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12258. /**
  12259. * Instantiates a particle system.
  12260. * 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.
  12261. * @param name The name of the particle system
  12262. */
  12263. constructor(name: string);
  12264. /**
  12265. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12266. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12267. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12268. * @returns the emitter
  12269. */
  12270. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12271. /**
  12272. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12273. * @param radius The radius of the hemisphere to emit from
  12274. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12275. * @returns the emitter
  12276. */
  12277. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12278. /**
  12279. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12280. * @param radius The radius of the sphere to emit from
  12281. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12282. * @returns the emitter
  12283. */
  12284. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12285. /**
  12286. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12287. * @param radius The radius of the sphere to emit from
  12288. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12289. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12290. * @returns the emitter
  12291. */
  12292. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12293. /**
  12294. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12295. * @param radius The radius of the emission cylinder
  12296. * @param height The height of the emission cylinder
  12297. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12298. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12299. * @returns the emitter
  12300. */
  12301. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12302. /**
  12303. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12304. * @param radius The radius of the cylinder to emit from
  12305. * @param height The height of the emission cylinder
  12306. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12309. * @returns the emitter
  12310. */
  12311. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12312. /**
  12313. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12314. * @param radius The radius of the cone to emit from
  12315. * @param angle The base angle of the cone
  12316. * @returns the emitter
  12317. */
  12318. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12319. /**
  12320. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12321. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12322. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12323. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12324. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12325. * @returns the emitter
  12326. */
  12327. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12328. }
  12329. }
  12330. declare module BABYLON {
  12331. /**
  12332. * Type of sub emitter
  12333. */
  12334. export enum SubEmitterType {
  12335. /**
  12336. * Attached to the particle over it's lifetime
  12337. */
  12338. ATTACHED = 0,
  12339. /**
  12340. * Created when the particle dies
  12341. */
  12342. END = 1
  12343. }
  12344. /**
  12345. * Sub emitter class used to emit particles from an existing particle
  12346. */
  12347. export class SubEmitter {
  12348. /**
  12349. * the particle system to be used by the sub emitter
  12350. */
  12351. particleSystem: ParticleSystem;
  12352. /**
  12353. * Type of the submitter (Default: END)
  12354. */
  12355. type: SubEmitterType;
  12356. /**
  12357. * 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)
  12358. * Note: This only is supported when using an emitter of type Mesh
  12359. */
  12360. inheritDirection: boolean;
  12361. /**
  12362. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12363. */
  12364. inheritedVelocityAmount: number;
  12365. /**
  12366. * Creates a sub emitter
  12367. * @param particleSystem the particle system to be used by the sub emitter
  12368. */
  12369. constructor(
  12370. /**
  12371. * the particle system to be used by the sub emitter
  12372. */
  12373. particleSystem: ParticleSystem);
  12374. /**
  12375. * Clones the sub emitter
  12376. * @returns the cloned sub emitter
  12377. */
  12378. clone(): SubEmitter;
  12379. /**
  12380. * Serialize current object to a JSON object
  12381. * @returns the serialized object
  12382. */
  12383. serialize(): any;
  12384. /** @hidden */
  12385. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12386. /**
  12387. * Creates a new SubEmitter from a serialized JSON version
  12388. * @param serializationObject defines the JSON object to read from
  12389. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12390. * @param rootUrl defines the rootUrl for data loading
  12391. * @returns a new SubEmitter
  12392. */
  12393. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12394. /** Release associated resources */
  12395. dispose(): void;
  12396. }
  12397. }
  12398. declare module BABYLON {
  12399. /** @hidden */
  12400. export var imageProcessingDeclaration: {
  12401. name: string;
  12402. shader: string;
  12403. };
  12404. }
  12405. declare module BABYLON {
  12406. /** @hidden */
  12407. export var imageProcessingFunctions: {
  12408. name: string;
  12409. shader: string;
  12410. };
  12411. }
  12412. declare module BABYLON {
  12413. /** @hidden */
  12414. export var particlesPixelShader: {
  12415. name: string;
  12416. shader: string;
  12417. };
  12418. }
  12419. declare module BABYLON {
  12420. /** @hidden */
  12421. export var particlesVertexShader: {
  12422. name: string;
  12423. shader: string;
  12424. };
  12425. }
  12426. declare module BABYLON {
  12427. /**
  12428. * Interface used to define entities containing multiple clip planes
  12429. */
  12430. export interface IClipPlanesHolder {
  12431. /**
  12432. * Gets or sets the active clipplane 1
  12433. */
  12434. clipPlane: Nullable<Plane>;
  12435. /**
  12436. * Gets or sets the active clipplane 2
  12437. */
  12438. clipPlane2: Nullable<Plane>;
  12439. /**
  12440. * Gets or sets the active clipplane 3
  12441. */
  12442. clipPlane3: Nullable<Plane>;
  12443. /**
  12444. * Gets or sets the active clipplane 4
  12445. */
  12446. clipPlane4: Nullable<Plane>;
  12447. /**
  12448. * Gets or sets the active clipplane 5
  12449. */
  12450. clipPlane5: Nullable<Plane>;
  12451. /**
  12452. * Gets or sets the active clipplane 6
  12453. */
  12454. clipPlane6: Nullable<Plane>;
  12455. }
  12456. }
  12457. declare module BABYLON {
  12458. /**
  12459. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12460. *
  12461. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12462. *
  12463. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12464. */
  12465. export class ThinMaterialHelper {
  12466. /**
  12467. * Binds the clip plane information from the holder to the effect.
  12468. * @param effect The effect we are binding the data to
  12469. * @param holder The entity containing the clip plane information
  12470. */
  12471. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12472. }
  12473. }
  12474. declare module BABYLON {
  12475. /**
  12476. * This represents a particle system in Babylon.
  12477. * 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.
  12478. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12479. * @example https://doc.babylonjs.com/babylon101/particles
  12480. */
  12481. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12482. /**
  12483. * Billboard mode will only apply to Y axis
  12484. */
  12485. static readonly BILLBOARDMODE_Y: number;
  12486. /**
  12487. * Billboard mode will apply to all axes
  12488. */
  12489. static readonly BILLBOARDMODE_ALL: number;
  12490. /**
  12491. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12492. */
  12493. static readonly BILLBOARDMODE_STRETCHED: number;
  12494. /**
  12495. * This function can be defined to provide custom update for active particles.
  12496. * This function will be called instead of regular update (age, position, color, etc.).
  12497. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12498. */
  12499. updateFunction: (particles: Particle[]) => void;
  12500. private _emitterWorldMatrix;
  12501. /**
  12502. * This function can be defined to specify initial direction for every new particle.
  12503. * It by default use the emitterType defined function
  12504. */
  12505. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12506. /**
  12507. * This function can be defined to specify initial position for every new particle.
  12508. * It by default use the emitterType defined function
  12509. */
  12510. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12511. /**
  12512. * @hidden
  12513. */
  12514. _inheritedVelocityOffset: Vector3;
  12515. /**
  12516. * An event triggered when the system is disposed
  12517. */
  12518. onDisposeObservable: Observable<IParticleSystem>;
  12519. private _onDisposeObserver;
  12520. /**
  12521. * Sets a callback that will be triggered when the system is disposed
  12522. */
  12523. set onDispose(callback: () => void);
  12524. private _particles;
  12525. private _epsilon;
  12526. private _capacity;
  12527. private _stockParticles;
  12528. private _newPartsExcess;
  12529. private _vertexData;
  12530. private _vertexBuffer;
  12531. private _vertexBuffers;
  12532. private _spriteBuffer;
  12533. private _indexBuffer;
  12534. private _effect;
  12535. private _customEffect;
  12536. private _cachedDefines;
  12537. private _scaledColorStep;
  12538. private _colorDiff;
  12539. private _scaledDirection;
  12540. private _scaledGravity;
  12541. private _currentRenderId;
  12542. private _alive;
  12543. private _useInstancing;
  12544. private _started;
  12545. private _stopped;
  12546. private _actualFrame;
  12547. private _scaledUpdateSpeed;
  12548. private _vertexBufferSize;
  12549. /** @hidden */
  12550. _currentEmitRateGradient: Nullable<FactorGradient>;
  12551. /** @hidden */
  12552. _currentEmitRate1: number;
  12553. /** @hidden */
  12554. _currentEmitRate2: number;
  12555. /** @hidden */
  12556. _currentStartSizeGradient: Nullable<FactorGradient>;
  12557. /** @hidden */
  12558. _currentStartSize1: number;
  12559. /** @hidden */
  12560. _currentStartSize2: number;
  12561. private readonly _rawTextureWidth;
  12562. private _rampGradientsTexture;
  12563. private _useRampGradients;
  12564. /** Gets or sets a matrix to use to compute projection */
  12565. defaultProjectionMatrix: Matrix;
  12566. /** Gets or sets a boolean indicating that ramp gradients must be used
  12567. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12568. */
  12569. get useRampGradients(): boolean;
  12570. set useRampGradients(value: boolean);
  12571. /**
  12572. * 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.
  12573. * 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: [])
  12574. */
  12575. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12576. private _subEmitters;
  12577. /**
  12578. * @hidden
  12579. * If the particle systems emitter should be disposed when the particle system is disposed
  12580. */
  12581. _disposeEmitterOnDispose: boolean;
  12582. /**
  12583. * The current active Sub-systems, this property is used by the root particle system only.
  12584. */
  12585. activeSubSystems: Array<ParticleSystem>;
  12586. /**
  12587. * Specifies if the particles are updated in emitter local space or world space
  12588. */
  12589. isLocal: boolean;
  12590. private _rootParticleSystem;
  12591. /**
  12592. * Gets the current list of active particles
  12593. */
  12594. get particles(): Particle[];
  12595. /**
  12596. * Gets the number of particles active at the same time.
  12597. * @returns The number of active particles.
  12598. */
  12599. getActiveCount(): number;
  12600. /**
  12601. * Returns the string "ParticleSystem"
  12602. * @returns a string containing the class name
  12603. */
  12604. getClassName(): string;
  12605. /**
  12606. * Gets a boolean indicating that the system is stopping
  12607. * @returns true if the system is currently stopping
  12608. */
  12609. isStopping(): boolean;
  12610. /**
  12611. * Gets the custom effect used to render the particles
  12612. * @param blendMode Blend mode for which the effect should be retrieved
  12613. * @returns The effect
  12614. */
  12615. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12616. /**
  12617. * Sets the custom effect used to render the particles
  12618. * @param effect The effect to set
  12619. * @param blendMode Blend mode for which the effect should be set
  12620. */
  12621. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12622. /** @hidden */
  12623. private _onBeforeDrawParticlesObservable;
  12624. /**
  12625. * Observable that will be called just before the particles are drawn
  12626. */
  12627. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12628. /**
  12629. * Gets the name of the particle vertex shader
  12630. */
  12631. get vertexShaderName(): string;
  12632. /**
  12633. * Instantiates a particle system.
  12634. * 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.
  12635. * @param name The name of the particle system
  12636. * @param capacity The max number of particles alive at the same time
  12637. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12638. * @param customEffect a custom effect used to change the way particles are rendered by default
  12639. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12640. * @param epsilon Offset used to render the particles
  12641. */
  12642. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12643. private _addFactorGradient;
  12644. private _removeFactorGradient;
  12645. /**
  12646. * Adds a new life time gradient
  12647. * @param gradient defines the gradient to use (between 0 and 1)
  12648. * @param factor defines the life time factor to affect to the specified gradient
  12649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12650. * @returns the current particle system
  12651. */
  12652. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12653. /**
  12654. * Remove a specific life time gradient
  12655. * @param gradient defines the gradient to remove
  12656. * @returns the current particle system
  12657. */
  12658. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12659. /**
  12660. * Adds a new size gradient
  12661. * @param gradient defines the gradient to use (between 0 and 1)
  12662. * @param factor defines the size factor to affect to the specified gradient
  12663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12664. * @returns the current particle system
  12665. */
  12666. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12667. /**
  12668. * Remove a specific size gradient
  12669. * @param gradient defines the gradient to remove
  12670. * @returns the current particle system
  12671. */
  12672. removeSizeGradient(gradient: number): IParticleSystem;
  12673. /**
  12674. * Adds a new color remap gradient
  12675. * @param gradient defines the gradient to use (between 0 and 1)
  12676. * @param min defines the color remap minimal range
  12677. * @param max defines the color remap maximal range
  12678. * @returns the current particle system
  12679. */
  12680. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12681. /**
  12682. * Remove a specific color remap gradient
  12683. * @param gradient defines the gradient to remove
  12684. * @returns the current particle system
  12685. */
  12686. removeColorRemapGradient(gradient: number): IParticleSystem;
  12687. /**
  12688. * Adds a new alpha remap gradient
  12689. * @param gradient defines the gradient to use (between 0 and 1)
  12690. * @param min defines the alpha remap minimal range
  12691. * @param max defines the alpha remap maximal range
  12692. * @returns the current particle system
  12693. */
  12694. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12695. /**
  12696. * Remove a specific alpha remap gradient
  12697. * @param gradient defines the gradient to remove
  12698. * @returns the current particle system
  12699. */
  12700. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12701. /**
  12702. * Adds a new angular speed gradient
  12703. * @param gradient defines the gradient to use (between 0 and 1)
  12704. * @param factor defines the angular speed to affect to the specified gradient
  12705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12706. * @returns the current particle system
  12707. */
  12708. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12709. /**
  12710. * Remove a specific angular speed gradient
  12711. * @param gradient defines the gradient to remove
  12712. * @returns the current particle system
  12713. */
  12714. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12715. /**
  12716. * Adds a new velocity gradient
  12717. * @param gradient defines the gradient to use (between 0 and 1)
  12718. * @param factor defines the velocity to affect to the specified gradient
  12719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12720. * @returns the current particle system
  12721. */
  12722. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12723. /**
  12724. * Remove a specific velocity gradient
  12725. * @param gradient defines the gradient to remove
  12726. * @returns the current particle system
  12727. */
  12728. removeVelocityGradient(gradient: number): IParticleSystem;
  12729. /**
  12730. * Adds a new limit velocity gradient
  12731. * @param gradient defines the gradient to use (between 0 and 1)
  12732. * @param factor defines the limit velocity value to affect to the specified gradient
  12733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12734. * @returns the current particle system
  12735. */
  12736. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12737. /**
  12738. * Remove a specific limit velocity gradient
  12739. * @param gradient defines the gradient to remove
  12740. * @returns the current particle system
  12741. */
  12742. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12743. /**
  12744. * Adds a new drag gradient
  12745. * @param gradient defines the gradient to use (between 0 and 1)
  12746. * @param factor defines the drag value to affect to the specified gradient
  12747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12748. * @returns the current particle system
  12749. */
  12750. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12751. /**
  12752. * Remove a specific drag gradient
  12753. * @param gradient defines the gradient to remove
  12754. * @returns the current particle system
  12755. */
  12756. removeDragGradient(gradient: number): IParticleSystem;
  12757. /**
  12758. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12759. * @param gradient defines the gradient to use (between 0 and 1)
  12760. * @param factor defines the emit rate value to affect to the specified gradient
  12761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12762. * @returns the current particle system
  12763. */
  12764. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12765. /**
  12766. * Remove a specific emit rate gradient
  12767. * @param gradient defines the gradient to remove
  12768. * @returns the current particle system
  12769. */
  12770. removeEmitRateGradient(gradient: number): IParticleSystem;
  12771. /**
  12772. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12773. * @param gradient defines the gradient to use (between 0 and 1)
  12774. * @param factor defines the start size value to affect to the specified gradient
  12775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12776. * @returns the current particle system
  12777. */
  12778. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12779. /**
  12780. * Remove a specific start size gradient
  12781. * @param gradient defines the gradient to remove
  12782. * @returns the current particle system
  12783. */
  12784. removeStartSizeGradient(gradient: number): IParticleSystem;
  12785. private _createRampGradientTexture;
  12786. /**
  12787. * Gets the current list of ramp gradients.
  12788. * You must use addRampGradient and removeRampGradient to udpate this list
  12789. * @returns the list of ramp gradients
  12790. */
  12791. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12792. /** Force the system to rebuild all gradients that need to be resync */
  12793. forceRefreshGradients(): void;
  12794. private _syncRampGradientTexture;
  12795. /**
  12796. * Adds a new ramp gradient used to remap particle colors
  12797. * @param gradient defines the gradient to use (between 0 and 1)
  12798. * @param color defines the color to affect to the specified gradient
  12799. * @returns the current particle system
  12800. */
  12801. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12802. /**
  12803. * Remove a specific ramp gradient
  12804. * @param gradient defines the gradient to remove
  12805. * @returns the current particle system
  12806. */
  12807. removeRampGradient(gradient: number): ParticleSystem;
  12808. /**
  12809. * Adds a new color gradient
  12810. * @param gradient defines the gradient to use (between 0 and 1)
  12811. * @param color1 defines the color to affect to the specified gradient
  12812. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12813. * @returns this particle system
  12814. */
  12815. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12816. /**
  12817. * Remove a specific color gradient
  12818. * @param gradient defines the gradient to remove
  12819. * @returns this particle system
  12820. */
  12821. removeColorGradient(gradient: number): IParticleSystem;
  12822. private _fetchR;
  12823. protected _reset(): void;
  12824. private _resetEffect;
  12825. private _createVertexBuffers;
  12826. private _createIndexBuffer;
  12827. /**
  12828. * Gets the maximum number of particles active at the same time.
  12829. * @returns The max number of active particles.
  12830. */
  12831. getCapacity(): number;
  12832. /**
  12833. * Gets whether there are still active particles in the system.
  12834. * @returns True if it is alive, otherwise false.
  12835. */
  12836. isAlive(): boolean;
  12837. /**
  12838. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12839. * @returns True if it has been started, otherwise false.
  12840. */
  12841. isStarted(): boolean;
  12842. private _prepareSubEmitterInternalArray;
  12843. /**
  12844. * Starts the particle system and begins to emit
  12845. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12846. */
  12847. start(delay?: number): void;
  12848. /**
  12849. * Stops the particle system.
  12850. * @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.
  12851. */
  12852. stop(stopSubEmitters?: boolean): void;
  12853. /**
  12854. * Remove all active particles
  12855. */
  12856. reset(): void;
  12857. /**
  12858. * @hidden (for internal use only)
  12859. */
  12860. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12861. /**
  12862. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12863. * Its lifetime will start back at 0.
  12864. */
  12865. recycleParticle: (particle: Particle) => void;
  12866. private _stopSubEmitters;
  12867. private _createParticle;
  12868. private _removeFromRoot;
  12869. private _emitFromParticle;
  12870. private _update;
  12871. /** @hidden */
  12872. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12873. /** @hidden */
  12874. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12875. /**
  12876. * Fill the defines array according to the current settings of the particle system
  12877. * @param defines Array to be updated
  12878. * @param blendMode blend mode to take into account when updating the array
  12879. */
  12880. fillDefines(defines: Array<string>, blendMode: number): void;
  12881. /**
  12882. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12883. * @param uniforms Uniforms array to fill
  12884. * @param attributes Attributes array to fill
  12885. * @param samplers Samplers array to fill
  12886. */
  12887. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12888. /** @hidden */
  12889. private _getEffect;
  12890. /**
  12891. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12892. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12893. */
  12894. animate(preWarmOnly?: boolean): void;
  12895. private _appendParticleVertices;
  12896. /**
  12897. * Rebuilds the particle system.
  12898. */
  12899. rebuild(): void;
  12900. /**
  12901. * Is this system ready to be used/rendered
  12902. * @return true if the system is ready
  12903. */
  12904. isReady(): boolean;
  12905. private _render;
  12906. /**
  12907. * Renders the particle system in its current state.
  12908. * @returns the current number of particles
  12909. */
  12910. render(): number;
  12911. /**
  12912. * Disposes the particle system and free the associated resources
  12913. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12914. */
  12915. dispose(disposeTexture?: boolean): void;
  12916. /**
  12917. * Clones the particle system.
  12918. * @param name The name of the cloned object
  12919. * @param newEmitter The new emitter to use
  12920. * @returns the cloned particle system
  12921. */
  12922. clone(name: string, newEmitter: any): ParticleSystem;
  12923. /**
  12924. * Serializes the particle system to a JSON object
  12925. * @param serializeTexture defines if the texture must be serialized as well
  12926. * @returns the JSON object
  12927. */
  12928. serialize(serializeTexture?: boolean): any;
  12929. /** @hidden */
  12930. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12931. /** @hidden */
  12932. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  12933. /**
  12934. * Parses a JSON object to create a particle system.
  12935. * @param parsedParticleSystem The JSON object to parse
  12936. * @param sceneOrEngine The scene or the engine to create the particle system in
  12937. * @param rootUrl The root url to use to load external dependencies like texture
  12938. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12939. * @returns the Parsed particle system
  12940. */
  12941. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12942. }
  12943. }
  12944. declare module BABYLON {
  12945. /**
  12946. * A particle represents one of the element emitted by a particle system.
  12947. * This is mainly define by its coordinates, direction, velocity and age.
  12948. */
  12949. export class Particle {
  12950. /**
  12951. * The particle system the particle belongs to.
  12952. */
  12953. particleSystem: ParticleSystem;
  12954. private static _Count;
  12955. /**
  12956. * Unique ID of the particle
  12957. */
  12958. id: number;
  12959. /**
  12960. * The world position of the particle in the scene.
  12961. */
  12962. position: Vector3;
  12963. /**
  12964. * The world direction of the particle in the scene.
  12965. */
  12966. direction: Vector3;
  12967. /**
  12968. * The color of the particle.
  12969. */
  12970. color: Color4;
  12971. /**
  12972. * The color change of the particle per step.
  12973. */
  12974. colorStep: Color4;
  12975. /**
  12976. * Defines how long will the life of the particle be.
  12977. */
  12978. lifeTime: number;
  12979. /**
  12980. * The current age of the particle.
  12981. */
  12982. age: number;
  12983. /**
  12984. * The current size of the particle.
  12985. */
  12986. size: number;
  12987. /**
  12988. * The current scale of the particle.
  12989. */
  12990. scale: Vector2;
  12991. /**
  12992. * The current angle of the particle.
  12993. */
  12994. angle: number;
  12995. /**
  12996. * Defines how fast is the angle changing.
  12997. */
  12998. angularSpeed: number;
  12999. /**
  13000. * Defines the cell index used by the particle to be rendered from a sprite.
  13001. */
  13002. cellIndex: number;
  13003. /**
  13004. * The information required to support color remapping
  13005. */
  13006. remapData: Vector4;
  13007. /** @hidden */
  13008. _randomCellOffset?: number;
  13009. /** @hidden */
  13010. _initialDirection: Nullable<Vector3>;
  13011. /** @hidden */
  13012. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13013. /** @hidden */
  13014. _initialStartSpriteCellID: number;
  13015. /** @hidden */
  13016. _initialEndSpriteCellID: number;
  13017. /** @hidden */
  13018. _currentColorGradient: Nullable<ColorGradient>;
  13019. /** @hidden */
  13020. _currentColor1: Color4;
  13021. /** @hidden */
  13022. _currentColor2: Color4;
  13023. /** @hidden */
  13024. _currentSizeGradient: Nullable<FactorGradient>;
  13025. /** @hidden */
  13026. _currentSize1: number;
  13027. /** @hidden */
  13028. _currentSize2: number;
  13029. /** @hidden */
  13030. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13031. /** @hidden */
  13032. _currentAngularSpeed1: number;
  13033. /** @hidden */
  13034. _currentAngularSpeed2: number;
  13035. /** @hidden */
  13036. _currentVelocityGradient: Nullable<FactorGradient>;
  13037. /** @hidden */
  13038. _currentVelocity1: number;
  13039. /** @hidden */
  13040. _currentVelocity2: number;
  13041. /** @hidden */
  13042. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13043. /** @hidden */
  13044. _currentLimitVelocity1: number;
  13045. /** @hidden */
  13046. _currentLimitVelocity2: number;
  13047. /** @hidden */
  13048. _currentDragGradient: Nullable<FactorGradient>;
  13049. /** @hidden */
  13050. _currentDrag1: number;
  13051. /** @hidden */
  13052. _currentDrag2: number;
  13053. /** @hidden */
  13054. _randomNoiseCoordinates1: Vector3;
  13055. /** @hidden */
  13056. _randomNoiseCoordinates2: Vector3;
  13057. /** @hidden */
  13058. _localPosition?: Vector3;
  13059. /**
  13060. * Creates a new instance Particle
  13061. * @param particleSystem the particle system the particle belongs to
  13062. */
  13063. constructor(
  13064. /**
  13065. * The particle system the particle belongs to.
  13066. */
  13067. particleSystem: ParticleSystem);
  13068. private updateCellInfoFromSystem;
  13069. /**
  13070. * Defines how the sprite cell index is updated for the particle
  13071. */
  13072. updateCellIndex(): void;
  13073. /** @hidden */
  13074. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13075. /** @hidden */
  13076. _inheritParticleInfoToSubEmitters(): void;
  13077. /** @hidden */
  13078. _reset(): void;
  13079. /**
  13080. * Copy the properties of particle to another one.
  13081. * @param other the particle to copy the information to.
  13082. */
  13083. copyTo(other: Particle): void;
  13084. }
  13085. }
  13086. declare module BABYLON {
  13087. /**
  13088. * Particle emitter represents a volume emitting particles.
  13089. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13090. */
  13091. export interface IParticleEmitterType {
  13092. /**
  13093. * Called by the particle System when the direction is computed for the created particle.
  13094. * @param worldMatrix is the world matrix of the particle system
  13095. * @param directionToUpdate is the direction vector to update with the result
  13096. * @param particle is the particle we are computed the direction for
  13097. * @param isLocal defines if the direction should be set in local space
  13098. */
  13099. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13100. /**
  13101. * Called by the particle System when the position is computed for the created particle.
  13102. * @param worldMatrix is the world matrix of the particle system
  13103. * @param positionToUpdate is the position vector to update with the result
  13104. * @param particle is the particle we are computed the position for
  13105. * @param isLocal defines if the position should be set in local space
  13106. */
  13107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13108. /**
  13109. * Clones the current emitter and returns a copy of it
  13110. * @returns the new emitter
  13111. */
  13112. clone(): IParticleEmitterType;
  13113. /**
  13114. * Called by the GPUParticleSystem to setup the update shader
  13115. * @param effect defines the update shader
  13116. */
  13117. applyToShader(effect: Effect): void;
  13118. /**
  13119. * Returns a string to use to update the GPU particles update shader
  13120. * @returns the effect defines string
  13121. */
  13122. getEffectDefines(): string;
  13123. /**
  13124. * Returns a string representing the class name
  13125. * @returns a string containing the class name
  13126. */
  13127. getClassName(): string;
  13128. /**
  13129. * Serializes the particle system to a JSON object.
  13130. * @returns the JSON object
  13131. */
  13132. serialize(): any;
  13133. /**
  13134. * Parse properties from a JSON object
  13135. * @param serializationObject defines the JSON object
  13136. * @param scene defines the hosting scene
  13137. */
  13138. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13139. }
  13140. }
  13141. declare module BABYLON {
  13142. /**
  13143. * Particle emitter emitting particles from the inside of a box.
  13144. * It emits the particles randomly between 2 given directions.
  13145. */
  13146. export class BoxParticleEmitter implements IParticleEmitterType {
  13147. /**
  13148. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13149. */
  13150. direction1: Vector3;
  13151. /**
  13152. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13153. */
  13154. direction2: Vector3;
  13155. /**
  13156. * 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.
  13157. */
  13158. minEmitBox: Vector3;
  13159. /**
  13160. * 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.
  13161. */
  13162. maxEmitBox: Vector3;
  13163. /**
  13164. * Creates a new instance BoxParticleEmitter
  13165. */
  13166. constructor();
  13167. /**
  13168. * Called by the particle System when the direction is computed for the created particle.
  13169. * @param worldMatrix is the world matrix of the particle system
  13170. * @param directionToUpdate is the direction vector to update with the result
  13171. * @param particle is the particle we are computed the direction for
  13172. * @param isLocal defines if the direction should be set in local space
  13173. */
  13174. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13175. /**
  13176. * Called by the particle System when the position is computed for the created particle.
  13177. * @param worldMatrix is the world matrix of the particle system
  13178. * @param positionToUpdate is the position vector to update with the result
  13179. * @param particle is the particle we are computed the position for
  13180. * @param isLocal defines if the position should be set in local space
  13181. */
  13182. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13183. /**
  13184. * Clones the current emitter and returns a copy of it
  13185. * @returns the new emitter
  13186. */
  13187. clone(): BoxParticleEmitter;
  13188. /**
  13189. * Called by the GPUParticleSystem to setup the update shader
  13190. * @param effect defines the update shader
  13191. */
  13192. applyToShader(effect: Effect): void;
  13193. /**
  13194. * Returns a string to use to update the GPU particles update shader
  13195. * @returns a string containng the defines string
  13196. */
  13197. getEffectDefines(): string;
  13198. /**
  13199. * Returns the string "BoxParticleEmitter"
  13200. * @returns a string containing the class name
  13201. */
  13202. getClassName(): string;
  13203. /**
  13204. * Serializes the particle system to a JSON object.
  13205. * @returns the JSON object
  13206. */
  13207. serialize(): any;
  13208. /**
  13209. * Parse properties from a JSON object
  13210. * @param serializationObject defines the JSON object
  13211. */
  13212. parse(serializationObject: any): void;
  13213. }
  13214. }
  13215. declare module BABYLON {
  13216. /**
  13217. * Particle emitter emitting particles from the inside of a cone.
  13218. * It emits the particles alongside the cone volume from the base to the particle.
  13219. * The emission direction might be randomized.
  13220. */
  13221. export class ConeParticleEmitter implements IParticleEmitterType {
  13222. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13223. directionRandomizer: number;
  13224. private _radius;
  13225. private _angle;
  13226. private _height;
  13227. /**
  13228. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13229. */
  13230. radiusRange: number;
  13231. /**
  13232. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13233. */
  13234. heightRange: number;
  13235. /**
  13236. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13237. */
  13238. emitFromSpawnPointOnly: boolean;
  13239. /**
  13240. * Gets or sets the radius of the emission cone
  13241. */
  13242. get radius(): number;
  13243. set radius(value: number);
  13244. /**
  13245. * Gets or sets the angle of the emission cone
  13246. */
  13247. get angle(): number;
  13248. set angle(value: number);
  13249. private _buildHeight;
  13250. /**
  13251. * Creates a new instance ConeParticleEmitter
  13252. * @param radius the radius of the emission cone (1 by default)
  13253. * @param angle the cone base angle (PI by default)
  13254. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13255. */
  13256. constructor(radius?: number, angle?: number,
  13257. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13258. directionRandomizer?: number);
  13259. /**
  13260. * Called by the particle System when the direction is computed for the created particle.
  13261. * @param worldMatrix is the world matrix of the particle system
  13262. * @param directionToUpdate is the direction vector to update with the result
  13263. * @param particle is the particle we are computed the direction for
  13264. * @param isLocal defines if the direction should be set in local space
  13265. */
  13266. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13267. /**
  13268. * Called by the particle System when the position is computed for the created particle.
  13269. * @param worldMatrix is the world matrix of the particle system
  13270. * @param positionToUpdate is the position vector to update with the result
  13271. * @param particle is the particle we are computed the position for
  13272. * @param isLocal defines if the position should be set in local space
  13273. */
  13274. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13275. /**
  13276. * Clones the current emitter and returns a copy of it
  13277. * @returns the new emitter
  13278. */
  13279. clone(): ConeParticleEmitter;
  13280. /**
  13281. * Called by the GPUParticleSystem to setup the update shader
  13282. * @param effect defines the update shader
  13283. */
  13284. applyToShader(effect: Effect): void;
  13285. /**
  13286. * Returns a string to use to update the GPU particles update shader
  13287. * @returns a string containng the defines string
  13288. */
  13289. getEffectDefines(): string;
  13290. /**
  13291. * Returns the string "ConeParticleEmitter"
  13292. * @returns a string containing the class name
  13293. */
  13294. getClassName(): string;
  13295. /**
  13296. * Serializes the particle system to a JSON object.
  13297. * @returns the JSON object
  13298. */
  13299. serialize(): any;
  13300. /**
  13301. * Parse properties from a JSON object
  13302. * @param serializationObject defines the JSON object
  13303. */
  13304. parse(serializationObject: any): void;
  13305. }
  13306. }
  13307. declare module BABYLON {
  13308. /**
  13309. * Particle emitter emitting particles from the inside of a cylinder.
  13310. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13311. */
  13312. export class CylinderParticleEmitter implements IParticleEmitterType {
  13313. /**
  13314. * The radius of the emission cylinder.
  13315. */
  13316. radius: number;
  13317. /**
  13318. * The height of the emission cylinder.
  13319. */
  13320. height: number;
  13321. /**
  13322. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13323. */
  13324. radiusRange: number;
  13325. /**
  13326. * How much to randomize the particle direction [0-1].
  13327. */
  13328. directionRandomizer: number;
  13329. /**
  13330. * Creates a new instance CylinderParticleEmitter
  13331. * @param radius the radius of the emission cylinder (1 by default)
  13332. * @param height the height of the emission cylinder (1 by default)
  13333. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13334. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13335. */
  13336. constructor(
  13337. /**
  13338. * The radius of the emission cylinder.
  13339. */
  13340. radius?: number,
  13341. /**
  13342. * The height of the emission cylinder.
  13343. */
  13344. height?: number,
  13345. /**
  13346. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13347. */
  13348. radiusRange?: number,
  13349. /**
  13350. * How much to randomize the particle direction [0-1].
  13351. */
  13352. directionRandomizer?: number);
  13353. /**
  13354. * Called by the particle System when the direction is computed for the created particle.
  13355. * @param worldMatrix is the world matrix of the particle system
  13356. * @param directionToUpdate is the direction vector to update with the result
  13357. * @param particle is the particle we are computed the direction for
  13358. * @param isLocal defines if the direction should be set in local space
  13359. */
  13360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13361. /**
  13362. * Called by the particle System when the position is computed for the created particle.
  13363. * @param worldMatrix is the world matrix of the particle system
  13364. * @param positionToUpdate is the position vector to update with the result
  13365. * @param particle is the particle we are computed the position for
  13366. * @param isLocal defines if the position should be set in local space
  13367. */
  13368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13369. /**
  13370. * Clones the current emitter and returns a copy of it
  13371. * @returns the new emitter
  13372. */
  13373. clone(): CylinderParticleEmitter;
  13374. /**
  13375. * Called by the GPUParticleSystem to setup the update shader
  13376. * @param effect defines the update shader
  13377. */
  13378. applyToShader(effect: Effect): void;
  13379. /**
  13380. * Returns a string to use to update the GPU particles update shader
  13381. * @returns a string containng the defines string
  13382. */
  13383. getEffectDefines(): string;
  13384. /**
  13385. * Returns the string "CylinderParticleEmitter"
  13386. * @returns a string containing the class name
  13387. */
  13388. getClassName(): string;
  13389. /**
  13390. * Serializes the particle system to a JSON object.
  13391. * @returns the JSON object
  13392. */
  13393. serialize(): any;
  13394. /**
  13395. * Parse properties from a JSON object
  13396. * @param serializationObject defines the JSON object
  13397. */
  13398. parse(serializationObject: any): void;
  13399. }
  13400. /**
  13401. * Particle emitter emitting particles from the inside of a cylinder.
  13402. * It emits the particles randomly between two vectors.
  13403. */
  13404. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13405. /**
  13406. * The min limit of the emission direction.
  13407. */
  13408. direction1: Vector3;
  13409. /**
  13410. * The max limit of the emission direction.
  13411. */
  13412. direction2: Vector3;
  13413. /**
  13414. * Creates a new instance CylinderDirectedParticleEmitter
  13415. * @param radius the radius of the emission cylinder (1 by default)
  13416. * @param height the height of the emission cylinder (1 by default)
  13417. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13418. * @param direction1 the min limit of the emission direction (up vector by default)
  13419. * @param direction2 the max limit of the emission direction (up vector by default)
  13420. */
  13421. constructor(radius?: number, height?: number, radiusRange?: number,
  13422. /**
  13423. * The min limit of the emission direction.
  13424. */
  13425. direction1?: Vector3,
  13426. /**
  13427. * The max limit of the emission direction.
  13428. */
  13429. direction2?: Vector3);
  13430. /**
  13431. * Called by the particle System when the direction is computed for the created particle.
  13432. * @param worldMatrix is the world matrix of the particle system
  13433. * @param directionToUpdate is the direction vector to update with the result
  13434. * @param particle is the particle we are computed the direction for
  13435. */
  13436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13437. /**
  13438. * Clones the current emitter and returns a copy of it
  13439. * @returns the new emitter
  13440. */
  13441. clone(): CylinderDirectedParticleEmitter;
  13442. /**
  13443. * Called by the GPUParticleSystem to setup the update shader
  13444. * @param effect defines the update shader
  13445. */
  13446. applyToShader(effect: Effect): void;
  13447. /**
  13448. * Returns a string to use to update the GPU particles update shader
  13449. * @returns a string containng the defines string
  13450. */
  13451. getEffectDefines(): string;
  13452. /**
  13453. * Returns the string "CylinderDirectedParticleEmitter"
  13454. * @returns a string containing the class name
  13455. */
  13456. getClassName(): string;
  13457. /**
  13458. * Serializes the particle system to a JSON object.
  13459. * @returns the JSON object
  13460. */
  13461. serialize(): any;
  13462. /**
  13463. * Parse properties from a JSON object
  13464. * @param serializationObject defines the JSON object
  13465. */
  13466. parse(serializationObject: any): void;
  13467. }
  13468. }
  13469. declare module BABYLON {
  13470. /**
  13471. * Particle emitter emitting particles from the inside of a hemisphere.
  13472. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13473. */
  13474. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13475. /**
  13476. * The radius of the emission hemisphere.
  13477. */
  13478. radius: number;
  13479. /**
  13480. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13481. */
  13482. radiusRange: number;
  13483. /**
  13484. * How much to randomize the particle direction [0-1].
  13485. */
  13486. directionRandomizer: number;
  13487. /**
  13488. * Creates a new instance HemisphericParticleEmitter
  13489. * @param radius the radius of the emission hemisphere (1 by default)
  13490. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13491. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13492. */
  13493. constructor(
  13494. /**
  13495. * The radius of the emission hemisphere.
  13496. */
  13497. radius?: number,
  13498. /**
  13499. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13500. */
  13501. radiusRange?: number,
  13502. /**
  13503. * How much to randomize the particle direction [0-1].
  13504. */
  13505. directionRandomizer?: number);
  13506. /**
  13507. * Called by the particle System when the direction is computed for the created particle.
  13508. * @param worldMatrix is the world matrix of the particle system
  13509. * @param directionToUpdate is the direction vector to update with the result
  13510. * @param particle is the particle we are computed the direction for
  13511. * @param isLocal defines if the direction should be set in local space
  13512. */
  13513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13514. /**
  13515. * Called by the particle System when the position is computed for the created particle.
  13516. * @param worldMatrix is the world matrix of the particle system
  13517. * @param positionToUpdate is the position vector to update with the result
  13518. * @param particle is the particle we are computed the position for
  13519. * @param isLocal defines if the position should be set in local space
  13520. */
  13521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13522. /**
  13523. * Clones the current emitter and returns a copy of it
  13524. * @returns the new emitter
  13525. */
  13526. clone(): HemisphericParticleEmitter;
  13527. /**
  13528. * Called by the GPUParticleSystem to setup the update shader
  13529. * @param effect defines the update shader
  13530. */
  13531. applyToShader(effect: Effect): void;
  13532. /**
  13533. * Returns a string to use to update the GPU particles update shader
  13534. * @returns a string containng the defines string
  13535. */
  13536. getEffectDefines(): string;
  13537. /**
  13538. * Returns the string "HemisphericParticleEmitter"
  13539. * @returns a string containing the class name
  13540. */
  13541. getClassName(): string;
  13542. /**
  13543. * Serializes the particle system to a JSON object.
  13544. * @returns the JSON object
  13545. */
  13546. serialize(): any;
  13547. /**
  13548. * Parse properties from a JSON object
  13549. * @param serializationObject defines the JSON object
  13550. */
  13551. parse(serializationObject: any): void;
  13552. }
  13553. }
  13554. declare module BABYLON {
  13555. /**
  13556. * Particle emitter emitting particles from a point.
  13557. * It emits the particles randomly between 2 given directions.
  13558. */
  13559. export class PointParticleEmitter implements IParticleEmitterType {
  13560. /**
  13561. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13562. */
  13563. direction1: Vector3;
  13564. /**
  13565. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13566. */
  13567. direction2: Vector3;
  13568. /**
  13569. * Creates a new instance PointParticleEmitter
  13570. */
  13571. constructor();
  13572. /**
  13573. * Called by the particle System when the direction is computed for the created particle.
  13574. * @param worldMatrix is the world matrix of the particle system
  13575. * @param directionToUpdate is the direction vector to update with the result
  13576. * @param particle is the particle we are computed the direction for
  13577. * @param isLocal defines if the direction should be set in local space
  13578. */
  13579. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13580. /**
  13581. * Called by the particle System when the position is computed for the created particle.
  13582. * @param worldMatrix is the world matrix of the particle system
  13583. * @param positionToUpdate is the position vector to update with the result
  13584. * @param particle is the particle we are computed the position for
  13585. * @param isLocal defines if the position should be set in local space
  13586. */
  13587. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13588. /**
  13589. * Clones the current emitter and returns a copy of it
  13590. * @returns the new emitter
  13591. */
  13592. clone(): PointParticleEmitter;
  13593. /**
  13594. * Called by the GPUParticleSystem to setup the update shader
  13595. * @param effect defines the update shader
  13596. */
  13597. applyToShader(effect: Effect): void;
  13598. /**
  13599. * Returns a string to use to update the GPU particles update shader
  13600. * @returns a string containng the defines string
  13601. */
  13602. getEffectDefines(): string;
  13603. /**
  13604. * Returns the string "PointParticleEmitter"
  13605. * @returns a string containing the class name
  13606. */
  13607. getClassName(): string;
  13608. /**
  13609. * Serializes the particle system to a JSON object.
  13610. * @returns the JSON object
  13611. */
  13612. serialize(): any;
  13613. /**
  13614. * Parse properties from a JSON object
  13615. * @param serializationObject defines the JSON object
  13616. */
  13617. parse(serializationObject: any): void;
  13618. }
  13619. }
  13620. declare module BABYLON {
  13621. /**
  13622. * Particle emitter emitting particles from the inside of a sphere.
  13623. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13624. */
  13625. export class SphereParticleEmitter implements IParticleEmitterType {
  13626. /**
  13627. * The radius of the emission sphere.
  13628. */
  13629. radius: number;
  13630. /**
  13631. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13632. */
  13633. radiusRange: number;
  13634. /**
  13635. * How much to randomize the particle direction [0-1].
  13636. */
  13637. directionRandomizer: number;
  13638. /**
  13639. * Creates a new instance SphereParticleEmitter
  13640. * @param radius the radius of the emission sphere (1 by default)
  13641. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13642. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13643. */
  13644. constructor(
  13645. /**
  13646. * The radius of the emission sphere.
  13647. */
  13648. radius?: number,
  13649. /**
  13650. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13651. */
  13652. radiusRange?: number,
  13653. /**
  13654. * How much to randomize the particle direction [0-1].
  13655. */
  13656. directionRandomizer?: number);
  13657. /**
  13658. * Called by the particle System when the direction is computed for the created particle.
  13659. * @param worldMatrix is the world matrix of the particle system
  13660. * @param directionToUpdate is the direction vector to update with the result
  13661. * @param particle is the particle we are computed the direction for
  13662. * @param isLocal defines if the direction should be set in local space
  13663. */
  13664. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13665. /**
  13666. * Called by the particle System when the position is computed for the created particle.
  13667. * @param worldMatrix is the world matrix of the particle system
  13668. * @param positionToUpdate is the position vector to update with the result
  13669. * @param particle is the particle we are computed the position for
  13670. * @param isLocal defines if the position should be set in local space
  13671. */
  13672. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13673. /**
  13674. * Clones the current emitter and returns a copy of it
  13675. * @returns the new emitter
  13676. */
  13677. clone(): SphereParticleEmitter;
  13678. /**
  13679. * Called by the GPUParticleSystem to setup the update shader
  13680. * @param effect defines the update shader
  13681. */
  13682. applyToShader(effect: Effect): void;
  13683. /**
  13684. * Returns a string to use to update the GPU particles update shader
  13685. * @returns a string containng the defines string
  13686. */
  13687. getEffectDefines(): string;
  13688. /**
  13689. * Returns the string "SphereParticleEmitter"
  13690. * @returns a string containing the class name
  13691. */
  13692. getClassName(): string;
  13693. /**
  13694. * Serializes the particle system to a JSON object.
  13695. * @returns the JSON object
  13696. */
  13697. serialize(): any;
  13698. /**
  13699. * Parse properties from a JSON object
  13700. * @param serializationObject defines the JSON object
  13701. */
  13702. parse(serializationObject: any): void;
  13703. }
  13704. /**
  13705. * Particle emitter emitting particles from the inside of a sphere.
  13706. * It emits the particles randomly between two vectors.
  13707. */
  13708. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13709. /**
  13710. * The min limit of the emission direction.
  13711. */
  13712. direction1: Vector3;
  13713. /**
  13714. * The max limit of the emission direction.
  13715. */
  13716. direction2: Vector3;
  13717. /**
  13718. * Creates a new instance SphereDirectedParticleEmitter
  13719. * @param radius the radius of the emission sphere (1 by default)
  13720. * @param direction1 the min limit of the emission direction (up vector by default)
  13721. * @param direction2 the max limit of the emission direction (up vector by default)
  13722. */
  13723. constructor(radius?: number,
  13724. /**
  13725. * The min limit of the emission direction.
  13726. */
  13727. direction1?: Vector3,
  13728. /**
  13729. * The max limit of the emission direction.
  13730. */
  13731. direction2?: Vector3);
  13732. /**
  13733. * Called by the particle System when the direction is computed for the created particle.
  13734. * @param worldMatrix is the world matrix of the particle system
  13735. * @param directionToUpdate is the direction vector to update with the result
  13736. * @param particle is the particle we are computed the direction for
  13737. */
  13738. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13739. /**
  13740. * Clones the current emitter and returns a copy of it
  13741. * @returns the new emitter
  13742. */
  13743. clone(): SphereDirectedParticleEmitter;
  13744. /**
  13745. * Called by the GPUParticleSystem to setup the update shader
  13746. * @param effect defines the update shader
  13747. */
  13748. applyToShader(effect: Effect): void;
  13749. /**
  13750. * Returns a string to use to update the GPU particles update shader
  13751. * @returns a string containng the defines string
  13752. */
  13753. getEffectDefines(): string;
  13754. /**
  13755. * Returns the string "SphereDirectedParticleEmitter"
  13756. * @returns a string containing the class name
  13757. */
  13758. getClassName(): string;
  13759. /**
  13760. * Serializes the particle system to a JSON object.
  13761. * @returns the JSON object
  13762. */
  13763. serialize(): any;
  13764. /**
  13765. * Parse properties from a JSON object
  13766. * @param serializationObject defines the JSON object
  13767. */
  13768. parse(serializationObject: any): void;
  13769. }
  13770. }
  13771. declare module BABYLON {
  13772. /**
  13773. * Particle emitter emitting particles from a custom list of positions.
  13774. */
  13775. export class CustomParticleEmitter implements IParticleEmitterType {
  13776. /**
  13777. * Gets or sets the position generator that will create the inital position of each particle.
  13778. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13779. */
  13780. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13781. /**
  13782. * Gets or sets the destination generator that will create the final destination of each particle.
  13783. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13784. */
  13785. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13786. /**
  13787. * Creates a new instance CustomParticleEmitter
  13788. */
  13789. constructor();
  13790. /**
  13791. * Called by the particle System when the direction is computed for the created particle.
  13792. * @param worldMatrix is the world matrix of the particle system
  13793. * @param directionToUpdate is the direction vector to update with the result
  13794. * @param particle is the particle we are computed the direction for
  13795. * @param isLocal defines if the direction should be set in local space
  13796. */
  13797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13798. /**
  13799. * Called by the particle System when the position is computed for the created particle.
  13800. * @param worldMatrix is the world matrix of the particle system
  13801. * @param positionToUpdate is the position vector to update with the result
  13802. * @param particle is the particle we are computed the position for
  13803. * @param isLocal defines if the position should be set in local space
  13804. */
  13805. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13806. /**
  13807. * Clones the current emitter and returns a copy of it
  13808. * @returns the new emitter
  13809. */
  13810. clone(): CustomParticleEmitter;
  13811. /**
  13812. * Called by the GPUParticleSystem to setup the update shader
  13813. * @param effect defines the update shader
  13814. */
  13815. applyToShader(effect: Effect): void;
  13816. /**
  13817. * Returns a string to use to update the GPU particles update shader
  13818. * @returns a string containng the defines string
  13819. */
  13820. getEffectDefines(): string;
  13821. /**
  13822. * Returns the string "PointParticleEmitter"
  13823. * @returns a string containing the class name
  13824. */
  13825. getClassName(): string;
  13826. /**
  13827. * Serializes the particle system to a JSON object.
  13828. * @returns the JSON object
  13829. */
  13830. serialize(): any;
  13831. /**
  13832. * Parse properties from a JSON object
  13833. * @param serializationObject defines the JSON object
  13834. */
  13835. parse(serializationObject: any): void;
  13836. }
  13837. }
  13838. declare module BABYLON {
  13839. /**
  13840. * Particle emitter emitting particles from the inside of a box.
  13841. * It emits the particles randomly between 2 given directions.
  13842. */
  13843. export class MeshParticleEmitter implements IParticleEmitterType {
  13844. private _indices;
  13845. private _positions;
  13846. private _normals;
  13847. private _storedNormal;
  13848. private _mesh;
  13849. /**
  13850. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13851. */
  13852. direction1: Vector3;
  13853. /**
  13854. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13855. */
  13856. direction2: Vector3;
  13857. /**
  13858. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13859. */
  13860. useMeshNormalsForDirection: boolean;
  13861. /** Defines the mesh to use as source */
  13862. get mesh(): Nullable<AbstractMesh>;
  13863. set mesh(value: Nullable<AbstractMesh>);
  13864. /**
  13865. * Creates a new instance MeshParticleEmitter
  13866. * @param mesh defines the mesh to use as source
  13867. */
  13868. constructor(mesh?: Nullable<AbstractMesh>);
  13869. /**
  13870. * Called by the particle System when the direction is computed for the created particle.
  13871. * @param worldMatrix is the world matrix of the particle system
  13872. * @param directionToUpdate is the direction vector to update with the result
  13873. * @param particle is the particle we are computed the direction for
  13874. * @param isLocal defines if the direction should be set in local space
  13875. */
  13876. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13877. /**
  13878. * Called by the particle System when the position is computed for the created particle.
  13879. * @param worldMatrix is the world matrix of the particle system
  13880. * @param positionToUpdate is the position vector to update with the result
  13881. * @param particle is the particle we are computed the position for
  13882. * @param isLocal defines if the position should be set in local space
  13883. */
  13884. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13885. /**
  13886. * Clones the current emitter and returns a copy of it
  13887. * @returns the new emitter
  13888. */
  13889. clone(): MeshParticleEmitter;
  13890. /**
  13891. * Called by the GPUParticleSystem to setup the update shader
  13892. * @param effect defines the update shader
  13893. */
  13894. applyToShader(effect: Effect): void;
  13895. /**
  13896. * Returns a string to use to update the GPU particles update shader
  13897. * @returns a string containng the defines string
  13898. */
  13899. getEffectDefines(): string;
  13900. /**
  13901. * Returns the string "BoxParticleEmitter"
  13902. * @returns a string containing the class name
  13903. */
  13904. getClassName(): string;
  13905. /**
  13906. * Serializes the particle system to a JSON object.
  13907. * @returns the JSON object
  13908. */
  13909. serialize(): any;
  13910. /**
  13911. * Parse properties from a JSON object
  13912. * @param serializationObject defines the JSON object
  13913. * @param scene defines the hosting scene
  13914. */
  13915. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13916. }
  13917. }
  13918. declare module BABYLON {
  13919. /**
  13920. * Interface representing a particle system in Babylon.js.
  13921. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13922. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13923. */
  13924. export interface IParticleSystem {
  13925. /**
  13926. * List of animations used by the particle system.
  13927. */
  13928. animations: Animation[];
  13929. /**
  13930. * The id of the Particle system.
  13931. */
  13932. id: string;
  13933. /**
  13934. * The name of the Particle system.
  13935. */
  13936. name: string;
  13937. /**
  13938. * The emitter represents the Mesh or position we are attaching the particle system to.
  13939. */
  13940. emitter: Nullable<AbstractMesh | Vector3>;
  13941. /**
  13942. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13943. */
  13944. isBillboardBased: boolean;
  13945. /**
  13946. * The rendering group used by the Particle system to chose when to render.
  13947. */
  13948. renderingGroupId: number;
  13949. /**
  13950. * The layer mask we are rendering the particles through.
  13951. */
  13952. layerMask: number;
  13953. /**
  13954. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13955. */
  13956. updateSpeed: number;
  13957. /**
  13958. * The amount of time the particle system is running (depends of the overall update speed).
  13959. */
  13960. targetStopDuration: number;
  13961. /**
  13962. * The texture used to render each particle. (this can be a spritesheet)
  13963. */
  13964. particleTexture: Nullable<BaseTexture>;
  13965. /**
  13966. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13967. */
  13968. blendMode: number;
  13969. /**
  13970. * Minimum life time of emitting particles.
  13971. */
  13972. minLifeTime: number;
  13973. /**
  13974. * Maximum life time of emitting particles.
  13975. */
  13976. maxLifeTime: number;
  13977. /**
  13978. * Minimum Size of emitting particles.
  13979. */
  13980. minSize: number;
  13981. /**
  13982. * Maximum Size of emitting particles.
  13983. */
  13984. maxSize: number;
  13985. /**
  13986. * Minimum scale of emitting particles on X axis.
  13987. */
  13988. minScaleX: number;
  13989. /**
  13990. * Maximum scale of emitting particles on X axis.
  13991. */
  13992. maxScaleX: number;
  13993. /**
  13994. * Minimum scale of emitting particles on Y axis.
  13995. */
  13996. minScaleY: number;
  13997. /**
  13998. * Maximum scale of emitting particles on Y axis.
  13999. */
  14000. maxScaleY: number;
  14001. /**
  14002. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14003. */
  14004. color1: Color4;
  14005. /**
  14006. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14007. */
  14008. color2: Color4;
  14009. /**
  14010. * Color the particle will have at the end of its lifetime.
  14011. */
  14012. colorDead: Color4;
  14013. /**
  14014. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14015. */
  14016. emitRate: number;
  14017. /**
  14018. * You can use gravity if you want to give an orientation to your particles.
  14019. */
  14020. gravity: Vector3;
  14021. /**
  14022. * Minimum power of emitting particles.
  14023. */
  14024. minEmitPower: number;
  14025. /**
  14026. * Maximum power of emitting particles.
  14027. */
  14028. maxEmitPower: number;
  14029. /**
  14030. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14031. */
  14032. minAngularSpeed: number;
  14033. /**
  14034. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14035. */
  14036. maxAngularSpeed: number;
  14037. /**
  14038. * Gets or sets the minimal initial rotation in radians.
  14039. */
  14040. minInitialRotation: number;
  14041. /**
  14042. * Gets or sets the maximal initial rotation in radians.
  14043. */
  14044. maxInitialRotation: number;
  14045. /**
  14046. * The particle emitter type defines the emitter used by the particle system.
  14047. * It can be for example box, sphere, or cone...
  14048. */
  14049. particleEmitterType: Nullable<IParticleEmitterType>;
  14050. /**
  14051. * Defines the delay in milliseconds before starting the system (0 by default)
  14052. */
  14053. startDelay: number;
  14054. /**
  14055. * 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
  14056. */
  14057. preWarmCycles: number;
  14058. /**
  14059. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14060. */
  14061. preWarmStepOffset: number;
  14062. /**
  14063. * 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)
  14064. */
  14065. spriteCellChangeSpeed: number;
  14066. /**
  14067. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14068. */
  14069. startSpriteCellID: number;
  14070. /**
  14071. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14072. */
  14073. endSpriteCellID: number;
  14074. /**
  14075. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14076. */
  14077. spriteCellWidth: number;
  14078. /**
  14079. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14080. */
  14081. spriteCellHeight: number;
  14082. /**
  14083. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14084. */
  14085. spriteRandomStartCell: boolean;
  14086. /**
  14087. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14088. */
  14089. isAnimationSheetEnabled: boolean;
  14090. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14091. translationPivot: Vector2;
  14092. /**
  14093. * Gets or sets a texture used to add random noise to particle positions
  14094. */
  14095. noiseTexture: Nullable<BaseTexture>;
  14096. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14097. noiseStrength: Vector3;
  14098. /**
  14099. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14100. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14101. */
  14102. billboardMode: number;
  14103. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14104. limitVelocityDamping: number;
  14105. /**
  14106. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14107. */
  14108. beginAnimationOnStart: boolean;
  14109. /**
  14110. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14111. */
  14112. beginAnimationFrom: number;
  14113. /**
  14114. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14115. */
  14116. beginAnimationTo: number;
  14117. /**
  14118. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14119. */
  14120. beginAnimationLoop: boolean;
  14121. /**
  14122. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14123. */
  14124. disposeOnStop: boolean;
  14125. /**
  14126. * Specifies if the particles are updated in emitter local space or world space
  14127. */
  14128. isLocal: boolean;
  14129. /** Snippet ID if the particle system was created from the snippet server */
  14130. snippetId: string;
  14131. /** Gets or sets a matrix to use to compute projection */
  14132. defaultProjectionMatrix: Matrix;
  14133. /**
  14134. * Gets the maximum number of particles active at the same time.
  14135. * @returns The max number of active particles.
  14136. */
  14137. getCapacity(): number;
  14138. /**
  14139. * Gets the number of particles active at the same time.
  14140. * @returns The number of active particles.
  14141. */
  14142. getActiveCount(): number;
  14143. /**
  14144. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14145. * @returns True if it has been started, otherwise false.
  14146. */
  14147. isStarted(): boolean;
  14148. /**
  14149. * Animates the particle system for this frame.
  14150. */
  14151. animate(): void;
  14152. /**
  14153. * Renders the particle system in its current state.
  14154. * @returns the current number of particles
  14155. */
  14156. render(): number;
  14157. /**
  14158. * Dispose the particle system and frees its associated resources.
  14159. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14160. */
  14161. dispose(disposeTexture?: boolean): void;
  14162. /**
  14163. * An event triggered when the system is disposed
  14164. */
  14165. onDisposeObservable: Observable<IParticleSystem>;
  14166. /**
  14167. * Clones the particle system.
  14168. * @param name The name of the cloned object
  14169. * @param newEmitter The new emitter to use
  14170. * @returns the cloned particle system
  14171. */
  14172. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14173. /**
  14174. * Serializes the particle system to a JSON object
  14175. * @param serializeTexture defines if the texture must be serialized as well
  14176. * @returns the JSON object
  14177. */
  14178. serialize(serializeTexture: boolean): any;
  14179. /**
  14180. * Rebuild the particle system
  14181. */
  14182. rebuild(): void;
  14183. /** Force the system to rebuild all gradients that need to be resync */
  14184. forceRefreshGradients(): void;
  14185. /**
  14186. * Starts the particle system and begins to emit
  14187. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14188. */
  14189. start(delay?: number): void;
  14190. /**
  14191. * Stops the particle system.
  14192. */
  14193. stop(): void;
  14194. /**
  14195. * Remove all active particles
  14196. */
  14197. reset(): void;
  14198. /**
  14199. * Gets a boolean indicating that the system is stopping
  14200. * @returns true if the system is currently stopping
  14201. */
  14202. isStopping(): boolean;
  14203. /**
  14204. * Is this system ready to be used/rendered
  14205. * @return true if the system is ready
  14206. */
  14207. isReady(): boolean;
  14208. /**
  14209. * Returns the string "ParticleSystem"
  14210. * @returns a string containing the class name
  14211. */
  14212. getClassName(): string;
  14213. /**
  14214. * Gets the custom effect used to render the particles
  14215. * @param blendMode Blend mode for which the effect should be retrieved
  14216. * @returns The effect
  14217. */
  14218. getCustomEffect(blendMode: number): Nullable<Effect>;
  14219. /**
  14220. * Sets the custom effect used to render the particles
  14221. * @param effect The effect to set
  14222. * @param blendMode Blend mode for which the effect should be set
  14223. */
  14224. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14225. /**
  14226. * Fill the defines array according to the current settings of the particle system
  14227. * @param defines Array to be updated
  14228. * @param blendMode blend mode to take into account when updating the array
  14229. */
  14230. fillDefines(defines: Array<string>, blendMode: number): void;
  14231. /**
  14232. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14233. * @param uniforms Uniforms array to fill
  14234. * @param attributes Attributes array to fill
  14235. * @param samplers Samplers array to fill
  14236. */
  14237. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14238. /**
  14239. * Observable that will be called just before the particles are drawn
  14240. */
  14241. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14242. /**
  14243. * Gets the name of the particle vertex shader
  14244. */
  14245. vertexShaderName: string;
  14246. /**
  14247. * Adds a new color gradient
  14248. * @param gradient defines the gradient to use (between 0 and 1)
  14249. * @param color1 defines the color to affect to the specified gradient
  14250. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14251. * @returns the current particle system
  14252. */
  14253. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14254. /**
  14255. * Remove a specific color gradient
  14256. * @param gradient defines the gradient to remove
  14257. * @returns the current particle system
  14258. */
  14259. removeColorGradient(gradient: number): IParticleSystem;
  14260. /**
  14261. * Adds a new size gradient
  14262. * @param gradient defines the gradient to use (between 0 and 1)
  14263. * @param factor defines the size factor to affect to the specified gradient
  14264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14265. * @returns the current particle system
  14266. */
  14267. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14268. /**
  14269. * Remove a specific size gradient
  14270. * @param gradient defines the gradient to remove
  14271. * @returns the current particle system
  14272. */
  14273. removeSizeGradient(gradient: number): IParticleSystem;
  14274. /**
  14275. * Gets the current list of color gradients.
  14276. * You must use addColorGradient and removeColorGradient to udpate this list
  14277. * @returns the list of color gradients
  14278. */
  14279. getColorGradients(): Nullable<Array<ColorGradient>>;
  14280. /**
  14281. * Gets the current list of size gradients.
  14282. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14283. * @returns the list of size gradients
  14284. */
  14285. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14286. /**
  14287. * Gets the current list of angular speed gradients.
  14288. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14289. * @returns the list of angular speed gradients
  14290. */
  14291. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14292. /**
  14293. * Adds a new angular speed gradient
  14294. * @param gradient defines the gradient to use (between 0 and 1)
  14295. * @param factor defines the angular speed to affect to the specified gradient
  14296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14297. * @returns the current particle system
  14298. */
  14299. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14300. /**
  14301. * Remove a specific angular speed gradient
  14302. * @param gradient defines the gradient to remove
  14303. * @returns the current particle system
  14304. */
  14305. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14306. /**
  14307. * Gets the current list of velocity gradients.
  14308. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14309. * @returns the list of velocity gradients
  14310. */
  14311. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14312. /**
  14313. * Adds a new velocity gradient
  14314. * @param gradient defines the gradient to use (between 0 and 1)
  14315. * @param factor defines the velocity to affect to the specified gradient
  14316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14317. * @returns the current particle system
  14318. */
  14319. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14320. /**
  14321. * Remove a specific velocity gradient
  14322. * @param gradient defines the gradient to remove
  14323. * @returns the current particle system
  14324. */
  14325. removeVelocityGradient(gradient: number): IParticleSystem;
  14326. /**
  14327. * Gets the current list of limit velocity gradients.
  14328. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14329. * @returns the list of limit velocity gradients
  14330. */
  14331. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14332. /**
  14333. * Adds a new limit velocity gradient
  14334. * @param gradient defines the gradient to use (between 0 and 1)
  14335. * @param factor defines the limit velocity to affect to the specified gradient
  14336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14337. * @returns the current particle system
  14338. */
  14339. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14340. /**
  14341. * Remove a specific limit velocity gradient
  14342. * @param gradient defines the gradient to remove
  14343. * @returns the current particle system
  14344. */
  14345. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14346. /**
  14347. * Adds a new drag gradient
  14348. * @param gradient defines the gradient to use (between 0 and 1)
  14349. * @param factor defines the drag to affect to the specified gradient
  14350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14351. * @returns the current particle system
  14352. */
  14353. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14354. /**
  14355. * Remove a specific drag gradient
  14356. * @param gradient defines the gradient to remove
  14357. * @returns the current particle system
  14358. */
  14359. removeDragGradient(gradient: number): IParticleSystem;
  14360. /**
  14361. * Gets the current list of drag gradients.
  14362. * You must use addDragGradient and removeDragGradient to udpate this list
  14363. * @returns the list of drag gradients
  14364. */
  14365. getDragGradients(): Nullable<Array<FactorGradient>>;
  14366. /**
  14367. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14368. * @param gradient defines the gradient to use (between 0 and 1)
  14369. * @param factor defines the emit rate to affect to the specified gradient
  14370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14371. * @returns the current particle system
  14372. */
  14373. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14374. /**
  14375. * Remove a specific emit rate gradient
  14376. * @param gradient defines the gradient to remove
  14377. * @returns the current particle system
  14378. */
  14379. removeEmitRateGradient(gradient: number): IParticleSystem;
  14380. /**
  14381. * Gets the current list of emit rate gradients.
  14382. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14383. * @returns the list of emit rate gradients
  14384. */
  14385. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14386. /**
  14387. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14388. * @param gradient defines the gradient to use (between 0 and 1)
  14389. * @param factor defines the start size to affect to the specified gradient
  14390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14391. * @returns the current particle system
  14392. */
  14393. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14394. /**
  14395. * Remove a specific start size gradient
  14396. * @param gradient defines the gradient to remove
  14397. * @returns the current particle system
  14398. */
  14399. removeStartSizeGradient(gradient: number): IParticleSystem;
  14400. /**
  14401. * Gets the current list of start size gradients.
  14402. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14403. * @returns the list of start size gradients
  14404. */
  14405. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14406. /**
  14407. * Adds a new life time gradient
  14408. * @param gradient defines the gradient to use (between 0 and 1)
  14409. * @param factor defines the life time factor to affect to the specified gradient
  14410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14411. * @returns the current particle system
  14412. */
  14413. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14414. /**
  14415. * Remove a specific life time gradient
  14416. * @param gradient defines the gradient to remove
  14417. * @returns the current particle system
  14418. */
  14419. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14420. /**
  14421. * Gets the current list of life time gradients.
  14422. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14423. * @returns the list of life time gradients
  14424. */
  14425. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14426. /**
  14427. * Gets the current list of color gradients.
  14428. * You must use addColorGradient and removeColorGradient to udpate this list
  14429. * @returns the list of color gradients
  14430. */
  14431. getColorGradients(): Nullable<Array<ColorGradient>>;
  14432. /**
  14433. * Adds a new ramp gradient used to remap particle colors
  14434. * @param gradient defines the gradient to use (between 0 and 1)
  14435. * @param color defines the color to affect to the specified gradient
  14436. * @returns the current particle system
  14437. */
  14438. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14439. /**
  14440. * Gets the current list of ramp gradients.
  14441. * You must use addRampGradient and removeRampGradient to udpate this list
  14442. * @returns the list of ramp gradients
  14443. */
  14444. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14445. /** Gets or sets a boolean indicating that ramp gradients must be used
  14446. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14447. */
  14448. useRampGradients: boolean;
  14449. /**
  14450. * Adds a new color remap gradient
  14451. * @param gradient defines the gradient to use (between 0 and 1)
  14452. * @param min defines the color remap minimal range
  14453. * @param max defines the color remap maximal range
  14454. * @returns the current particle system
  14455. */
  14456. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14457. /**
  14458. * Gets the current list of color remap gradients.
  14459. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14460. * @returns the list of color remap gradients
  14461. */
  14462. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14463. /**
  14464. * Adds a new alpha remap gradient
  14465. * @param gradient defines the gradient to use (between 0 and 1)
  14466. * @param min defines the alpha remap minimal range
  14467. * @param max defines the alpha remap maximal range
  14468. * @returns the current particle system
  14469. */
  14470. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14471. /**
  14472. * Gets the current list of alpha remap gradients.
  14473. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14474. * @returns the list of alpha remap gradients
  14475. */
  14476. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14477. /**
  14478. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14481. * @returns the emitter
  14482. */
  14483. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14484. /**
  14485. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14486. * @param radius The radius of the hemisphere to emit from
  14487. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14488. * @returns the emitter
  14489. */
  14490. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14491. /**
  14492. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14493. * @param radius The radius of the sphere to emit from
  14494. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14495. * @returns the emitter
  14496. */
  14497. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14498. /**
  14499. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14500. * @param radius The radius of the sphere to emit from
  14501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14503. * @returns the emitter
  14504. */
  14505. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14506. /**
  14507. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14508. * @param radius The radius of the emission cylinder
  14509. * @param height The height of the emission cylinder
  14510. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14511. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14512. * @returns the emitter
  14513. */
  14514. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14515. /**
  14516. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14517. * @param radius The radius of the cylinder to emit from
  14518. * @param height The height of the emission cylinder
  14519. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14522. * @returns the emitter
  14523. */
  14524. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14525. /**
  14526. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14527. * @param radius The radius of the cone to emit from
  14528. * @param angle The base angle of the cone
  14529. * @returns the emitter
  14530. */
  14531. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14532. /**
  14533. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14536. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14537. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14538. * @returns the emitter
  14539. */
  14540. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14541. /**
  14542. * Get hosting scene
  14543. * @returns the scene
  14544. */
  14545. getScene(): Nullable<Scene>;
  14546. }
  14547. }
  14548. declare module BABYLON {
  14549. /**
  14550. * 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.
  14551. * @see https://doc.babylonjs.com/how_to/transformnode
  14552. */
  14553. export class TransformNode extends Node {
  14554. /**
  14555. * Object will not rotate to face the camera
  14556. */
  14557. static BILLBOARDMODE_NONE: number;
  14558. /**
  14559. * Object will rotate to face the camera but only on the x axis
  14560. */
  14561. static BILLBOARDMODE_X: number;
  14562. /**
  14563. * Object will rotate to face the camera but only on the y axis
  14564. */
  14565. static BILLBOARDMODE_Y: number;
  14566. /**
  14567. * Object will rotate to face the camera but only on the z axis
  14568. */
  14569. static BILLBOARDMODE_Z: number;
  14570. /**
  14571. * Object will rotate to face the camera
  14572. */
  14573. static BILLBOARDMODE_ALL: number;
  14574. /**
  14575. * Object will rotate to face the camera's position instead of orientation
  14576. */
  14577. static BILLBOARDMODE_USE_POSITION: number;
  14578. private static _TmpRotation;
  14579. private static _TmpScaling;
  14580. private static _TmpTranslation;
  14581. private _forward;
  14582. private _forwardInverted;
  14583. private _up;
  14584. private _right;
  14585. private _rightInverted;
  14586. private _position;
  14587. private _rotation;
  14588. private _rotationQuaternion;
  14589. protected _scaling: Vector3;
  14590. protected _isDirty: boolean;
  14591. private _transformToBoneReferal;
  14592. private _isAbsoluteSynced;
  14593. private _billboardMode;
  14594. /**
  14595. * Gets or sets the billboard mode. Default is 0.
  14596. *
  14597. * | Value | Type | Description |
  14598. * | --- | --- | --- |
  14599. * | 0 | BILLBOARDMODE_NONE | |
  14600. * | 1 | BILLBOARDMODE_X | |
  14601. * | 2 | BILLBOARDMODE_Y | |
  14602. * | 4 | BILLBOARDMODE_Z | |
  14603. * | 7 | BILLBOARDMODE_ALL | |
  14604. *
  14605. */
  14606. get billboardMode(): number;
  14607. set billboardMode(value: number);
  14608. private _preserveParentRotationForBillboard;
  14609. /**
  14610. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14611. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14612. */
  14613. get preserveParentRotationForBillboard(): boolean;
  14614. set preserveParentRotationForBillboard(value: boolean);
  14615. /**
  14616. * 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
  14617. */
  14618. scalingDeterminant: number;
  14619. private _infiniteDistance;
  14620. /**
  14621. * Gets or sets the distance of the object to max, often used by skybox
  14622. */
  14623. get infiniteDistance(): boolean;
  14624. set infiniteDistance(value: boolean);
  14625. /**
  14626. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14627. * By default the system will update normals to compensate
  14628. */
  14629. ignoreNonUniformScaling: boolean;
  14630. /**
  14631. * 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
  14632. */
  14633. reIntegrateRotationIntoRotationQuaternion: boolean;
  14634. /** @hidden */
  14635. _poseMatrix: Nullable<Matrix>;
  14636. /** @hidden */
  14637. _localMatrix: Matrix;
  14638. private _usePivotMatrix;
  14639. private _absolutePosition;
  14640. private _absoluteScaling;
  14641. private _absoluteRotationQuaternion;
  14642. private _pivotMatrix;
  14643. private _pivotMatrixInverse;
  14644. protected _postMultiplyPivotMatrix: boolean;
  14645. protected _isWorldMatrixFrozen: boolean;
  14646. /** @hidden */
  14647. _indexInSceneTransformNodesArray: number;
  14648. /**
  14649. * An event triggered after the world matrix is updated
  14650. */
  14651. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14652. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14653. /**
  14654. * Gets a string identifying the name of the class
  14655. * @returns "TransformNode" string
  14656. */
  14657. getClassName(): string;
  14658. /**
  14659. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14660. */
  14661. get position(): Vector3;
  14662. set position(newPosition: Vector3);
  14663. /**
  14664. * 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)).
  14665. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14666. */
  14667. get rotation(): Vector3;
  14668. set rotation(newRotation: Vector3);
  14669. /**
  14670. * 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)).
  14671. */
  14672. get scaling(): Vector3;
  14673. set scaling(newScaling: Vector3);
  14674. /**
  14675. * 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).
  14676. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14677. */
  14678. get rotationQuaternion(): Nullable<Quaternion>;
  14679. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14680. /**
  14681. * The forward direction of that transform in world space.
  14682. */
  14683. get forward(): Vector3;
  14684. /**
  14685. * The up direction of that transform in world space.
  14686. */
  14687. get up(): Vector3;
  14688. /**
  14689. * The right direction of that transform in world space.
  14690. */
  14691. get right(): Vector3;
  14692. /**
  14693. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14694. * @param matrix the matrix to copy the pose from
  14695. * @returns this TransformNode.
  14696. */
  14697. updatePoseMatrix(matrix: Matrix): TransformNode;
  14698. /**
  14699. * Returns the mesh Pose matrix.
  14700. * @returns the pose matrix
  14701. */
  14702. getPoseMatrix(): Matrix;
  14703. /** @hidden */
  14704. _isSynchronized(): boolean;
  14705. /** @hidden */
  14706. _initCache(): void;
  14707. /**
  14708. * Flag the transform node as dirty (Forcing it to update everything)
  14709. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14710. * @returns this transform node
  14711. */
  14712. markAsDirty(property: string): TransformNode;
  14713. /**
  14714. * Returns the current mesh absolute position.
  14715. * Returns a Vector3.
  14716. */
  14717. get absolutePosition(): Vector3;
  14718. /**
  14719. * Returns the current mesh absolute scaling.
  14720. * Returns a Vector3.
  14721. */
  14722. get absoluteScaling(): Vector3;
  14723. /**
  14724. * Returns the current mesh absolute rotation.
  14725. * Returns a Quaternion.
  14726. */
  14727. get absoluteRotationQuaternion(): Quaternion;
  14728. /**
  14729. * Sets a new matrix to apply before all other transformation
  14730. * @param matrix defines the transform matrix
  14731. * @returns the current TransformNode
  14732. */
  14733. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14734. /**
  14735. * Sets a new pivot matrix to the current node
  14736. * @param matrix defines the new pivot matrix to use
  14737. * @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
  14738. * @returns the current TransformNode
  14739. */
  14740. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14741. /**
  14742. * Returns the mesh pivot matrix.
  14743. * Default : Identity.
  14744. * @returns the matrix
  14745. */
  14746. getPivotMatrix(): Matrix;
  14747. /**
  14748. * Instantiate (when possible) or clone that node with its hierarchy
  14749. * @param newParent defines the new parent to use for the instance (or clone)
  14750. * @param options defines options to configure how copy is done
  14751. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14752. * @returns an instance (or a clone) of the current node with its hiearchy
  14753. */
  14754. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14755. doNotInstantiate: boolean;
  14756. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14757. /**
  14758. * Prevents the World matrix to be computed any longer
  14759. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14760. * @returns the TransformNode.
  14761. */
  14762. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14763. /**
  14764. * Allows back the World matrix computation.
  14765. * @returns the TransformNode.
  14766. */
  14767. unfreezeWorldMatrix(): this;
  14768. /**
  14769. * True if the World matrix has been frozen.
  14770. */
  14771. get isWorldMatrixFrozen(): boolean;
  14772. /**
  14773. * Retuns the mesh absolute position in the World.
  14774. * @returns a Vector3.
  14775. */
  14776. getAbsolutePosition(): Vector3;
  14777. /**
  14778. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14779. * @param absolutePosition the absolute position to set
  14780. * @returns the TransformNode.
  14781. */
  14782. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14783. /**
  14784. * Sets the mesh position in its local space.
  14785. * @param vector3 the position to set in localspace
  14786. * @returns the TransformNode.
  14787. */
  14788. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14789. /**
  14790. * Returns the mesh position in the local space from the current World matrix values.
  14791. * @returns a new Vector3.
  14792. */
  14793. getPositionExpressedInLocalSpace(): Vector3;
  14794. /**
  14795. * Translates the mesh along the passed Vector3 in its local space.
  14796. * @param vector3 the distance to translate in localspace
  14797. * @returns the TransformNode.
  14798. */
  14799. locallyTranslate(vector3: Vector3): TransformNode;
  14800. private static _lookAtVectorCache;
  14801. /**
  14802. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14803. * @param targetPoint the position (must be in same space as current mesh) to look at
  14804. * @param yawCor optional yaw (y-axis) correction in radians
  14805. * @param pitchCor optional pitch (x-axis) correction in radians
  14806. * @param rollCor optional roll (z-axis) correction in radians
  14807. * @param space the choosen space of the target
  14808. * @returns the TransformNode.
  14809. */
  14810. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14811. /**
  14812. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14813. * This Vector3 is expressed in the World space.
  14814. * @param localAxis axis to rotate
  14815. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14816. */
  14817. getDirection(localAxis: Vector3): Vector3;
  14818. /**
  14819. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14820. * localAxis is expressed in the mesh local space.
  14821. * result is computed in the Wordl space from the mesh World matrix.
  14822. * @param localAxis axis to rotate
  14823. * @param result the resulting transformnode
  14824. * @returns this TransformNode.
  14825. */
  14826. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14827. /**
  14828. * Sets this transform node rotation to the given local axis.
  14829. * @param localAxis the axis in local space
  14830. * @param yawCor optional yaw (y-axis) correction in radians
  14831. * @param pitchCor optional pitch (x-axis) correction in radians
  14832. * @param rollCor optional roll (z-axis) correction in radians
  14833. * @returns this TransformNode
  14834. */
  14835. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14836. /**
  14837. * Sets a new pivot point to the current node
  14838. * @param point defines the new pivot point to use
  14839. * @param space defines if the point is in world or local space (local by default)
  14840. * @returns the current TransformNode
  14841. */
  14842. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14843. /**
  14844. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14845. * @returns the pivot point
  14846. */
  14847. getPivotPoint(): Vector3;
  14848. /**
  14849. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14850. * @param result the vector3 to store the result
  14851. * @returns this TransformNode.
  14852. */
  14853. getPivotPointToRef(result: Vector3): TransformNode;
  14854. /**
  14855. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14856. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14857. */
  14858. getAbsolutePivotPoint(): Vector3;
  14859. /**
  14860. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14861. * @param result vector3 to store the result
  14862. * @returns this TransformNode.
  14863. */
  14864. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14865. /**
  14866. * Defines the passed node as the parent of the current node.
  14867. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14868. * @see https://doc.babylonjs.com/how_to/parenting
  14869. * @param node the node ot set as the parent
  14870. * @returns this TransformNode.
  14871. */
  14872. setParent(node: Nullable<Node>): TransformNode;
  14873. private _nonUniformScaling;
  14874. /**
  14875. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14876. */
  14877. get nonUniformScaling(): boolean;
  14878. /** @hidden */
  14879. _updateNonUniformScalingState(value: boolean): boolean;
  14880. /**
  14881. * Attach the current TransformNode to another TransformNode associated with a bone
  14882. * @param bone Bone affecting the TransformNode
  14883. * @param affectedTransformNode TransformNode associated with the bone
  14884. * @returns this object
  14885. */
  14886. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14887. /**
  14888. * Detach the transform node if its associated with a bone
  14889. * @returns this object
  14890. */
  14891. detachFromBone(): TransformNode;
  14892. private static _rotationAxisCache;
  14893. /**
  14894. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14895. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14896. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14897. * The passed axis is also normalized.
  14898. * @param axis the axis to rotate around
  14899. * @param amount the amount to rotate in radians
  14900. * @param space Space to rotate in (Default: local)
  14901. * @returns the TransformNode.
  14902. */
  14903. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14904. /**
  14905. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14906. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14907. * The passed axis is also normalized. .
  14908. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14909. * @param point the point to rotate around
  14910. * @param axis the axis to rotate around
  14911. * @param amount the amount to rotate in radians
  14912. * @returns the TransformNode
  14913. */
  14914. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14915. /**
  14916. * Translates the mesh along the axis vector for the passed distance in the given space.
  14917. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14918. * @param axis the axis to translate in
  14919. * @param distance the distance to translate
  14920. * @param space Space to rotate in (Default: local)
  14921. * @returns the TransformNode.
  14922. */
  14923. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14924. /**
  14925. * Adds a rotation step to the mesh current rotation.
  14926. * x, y, z are Euler angles expressed in radians.
  14927. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14928. * This means this rotation is made in the mesh local space only.
  14929. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14930. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14931. * ```javascript
  14932. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14933. * ```
  14934. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14935. * 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.
  14936. * @param x Rotation to add
  14937. * @param y Rotation to add
  14938. * @param z Rotation to add
  14939. * @returns the TransformNode.
  14940. */
  14941. addRotation(x: number, y: number, z: number): TransformNode;
  14942. /**
  14943. * @hidden
  14944. */
  14945. protected _getEffectiveParent(): Nullable<Node>;
  14946. /**
  14947. * Computes the world matrix of the node
  14948. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14949. * @returns the world matrix
  14950. */
  14951. computeWorldMatrix(force?: boolean): Matrix;
  14952. /**
  14953. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14954. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14955. */
  14956. resetLocalMatrix(independentOfChildren?: boolean): void;
  14957. protected _afterComputeWorldMatrix(): void;
  14958. /**
  14959. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14960. * @param func callback function to add
  14961. *
  14962. * @returns the TransformNode.
  14963. */
  14964. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14965. /**
  14966. * Removes a registered callback function.
  14967. * @param func callback function to remove
  14968. * @returns the TransformNode.
  14969. */
  14970. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14971. /**
  14972. * Gets the position of the current mesh in camera space
  14973. * @param camera defines the camera to use
  14974. * @returns a position
  14975. */
  14976. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14977. /**
  14978. * Returns the distance from the mesh to the active camera
  14979. * @param camera defines the camera to use
  14980. * @returns the distance
  14981. */
  14982. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14983. /**
  14984. * Clone the current transform node
  14985. * @param name Name of the new clone
  14986. * @param newParent New parent for the clone
  14987. * @param doNotCloneChildren Do not clone children hierarchy
  14988. * @returns the new transform node
  14989. */
  14990. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14991. /**
  14992. * Serializes the objects information.
  14993. * @param currentSerializationObject defines the object to serialize in
  14994. * @returns the serialized object
  14995. */
  14996. serialize(currentSerializationObject?: any): any;
  14997. /**
  14998. * Returns a new TransformNode object parsed from the source provided.
  14999. * @param parsedTransformNode is the source.
  15000. * @param scene the scne the object belongs to
  15001. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15002. * @returns a new TransformNode object parsed from the source provided.
  15003. */
  15004. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15005. /**
  15006. * Get all child-transformNodes of this node
  15007. * @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
  15008. * @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
  15009. * @returns an array of TransformNode
  15010. */
  15011. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15012. /**
  15013. * Releases resources associated with this transform node.
  15014. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15015. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15016. */
  15017. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15018. /**
  15019. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15020. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15021. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15022. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15023. * @returns the current mesh
  15024. */
  15025. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15026. private _syncAbsoluteScalingAndRotation;
  15027. }
  15028. }
  15029. declare module BABYLON {
  15030. /**
  15031. * Class used to override all child animations of a given target
  15032. */
  15033. export class AnimationPropertiesOverride {
  15034. /**
  15035. * Gets or sets a value indicating if animation blending must be used
  15036. */
  15037. enableBlending: boolean;
  15038. /**
  15039. * Gets or sets the blending speed to use when enableBlending is true
  15040. */
  15041. blendingSpeed: number;
  15042. /**
  15043. * Gets or sets the default loop mode to use
  15044. */
  15045. loopMode: number;
  15046. }
  15047. }
  15048. declare module BABYLON {
  15049. /**
  15050. * Class used to store bone information
  15051. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15052. */
  15053. export class Bone extends Node {
  15054. /**
  15055. * defines the bone name
  15056. */
  15057. name: string;
  15058. private static _tmpVecs;
  15059. private static _tmpQuat;
  15060. private static _tmpMats;
  15061. /**
  15062. * Gets the list of child bones
  15063. */
  15064. children: Bone[];
  15065. /** Gets the animations associated with this bone */
  15066. animations: Animation[];
  15067. /**
  15068. * Gets or sets bone length
  15069. */
  15070. length: number;
  15071. /**
  15072. * @hidden Internal only
  15073. * Set this value to map this bone to a different index in the transform matrices
  15074. * Set this value to -1 to exclude the bone from the transform matrices
  15075. */
  15076. _index: Nullable<number>;
  15077. private _skeleton;
  15078. private _localMatrix;
  15079. private _restPose;
  15080. private _bindPose;
  15081. private _baseMatrix;
  15082. private _absoluteTransform;
  15083. private _invertedAbsoluteTransform;
  15084. private _parent;
  15085. private _scalingDeterminant;
  15086. private _worldTransform;
  15087. private _localScaling;
  15088. private _localRotation;
  15089. private _localPosition;
  15090. private _needToDecompose;
  15091. private _needToCompose;
  15092. /** @hidden */
  15093. _linkedTransformNode: Nullable<TransformNode>;
  15094. /** @hidden */
  15095. _waitingTransformNodeId: Nullable<string>;
  15096. /** @hidden */
  15097. get _matrix(): Matrix;
  15098. /** @hidden */
  15099. set _matrix(value: Matrix);
  15100. /**
  15101. * Create a new bone
  15102. * @param name defines the bone name
  15103. * @param skeleton defines the parent skeleton
  15104. * @param parentBone defines the parent (can be null if the bone is the root)
  15105. * @param localMatrix defines the local matrix
  15106. * @param restPose defines the rest pose matrix
  15107. * @param baseMatrix defines the base matrix
  15108. * @param index defines index of the bone in the hiearchy
  15109. */
  15110. constructor(
  15111. /**
  15112. * defines the bone name
  15113. */
  15114. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15115. /**
  15116. * Gets the current object class name.
  15117. * @return the class name
  15118. */
  15119. getClassName(): string;
  15120. /**
  15121. * Gets the parent skeleton
  15122. * @returns a skeleton
  15123. */
  15124. getSkeleton(): Skeleton;
  15125. /**
  15126. * Gets parent bone
  15127. * @returns a bone or null if the bone is the root of the bone hierarchy
  15128. */
  15129. getParent(): Nullable<Bone>;
  15130. /**
  15131. * Returns an array containing the root bones
  15132. * @returns an array containing the root bones
  15133. */
  15134. getChildren(): Array<Bone>;
  15135. /**
  15136. * Gets the node index in matrix array generated for rendering
  15137. * @returns the node index
  15138. */
  15139. getIndex(): number;
  15140. /**
  15141. * Sets the parent bone
  15142. * @param parent defines the parent (can be null if the bone is the root)
  15143. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15144. */
  15145. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15146. /**
  15147. * Gets the local matrix
  15148. * @returns a matrix
  15149. */
  15150. getLocalMatrix(): Matrix;
  15151. /**
  15152. * Gets the base matrix (initial matrix which remains unchanged)
  15153. * @returns a matrix
  15154. */
  15155. getBaseMatrix(): Matrix;
  15156. /**
  15157. * Gets the rest pose matrix
  15158. * @returns a matrix
  15159. */
  15160. getRestPose(): Matrix;
  15161. /**
  15162. * Sets the rest pose matrix
  15163. * @param matrix the local-space rest pose to set for this bone
  15164. */
  15165. setRestPose(matrix: Matrix): void;
  15166. /**
  15167. * Gets the bind pose matrix
  15168. * @returns the bind pose matrix
  15169. */
  15170. getBindPose(): Matrix;
  15171. /**
  15172. * Sets the bind pose matrix
  15173. * @param matrix the local-space bind pose to set for this bone
  15174. */
  15175. setBindPose(matrix: Matrix): void;
  15176. /**
  15177. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15178. */
  15179. getWorldMatrix(): Matrix;
  15180. /**
  15181. * Sets the local matrix to rest pose matrix
  15182. */
  15183. returnToRest(): void;
  15184. /**
  15185. * Gets the inverse of the absolute transform matrix.
  15186. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15187. * @returns a matrix
  15188. */
  15189. getInvertedAbsoluteTransform(): Matrix;
  15190. /**
  15191. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15192. * @returns a matrix
  15193. */
  15194. getAbsoluteTransform(): Matrix;
  15195. /**
  15196. * Links with the given transform node.
  15197. * The local matrix of this bone is copied from the transform node every frame.
  15198. * @param transformNode defines the transform node to link to
  15199. */
  15200. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15201. /**
  15202. * Gets the node used to drive the bone's transformation
  15203. * @returns a transform node or null
  15204. */
  15205. getTransformNode(): Nullable<TransformNode>;
  15206. /** Gets or sets current position (in local space) */
  15207. get position(): Vector3;
  15208. set position(newPosition: Vector3);
  15209. /** Gets or sets current rotation (in local space) */
  15210. get rotation(): Vector3;
  15211. set rotation(newRotation: Vector3);
  15212. /** Gets or sets current rotation quaternion (in local space) */
  15213. get rotationQuaternion(): Quaternion;
  15214. set rotationQuaternion(newRotation: Quaternion);
  15215. /** Gets or sets current scaling (in local space) */
  15216. get scaling(): Vector3;
  15217. set scaling(newScaling: Vector3);
  15218. /**
  15219. * Gets the animation properties override
  15220. */
  15221. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15222. private _decompose;
  15223. private _compose;
  15224. /**
  15225. * Update the base and local matrices
  15226. * @param matrix defines the new base or local matrix
  15227. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15228. * @param updateLocalMatrix defines if the local matrix should be updated
  15229. */
  15230. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15231. /** @hidden */
  15232. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15233. /**
  15234. * Flag the bone as dirty (Forcing it to update everything)
  15235. */
  15236. markAsDirty(): void;
  15237. /** @hidden */
  15238. _markAsDirtyAndCompose(): void;
  15239. private _markAsDirtyAndDecompose;
  15240. /**
  15241. * Translate the bone in local or world space
  15242. * @param vec The amount to translate the bone
  15243. * @param space The space that the translation is in
  15244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15245. */
  15246. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15247. /**
  15248. * Set the postion of the bone in local or world space
  15249. * @param position The position to set the bone
  15250. * @param space The space that the position is in
  15251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15252. */
  15253. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15254. /**
  15255. * Set the absolute position of the bone (world space)
  15256. * @param position The position to set the bone
  15257. * @param mesh The mesh that this bone is attached to
  15258. */
  15259. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15260. /**
  15261. * Scale the bone on the x, y and z axes (in local space)
  15262. * @param x The amount to scale the bone on the x axis
  15263. * @param y The amount to scale the bone on the y axis
  15264. * @param z The amount to scale the bone on the z axis
  15265. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15266. */
  15267. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15268. /**
  15269. * Set the bone scaling in local space
  15270. * @param scale defines the scaling vector
  15271. */
  15272. setScale(scale: Vector3): void;
  15273. /**
  15274. * Gets the current scaling in local space
  15275. * @returns the current scaling vector
  15276. */
  15277. getScale(): Vector3;
  15278. /**
  15279. * Gets the current scaling in local space and stores it in a target vector
  15280. * @param result defines the target vector
  15281. */
  15282. getScaleToRef(result: Vector3): void;
  15283. /**
  15284. * Set the yaw, pitch, and roll of the bone in local or world space
  15285. * @param yaw The rotation of the bone on the y axis
  15286. * @param pitch The rotation of the bone on the x axis
  15287. * @param roll The rotation of the bone on the z axis
  15288. * @param space The space that the axes of rotation are in
  15289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15290. */
  15291. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15292. /**
  15293. * Add a rotation to the bone on an axis in local or world space
  15294. * @param axis The axis to rotate the bone on
  15295. * @param amount The amount to rotate the bone
  15296. * @param space The space that the axis is in
  15297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15298. */
  15299. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15300. /**
  15301. * Set the rotation of the bone to a particular axis angle in local or world space
  15302. * @param axis The axis to rotate the bone on
  15303. * @param angle The angle that the bone should be rotated to
  15304. * @param space The space that the axis is in
  15305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15306. */
  15307. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15308. /**
  15309. * Set the euler rotation of the bone in local of world space
  15310. * @param rotation The euler rotation that the bone should be set to
  15311. * @param space The space that the rotation is in
  15312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15313. */
  15314. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15315. /**
  15316. * Set the quaternion rotation of the bone in local of world space
  15317. * @param quat The quaternion rotation that the bone should be set to
  15318. * @param space The space that the rotation is in
  15319. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15320. */
  15321. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15322. /**
  15323. * Set the rotation matrix of the bone in local of world space
  15324. * @param rotMat The rotation matrix that the bone should be set to
  15325. * @param space The space that the rotation is in
  15326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15327. */
  15328. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15329. private _rotateWithMatrix;
  15330. private _getNegativeRotationToRef;
  15331. /**
  15332. * Get the position of the bone in local or world space
  15333. * @param space The space that the returned position is in
  15334. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15335. * @returns The position of the bone
  15336. */
  15337. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15338. /**
  15339. * Copy the position of the bone to a vector3 in local or world space
  15340. * @param space The space that the returned position is in
  15341. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15342. * @param result The vector3 to copy the position to
  15343. */
  15344. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15345. /**
  15346. * Get the absolute position of the bone (world space)
  15347. * @param mesh The mesh that this bone is attached to
  15348. * @returns The absolute position of the bone
  15349. */
  15350. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15351. /**
  15352. * Copy the absolute position of the bone (world space) to the result param
  15353. * @param mesh The mesh that this bone is attached to
  15354. * @param result The vector3 to copy the absolute position to
  15355. */
  15356. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15357. /**
  15358. * Compute the absolute transforms of this bone and its children
  15359. */
  15360. computeAbsoluteTransforms(): void;
  15361. /**
  15362. * Get the world direction from an axis that is in the local space of the bone
  15363. * @param localAxis The local direction that is used to compute the world direction
  15364. * @param mesh The mesh that this bone is attached to
  15365. * @returns The world direction
  15366. */
  15367. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15368. /**
  15369. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15370. * @param localAxis The local direction that is used to compute the world direction
  15371. * @param mesh The mesh that this bone is attached to
  15372. * @param result The vector3 that the world direction will be copied to
  15373. */
  15374. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15375. /**
  15376. * Get the euler rotation of the bone in local or world space
  15377. * @param space The space that the rotation should be in
  15378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15379. * @returns The euler rotation
  15380. */
  15381. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15382. /**
  15383. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15384. * @param space The space that the rotation should be in
  15385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15386. * @param result The vector3 that the rotation should be copied to
  15387. */
  15388. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15389. /**
  15390. * Get the quaternion rotation of the bone in either local or world space
  15391. * @param space The space that the rotation should be in
  15392. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15393. * @returns The quaternion rotation
  15394. */
  15395. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15396. /**
  15397. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15398. * @param space The space that the rotation should be in
  15399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15400. * @param result The quaternion that the rotation should be copied to
  15401. */
  15402. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15403. /**
  15404. * Get the rotation matrix of the bone in local or world space
  15405. * @param space The space that the rotation should be in
  15406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15407. * @returns The rotation matrix
  15408. */
  15409. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15410. /**
  15411. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15412. * @param space The space that the rotation should be in
  15413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15414. * @param result The quaternion that the rotation should be copied to
  15415. */
  15416. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15417. /**
  15418. * Get the world position of a point that is in the local space of the bone
  15419. * @param position The local position
  15420. * @param mesh The mesh that this bone is attached to
  15421. * @returns The world position
  15422. */
  15423. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15424. /**
  15425. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15426. * @param position The local position
  15427. * @param mesh The mesh that this bone is attached to
  15428. * @param result The vector3 that the world position should be copied to
  15429. */
  15430. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15431. /**
  15432. * Get the local position of a point that is in world space
  15433. * @param position The world position
  15434. * @param mesh The mesh that this bone is attached to
  15435. * @returns The local position
  15436. */
  15437. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15438. /**
  15439. * Get the local position of a point that is in world space and copy it to the result param
  15440. * @param position The world position
  15441. * @param mesh The mesh that this bone is attached to
  15442. * @param result The vector3 that the local position should be copied to
  15443. */
  15444. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15445. }
  15446. }
  15447. declare module BABYLON {
  15448. /**
  15449. * Defines a runtime animation
  15450. */
  15451. export class RuntimeAnimation {
  15452. private _events;
  15453. /**
  15454. * The current frame of the runtime animation
  15455. */
  15456. private _currentFrame;
  15457. /**
  15458. * The animation used by the runtime animation
  15459. */
  15460. private _animation;
  15461. /**
  15462. * The target of the runtime animation
  15463. */
  15464. private _target;
  15465. /**
  15466. * The initiating animatable
  15467. */
  15468. private _host;
  15469. /**
  15470. * The original value of the runtime animation
  15471. */
  15472. private _originalValue;
  15473. /**
  15474. * The original blend value of the runtime animation
  15475. */
  15476. private _originalBlendValue;
  15477. /**
  15478. * The offsets cache of the runtime animation
  15479. */
  15480. private _offsetsCache;
  15481. /**
  15482. * The high limits cache of the runtime animation
  15483. */
  15484. private _highLimitsCache;
  15485. /**
  15486. * Specifies if the runtime animation has been stopped
  15487. */
  15488. private _stopped;
  15489. /**
  15490. * The blending factor of the runtime animation
  15491. */
  15492. private _blendingFactor;
  15493. /**
  15494. * The BabylonJS scene
  15495. */
  15496. private _scene;
  15497. /**
  15498. * The current value of the runtime animation
  15499. */
  15500. private _currentValue;
  15501. /** @hidden */
  15502. _animationState: _IAnimationState;
  15503. /**
  15504. * The active target of the runtime animation
  15505. */
  15506. private _activeTargets;
  15507. private _currentActiveTarget;
  15508. private _directTarget;
  15509. /**
  15510. * The target path of the runtime animation
  15511. */
  15512. private _targetPath;
  15513. /**
  15514. * The weight of the runtime animation
  15515. */
  15516. private _weight;
  15517. /**
  15518. * The ratio offset of the runtime animation
  15519. */
  15520. private _ratioOffset;
  15521. /**
  15522. * The previous delay of the runtime animation
  15523. */
  15524. private _previousDelay;
  15525. /**
  15526. * The previous ratio of the runtime animation
  15527. */
  15528. private _previousRatio;
  15529. private _enableBlending;
  15530. private _keys;
  15531. private _minFrame;
  15532. private _maxFrame;
  15533. private _minValue;
  15534. private _maxValue;
  15535. private _targetIsArray;
  15536. /**
  15537. * Gets the current frame of the runtime animation
  15538. */
  15539. get currentFrame(): number;
  15540. /**
  15541. * Gets the weight of the runtime animation
  15542. */
  15543. get weight(): number;
  15544. /**
  15545. * Gets the current value of the runtime animation
  15546. */
  15547. get currentValue(): any;
  15548. /**
  15549. * Gets the target path of the runtime animation
  15550. */
  15551. get targetPath(): string;
  15552. /**
  15553. * Gets the actual target of the runtime animation
  15554. */
  15555. get target(): any;
  15556. /**
  15557. * Gets the additive state of the runtime animation
  15558. */
  15559. get isAdditive(): boolean;
  15560. /** @hidden */
  15561. _onLoop: () => void;
  15562. /**
  15563. * Create a new RuntimeAnimation object
  15564. * @param target defines the target of the animation
  15565. * @param animation defines the source animation object
  15566. * @param scene defines the hosting scene
  15567. * @param host defines the initiating Animatable
  15568. */
  15569. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15570. private _preparePath;
  15571. /**
  15572. * Gets the animation from the runtime animation
  15573. */
  15574. get animation(): Animation;
  15575. /**
  15576. * Resets the runtime animation to the beginning
  15577. * @param restoreOriginal defines whether to restore the target property to the original value
  15578. */
  15579. reset(restoreOriginal?: boolean): void;
  15580. /**
  15581. * Specifies if the runtime animation is stopped
  15582. * @returns Boolean specifying if the runtime animation is stopped
  15583. */
  15584. isStopped(): boolean;
  15585. /**
  15586. * Disposes of the runtime animation
  15587. */
  15588. dispose(): void;
  15589. /**
  15590. * Apply the interpolated value to the target
  15591. * @param currentValue defines the value computed by the animation
  15592. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15593. */
  15594. setValue(currentValue: any, weight: number): void;
  15595. private _getOriginalValues;
  15596. private _setValue;
  15597. /**
  15598. * Gets the loop pmode of the runtime animation
  15599. * @returns Loop Mode
  15600. */
  15601. private _getCorrectLoopMode;
  15602. /**
  15603. * Move the current animation to a given frame
  15604. * @param frame defines the frame to move to
  15605. */
  15606. goToFrame(frame: number): void;
  15607. /**
  15608. * @hidden Internal use only
  15609. */
  15610. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15611. /**
  15612. * Execute the current animation
  15613. * @param delay defines the delay to add to the current frame
  15614. * @param from defines the lower bound of the animation range
  15615. * @param to defines the upper bound of the animation range
  15616. * @param loop defines if the current animation must loop
  15617. * @param speedRatio defines the current speed ratio
  15618. * @param weight defines the weight of the animation (default is -1 so no weight)
  15619. * @param onLoop optional callback called when animation loops
  15620. * @returns a boolean indicating if the animation is running
  15621. */
  15622. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15623. }
  15624. }
  15625. declare module BABYLON {
  15626. /**
  15627. * Class used to store an actual running animation
  15628. */
  15629. export class Animatable {
  15630. /** defines the target object */
  15631. target: any;
  15632. /** defines the starting frame number (default is 0) */
  15633. fromFrame: number;
  15634. /** defines the ending frame number (default is 100) */
  15635. toFrame: number;
  15636. /** defines if the animation must loop (default is false) */
  15637. loopAnimation: boolean;
  15638. /** defines a callback to call when animation ends if it is not looping */
  15639. onAnimationEnd?: (() => void) | null | undefined;
  15640. /** defines a callback to call when animation loops */
  15641. onAnimationLoop?: (() => void) | null | undefined;
  15642. /** defines whether the animation should be evaluated additively */
  15643. isAdditive: boolean;
  15644. private _localDelayOffset;
  15645. private _pausedDelay;
  15646. private _runtimeAnimations;
  15647. private _paused;
  15648. private _scene;
  15649. private _speedRatio;
  15650. private _weight;
  15651. private _syncRoot;
  15652. /**
  15653. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15654. * This will only apply for non looping animation (default is true)
  15655. */
  15656. disposeOnEnd: boolean;
  15657. /**
  15658. * Gets a boolean indicating if the animation has started
  15659. */
  15660. animationStarted: boolean;
  15661. /**
  15662. * Observer raised when the animation ends
  15663. */
  15664. onAnimationEndObservable: Observable<Animatable>;
  15665. /**
  15666. * Observer raised when the animation loops
  15667. */
  15668. onAnimationLoopObservable: Observable<Animatable>;
  15669. /**
  15670. * Gets the root Animatable used to synchronize and normalize animations
  15671. */
  15672. get syncRoot(): Nullable<Animatable>;
  15673. /**
  15674. * Gets the current frame of the first RuntimeAnimation
  15675. * Used to synchronize Animatables
  15676. */
  15677. get masterFrame(): number;
  15678. /**
  15679. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15680. */
  15681. get weight(): number;
  15682. set weight(value: number);
  15683. /**
  15684. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15685. */
  15686. get speedRatio(): number;
  15687. set speedRatio(value: number);
  15688. /**
  15689. * Creates a new Animatable
  15690. * @param scene defines the hosting scene
  15691. * @param target defines the target object
  15692. * @param fromFrame defines the starting frame number (default is 0)
  15693. * @param toFrame defines the ending frame number (default is 100)
  15694. * @param loopAnimation defines if the animation must loop (default is false)
  15695. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15696. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15697. * @param animations defines a group of animation to add to the new Animatable
  15698. * @param onAnimationLoop defines a callback to call when animation loops
  15699. * @param isAdditive defines whether the animation should be evaluated additively
  15700. */
  15701. constructor(scene: Scene,
  15702. /** defines the target object */
  15703. target: any,
  15704. /** defines the starting frame number (default is 0) */
  15705. fromFrame?: number,
  15706. /** defines the ending frame number (default is 100) */
  15707. toFrame?: number,
  15708. /** defines if the animation must loop (default is false) */
  15709. loopAnimation?: boolean, speedRatio?: number,
  15710. /** defines a callback to call when animation ends if it is not looping */
  15711. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15712. /** defines a callback to call when animation loops */
  15713. onAnimationLoop?: (() => void) | null | undefined,
  15714. /** defines whether the animation should be evaluated additively */
  15715. isAdditive?: boolean);
  15716. /**
  15717. * Synchronize and normalize current Animatable with a source Animatable
  15718. * This is useful when using animation weights and when animations are not of the same length
  15719. * @param root defines the root Animatable to synchronize with
  15720. * @returns the current Animatable
  15721. */
  15722. syncWith(root: Animatable): Animatable;
  15723. /**
  15724. * Gets the list of runtime animations
  15725. * @returns an array of RuntimeAnimation
  15726. */
  15727. getAnimations(): RuntimeAnimation[];
  15728. /**
  15729. * Adds more animations to the current animatable
  15730. * @param target defines the target of the animations
  15731. * @param animations defines the new animations to add
  15732. */
  15733. appendAnimations(target: any, animations: Animation[]): void;
  15734. /**
  15735. * Gets the source animation for a specific property
  15736. * @param property defines the propertyu to look for
  15737. * @returns null or the source animation for the given property
  15738. */
  15739. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15740. /**
  15741. * Gets the runtime animation for a specific property
  15742. * @param property defines the propertyu to look for
  15743. * @returns null or the runtime animation for the given property
  15744. */
  15745. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15746. /**
  15747. * Resets the animatable to its original state
  15748. */
  15749. reset(): void;
  15750. /**
  15751. * Allows the animatable to blend with current running animations
  15752. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15753. * @param blendingSpeed defines the blending speed to use
  15754. */
  15755. enableBlending(blendingSpeed: number): void;
  15756. /**
  15757. * Disable animation blending
  15758. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15759. */
  15760. disableBlending(): void;
  15761. /**
  15762. * Jump directly to a given frame
  15763. * @param frame defines the frame to jump to
  15764. */
  15765. goToFrame(frame: number): void;
  15766. /**
  15767. * Pause the animation
  15768. */
  15769. pause(): void;
  15770. /**
  15771. * Restart the animation
  15772. */
  15773. restart(): void;
  15774. private _raiseOnAnimationEnd;
  15775. /**
  15776. * Stop and delete the current animation
  15777. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15778. * @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)
  15779. */
  15780. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15781. /**
  15782. * Wait asynchronously for the animation to end
  15783. * @returns a promise which will be fullfilled when the animation ends
  15784. */
  15785. waitAsync(): Promise<Animatable>;
  15786. /** @hidden */
  15787. _animate(delay: number): boolean;
  15788. }
  15789. interface Scene {
  15790. /** @hidden */
  15791. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15792. /** @hidden */
  15793. _processLateAnimationBindingsForMatrices(holder: {
  15794. totalWeight: number;
  15795. totalAdditiveWeight: number;
  15796. animations: RuntimeAnimation[];
  15797. additiveAnimations: RuntimeAnimation[];
  15798. originalValue: Matrix;
  15799. }): any;
  15800. /** @hidden */
  15801. _processLateAnimationBindingsForQuaternions(holder: {
  15802. totalWeight: number;
  15803. totalAdditiveWeight: number;
  15804. animations: RuntimeAnimation[];
  15805. additiveAnimations: RuntimeAnimation[];
  15806. originalValue: Quaternion;
  15807. }, refQuaternion: Quaternion): Quaternion;
  15808. /** @hidden */
  15809. _processLateAnimationBindings(): void;
  15810. /**
  15811. * Will start the animation sequence of a given target
  15812. * @param target defines the target
  15813. * @param from defines from which frame should animation start
  15814. * @param to defines until which frame should animation run.
  15815. * @param weight defines the weight to apply to the animation (1.0 by default)
  15816. * @param loop defines if the animation loops
  15817. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15818. * @param onAnimationEnd defines the function to be executed when the animation ends
  15819. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15820. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15821. * @param onAnimationLoop defines the callback to call when an animation loops
  15822. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15823. * @returns the animatable object created for this animation
  15824. */
  15825. 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;
  15826. /**
  15827. * Will start the animation sequence of a given target
  15828. * @param target defines the target
  15829. * @param from defines from which frame should animation start
  15830. * @param to defines until which frame should animation run.
  15831. * @param loop defines if the animation loops
  15832. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15833. * @param onAnimationEnd defines the function to be executed when the animation ends
  15834. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15835. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15836. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15837. * @param onAnimationLoop defines the callback to call when an animation loops
  15838. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15839. * @returns the animatable object created for this animation
  15840. */
  15841. 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;
  15842. /**
  15843. * Will start the animation sequence of a given target and its hierarchy
  15844. * @param target defines the target
  15845. * @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.
  15846. * @param from defines from which frame should animation start
  15847. * @param to defines until which frame should animation run.
  15848. * @param loop defines if the animation loops
  15849. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15850. * @param onAnimationEnd defines the function to be executed when the animation ends
  15851. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15852. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15853. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15854. * @param onAnimationLoop defines the callback to call when an animation loops
  15855. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15856. * @returns the list of created animatables
  15857. */
  15858. 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[];
  15859. /**
  15860. * Begin a new animation on a given node
  15861. * @param target defines the target where the animation will take place
  15862. * @param animations defines the list of animations to start
  15863. * @param from defines the initial value
  15864. * @param to defines the final value
  15865. * @param loop defines if you want animation to loop (off by default)
  15866. * @param speedRatio defines the speed ratio to apply to all animations
  15867. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15868. * @param onAnimationLoop defines the callback to call when an animation loops
  15869. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15870. * @returns the list of created animatables
  15871. */
  15872. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15873. /**
  15874. * Begin a new animation on a given node and its hierarchy
  15875. * @param target defines the root node where the animation will take place
  15876. * @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.
  15877. * @param animations defines the list of animations to start
  15878. * @param from defines the initial value
  15879. * @param to defines the final value
  15880. * @param loop defines if you want animation to loop (off by default)
  15881. * @param speedRatio defines the speed ratio to apply to all animations
  15882. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15883. * @param onAnimationLoop defines the callback to call when an animation loops
  15884. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15885. * @returns the list of animatables created for all nodes
  15886. */
  15887. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15888. /**
  15889. * Gets the animatable associated with a specific target
  15890. * @param target defines the target of the animatable
  15891. * @returns the required animatable if found
  15892. */
  15893. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15894. /**
  15895. * Gets all animatables associated with a given target
  15896. * @param target defines the target to look animatables for
  15897. * @returns an array of Animatables
  15898. */
  15899. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15900. /**
  15901. * Stops and removes all animations that have been applied to the scene
  15902. */
  15903. stopAllAnimations(): void;
  15904. /**
  15905. * Gets the current delta time used by animation engine
  15906. */
  15907. deltaTime: number;
  15908. }
  15909. interface Bone {
  15910. /**
  15911. * Copy an animation range from another bone
  15912. * @param source defines the source bone
  15913. * @param rangeName defines the range name to copy
  15914. * @param frameOffset defines the frame offset
  15915. * @param rescaleAsRequired defines if rescaling must be applied if required
  15916. * @param skelDimensionsRatio defines the scaling ratio
  15917. * @returns true if operation was successful
  15918. */
  15919. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15920. }
  15921. }
  15922. declare module BABYLON {
  15923. /**
  15924. * Class used to handle skinning animations
  15925. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15926. */
  15927. export class Skeleton implements IAnimatable {
  15928. /** defines the skeleton name */
  15929. name: string;
  15930. /** defines the skeleton Id */
  15931. id: string;
  15932. /**
  15933. * Defines the list of child bones
  15934. */
  15935. bones: Bone[];
  15936. /**
  15937. * Defines an estimate of the dimension of the skeleton at rest
  15938. */
  15939. dimensionsAtRest: Vector3;
  15940. /**
  15941. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15942. */
  15943. needInitialSkinMatrix: boolean;
  15944. /**
  15945. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15946. */
  15947. overrideMesh: Nullable<AbstractMesh>;
  15948. /**
  15949. * Gets the list of animations attached to this skeleton
  15950. */
  15951. animations: Array<Animation>;
  15952. private _scene;
  15953. private _isDirty;
  15954. private _transformMatrices;
  15955. private _transformMatrixTexture;
  15956. private _meshesWithPoseMatrix;
  15957. private _animatables;
  15958. private _identity;
  15959. private _synchronizedWithMesh;
  15960. private _ranges;
  15961. private _lastAbsoluteTransformsUpdateId;
  15962. private _canUseTextureForBones;
  15963. private _uniqueId;
  15964. /** @hidden */
  15965. _numBonesWithLinkedTransformNode: number;
  15966. /** @hidden */
  15967. _hasWaitingData: Nullable<boolean>;
  15968. /**
  15969. * Specifies if the skeleton should be serialized
  15970. */
  15971. doNotSerialize: boolean;
  15972. private _useTextureToStoreBoneMatrices;
  15973. /**
  15974. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15975. * Please note that this option is not available if the hardware does not support it
  15976. */
  15977. get useTextureToStoreBoneMatrices(): boolean;
  15978. set useTextureToStoreBoneMatrices(value: boolean);
  15979. private _animationPropertiesOverride;
  15980. /**
  15981. * Gets or sets the animation properties override
  15982. */
  15983. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15984. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15985. /**
  15986. * List of inspectable custom properties (used by the Inspector)
  15987. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15988. */
  15989. inspectableCustomProperties: IInspectable[];
  15990. /**
  15991. * An observable triggered before computing the skeleton's matrices
  15992. */
  15993. onBeforeComputeObservable: Observable<Skeleton>;
  15994. /**
  15995. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15996. */
  15997. get isUsingTextureForMatrices(): boolean;
  15998. /**
  15999. * Gets the unique ID of this skeleton
  16000. */
  16001. get uniqueId(): number;
  16002. /**
  16003. * Creates a new skeleton
  16004. * @param name defines the skeleton name
  16005. * @param id defines the skeleton Id
  16006. * @param scene defines the hosting scene
  16007. */
  16008. constructor(
  16009. /** defines the skeleton name */
  16010. name: string,
  16011. /** defines the skeleton Id */
  16012. id: string, scene: Scene);
  16013. /**
  16014. * Gets the current object class name.
  16015. * @return the class name
  16016. */
  16017. getClassName(): string;
  16018. /**
  16019. * Returns an array containing the root bones
  16020. * @returns an array containing the root bones
  16021. */
  16022. getChildren(): Array<Bone>;
  16023. /**
  16024. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16025. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16026. * @returns a Float32Array containing matrices data
  16027. */
  16028. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16029. /**
  16030. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16031. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16032. * @returns a raw texture containing the data
  16033. */
  16034. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16035. /**
  16036. * Gets the current hosting scene
  16037. * @returns a scene object
  16038. */
  16039. getScene(): Scene;
  16040. /**
  16041. * Gets a string representing the current skeleton data
  16042. * @param fullDetails defines a boolean indicating if we want a verbose version
  16043. * @returns a string representing the current skeleton data
  16044. */
  16045. toString(fullDetails?: boolean): string;
  16046. /**
  16047. * Get bone's index searching by name
  16048. * @param name defines bone's name to search for
  16049. * @return the indice of the bone. Returns -1 if not found
  16050. */
  16051. getBoneIndexByName(name: string): number;
  16052. /**
  16053. * Creater a new animation range
  16054. * @param name defines the name of the range
  16055. * @param from defines the start key
  16056. * @param to defines the end key
  16057. */
  16058. createAnimationRange(name: string, from: number, to: number): void;
  16059. /**
  16060. * Delete a specific animation range
  16061. * @param name defines the name of the range
  16062. * @param deleteFrames defines if frames must be removed as well
  16063. */
  16064. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16065. /**
  16066. * Gets a specific animation range
  16067. * @param name defines the name of the range to look for
  16068. * @returns the requested animation range or null if not found
  16069. */
  16070. getAnimationRange(name: string): Nullable<AnimationRange>;
  16071. /**
  16072. * Gets the list of all animation ranges defined on this skeleton
  16073. * @returns an array
  16074. */
  16075. getAnimationRanges(): Nullable<AnimationRange>[];
  16076. /**
  16077. * Copy animation range from a source skeleton.
  16078. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16079. * @param source defines the source skeleton
  16080. * @param name defines the name of the range to copy
  16081. * @param rescaleAsRequired defines if rescaling must be applied if required
  16082. * @returns true if operation was successful
  16083. */
  16084. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16085. /**
  16086. * Forces the skeleton to go to rest pose
  16087. */
  16088. returnToRest(): void;
  16089. private _getHighestAnimationFrame;
  16090. /**
  16091. * Begin a specific animation range
  16092. * @param name defines the name of the range to start
  16093. * @param loop defines if looping must be turned on (false by default)
  16094. * @param speedRatio defines the speed ratio to apply (1 by default)
  16095. * @param onAnimationEnd defines a callback which will be called when animation will end
  16096. * @returns a new animatable
  16097. */
  16098. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16099. /**
  16100. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16101. * @param skeleton defines the Skeleton containing the animation range to convert
  16102. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16103. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16104. * @returns the original skeleton
  16105. */
  16106. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16107. /** @hidden */
  16108. _markAsDirty(): void;
  16109. /** @hidden */
  16110. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16111. /** @hidden */
  16112. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16113. private _computeTransformMatrices;
  16114. /**
  16115. * Build all resources required to render a skeleton
  16116. */
  16117. prepare(): void;
  16118. /**
  16119. * Gets the list of animatables currently running for this skeleton
  16120. * @returns an array of animatables
  16121. */
  16122. getAnimatables(): IAnimatable[];
  16123. /**
  16124. * Clone the current skeleton
  16125. * @param name defines the name of the new skeleton
  16126. * @param id defines the id of the new skeleton
  16127. * @returns the new skeleton
  16128. */
  16129. clone(name: string, id?: string): Skeleton;
  16130. /**
  16131. * Enable animation blending for this skeleton
  16132. * @param blendingSpeed defines the blending speed to apply
  16133. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16134. */
  16135. enableBlending(blendingSpeed?: number): void;
  16136. /**
  16137. * Releases all resources associated with the current skeleton
  16138. */
  16139. dispose(): void;
  16140. /**
  16141. * Serialize the skeleton in a JSON object
  16142. * @returns a JSON object
  16143. */
  16144. serialize(): any;
  16145. /**
  16146. * Creates a new skeleton from serialized data
  16147. * @param parsedSkeleton defines the serialized data
  16148. * @param scene defines the hosting scene
  16149. * @returns a new skeleton
  16150. */
  16151. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16152. /**
  16153. * Compute all node absolute transforms
  16154. * @param forceUpdate defines if computation must be done even if cache is up to date
  16155. */
  16156. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16157. /**
  16158. * Gets the root pose matrix
  16159. * @returns a matrix
  16160. */
  16161. getPoseMatrix(): Nullable<Matrix>;
  16162. /**
  16163. * Sorts bones per internal index
  16164. */
  16165. sortBones(): void;
  16166. private _sortBones;
  16167. }
  16168. }
  16169. declare module BABYLON {
  16170. /**
  16171. * Creates an instance based on a source mesh.
  16172. */
  16173. export class InstancedMesh extends AbstractMesh {
  16174. private _sourceMesh;
  16175. private _currentLOD;
  16176. /** @hidden */
  16177. _indexInSourceMeshInstanceArray: number;
  16178. constructor(name: string, source: Mesh);
  16179. /**
  16180. * Returns the string "InstancedMesh".
  16181. */
  16182. getClassName(): string;
  16183. /** Gets the list of lights affecting that mesh */
  16184. get lightSources(): Light[];
  16185. _resyncLightSources(): void;
  16186. _resyncLightSource(light: Light): void;
  16187. _removeLightSource(light: Light, dispose: boolean): void;
  16188. /**
  16189. * If the source mesh receives shadows
  16190. */
  16191. get receiveShadows(): boolean;
  16192. /**
  16193. * The material of the source mesh
  16194. */
  16195. get material(): Nullable<Material>;
  16196. /**
  16197. * Visibility of the source mesh
  16198. */
  16199. get visibility(): number;
  16200. /**
  16201. * Skeleton of the source mesh
  16202. */
  16203. get skeleton(): Nullable<Skeleton>;
  16204. /**
  16205. * Rendering ground id of the source mesh
  16206. */
  16207. get renderingGroupId(): number;
  16208. set renderingGroupId(value: number);
  16209. /**
  16210. * Returns the total number of vertices (integer).
  16211. */
  16212. getTotalVertices(): number;
  16213. /**
  16214. * Returns a positive integer : the total number of indices in this mesh geometry.
  16215. * @returns the numner of indices or zero if the mesh has no geometry.
  16216. */
  16217. getTotalIndices(): number;
  16218. /**
  16219. * The source mesh of the instance
  16220. */
  16221. get sourceMesh(): Mesh;
  16222. /**
  16223. * Creates a new InstancedMesh object from the mesh model.
  16224. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16225. * @param name defines the name of the new instance
  16226. * @returns a new InstancedMesh
  16227. */
  16228. createInstance(name: string): InstancedMesh;
  16229. /**
  16230. * Is this node ready to be used/rendered
  16231. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16232. * @return {boolean} is it ready
  16233. */
  16234. isReady(completeCheck?: boolean): boolean;
  16235. /**
  16236. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16237. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16238. * @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.
  16239. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16240. */
  16241. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16242. /**
  16243. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16244. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16245. * The `data` are either a numeric array either a Float32Array.
  16246. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16247. * 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).
  16248. * Note that a new underlying VertexBuffer object is created each call.
  16249. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16250. *
  16251. * Possible `kind` values :
  16252. * - VertexBuffer.PositionKind
  16253. * - VertexBuffer.UVKind
  16254. * - VertexBuffer.UV2Kind
  16255. * - VertexBuffer.UV3Kind
  16256. * - VertexBuffer.UV4Kind
  16257. * - VertexBuffer.UV5Kind
  16258. * - VertexBuffer.UV6Kind
  16259. * - VertexBuffer.ColorKind
  16260. * - VertexBuffer.MatricesIndicesKind
  16261. * - VertexBuffer.MatricesIndicesExtraKind
  16262. * - VertexBuffer.MatricesWeightsKind
  16263. * - VertexBuffer.MatricesWeightsExtraKind
  16264. *
  16265. * Returns the Mesh.
  16266. */
  16267. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16268. /**
  16269. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16270. * If the mesh has no geometry, it is simply returned as it is.
  16271. * The `data` are either a numeric array either a Float32Array.
  16272. * No new underlying VertexBuffer object is created.
  16273. * 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.
  16274. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16275. *
  16276. * Possible `kind` values :
  16277. * - VertexBuffer.PositionKind
  16278. * - VertexBuffer.UVKind
  16279. * - VertexBuffer.UV2Kind
  16280. * - VertexBuffer.UV3Kind
  16281. * - VertexBuffer.UV4Kind
  16282. * - VertexBuffer.UV5Kind
  16283. * - VertexBuffer.UV6Kind
  16284. * - VertexBuffer.ColorKind
  16285. * - VertexBuffer.MatricesIndicesKind
  16286. * - VertexBuffer.MatricesIndicesExtraKind
  16287. * - VertexBuffer.MatricesWeightsKind
  16288. * - VertexBuffer.MatricesWeightsExtraKind
  16289. *
  16290. * Returns the Mesh.
  16291. */
  16292. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16293. /**
  16294. * Sets the mesh indices.
  16295. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16296. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16297. * This method creates a new index buffer each call.
  16298. * Returns the Mesh.
  16299. */
  16300. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16301. /**
  16302. * Boolean : True if the mesh owns the requested kind of data.
  16303. */
  16304. isVerticesDataPresent(kind: string): boolean;
  16305. /**
  16306. * Returns an array of indices (IndicesArray).
  16307. */
  16308. getIndices(): Nullable<IndicesArray>;
  16309. get _positions(): Nullable<Vector3[]>;
  16310. /**
  16311. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16312. * This means the mesh underlying bounding box and sphere are recomputed.
  16313. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16314. * @returns the current mesh
  16315. */
  16316. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16317. /** @hidden */
  16318. _preActivate(): InstancedMesh;
  16319. /** @hidden */
  16320. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16321. /** @hidden */
  16322. _postActivate(): void;
  16323. getWorldMatrix(): Matrix;
  16324. get isAnInstance(): boolean;
  16325. /**
  16326. * Returns the current associated LOD AbstractMesh.
  16327. */
  16328. getLOD(camera: Camera): AbstractMesh;
  16329. /** @hidden */
  16330. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16331. /** @hidden */
  16332. _syncSubMeshes(): InstancedMesh;
  16333. /** @hidden */
  16334. _generatePointsArray(): boolean;
  16335. /** @hidden */
  16336. _updateBoundingInfo(): AbstractMesh;
  16337. /**
  16338. * Creates a new InstancedMesh from the current mesh.
  16339. * - name (string) : the cloned mesh name
  16340. * - newParent (optional Node) : the optional Node to parent the clone to.
  16341. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16342. *
  16343. * Returns the clone.
  16344. */
  16345. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16346. /**
  16347. * Disposes the InstancedMesh.
  16348. * Returns nothing.
  16349. */
  16350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16351. }
  16352. interface Mesh {
  16353. /**
  16354. * Register a custom buffer that will be instanced
  16355. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16356. * @param kind defines the buffer kind
  16357. * @param stride defines the stride in floats
  16358. */
  16359. registerInstancedBuffer(kind: string, stride: number): void;
  16360. /**
  16361. * true to use the edge renderer for all instances of this mesh
  16362. */
  16363. edgesShareWithInstances: boolean;
  16364. /** @hidden */
  16365. _userInstancedBuffersStorage: {
  16366. data: {
  16367. [key: string]: Float32Array;
  16368. };
  16369. sizes: {
  16370. [key: string]: number;
  16371. };
  16372. vertexBuffers: {
  16373. [key: string]: Nullable<VertexBuffer>;
  16374. };
  16375. strides: {
  16376. [key: string]: number;
  16377. };
  16378. };
  16379. }
  16380. interface AbstractMesh {
  16381. /**
  16382. * Object used to store instanced buffers defined by user
  16383. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16384. */
  16385. instancedBuffers: {
  16386. [key: string]: any;
  16387. };
  16388. }
  16389. }
  16390. declare module BABYLON {
  16391. /**
  16392. * Defines the options associated with the creation of a shader material.
  16393. */
  16394. export interface IShaderMaterialOptions {
  16395. /**
  16396. * Does the material work in alpha blend mode
  16397. */
  16398. needAlphaBlending: boolean;
  16399. /**
  16400. * Does the material work in alpha test mode
  16401. */
  16402. needAlphaTesting: boolean;
  16403. /**
  16404. * The list of attribute names used in the shader
  16405. */
  16406. attributes: string[];
  16407. /**
  16408. * The list of unifrom names used in the shader
  16409. */
  16410. uniforms: string[];
  16411. /**
  16412. * The list of UBO names used in the shader
  16413. */
  16414. uniformBuffers: string[];
  16415. /**
  16416. * The list of sampler names used in the shader
  16417. */
  16418. samplers: string[];
  16419. /**
  16420. * The list of defines used in the shader
  16421. */
  16422. defines: string[];
  16423. }
  16424. /**
  16425. * 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.
  16426. *
  16427. * This returned material effects how the mesh will look based on the code in the shaders.
  16428. *
  16429. * @see https://doc.babylonjs.com/how_to/shader_material
  16430. */
  16431. export class ShaderMaterial extends Material {
  16432. private _shaderPath;
  16433. private _options;
  16434. private _textures;
  16435. private _textureArrays;
  16436. private _floats;
  16437. private _ints;
  16438. private _floatsArrays;
  16439. private _colors3;
  16440. private _colors3Arrays;
  16441. private _colors4;
  16442. private _colors4Arrays;
  16443. private _vectors2;
  16444. private _vectors3;
  16445. private _vectors4;
  16446. private _matrices;
  16447. private _matrixArrays;
  16448. private _matrices3x3;
  16449. private _matrices2x2;
  16450. private _vectors2Arrays;
  16451. private _vectors3Arrays;
  16452. private _vectors4Arrays;
  16453. private _cachedWorldViewMatrix;
  16454. private _cachedWorldViewProjectionMatrix;
  16455. private _renderId;
  16456. private _multiview;
  16457. private _cachedDefines;
  16458. /** Define the Url to load snippets */
  16459. static SnippetUrl: string;
  16460. /** Snippet ID if the material was created from the snippet server */
  16461. snippetId: string;
  16462. /**
  16463. * Instantiate a new shader material.
  16464. * 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.
  16465. * This returned material effects how the mesh will look based on the code in the shaders.
  16466. * @see https://doc.babylonjs.com/how_to/shader_material
  16467. * @param name Define the name of the material in the scene
  16468. * @param scene Define the scene the material belongs to
  16469. * @param shaderPath Defines the route to the shader code in one of three ways:
  16470. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16471. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16472. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16473. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16474. * @param options Define the options used to create the shader
  16475. */
  16476. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16477. /**
  16478. * Gets the shader path used to define the shader code
  16479. * It can be modified to trigger a new compilation
  16480. */
  16481. get shaderPath(): any;
  16482. /**
  16483. * Sets the shader path used to define the shader code
  16484. * It can be modified to trigger a new compilation
  16485. */
  16486. set shaderPath(shaderPath: any);
  16487. /**
  16488. * Gets the options used to compile the shader.
  16489. * They can be modified to trigger a new compilation
  16490. */
  16491. get options(): IShaderMaterialOptions;
  16492. /**
  16493. * Gets the current class name of the material e.g. "ShaderMaterial"
  16494. * Mainly use in serialization.
  16495. * @returns the class name
  16496. */
  16497. getClassName(): string;
  16498. /**
  16499. * Specifies if the material will require alpha blending
  16500. * @returns a boolean specifying if alpha blending is needed
  16501. */
  16502. needAlphaBlending(): boolean;
  16503. /**
  16504. * Specifies if this material should be rendered in alpha test mode
  16505. * @returns a boolean specifying if an alpha test is needed.
  16506. */
  16507. needAlphaTesting(): boolean;
  16508. private _checkUniform;
  16509. /**
  16510. * Set a texture in the shader.
  16511. * @param name Define the name of the uniform samplers as defined in the shader
  16512. * @param texture Define the texture to bind to this sampler
  16513. * @return the material itself allowing "fluent" like uniform updates
  16514. */
  16515. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16516. /**
  16517. * Set a texture array in the shader.
  16518. * @param name Define the name of the uniform sampler array as defined in the shader
  16519. * @param textures Define the list of textures to bind to this sampler
  16520. * @return the material itself allowing "fluent" like uniform updates
  16521. */
  16522. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16523. /**
  16524. * Set a float in the shader.
  16525. * @param name Define the name of the uniform as defined in the shader
  16526. * @param value Define the value to give to the uniform
  16527. * @return the material itself allowing "fluent" like uniform updates
  16528. */
  16529. setFloat(name: string, value: number): ShaderMaterial;
  16530. /**
  16531. * Set a int in the shader.
  16532. * @param name Define the name of the uniform as defined in the shader
  16533. * @param value Define the value to give to the uniform
  16534. * @return the material itself allowing "fluent" like uniform updates
  16535. */
  16536. setInt(name: string, value: number): ShaderMaterial;
  16537. /**
  16538. * Set an array of floats in the shader.
  16539. * @param name Define the name of the uniform as defined in the shader
  16540. * @param value Define the value to give to the uniform
  16541. * @return the material itself allowing "fluent" like uniform updates
  16542. */
  16543. setFloats(name: string, value: number[]): ShaderMaterial;
  16544. /**
  16545. * Set a vec3 in the shader from a Color3.
  16546. * @param name Define the name of the uniform as defined in the shader
  16547. * @param value Define the value to give to the uniform
  16548. * @return the material itself allowing "fluent" like uniform updates
  16549. */
  16550. setColor3(name: string, value: Color3): ShaderMaterial;
  16551. /**
  16552. * Set a vec3 array in the shader from a Color3 array.
  16553. * @param name Define the name of the uniform as defined in the shader
  16554. * @param value Define the value to give to the uniform
  16555. * @return the material itself allowing "fluent" like uniform updates
  16556. */
  16557. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16558. /**
  16559. * Set a vec4 in the shader from a Color4.
  16560. * @param name Define the name of the uniform as defined in the shader
  16561. * @param value Define the value to give to the uniform
  16562. * @return the material itself allowing "fluent" like uniform updates
  16563. */
  16564. setColor4(name: string, value: Color4): ShaderMaterial;
  16565. /**
  16566. * Set a vec4 array in the shader from a Color4 array.
  16567. * @param name Define the name of the uniform as defined in the shader
  16568. * @param value Define the value to give to the uniform
  16569. * @return the material itself allowing "fluent" like uniform updates
  16570. */
  16571. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16572. /**
  16573. * Set a vec2 in the shader from a Vector2.
  16574. * @param name Define the name of the uniform as defined in the shader
  16575. * @param value Define the value to give to the uniform
  16576. * @return the material itself allowing "fluent" like uniform updates
  16577. */
  16578. setVector2(name: string, value: Vector2): ShaderMaterial;
  16579. /**
  16580. * Set a vec3 in the shader from a Vector3.
  16581. * @param name Define the name of the uniform as defined in the shader
  16582. * @param value Define the value to give to the uniform
  16583. * @return the material itself allowing "fluent" like uniform updates
  16584. */
  16585. setVector3(name: string, value: Vector3): ShaderMaterial;
  16586. /**
  16587. * Set a vec4 in the shader from a Vector4.
  16588. * @param name Define the name of the uniform as defined in the shader
  16589. * @param value Define the value to give to the uniform
  16590. * @return the material itself allowing "fluent" like uniform updates
  16591. */
  16592. setVector4(name: string, value: Vector4): ShaderMaterial;
  16593. /**
  16594. * Set a mat4 in the shader from a Matrix.
  16595. * @param name Define the name of the uniform as defined in the shader
  16596. * @param value Define the value to give to the uniform
  16597. * @return the material itself allowing "fluent" like uniform updates
  16598. */
  16599. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16600. /**
  16601. * Set a float32Array in the shader from a matrix array.
  16602. * @param name Define the name of the uniform as defined in the shader
  16603. * @param value Define the value to give to the uniform
  16604. * @return the material itself allowing "fluent" like uniform updates
  16605. */
  16606. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16607. /**
  16608. * Set a mat3 in the shader from a Float32Array.
  16609. * @param name Define the name of the uniform as defined in the shader
  16610. * @param value Define the value to give to the uniform
  16611. * @return the material itself allowing "fluent" like uniform updates
  16612. */
  16613. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16614. /**
  16615. * Set a mat2 in the shader from a Float32Array.
  16616. * @param name Define the name of the uniform as defined in the shader
  16617. * @param value Define the value to give to the uniform
  16618. * @return the material itself allowing "fluent" like uniform updates
  16619. */
  16620. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16621. /**
  16622. * Set a vec2 array in the shader from a number array.
  16623. * @param name Define the name of the uniform as defined in the shader
  16624. * @param value Define the value to give to the uniform
  16625. * @return the material itself allowing "fluent" like uniform updates
  16626. */
  16627. setArray2(name: string, value: number[]): ShaderMaterial;
  16628. /**
  16629. * Set a vec3 array in the shader from a number array.
  16630. * @param name Define the name of the uniform as defined in the shader
  16631. * @param value Define the value to give to the uniform
  16632. * @return the material itself allowing "fluent" like uniform updates
  16633. */
  16634. setArray3(name: string, value: number[]): ShaderMaterial;
  16635. /**
  16636. * Set a vec4 array in the shader from a number array.
  16637. * @param name Define the name of the uniform as defined in the shader
  16638. * @param value Define the value to give to the uniform
  16639. * @return the material itself allowing "fluent" like uniform updates
  16640. */
  16641. setArray4(name: string, value: number[]): ShaderMaterial;
  16642. private _checkCache;
  16643. /**
  16644. * Specifies that the submesh is ready to be used
  16645. * @param mesh defines the mesh to check
  16646. * @param subMesh defines which submesh to check
  16647. * @param useInstances specifies that instances should be used
  16648. * @returns a boolean indicating that the submesh is ready or not
  16649. */
  16650. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16651. /**
  16652. * Checks if the material is ready to render the requested mesh
  16653. * @param mesh Define the mesh to render
  16654. * @param useInstances Define whether or not the material is used with instances
  16655. * @returns true if ready, otherwise false
  16656. */
  16657. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16658. /**
  16659. * Binds the world matrix to the material
  16660. * @param world defines the world transformation matrix
  16661. * @param effectOverride - If provided, use this effect instead of internal effect
  16662. */
  16663. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16664. /**
  16665. * Binds the submesh to this material by preparing the effect and shader to draw
  16666. * @param world defines the world transformation matrix
  16667. * @param mesh defines the mesh containing the submesh
  16668. * @param subMesh defines the submesh to bind the material to
  16669. */
  16670. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16671. /**
  16672. * Binds the material to the mesh
  16673. * @param world defines the world transformation matrix
  16674. * @param mesh defines the mesh to bind the material to
  16675. * @param effectOverride - If provided, use this effect instead of internal effect
  16676. */
  16677. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16678. protected _afterBind(mesh?: Mesh): void;
  16679. /**
  16680. * Gets the active textures from the material
  16681. * @returns an array of textures
  16682. */
  16683. getActiveTextures(): BaseTexture[];
  16684. /**
  16685. * Specifies if the material uses a texture
  16686. * @param texture defines the texture to check against the material
  16687. * @returns a boolean specifying if the material uses the texture
  16688. */
  16689. hasTexture(texture: BaseTexture): boolean;
  16690. /**
  16691. * Makes a duplicate of the material, and gives it a new name
  16692. * @param name defines the new name for the duplicated material
  16693. * @returns the cloned material
  16694. */
  16695. clone(name: string): ShaderMaterial;
  16696. /**
  16697. * Disposes the material
  16698. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16699. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16700. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16701. */
  16702. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16703. /**
  16704. * Serializes this material in a JSON representation
  16705. * @returns the serialized material object
  16706. */
  16707. serialize(): any;
  16708. /**
  16709. * Creates a shader material from parsed shader material data
  16710. * @param source defines the JSON represnetation of the material
  16711. * @param scene defines the hosting scene
  16712. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16713. * @returns a new material
  16714. */
  16715. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16716. /**
  16717. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16718. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16719. * @param url defines the url to load from
  16720. * @param scene defines the hosting scene
  16721. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16722. * @returns a promise that will resolve to the new ShaderMaterial
  16723. */
  16724. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16725. /**
  16726. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16727. * @param snippetId defines the snippet to load
  16728. * @param scene defines the hosting scene
  16729. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16730. * @returns a promise that will resolve to the new ShaderMaterial
  16731. */
  16732. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16733. }
  16734. }
  16735. declare module BABYLON {
  16736. /** @hidden */
  16737. export var colorPixelShader: {
  16738. name: string;
  16739. shader: string;
  16740. };
  16741. }
  16742. declare module BABYLON {
  16743. /** @hidden */
  16744. export var colorVertexShader: {
  16745. name: string;
  16746. shader: string;
  16747. };
  16748. }
  16749. declare module BABYLON {
  16750. /**
  16751. * Line mesh
  16752. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16753. */
  16754. export class LinesMesh extends Mesh {
  16755. /**
  16756. * If vertex color should be applied to the mesh
  16757. */
  16758. readonly useVertexColor?: boolean | undefined;
  16759. /**
  16760. * If vertex alpha should be applied to the mesh
  16761. */
  16762. readonly useVertexAlpha?: boolean | undefined;
  16763. /**
  16764. * Color of the line (Default: White)
  16765. */
  16766. color: Color3;
  16767. /**
  16768. * Alpha of the line (Default: 1)
  16769. */
  16770. alpha: number;
  16771. /**
  16772. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16773. * This margin is expressed in world space coordinates, so its value may vary.
  16774. * Default value is 0.1
  16775. */
  16776. intersectionThreshold: number;
  16777. private _colorShader;
  16778. private color4;
  16779. /**
  16780. * Creates a new LinesMesh
  16781. * @param name defines the name
  16782. * @param scene defines the hosting scene
  16783. * @param parent defines the parent mesh if any
  16784. * @param source defines the optional source LinesMesh used to clone data from
  16785. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16786. * When false, achieved by calling a clone(), also passing False.
  16787. * This will make creation of children, recursive.
  16788. * @param useVertexColor defines if this LinesMesh supports vertex color
  16789. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16790. */
  16791. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16792. /**
  16793. * If vertex color should be applied to the mesh
  16794. */
  16795. useVertexColor?: boolean | undefined,
  16796. /**
  16797. * If vertex alpha should be applied to the mesh
  16798. */
  16799. useVertexAlpha?: boolean | undefined);
  16800. private _addClipPlaneDefine;
  16801. private _removeClipPlaneDefine;
  16802. isReady(): boolean;
  16803. /**
  16804. * Returns the string "LineMesh"
  16805. */
  16806. getClassName(): string;
  16807. /**
  16808. * @hidden
  16809. */
  16810. get material(): Material;
  16811. /**
  16812. * @hidden
  16813. */
  16814. set material(value: Material);
  16815. /**
  16816. * @hidden
  16817. */
  16818. get checkCollisions(): boolean;
  16819. /** @hidden */
  16820. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16821. /** @hidden */
  16822. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16823. /**
  16824. * Disposes of the line mesh
  16825. * @param doNotRecurse If children should be disposed
  16826. */
  16827. dispose(doNotRecurse?: boolean): void;
  16828. /**
  16829. * Returns a new LineMesh object cloned from the current one.
  16830. */
  16831. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16832. /**
  16833. * Creates a new InstancedLinesMesh object from the mesh model.
  16834. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16835. * @param name defines the name of the new instance
  16836. * @returns a new InstancedLinesMesh
  16837. */
  16838. createInstance(name: string): InstancedLinesMesh;
  16839. }
  16840. /**
  16841. * Creates an instance based on a source LinesMesh
  16842. */
  16843. export class InstancedLinesMesh extends InstancedMesh {
  16844. /**
  16845. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16846. * This margin is expressed in world space coordinates, so its value may vary.
  16847. * Initilized with the intersectionThreshold value of the source LinesMesh
  16848. */
  16849. intersectionThreshold: number;
  16850. constructor(name: string, source: LinesMesh);
  16851. /**
  16852. * Returns the string "InstancedLinesMesh".
  16853. */
  16854. getClassName(): string;
  16855. }
  16856. }
  16857. declare module BABYLON {
  16858. /** @hidden */
  16859. export var linePixelShader: {
  16860. name: string;
  16861. shader: string;
  16862. };
  16863. }
  16864. declare module BABYLON {
  16865. /** @hidden */
  16866. export var lineVertexShader: {
  16867. name: string;
  16868. shader: string;
  16869. };
  16870. }
  16871. declare module BABYLON {
  16872. interface Scene {
  16873. /** @hidden */
  16874. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16875. }
  16876. interface AbstractMesh {
  16877. /**
  16878. * Gets the edgesRenderer associated with the mesh
  16879. */
  16880. edgesRenderer: Nullable<EdgesRenderer>;
  16881. }
  16882. interface LinesMesh {
  16883. /**
  16884. * Enables the edge rendering mode on the mesh.
  16885. * This mode makes the mesh edges visible
  16886. * @param epsilon defines the maximal distance between two angles to detect a face
  16887. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16888. * @returns the currentAbstractMesh
  16889. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16890. */
  16891. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16892. }
  16893. interface InstancedLinesMesh {
  16894. /**
  16895. * Enables the edge rendering mode on the mesh.
  16896. * This mode makes the mesh edges visible
  16897. * @param epsilon defines the maximal distance between two angles to detect a face
  16898. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16899. * @returns the current InstancedLinesMesh
  16900. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16901. */
  16902. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16903. }
  16904. /**
  16905. * Defines the minimum contract an Edges renderer should follow.
  16906. */
  16907. export interface IEdgesRenderer extends IDisposable {
  16908. /**
  16909. * Gets or sets a boolean indicating if the edgesRenderer is active
  16910. */
  16911. isEnabled: boolean;
  16912. /**
  16913. * Renders the edges of the attached mesh,
  16914. */
  16915. render(): void;
  16916. /**
  16917. * Checks wether or not the edges renderer is ready to render.
  16918. * @return true if ready, otherwise false.
  16919. */
  16920. isReady(): boolean;
  16921. /**
  16922. * List of instances to render in case the source mesh has instances
  16923. */
  16924. customInstances: SmartArray<Matrix>;
  16925. }
  16926. /**
  16927. * Defines the additional options of the edges renderer
  16928. */
  16929. export interface IEdgesRendererOptions {
  16930. /**
  16931. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16932. * If not defined, the default value is true
  16933. */
  16934. useAlternateEdgeFinder?: boolean;
  16935. /**
  16936. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16937. * If not defined, the default value is true.
  16938. * 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)
  16939. * This option is used only if useAlternateEdgeFinder = true
  16940. */
  16941. useFastVertexMerger?: boolean;
  16942. /**
  16943. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  16944. * The default value is 1e-6
  16945. * This option is used only if useAlternateEdgeFinder = true
  16946. */
  16947. epsilonVertexMerge?: number;
  16948. /**
  16949. * 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
  16950. * 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.
  16951. * This option is used only if useAlternateEdgeFinder = true
  16952. */
  16953. applyTessellation?: boolean;
  16954. /**
  16955. * 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
  16956. * The default value is 1e-6
  16957. * This option is used only if useAlternateEdgeFinder = true
  16958. */
  16959. epsilonVertexAligned?: number;
  16960. }
  16961. /**
  16962. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16963. */
  16964. export class EdgesRenderer implements IEdgesRenderer {
  16965. /**
  16966. * Define the size of the edges with an orthographic camera
  16967. */
  16968. edgesWidthScalerForOrthographic: number;
  16969. /**
  16970. * Define the size of the edges with a perspective camera
  16971. */
  16972. edgesWidthScalerForPerspective: number;
  16973. protected _source: AbstractMesh;
  16974. protected _linesPositions: number[];
  16975. protected _linesNormals: number[];
  16976. protected _linesIndices: number[];
  16977. protected _epsilon: number;
  16978. protected _indicesCount: number;
  16979. protected _lineShader: ShaderMaterial;
  16980. protected _ib: DataBuffer;
  16981. protected _buffers: {
  16982. [key: string]: Nullable<VertexBuffer>;
  16983. };
  16984. protected _buffersForInstances: {
  16985. [key: string]: Nullable<VertexBuffer>;
  16986. };
  16987. protected _checkVerticesInsteadOfIndices: boolean;
  16988. protected _options: Nullable<IEdgesRendererOptions>;
  16989. private _meshRebuildObserver;
  16990. private _meshDisposeObserver;
  16991. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16992. isEnabled: boolean;
  16993. /**
  16994. * List of instances to render in case the source mesh has instances
  16995. */
  16996. customInstances: SmartArray<Matrix>;
  16997. private static GetShader;
  16998. /**
  16999. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17000. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17001. * @param source Mesh used to create edges
  17002. * @param epsilon sum of angles in adjacency to check for edge
  17003. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17004. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17005. * @param options The options to apply when generating the edges
  17006. */
  17007. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17008. protected _prepareRessources(): void;
  17009. /** @hidden */
  17010. _rebuild(): void;
  17011. /**
  17012. * Releases the required resources for the edges renderer
  17013. */
  17014. dispose(): void;
  17015. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17016. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17017. /**
  17018. * Checks if the pair of p0 and p1 is en edge
  17019. * @param faceIndex
  17020. * @param edge
  17021. * @param faceNormals
  17022. * @param p0
  17023. * @param p1
  17024. * @private
  17025. */
  17026. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17027. /**
  17028. * push line into the position, normal and index buffer
  17029. * @protected
  17030. */
  17031. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17032. /**
  17033. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17034. */
  17035. private _tessellateTriangle;
  17036. private _generateEdgesLinesAlternate;
  17037. /**
  17038. * Generates lines edges from adjacencjes
  17039. * @private
  17040. */
  17041. _generateEdgesLines(): void;
  17042. /**
  17043. * Checks wether or not the edges renderer is ready to render.
  17044. * @return true if ready, otherwise false.
  17045. */
  17046. isReady(): boolean;
  17047. /**
  17048. * Renders the edges of the attached mesh,
  17049. */
  17050. render(): void;
  17051. }
  17052. /**
  17053. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17054. */
  17055. export class LineEdgesRenderer extends EdgesRenderer {
  17056. /**
  17057. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17058. * @param source LineMesh used to generate edges
  17059. * @param epsilon not important (specified angle for edge detection)
  17060. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17061. */
  17062. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17063. /**
  17064. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17065. */
  17066. _generateEdgesLines(): void;
  17067. }
  17068. }
  17069. declare module BABYLON {
  17070. /**
  17071. * This represents the object necessary to create a rendering group.
  17072. * This is exclusively used and created by the rendering manager.
  17073. * To modify the behavior, you use the available helpers in your scene or meshes.
  17074. * @hidden
  17075. */
  17076. export class RenderingGroup {
  17077. index: number;
  17078. private static _zeroVector;
  17079. private _scene;
  17080. private _opaqueSubMeshes;
  17081. private _transparentSubMeshes;
  17082. private _alphaTestSubMeshes;
  17083. private _depthOnlySubMeshes;
  17084. private _particleSystems;
  17085. private _spriteManagers;
  17086. private _opaqueSortCompareFn;
  17087. private _alphaTestSortCompareFn;
  17088. private _transparentSortCompareFn;
  17089. private _renderOpaque;
  17090. private _renderAlphaTest;
  17091. private _renderTransparent;
  17092. /** @hidden */
  17093. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17094. onBeforeTransparentRendering: () => void;
  17095. /**
  17096. * Set the opaque sort comparison function.
  17097. * If null the sub meshes will be render in the order they were created
  17098. */
  17099. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17100. /**
  17101. * Set the alpha test sort comparison function.
  17102. * If null the sub meshes will be render in the order they were created
  17103. */
  17104. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17105. /**
  17106. * Set the transparent sort comparison function.
  17107. * If null the sub meshes will be render in the order they were created
  17108. */
  17109. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17110. /**
  17111. * Creates a new rendering group.
  17112. * @param index The rendering group index
  17113. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17114. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17115. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17116. */
  17117. 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>);
  17118. /**
  17119. * Render all the sub meshes contained in the group.
  17120. * @param customRenderFunction Used to override the default render behaviour of the group.
  17121. * @returns true if rendered some submeshes.
  17122. */
  17123. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17124. /**
  17125. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17126. * @param subMeshes The submeshes to render
  17127. */
  17128. private renderOpaqueSorted;
  17129. /**
  17130. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17131. * @param subMeshes The submeshes to render
  17132. */
  17133. private renderAlphaTestSorted;
  17134. /**
  17135. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17136. * @param subMeshes The submeshes to render
  17137. */
  17138. private renderTransparentSorted;
  17139. /**
  17140. * Renders the submeshes in a specified order.
  17141. * @param subMeshes The submeshes to sort before render
  17142. * @param sortCompareFn The comparison function use to sort
  17143. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17144. * @param transparent Specifies to activate blending if true
  17145. */
  17146. private static renderSorted;
  17147. /**
  17148. * Renders the submeshes in the order they were dispatched (no sort applied).
  17149. * @param subMeshes The submeshes to render
  17150. */
  17151. private static renderUnsorted;
  17152. /**
  17153. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17154. * are rendered back to front if in the same alpha index.
  17155. *
  17156. * @param a The first submesh
  17157. * @param b The second submesh
  17158. * @returns The result of the comparison
  17159. */
  17160. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17161. /**
  17162. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17163. * are rendered back to front.
  17164. *
  17165. * @param a The first submesh
  17166. * @param b The second submesh
  17167. * @returns The result of the comparison
  17168. */
  17169. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17170. /**
  17171. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17172. * are rendered front to back (prevent overdraw).
  17173. *
  17174. * @param a The first submesh
  17175. * @param b The second submesh
  17176. * @returns The result of the comparison
  17177. */
  17178. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17179. /**
  17180. * Resets the different lists of submeshes to prepare a new frame.
  17181. */
  17182. prepare(): void;
  17183. dispose(): void;
  17184. /**
  17185. * Inserts the submesh in its correct queue depending on its material.
  17186. * @param subMesh The submesh to dispatch
  17187. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17188. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17189. */
  17190. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17191. dispatchSprites(spriteManager: ISpriteManager): void;
  17192. dispatchParticles(particleSystem: IParticleSystem): void;
  17193. private _renderParticles;
  17194. private _renderSprites;
  17195. }
  17196. }
  17197. declare module BABYLON {
  17198. /**
  17199. * Interface describing the different options available in the rendering manager
  17200. * regarding Auto Clear between groups.
  17201. */
  17202. export interface IRenderingManagerAutoClearSetup {
  17203. /**
  17204. * Defines whether or not autoclear is enable.
  17205. */
  17206. autoClear: boolean;
  17207. /**
  17208. * Defines whether or not to autoclear the depth buffer.
  17209. */
  17210. depth: boolean;
  17211. /**
  17212. * Defines whether or not to autoclear the stencil buffer.
  17213. */
  17214. stencil: boolean;
  17215. }
  17216. /**
  17217. * This class is used by the onRenderingGroupObservable
  17218. */
  17219. export class RenderingGroupInfo {
  17220. /**
  17221. * The Scene that being rendered
  17222. */
  17223. scene: Scene;
  17224. /**
  17225. * The camera currently used for the rendering pass
  17226. */
  17227. camera: Nullable<Camera>;
  17228. /**
  17229. * The ID of the renderingGroup being processed
  17230. */
  17231. renderingGroupId: number;
  17232. }
  17233. /**
  17234. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17235. * It is enable to manage the different groups as well as the different necessary sort functions.
  17236. * This should not be used directly aside of the few static configurations
  17237. */
  17238. export class RenderingManager {
  17239. /**
  17240. * The max id used for rendering groups (not included)
  17241. */
  17242. static MAX_RENDERINGGROUPS: number;
  17243. /**
  17244. * The min id used for rendering groups (included)
  17245. */
  17246. static MIN_RENDERINGGROUPS: number;
  17247. /**
  17248. * Used to globally prevent autoclearing scenes.
  17249. */
  17250. static AUTOCLEAR: boolean;
  17251. /**
  17252. * @hidden
  17253. */
  17254. _useSceneAutoClearSetup: boolean;
  17255. private _scene;
  17256. private _renderingGroups;
  17257. private _depthStencilBufferAlreadyCleaned;
  17258. private _autoClearDepthStencil;
  17259. private _customOpaqueSortCompareFn;
  17260. private _customAlphaTestSortCompareFn;
  17261. private _customTransparentSortCompareFn;
  17262. private _renderingGroupInfo;
  17263. /**
  17264. * Instantiates a new rendering group for a particular scene
  17265. * @param scene Defines the scene the groups belongs to
  17266. */
  17267. constructor(scene: Scene);
  17268. private _clearDepthStencilBuffer;
  17269. /**
  17270. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17271. * @hidden
  17272. */
  17273. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17274. /**
  17275. * Resets the different information of the group to prepare a new frame
  17276. * @hidden
  17277. */
  17278. reset(): void;
  17279. /**
  17280. * Dispose and release the group and its associated resources.
  17281. * @hidden
  17282. */
  17283. dispose(): void;
  17284. /**
  17285. * Clear the info related to rendering groups preventing retention points during dispose.
  17286. */
  17287. freeRenderingGroups(): void;
  17288. private _prepareRenderingGroup;
  17289. /**
  17290. * Add a sprite manager to the rendering manager in order to render it this frame.
  17291. * @param spriteManager Define the sprite manager to render
  17292. */
  17293. dispatchSprites(spriteManager: ISpriteManager): void;
  17294. /**
  17295. * Add a particle system to the rendering manager in order to render it this frame.
  17296. * @param particleSystem Define the particle system to render
  17297. */
  17298. dispatchParticles(particleSystem: IParticleSystem): void;
  17299. /**
  17300. * Add a submesh to the manager in order to render it this frame
  17301. * @param subMesh The submesh to dispatch
  17302. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17303. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17304. */
  17305. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17306. /**
  17307. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17308. * This allowed control for front to back rendering or reversly depending of the special needs.
  17309. *
  17310. * @param renderingGroupId The rendering group id corresponding to its index
  17311. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17312. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17313. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17314. */
  17315. 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;
  17316. /**
  17317. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17318. *
  17319. * @param renderingGroupId The rendering group id corresponding to its index
  17320. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17321. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17322. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17323. */
  17324. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17325. /**
  17326. * Gets the current auto clear configuration for one rendering group of the rendering
  17327. * manager.
  17328. * @param index the rendering group index to get the information for
  17329. * @returns The auto clear setup for the requested rendering group
  17330. */
  17331. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17332. }
  17333. }
  17334. declare module BABYLON {
  17335. /**
  17336. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17337. */
  17338. export interface ICustomShaderOptions {
  17339. /**
  17340. * Gets or sets the custom shader name to use
  17341. */
  17342. shaderName: string;
  17343. /**
  17344. * The list of attribute names used in the shader
  17345. */
  17346. attributes?: string[];
  17347. /**
  17348. * The list of unifrom names used in the shader
  17349. */
  17350. uniforms?: string[];
  17351. /**
  17352. * The list of sampler names used in the shader
  17353. */
  17354. samplers?: string[];
  17355. /**
  17356. * The list of defines used in the shader
  17357. */
  17358. defines?: string[];
  17359. }
  17360. /**
  17361. * Interface to implement to create a shadow generator compatible with BJS.
  17362. */
  17363. export interface IShadowGenerator {
  17364. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17365. id: string;
  17366. /**
  17367. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17368. * @returns The render target texture if present otherwise, null
  17369. */
  17370. getShadowMap(): Nullable<RenderTargetTexture>;
  17371. /**
  17372. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17373. * @param subMesh The submesh we want to render in the shadow map
  17374. * @param useInstances Defines wether will draw in the map using instances
  17375. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17376. * @returns true if ready otherwise, false
  17377. */
  17378. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17379. /**
  17380. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17381. * @param defines Defines of the material we want to update
  17382. * @param lightIndex Index of the light in the enabled light list of the material
  17383. */
  17384. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17385. /**
  17386. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17387. * defined in the generator but impacting the effect).
  17388. * It implies the unifroms available on the materials are the standard BJS ones.
  17389. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17390. * @param effect The effect we are binfing the information for
  17391. */
  17392. bindShadowLight(lightIndex: string, effect: Effect): void;
  17393. /**
  17394. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17395. * (eq to shadow prjection matrix * light transform matrix)
  17396. * @returns The transform matrix used to create the shadow map
  17397. */
  17398. getTransformMatrix(): Matrix;
  17399. /**
  17400. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17401. * Cube and 2D textures for instance.
  17402. */
  17403. recreateShadowMap(): void;
  17404. /**
  17405. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17406. * @param onCompiled Callback triggered at the and of the effects compilation
  17407. * @param options Sets of optional options forcing the compilation with different modes
  17408. */
  17409. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17410. useInstances: boolean;
  17411. }>): void;
  17412. /**
  17413. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17414. * @param options Sets of optional options forcing the compilation with different modes
  17415. * @returns A promise that resolves when the compilation completes
  17416. */
  17417. forceCompilationAsync(options?: Partial<{
  17418. useInstances: boolean;
  17419. }>): Promise<void>;
  17420. /**
  17421. * Serializes the shadow generator setup to a json object.
  17422. * @returns The serialized JSON object
  17423. */
  17424. serialize(): any;
  17425. /**
  17426. * Disposes the Shadow map and related Textures and effects.
  17427. */
  17428. dispose(): void;
  17429. }
  17430. /**
  17431. * Default implementation IShadowGenerator.
  17432. * This is the main object responsible of generating shadows in the framework.
  17433. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17434. */
  17435. export class ShadowGenerator implements IShadowGenerator {
  17436. /**
  17437. * Name of the shadow generator class
  17438. */
  17439. static CLASSNAME: string;
  17440. /**
  17441. * Shadow generator mode None: no filtering applied.
  17442. */
  17443. static readonly FILTER_NONE: number;
  17444. /**
  17445. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17446. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17447. */
  17448. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17449. /**
  17450. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17451. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17452. */
  17453. static readonly FILTER_POISSONSAMPLING: number;
  17454. /**
  17455. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17456. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17457. */
  17458. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17459. /**
  17460. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17461. * edge artifacts on steep falloff.
  17462. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17463. */
  17464. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17465. /**
  17466. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17467. * edge artifacts on steep falloff.
  17468. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17469. */
  17470. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17471. /**
  17472. * Shadow generator mode PCF: Percentage Closer Filtering
  17473. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17474. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17475. */
  17476. static readonly FILTER_PCF: number;
  17477. /**
  17478. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17479. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17480. * Contact Hardening
  17481. */
  17482. static readonly FILTER_PCSS: number;
  17483. /**
  17484. * Reserved for PCF and PCSS
  17485. * Highest Quality.
  17486. *
  17487. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17488. *
  17489. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17490. */
  17491. static readonly QUALITY_HIGH: number;
  17492. /**
  17493. * Reserved for PCF and PCSS
  17494. * Good tradeoff for quality/perf cross devices
  17495. *
  17496. * Execute PCF on a 3*3 kernel.
  17497. *
  17498. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17499. */
  17500. static readonly QUALITY_MEDIUM: number;
  17501. /**
  17502. * Reserved for PCF and PCSS
  17503. * The lowest quality but the fastest.
  17504. *
  17505. * Execute PCF on a 1*1 kernel.
  17506. *
  17507. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17508. */
  17509. static readonly QUALITY_LOW: number;
  17510. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17511. id: string;
  17512. /** Gets or sets the custom shader name to use */
  17513. customShaderOptions: ICustomShaderOptions;
  17514. /**
  17515. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17516. */
  17517. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17518. /**
  17519. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17520. */
  17521. onAfterShadowMapRenderObservable: Observable<Effect>;
  17522. /**
  17523. * Observable triggered before a mesh is rendered in the shadow map.
  17524. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17525. */
  17526. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17527. /**
  17528. * Observable triggered after a mesh is rendered in the shadow map.
  17529. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17530. */
  17531. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17532. protected _bias: number;
  17533. /**
  17534. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17535. */
  17536. get bias(): number;
  17537. /**
  17538. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17539. */
  17540. set bias(bias: number);
  17541. protected _normalBias: number;
  17542. /**
  17543. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17544. */
  17545. get normalBias(): number;
  17546. /**
  17547. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17548. */
  17549. set normalBias(normalBias: number);
  17550. protected _blurBoxOffset: number;
  17551. /**
  17552. * Gets the blur box offset: offset applied during the blur pass.
  17553. * Only useful if useKernelBlur = false
  17554. */
  17555. get blurBoxOffset(): number;
  17556. /**
  17557. * Sets the blur box offset: offset applied during the blur pass.
  17558. * Only useful if useKernelBlur = false
  17559. */
  17560. set blurBoxOffset(value: number);
  17561. protected _blurScale: number;
  17562. /**
  17563. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17564. * 2 means half of the size.
  17565. */
  17566. get blurScale(): number;
  17567. /**
  17568. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17569. * 2 means half of the size.
  17570. */
  17571. set blurScale(value: number);
  17572. protected _blurKernel: number;
  17573. /**
  17574. * Gets the blur kernel: kernel size of the blur pass.
  17575. * Only useful if useKernelBlur = true
  17576. */
  17577. get blurKernel(): number;
  17578. /**
  17579. * Sets the blur kernel: kernel size of the blur pass.
  17580. * Only useful if useKernelBlur = true
  17581. */
  17582. set blurKernel(value: number);
  17583. protected _useKernelBlur: boolean;
  17584. /**
  17585. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17586. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17587. */
  17588. get useKernelBlur(): boolean;
  17589. /**
  17590. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17591. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17592. */
  17593. set useKernelBlur(value: boolean);
  17594. protected _depthScale: number;
  17595. /**
  17596. * Gets the depth scale used in ESM mode.
  17597. */
  17598. get depthScale(): number;
  17599. /**
  17600. * Sets the depth scale used in ESM mode.
  17601. * This can override the scale stored on the light.
  17602. */
  17603. set depthScale(value: number);
  17604. protected _validateFilter(filter: number): number;
  17605. protected _filter: number;
  17606. /**
  17607. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17608. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17609. */
  17610. get filter(): number;
  17611. /**
  17612. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17613. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17614. */
  17615. set filter(value: number);
  17616. /**
  17617. * Gets if the current filter is set to Poisson Sampling.
  17618. */
  17619. get usePoissonSampling(): boolean;
  17620. /**
  17621. * Sets the current filter to Poisson Sampling.
  17622. */
  17623. set usePoissonSampling(value: boolean);
  17624. /**
  17625. * Gets if the current filter is set to ESM.
  17626. */
  17627. get useExponentialShadowMap(): boolean;
  17628. /**
  17629. * Sets the current filter is to ESM.
  17630. */
  17631. set useExponentialShadowMap(value: boolean);
  17632. /**
  17633. * Gets if the current filter is set to filtered ESM.
  17634. */
  17635. get useBlurExponentialShadowMap(): boolean;
  17636. /**
  17637. * Gets if the current filter is set to filtered ESM.
  17638. */
  17639. set useBlurExponentialShadowMap(value: boolean);
  17640. /**
  17641. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17642. * exponential to prevent steep falloff artifacts).
  17643. */
  17644. get useCloseExponentialShadowMap(): boolean;
  17645. /**
  17646. * Sets the current filter to "close ESM" (using the inverse of the
  17647. * exponential to prevent steep falloff artifacts).
  17648. */
  17649. set useCloseExponentialShadowMap(value: boolean);
  17650. /**
  17651. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17652. * exponential to prevent steep falloff artifacts).
  17653. */
  17654. get useBlurCloseExponentialShadowMap(): boolean;
  17655. /**
  17656. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17657. * exponential to prevent steep falloff artifacts).
  17658. */
  17659. set useBlurCloseExponentialShadowMap(value: boolean);
  17660. /**
  17661. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17662. */
  17663. get usePercentageCloserFiltering(): boolean;
  17664. /**
  17665. * Sets the current filter to "PCF" (percentage closer filtering).
  17666. */
  17667. set usePercentageCloserFiltering(value: boolean);
  17668. protected _filteringQuality: number;
  17669. /**
  17670. * Gets the PCF or PCSS Quality.
  17671. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17672. */
  17673. get filteringQuality(): number;
  17674. /**
  17675. * Sets the PCF or PCSS Quality.
  17676. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17677. */
  17678. set filteringQuality(filteringQuality: number);
  17679. /**
  17680. * Gets if the current filter is set to "PCSS" (contact hardening).
  17681. */
  17682. get useContactHardeningShadow(): boolean;
  17683. /**
  17684. * Sets the current filter to "PCSS" (contact hardening).
  17685. */
  17686. set useContactHardeningShadow(value: boolean);
  17687. protected _contactHardeningLightSizeUVRatio: number;
  17688. /**
  17689. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17690. * Using a ratio helps keeping shape stability independently of the map size.
  17691. *
  17692. * It does not account for the light projection as it was having too much
  17693. * instability during the light setup or during light position changes.
  17694. *
  17695. * Only valid if useContactHardeningShadow is true.
  17696. */
  17697. get contactHardeningLightSizeUVRatio(): number;
  17698. /**
  17699. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17700. * Using a ratio helps keeping shape stability independently of the map size.
  17701. *
  17702. * It does not account for the light projection as it was having too much
  17703. * instability during the light setup or during light position changes.
  17704. *
  17705. * Only valid if useContactHardeningShadow is true.
  17706. */
  17707. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17708. protected _darkness: number;
  17709. /** Gets or sets the actual darkness of a shadow */
  17710. get darkness(): number;
  17711. set darkness(value: number);
  17712. /**
  17713. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17714. * 0 means strongest and 1 would means no shadow.
  17715. * @returns the darkness.
  17716. */
  17717. getDarkness(): number;
  17718. /**
  17719. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17720. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17721. * @returns the shadow generator allowing fluent coding.
  17722. */
  17723. setDarkness(darkness: number): ShadowGenerator;
  17724. protected _transparencyShadow: boolean;
  17725. /** Gets or sets the ability to have transparent shadow */
  17726. get transparencyShadow(): boolean;
  17727. set transparencyShadow(value: boolean);
  17728. /**
  17729. * Sets the ability to have transparent shadow (boolean).
  17730. * @param transparent True if transparent else False
  17731. * @returns the shadow generator allowing fluent coding
  17732. */
  17733. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17734. /**
  17735. * Enables or disables shadows with varying strength based on the transparency
  17736. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17737. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17738. * mesh.visibility * alphaTexture.a
  17739. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17740. */
  17741. enableSoftTransparentShadow: boolean;
  17742. protected _shadowMap: Nullable<RenderTargetTexture>;
  17743. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17744. /**
  17745. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17746. * @returns The render target texture if present otherwise, null
  17747. */
  17748. getShadowMap(): Nullable<RenderTargetTexture>;
  17749. /**
  17750. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17751. * @returns The render target texture if the shadow map is present otherwise, null
  17752. */
  17753. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17754. /**
  17755. * Gets the class name of that object
  17756. * @returns "ShadowGenerator"
  17757. */
  17758. getClassName(): string;
  17759. /**
  17760. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17761. * @param mesh Mesh to add
  17762. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17763. * @returns the Shadow Generator itself
  17764. */
  17765. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17766. /**
  17767. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17768. * @param mesh Mesh to remove
  17769. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17770. * @returns the Shadow Generator itself
  17771. */
  17772. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17773. /**
  17774. * Controls the extent to which the shadows fade out at the edge of the frustum
  17775. */
  17776. frustumEdgeFalloff: number;
  17777. protected _light: IShadowLight;
  17778. /**
  17779. * Returns the associated light object.
  17780. * @returns the light generating the shadow
  17781. */
  17782. getLight(): IShadowLight;
  17783. /**
  17784. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17785. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17786. * It might on the other hand introduce peter panning.
  17787. */
  17788. forceBackFacesOnly: boolean;
  17789. protected _scene: Scene;
  17790. protected _lightDirection: Vector3;
  17791. protected _effect: Effect;
  17792. protected _viewMatrix: Matrix;
  17793. protected _projectionMatrix: Matrix;
  17794. protected _transformMatrix: Matrix;
  17795. protected _cachedPosition: Vector3;
  17796. protected _cachedDirection: Vector3;
  17797. protected _cachedDefines: string;
  17798. protected _currentRenderID: number;
  17799. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17800. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17801. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17802. protected _blurPostProcesses: PostProcess[];
  17803. protected _mapSize: number;
  17804. protected _currentFaceIndex: number;
  17805. protected _currentFaceIndexCache: number;
  17806. protected _textureType: number;
  17807. protected _defaultTextureMatrix: Matrix;
  17808. protected _storedUniqueId: Nullable<number>;
  17809. /** @hidden */
  17810. static _SceneComponentInitialization: (scene: Scene) => void;
  17811. /**
  17812. * Creates a ShadowGenerator object.
  17813. * A ShadowGenerator is the required tool to use the shadows.
  17814. * Each light casting shadows needs to use its own ShadowGenerator.
  17815. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17816. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17817. * @param light The light object generating the shadows.
  17818. * @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.
  17819. */
  17820. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17821. protected _initializeGenerator(): void;
  17822. protected _createTargetRenderTexture(): void;
  17823. protected _initializeShadowMap(): void;
  17824. protected _initializeBlurRTTAndPostProcesses(): void;
  17825. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17826. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17827. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17828. protected _applyFilterValues(): void;
  17829. /**
  17830. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17831. * @param onCompiled Callback triggered at the and of the effects compilation
  17832. * @param options Sets of optional options forcing the compilation with different modes
  17833. */
  17834. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17835. useInstances: boolean;
  17836. }>): void;
  17837. /**
  17838. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17839. * @param options Sets of optional options forcing the compilation with different modes
  17840. * @returns A promise that resolves when the compilation completes
  17841. */
  17842. forceCompilationAsync(options?: Partial<{
  17843. useInstances: boolean;
  17844. }>): Promise<void>;
  17845. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17846. private _prepareShadowDefines;
  17847. /**
  17848. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17849. * @param subMesh The submesh we want to render in the shadow map
  17850. * @param useInstances Defines wether will draw in the map using instances
  17851. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17852. * @returns true if ready otherwise, false
  17853. */
  17854. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17855. /**
  17856. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17857. * @param defines Defines of the material we want to update
  17858. * @param lightIndex Index of the light in the enabled light list of the material
  17859. */
  17860. prepareDefines(defines: any, lightIndex: number): void;
  17861. /**
  17862. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17863. * defined in the generator but impacting the effect).
  17864. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17865. * @param effect The effect we are binfing the information for
  17866. */
  17867. bindShadowLight(lightIndex: string, effect: Effect): void;
  17868. /**
  17869. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17870. * (eq to shadow prjection matrix * light transform matrix)
  17871. * @returns The transform matrix used to create the shadow map
  17872. */
  17873. getTransformMatrix(): Matrix;
  17874. /**
  17875. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17876. * Cube and 2D textures for instance.
  17877. */
  17878. recreateShadowMap(): void;
  17879. protected _disposeBlurPostProcesses(): void;
  17880. protected _disposeRTTandPostProcesses(): void;
  17881. /**
  17882. * Disposes the ShadowGenerator.
  17883. * Returns nothing.
  17884. */
  17885. dispose(): void;
  17886. /**
  17887. * Serializes the shadow generator setup to a json object.
  17888. * @returns The serialized JSON object
  17889. */
  17890. serialize(): any;
  17891. /**
  17892. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17893. * @param parsedShadowGenerator The JSON object to parse
  17894. * @param scene The scene to create the shadow map for
  17895. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17896. * @returns The parsed shadow generator
  17897. */
  17898. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17899. }
  17900. }
  17901. declare module BABYLON {
  17902. /**
  17903. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17904. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17905. * 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.
  17906. */
  17907. export abstract class Light extends Node {
  17908. /**
  17909. * Falloff Default: light is falling off following the material specification:
  17910. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17911. */
  17912. static readonly FALLOFF_DEFAULT: number;
  17913. /**
  17914. * Falloff Physical: light is falling off following the inverse squared distance law.
  17915. */
  17916. static readonly FALLOFF_PHYSICAL: number;
  17917. /**
  17918. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17919. * to enhance interoperability with other engines.
  17920. */
  17921. static readonly FALLOFF_GLTF: number;
  17922. /**
  17923. * Falloff Standard: light is falling off like in the standard material
  17924. * to enhance interoperability with other materials.
  17925. */
  17926. static readonly FALLOFF_STANDARD: number;
  17927. /**
  17928. * If every light affecting the material is in this lightmapMode,
  17929. * material.lightmapTexture adds or multiplies
  17930. * (depends on material.useLightmapAsShadowmap)
  17931. * after every other light calculations.
  17932. */
  17933. static readonly LIGHTMAP_DEFAULT: number;
  17934. /**
  17935. * material.lightmapTexture as only diffuse lighting from this light
  17936. * adds only specular lighting from this light
  17937. * adds dynamic shadows
  17938. */
  17939. static readonly LIGHTMAP_SPECULAR: number;
  17940. /**
  17941. * material.lightmapTexture as only lighting
  17942. * no light calculation from this light
  17943. * only adds dynamic shadows from this light
  17944. */
  17945. static readonly LIGHTMAP_SHADOWSONLY: number;
  17946. /**
  17947. * Each light type uses the default quantity according to its type:
  17948. * point/spot lights use luminous intensity
  17949. * directional lights use illuminance
  17950. */
  17951. static readonly INTENSITYMODE_AUTOMATIC: number;
  17952. /**
  17953. * lumen (lm)
  17954. */
  17955. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17956. /**
  17957. * candela (lm/sr)
  17958. */
  17959. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17960. /**
  17961. * lux (lm/m^2)
  17962. */
  17963. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17964. /**
  17965. * nit (cd/m^2)
  17966. */
  17967. static readonly INTENSITYMODE_LUMINANCE: number;
  17968. /**
  17969. * Light type const id of the point light.
  17970. */
  17971. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17972. /**
  17973. * Light type const id of the directional light.
  17974. */
  17975. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17976. /**
  17977. * Light type const id of the spot light.
  17978. */
  17979. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17980. /**
  17981. * Light type const id of the hemispheric light.
  17982. */
  17983. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17984. /**
  17985. * Diffuse gives the basic color to an object.
  17986. */
  17987. diffuse: Color3;
  17988. /**
  17989. * Specular produces a highlight color on an object.
  17990. * Note: This is note affecting PBR materials.
  17991. */
  17992. specular: Color3;
  17993. /**
  17994. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17995. * falling off base on range or angle.
  17996. * This can be set to any values in Light.FALLOFF_x.
  17997. *
  17998. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17999. * other types of materials.
  18000. */
  18001. falloffType: number;
  18002. /**
  18003. * Strength of the light.
  18004. * Note: By default it is define in the framework own unit.
  18005. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18006. */
  18007. intensity: number;
  18008. private _range;
  18009. protected _inverseSquaredRange: number;
  18010. /**
  18011. * Defines how far from the source the light is impacting in scene units.
  18012. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18013. */
  18014. get range(): number;
  18015. /**
  18016. * Defines how far from the source the light is impacting in scene units.
  18017. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18018. */
  18019. set range(value: number);
  18020. /**
  18021. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18022. * of light.
  18023. */
  18024. private _photometricScale;
  18025. private _intensityMode;
  18026. /**
  18027. * Gets the photometric scale used to interpret the intensity.
  18028. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18029. */
  18030. get intensityMode(): number;
  18031. /**
  18032. * Sets the photometric scale used to interpret the intensity.
  18033. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18034. */
  18035. set intensityMode(value: number);
  18036. private _radius;
  18037. /**
  18038. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18039. */
  18040. get radius(): number;
  18041. /**
  18042. * sets the light radius used by PBR Materials to simulate soft area lights.
  18043. */
  18044. set radius(value: number);
  18045. private _renderPriority;
  18046. /**
  18047. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18048. * exceeding the number allowed of the materials.
  18049. */
  18050. renderPriority: number;
  18051. private _shadowEnabled;
  18052. /**
  18053. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18054. * the current shadow generator.
  18055. */
  18056. get shadowEnabled(): boolean;
  18057. /**
  18058. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18059. * the current shadow generator.
  18060. */
  18061. set shadowEnabled(value: boolean);
  18062. private _includedOnlyMeshes;
  18063. /**
  18064. * Gets the only meshes impacted by this light.
  18065. */
  18066. get includedOnlyMeshes(): AbstractMesh[];
  18067. /**
  18068. * Sets the only meshes impacted by this light.
  18069. */
  18070. set includedOnlyMeshes(value: AbstractMesh[]);
  18071. private _excludedMeshes;
  18072. /**
  18073. * Gets the meshes not impacted by this light.
  18074. */
  18075. get excludedMeshes(): AbstractMesh[];
  18076. /**
  18077. * Sets the meshes not impacted by this light.
  18078. */
  18079. set excludedMeshes(value: AbstractMesh[]);
  18080. private _excludeWithLayerMask;
  18081. /**
  18082. * Gets the layer id use to find what meshes are not impacted by the light.
  18083. * Inactive if 0
  18084. */
  18085. get excludeWithLayerMask(): number;
  18086. /**
  18087. * Sets the layer id use to find what meshes are not impacted by the light.
  18088. * Inactive if 0
  18089. */
  18090. set excludeWithLayerMask(value: number);
  18091. private _includeOnlyWithLayerMask;
  18092. /**
  18093. * Gets the layer id use to find what meshes are impacted by the light.
  18094. * Inactive if 0
  18095. */
  18096. get includeOnlyWithLayerMask(): number;
  18097. /**
  18098. * Sets the layer id use to find what meshes are impacted by the light.
  18099. * Inactive if 0
  18100. */
  18101. set includeOnlyWithLayerMask(value: number);
  18102. private _lightmapMode;
  18103. /**
  18104. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18105. */
  18106. get lightmapMode(): number;
  18107. /**
  18108. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18109. */
  18110. set lightmapMode(value: number);
  18111. /**
  18112. * Shadow generator associted to the light.
  18113. * @hidden Internal use only.
  18114. */
  18115. _shadowGenerator: Nullable<IShadowGenerator>;
  18116. /**
  18117. * @hidden Internal use only.
  18118. */
  18119. _excludedMeshesIds: string[];
  18120. /**
  18121. * @hidden Internal use only.
  18122. */
  18123. _includedOnlyMeshesIds: string[];
  18124. /**
  18125. * The current light unifom buffer.
  18126. * @hidden Internal use only.
  18127. */
  18128. _uniformBuffer: UniformBuffer;
  18129. /** @hidden */
  18130. _renderId: number;
  18131. /**
  18132. * Creates a Light object in the scene.
  18133. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18134. * @param name The firendly name of the light
  18135. * @param scene The scene the light belongs too
  18136. */
  18137. constructor(name: string, scene: Scene);
  18138. protected abstract _buildUniformLayout(): void;
  18139. /**
  18140. * Sets the passed Effect "effect" with the Light information.
  18141. * @param effect The effect to update
  18142. * @param lightIndex The index of the light in the effect to update
  18143. * @returns The light
  18144. */
  18145. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18146. /**
  18147. * Sets the passed Effect "effect" with the Light textures.
  18148. * @param effect The effect to update
  18149. * @param lightIndex The index of the light in the effect to update
  18150. * @returns The light
  18151. */
  18152. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18153. /**
  18154. * Binds the lights information from the scene to the effect for the given mesh.
  18155. * @param lightIndex Light index
  18156. * @param scene The scene where the light belongs to
  18157. * @param effect The effect we are binding the data to
  18158. * @param useSpecular Defines if specular is supported
  18159. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18160. */
  18161. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18162. /**
  18163. * Sets the passed Effect "effect" with the Light information.
  18164. * @param effect The effect to update
  18165. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18166. * @returns The light
  18167. */
  18168. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18169. /**
  18170. * Returns the string "Light".
  18171. * @returns the class name
  18172. */
  18173. getClassName(): string;
  18174. /** @hidden */
  18175. readonly _isLight: boolean;
  18176. /**
  18177. * Converts the light information to a readable string for debug purpose.
  18178. * @param fullDetails Supports for multiple levels of logging within scene loading
  18179. * @returns the human readable light info
  18180. */
  18181. toString(fullDetails?: boolean): string;
  18182. /** @hidden */
  18183. protected _syncParentEnabledState(): void;
  18184. /**
  18185. * Set the enabled state of this node.
  18186. * @param value - the new enabled state
  18187. */
  18188. setEnabled(value: boolean): void;
  18189. /**
  18190. * Returns the Light associated shadow generator if any.
  18191. * @return the associated shadow generator.
  18192. */
  18193. getShadowGenerator(): Nullable<IShadowGenerator>;
  18194. /**
  18195. * Returns a Vector3, the absolute light position in the World.
  18196. * @returns the world space position of the light
  18197. */
  18198. getAbsolutePosition(): Vector3;
  18199. /**
  18200. * Specifies if the light will affect the passed mesh.
  18201. * @param mesh The mesh to test against the light
  18202. * @return true the mesh is affected otherwise, false.
  18203. */
  18204. canAffectMesh(mesh: AbstractMesh): boolean;
  18205. /**
  18206. * Sort function to order lights for rendering.
  18207. * @param a First Light object to compare to second.
  18208. * @param b Second Light object to compare first.
  18209. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18210. */
  18211. static CompareLightsPriority(a: Light, b: Light): number;
  18212. /**
  18213. * Releases resources associated with this node.
  18214. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18215. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18216. */
  18217. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18218. /**
  18219. * Returns the light type ID (integer).
  18220. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18221. */
  18222. getTypeID(): number;
  18223. /**
  18224. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18225. * @returns the scaled intensity in intensity mode unit
  18226. */
  18227. getScaledIntensity(): number;
  18228. /**
  18229. * Returns a new Light object, named "name", from the current one.
  18230. * @param name The name of the cloned light
  18231. * @param newParent The parent of this light, if it has one
  18232. * @returns the new created light
  18233. */
  18234. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18235. /**
  18236. * Serializes the current light into a Serialization object.
  18237. * @returns the serialized object.
  18238. */
  18239. serialize(): any;
  18240. /**
  18241. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18242. * This new light is named "name" and added to the passed scene.
  18243. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18244. * @param name The friendly name of the light
  18245. * @param scene The scene the new light will belong to
  18246. * @returns the constructor function
  18247. */
  18248. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18249. /**
  18250. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18251. * @param parsedLight The JSON representation of the light
  18252. * @param scene The scene to create the parsed light in
  18253. * @returns the created light after parsing
  18254. */
  18255. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18256. private _hookArrayForExcluded;
  18257. private _hookArrayForIncludedOnly;
  18258. private _resyncMeshes;
  18259. /**
  18260. * Forces the meshes to update their light related information in their rendering used effects
  18261. * @hidden Internal Use Only
  18262. */
  18263. _markMeshesAsLightDirty(): void;
  18264. /**
  18265. * Recomputes the cached photometric scale if needed.
  18266. */
  18267. private _computePhotometricScale;
  18268. /**
  18269. * Returns the Photometric Scale according to the light type and intensity mode.
  18270. */
  18271. private _getPhotometricScale;
  18272. /**
  18273. * Reorder the light in the scene according to their defined priority.
  18274. * @hidden Internal Use Only
  18275. */
  18276. _reorderLightsInScene(): void;
  18277. /**
  18278. * Prepares the list of defines specific to the light type.
  18279. * @param defines the list of defines
  18280. * @param lightIndex defines the index of the light for the effect
  18281. */
  18282. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18283. }
  18284. }
  18285. declare module BABYLON {
  18286. /**
  18287. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18288. * This is the base of the follow, arc rotate cameras and Free camera
  18289. * @see https://doc.babylonjs.com/features/cameras
  18290. */
  18291. export class TargetCamera extends Camera {
  18292. private static _RigCamTransformMatrix;
  18293. private static _TargetTransformMatrix;
  18294. private static _TargetFocalPoint;
  18295. private _tmpUpVector;
  18296. private _tmpTargetVector;
  18297. /**
  18298. * Define the current direction the camera is moving to
  18299. */
  18300. cameraDirection: Vector3;
  18301. /**
  18302. * Define the current rotation the camera is rotating to
  18303. */
  18304. cameraRotation: Vector2;
  18305. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18306. ignoreParentScaling: boolean;
  18307. /**
  18308. * When set, the up vector of the camera will be updated by the rotation of the camera
  18309. */
  18310. updateUpVectorFromRotation: boolean;
  18311. private _tmpQuaternion;
  18312. /**
  18313. * Define the current rotation of the camera
  18314. */
  18315. rotation: Vector3;
  18316. /**
  18317. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18318. */
  18319. rotationQuaternion: Quaternion;
  18320. /**
  18321. * Define the current speed of the camera
  18322. */
  18323. speed: number;
  18324. /**
  18325. * Add constraint to the camera to prevent it to move freely in all directions and
  18326. * around all axis.
  18327. */
  18328. noRotationConstraint: boolean;
  18329. /**
  18330. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18331. * panning
  18332. */
  18333. invertRotation: boolean;
  18334. /**
  18335. * Speed multiplier for inverse camera panning
  18336. */
  18337. inverseRotationSpeed: number;
  18338. /**
  18339. * Define the current target of the camera as an object or a position.
  18340. */
  18341. lockedTarget: any;
  18342. /** @hidden */
  18343. _currentTarget: Vector3;
  18344. /** @hidden */
  18345. _initialFocalDistance: number;
  18346. /** @hidden */
  18347. _viewMatrix: Matrix;
  18348. /** @hidden */
  18349. _camMatrix: Matrix;
  18350. /** @hidden */
  18351. _cameraTransformMatrix: Matrix;
  18352. /** @hidden */
  18353. _cameraRotationMatrix: Matrix;
  18354. /** @hidden */
  18355. _referencePoint: Vector3;
  18356. /** @hidden */
  18357. _transformedReferencePoint: Vector3;
  18358. /** @hidden */
  18359. _reset: () => void;
  18360. private _defaultUp;
  18361. /**
  18362. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18363. * This is the base of the follow, arc rotate cameras and Free camera
  18364. * @see https://doc.babylonjs.com/features/cameras
  18365. * @param name Defines the name of the camera in the scene
  18366. * @param position Defines the start position of the camera in the scene
  18367. * @param scene Defines the scene the camera belongs to
  18368. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18369. */
  18370. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18371. /**
  18372. * Gets the position in front of the camera at a given distance.
  18373. * @param distance The distance from the camera we want the position to be
  18374. * @returns the position
  18375. */
  18376. getFrontPosition(distance: number): Vector3;
  18377. /** @hidden */
  18378. _getLockedTargetPosition(): Nullable<Vector3>;
  18379. private _storedPosition;
  18380. private _storedRotation;
  18381. private _storedRotationQuaternion;
  18382. /**
  18383. * Store current camera state of the camera (fov, position, rotation, etc..)
  18384. * @returns the camera
  18385. */
  18386. storeState(): Camera;
  18387. /**
  18388. * Restored camera state. You must call storeState() first
  18389. * @returns whether it was successful or not
  18390. * @hidden
  18391. */
  18392. _restoreStateValues(): boolean;
  18393. /** @hidden */
  18394. _initCache(): void;
  18395. /** @hidden */
  18396. _updateCache(ignoreParentClass?: boolean): void;
  18397. /** @hidden */
  18398. _isSynchronizedViewMatrix(): boolean;
  18399. /** @hidden */
  18400. _computeLocalCameraSpeed(): number;
  18401. /**
  18402. * Defines the target the camera should look at.
  18403. * @param target Defines the new target as a Vector or a mesh
  18404. */
  18405. setTarget(target: Vector3): void;
  18406. /**
  18407. * Defines the target point of the camera.
  18408. * The camera looks towards it form the radius distance.
  18409. */
  18410. get target(): Vector3;
  18411. set target(value: Vector3);
  18412. /**
  18413. * Return the current target position of the camera. This value is expressed in local space.
  18414. * @returns the target position
  18415. */
  18416. getTarget(): Vector3;
  18417. /** @hidden */
  18418. _decideIfNeedsToMove(): boolean;
  18419. /** @hidden */
  18420. _updatePosition(): void;
  18421. /** @hidden */
  18422. _checkInputs(): void;
  18423. protected _updateCameraRotationMatrix(): void;
  18424. /**
  18425. * 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)
  18426. * @returns the current camera
  18427. */
  18428. private _rotateUpVectorWithCameraRotationMatrix;
  18429. private _cachedRotationZ;
  18430. private _cachedQuaternionRotationZ;
  18431. /** @hidden */
  18432. _getViewMatrix(): Matrix;
  18433. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18434. /**
  18435. * @hidden
  18436. */
  18437. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18438. /**
  18439. * @hidden
  18440. */
  18441. _updateRigCameras(): void;
  18442. private _getRigCamPositionAndTarget;
  18443. /**
  18444. * Gets the current object class name.
  18445. * @return the class name
  18446. */
  18447. getClassName(): string;
  18448. }
  18449. }
  18450. declare module BABYLON {
  18451. /**
  18452. * Gather the list of keyboard event types as constants.
  18453. */
  18454. export class KeyboardEventTypes {
  18455. /**
  18456. * The keydown event is fired when a key becomes active (pressed).
  18457. */
  18458. static readonly KEYDOWN: number;
  18459. /**
  18460. * The keyup event is fired when a key has been released.
  18461. */
  18462. static readonly KEYUP: number;
  18463. }
  18464. /**
  18465. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18466. */
  18467. export class KeyboardInfo {
  18468. /**
  18469. * Defines the type of event (KeyboardEventTypes)
  18470. */
  18471. type: number;
  18472. /**
  18473. * Defines the related dom event
  18474. */
  18475. event: KeyboardEvent;
  18476. /**
  18477. * Instantiates a new keyboard info.
  18478. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18479. * @param type Defines the type of event (KeyboardEventTypes)
  18480. * @param event Defines the related dom event
  18481. */
  18482. constructor(
  18483. /**
  18484. * Defines the type of event (KeyboardEventTypes)
  18485. */
  18486. type: number,
  18487. /**
  18488. * Defines the related dom event
  18489. */
  18490. event: KeyboardEvent);
  18491. }
  18492. /**
  18493. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18494. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18495. */
  18496. export class KeyboardInfoPre extends KeyboardInfo {
  18497. /**
  18498. * Defines the type of event (KeyboardEventTypes)
  18499. */
  18500. type: number;
  18501. /**
  18502. * Defines the related dom event
  18503. */
  18504. event: KeyboardEvent;
  18505. /**
  18506. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18507. */
  18508. skipOnPointerObservable: boolean;
  18509. /**
  18510. * Instantiates a new keyboard pre info.
  18511. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18512. * @param type Defines the type of event (KeyboardEventTypes)
  18513. * @param event Defines the related dom event
  18514. */
  18515. constructor(
  18516. /**
  18517. * Defines the type of event (KeyboardEventTypes)
  18518. */
  18519. type: number,
  18520. /**
  18521. * Defines the related dom event
  18522. */
  18523. event: KeyboardEvent);
  18524. }
  18525. }
  18526. declare module BABYLON {
  18527. /**
  18528. * Manage the keyboard inputs to control the movement of a free camera.
  18529. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18530. */
  18531. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18532. /**
  18533. * Defines the camera the input is attached to.
  18534. */
  18535. camera: FreeCamera;
  18536. /**
  18537. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18538. */
  18539. keysUp: number[];
  18540. /**
  18541. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18542. */
  18543. keysUpward: number[];
  18544. /**
  18545. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18546. */
  18547. keysDown: number[];
  18548. /**
  18549. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18550. */
  18551. keysDownward: number[];
  18552. /**
  18553. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18554. */
  18555. keysLeft: number[];
  18556. /**
  18557. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18558. */
  18559. keysRight: number[];
  18560. private _keys;
  18561. private _onCanvasBlurObserver;
  18562. private _onKeyboardObserver;
  18563. private _engine;
  18564. private _scene;
  18565. /**
  18566. * Attach the input controls to a specific dom element to get the input from.
  18567. * @param element Defines the element the controls should be listened from
  18568. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18569. */
  18570. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18571. /**
  18572. * Detach the current controls from the specified dom element.
  18573. * @param element Defines the element to stop listening the inputs from
  18574. */
  18575. detachControl(element: Nullable<HTMLElement>): void;
  18576. /**
  18577. * Update the current camera state depending on the inputs that have been used this frame.
  18578. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18579. */
  18580. checkInputs(): void;
  18581. /**
  18582. * Gets the class name of the current intput.
  18583. * @returns the class name
  18584. */
  18585. getClassName(): string;
  18586. /** @hidden */
  18587. _onLostFocus(): void;
  18588. /**
  18589. * Get the friendly name associated with the input class.
  18590. * @returns the input friendly name
  18591. */
  18592. getSimpleName(): string;
  18593. }
  18594. }
  18595. declare module BABYLON {
  18596. /**
  18597. * Gather the list of pointer event types as constants.
  18598. */
  18599. export class PointerEventTypes {
  18600. /**
  18601. * 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.
  18602. */
  18603. static readonly POINTERDOWN: number;
  18604. /**
  18605. * The pointerup event is fired when a pointer is no longer active.
  18606. */
  18607. static readonly POINTERUP: number;
  18608. /**
  18609. * The pointermove event is fired when a pointer changes coordinates.
  18610. */
  18611. static readonly POINTERMOVE: number;
  18612. /**
  18613. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18614. */
  18615. static readonly POINTERWHEEL: number;
  18616. /**
  18617. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18618. */
  18619. static readonly POINTERPICK: number;
  18620. /**
  18621. * The pointertap event is fired when a the object has been touched and released without drag.
  18622. */
  18623. static readonly POINTERTAP: number;
  18624. /**
  18625. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18626. */
  18627. static readonly POINTERDOUBLETAP: number;
  18628. }
  18629. /**
  18630. * Base class of pointer info types.
  18631. */
  18632. export class PointerInfoBase {
  18633. /**
  18634. * Defines the type of event (PointerEventTypes)
  18635. */
  18636. type: number;
  18637. /**
  18638. * Defines the related dom event
  18639. */
  18640. event: PointerEvent | MouseWheelEvent;
  18641. /**
  18642. * Instantiates the base class of pointers info.
  18643. * @param type Defines the type of event (PointerEventTypes)
  18644. * @param event Defines the related dom event
  18645. */
  18646. constructor(
  18647. /**
  18648. * Defines the type of event (PointerEventTypes)
  18649. */
  18650. type: number,
  18651. /**
  18652. * Defines the related dom event
  18653. */
  18654. event: PointerEvent | MouseWheelEvent);
  18655. }
  18656. /**
  18657. * This class is used to store pointer related info for the onPrePointerObservable event.
  18658. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18659. */
  18660. export class PointerInfoPre extends PointerInfoBase {
  18661. /**
  18662. * Ray from a pointer if availible (eg. 6dof controller)
  18663. */
  18664. ray: Nullable<Ray>;
  18665. /**
  18666. * Defines the local position of the pointer on the canvas.
  18667. */
  18668. localPosition: Vector2;
  18669. /**
  18670. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18671. */
  18672. skipOnPointerObservable: boolean;
  18673. /**
  18674. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18675. * @param type Defines the type of event (PointerEventTypes)
  18676. * @param event Defines the related dom event
  18677. * @param localX Defines the local x coordinates of the pointer when the event occured
  18678. * @param localY Defines the local y coordinates of the pointer when the event occured
  18679. */
  18680. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18681. }
  18682. /**
  18683. * This type contains all the data related to a pointer event in Babylon.js.
  18684. * 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.
  18685. */
  18686. export class PointerInfo extends PointerInfoBase {
  18687. /**
  18688. * Defines the picking info associated to the info (if any)\
  18689. */
  18690. pickInfo: Nullable<PickingInfo>;
  18691. /**
  18692. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18693. * @param type Defines the type of event (PointerEventTypes)
  18694. * @param event Defines the related dom event
  18695. * @param pickInfo Defines the picking info associated to the info (if any)\
  18696. */
  18697. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18698. /**
  18699. * Defines the picking info associated to the info (if any)\
  18700. */
  18701. pickInfo: Nullable<PickingInfo>);
  18702. }
  18703. /**
  18704. * Data relating to a touch event on the screen.
  18705. */
  18706. export interface PointerTouch {
  18707. /**
  18708. * X coordinate of touch.
  18709. */
  18710. x: number;
  18711. /**
  18712. * Y coordinate of touch.
  18713. */
  18714. y: number;
  18715. /**
  18716. * Id of touch. Unique for each finger.
  18717. */
  18718. pointerId: number;
  18719. /**
  18720. * Event type passed from DOM.
  18721. */
  18722. type: any;
  18723. }
  18724. }
  18725. declare module BABYLON {
  18726. /**
  18727. * Manage the mouse inputs to control the movement of a free camera.
  18728. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18729. */
  18730. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18731. /**
  18732. * Define if touch is enabled in the mouse input
  18733. */
  18734. touchEnabled: boolean;
  18735. /**
  18736. * Defines the camera the input is attached to.
  18737. */
  18738. camera: FreeCamera;
  18739. /**
  18740. * Defines the buttons associated with the input to handle camera move.
  18741. */
  18742. buttons: number[];
  18743. /**
  18744. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18745. */
  18746. angularSensibility: number;
  18747. private _pointerInput;
  18748. private _onMouseMove;
  18749. private _observer;
  18750. private previousPosition;
  18751. /**
  18752. * Observable for when a pointer move event occurs containing the move offset
  18753. */
  18754. onPointerMovedObservable: Observable<{
  18755. offsetX: number;
  18756. offsetY: number;
  18757. }>;
  18758. /**
  18759. * @hidden
  18760. * If the camera should be rotated automatically based on pointer movement
  18761. */
  18762. _allowCameraRotation: boolean;
  18763. /**
  18764. * Manage the mouse inputs to control the movement of a free camera.
  18765. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18766. * @param touchEnabled Defines if touch is enabled or not
  18767. */
  18768. constructor(
  18769. /**
  18770. * Define if touch is enabled in the mouse input
  18771. */
  18772. touchEnabled?: boolean);
  18773. /**
  18774. * Attach the input controls to a specific dom element to get the input from.
  18775. * @param element Defines the element the controls should be listened from
  18776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18777. */
  18778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18779. /**
  18780. * Called on JS contextmenu event.
  18781. * Override this method to provide functionality.
  18782. */
  18783. protected onContextMenu(evt: PointerEvent): void;
  18784. /**
  18785. * Detach the current controls from the specified dom element.
  18786. * @param element Defines the element to stop listening the inputs from
  18787. */
  18788. detachControl(element: Nullable<HTMLElement>): void;
  18789. /**
  18790. * Gets the class name of the current intput.
  18791. * @returns the class name
  18792. */
  18793. getClassName(): string;
  18794. /**
  18795. * Get the friendly name associated with the input class.
  18796. * @returns the input friendly name
  18797. */
  18798. getSimpleName(): string;
  18799. }
  18800. }
  18801. declare module BABYLON {
  18802. /**
  18803. * Manage the touch inputs to control the movement of a free camera.
  18804. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18805. */
  18806. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18807. /**
  18808. * Defines the camera the input is attached to.
  18809. */
  18810. camera: FreeCamera;
  18811. /**
  18812. * Defines the touch sensibility for rotation.
  18813. * The higher the faster.
  18814. */
  18815. touchAngularSensibility: number;
  18816. /**
  18817. * Defines the touch sensibility for move.
  18818. * The higher the faster.
  18819. */
  18820. touchMoveSensibility: number;
  18821. private _offsetX;
  18822. private _offsetY;
  18823. private _pointerPressed;
  18824. private _pointerInput;
  18825. private _observer;
  18826. private _onLostFocus;
  18827. /**
  18828. * Attach the input controls to a specific dom element to get the input from.
  18829. * @param element Defines the element the controls should be listened from
  18830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18831. */
  18832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18833. /**
  18834. * Detach the current controls from the specified dom element.
  18835. * @param element Defines the element to stop listening the inputs from
  18836. */
  18837. detachControl(element: Nullable<HTMLElement>): void;
  18838. /**
  18839. * Update the current camera state depending on the inputs that have been used this frame.
  18840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18841. */
  18842. checkInputs(): void;
  18843. /**
  18844. * Gets the class name of the current intput.
  18845. * @returns the class name
  18846. */
  18847. getClassName(): string;
  18848. /**
  18849. * Get the friendly name associated with the input class.
  18850. * @returns the input friendly name
  18851. */
  18852. getSimpleName(): string;
  18853. }
  18854. }
  18855. declare module BABYLON {
  18856. /**
  18857. * Default Inputs manager for the FreeCamera.
  18858. * It groups all the default supported inputs for ease of use.
  18859. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18860. */
  18861. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18862. /**
  18863. * @hidden
  18864. */
  18865. _mouseInput: Nullable<FreeCameraMouseInput>;
  18866. /**
  18867. * Instantiates a new FreeCameraInputsManager.
  18868. * @param camera Defines the camera the inputs belong to
  18869. */
  18870. constructor(camera: FreeCamera);
  18871. /**
  18872. * Add keyboard input support to the input manager.
  18873. * @returns the current input manager
  18874. */
  18875. addKeyboard(): FreeCameraInputsManager;
  18876. /**
  18877. * Add mouse input support to the input manager.
  18878. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18879. * @returns the current input manager
  18880. */
  18881. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18882. /**
  18883. * Removes the mouse input support from the manager
  18884. * @returns the current input manager
  18885. */
  18886. removeMouse(): FreeCameraInputsManager;
  18887. /**
  18888. * Add touch input support to the input manager.
  18889. * @returns the current input manager
  18890. */
  18891. addTouch(): FreeCameraInputsManager;
  18892. /**
  18893. * Remove all attached input methods from a camera
  18894. */
  18895. clear(): void;
  18896. }
  18897. }
  18898. declare module BABYLON {
  18899. /**
  18900. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18901. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18902. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18903. */
  18904. export class FreeCamera extends TargetCamera {
  18905. /**
  18906. * Define the collision ellipsoid of the camera.
  18907. * This is helpful to simulate a camera body like the player body around the camera
  18908. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18909. */
  18910. ellipsoid: Vector3;
  18911. /**
  18912. * Define an offset for the position of the ellipsoid around the camera.
  18913. * This can be helpful to determine the center of the body near the gravity center of the body
  18914. * instead of its head.
  18915. */
  18916. ellipsoidOffset: Vector3;
  18917. /**
  18918. * Enable or disable collisions of the camera with the rest of the scene objects.
  18919. */
  18920. checkCollisions: boolean;
  18921. /**
  18922. * Enable or disable gravity on the camera.
  18923. */
  18924. applyGravity: boolean;
  18925. /**
  18926. * Define the input manager associated to the camera.
  18927. */
  18928. inputs: FreeCameraInputsManager;
  18929. /**
  18930. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18931. * Higher values reduce sensitivity.
  18932. */
  18933. get angularSensibility(): number;
  18934. /**
  18935. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18936. * Higher values reduce sensitivity.
  18937. */
  18938. set angularSensibility(value: number);
  18939. /**
  18940. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18941. */
  18942. get keysUp(): number[];
  18943. set keysUp(value: number[]);
  18944. /**
  18945. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18946. */
  18947. get keysUpward(): number[];
  18948. set keysUpward(value: number[]);
  18949. /**
  18950. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18951. */
  18952. get keysDown(): number[];
  18953. set keysDown(value: number[]);
  18954. /**
  18955. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18956. */
  18957. get keysDownward(): number[];
  18958. set keysDownward(value: number[]);
  18959. /**
  18960. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18961. */
  18962. get keysLeft(): number[];
  18963. set keysLeft(value: number[]);
  18964. /**
  18965. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18966. */
  18967. get keysRight(): number[];
  18968. set keysRight(value: number[]);
  18969. /**
  18970. * Event raised when the camera collide with a mesh in the scene.
  18971. */
  18972. onCollide: (collidedMesh: AbstractMesh) => void;
  18973. private _collider;
  18974. private _needMoveForGravity;
  18975. private _oldPosition;
  18976. private _diffPosition;
  18977. private _newPosition;
  18978. /** @hidden */
  18979. _localDirection: Vector3;
  18980. /** @hidden */
  18981. _transformedDirection: Vector3;
  18982. /**
  18983. * Instantiates a Free Camera.
  18984. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18985. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18986. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18987. * @param name Define the name of the camera in the scene
  18988. * @param position Define the start position of the camera in the scene
  18989. * @param scene Define the scene the camera belongs to
  18990. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18991. */
  18992. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18993. /**
  18994. * Attached controls to the current camera.
  18995. * @param element Defines the element the controls should be listened from
  18996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18997. */
  18998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18999. /**
  19000. * Detach the current controls from the camera.
  19001. * The camera will stop reacting to inputs.
  19002. * @param element Defines the element to stop listening the inputs from
  19003. */
  19004. detachControl(element: HTMLElement): void;
  19005. private _collisionMask;
  19006. /**
  19007. * Define a collision mask to limit the list of object the camera can collide with
  19008. */
  19009. get collisionMask(): number;
  19010. set collisionMask(mask: number);
  19011. /** @hidden */
  19012. _collideWithWorld(displacement: Vector3): void;
  19013. private _onCollisionPositionChange;
  19014. /** @hidden */
  19015. _checkInputs(): void;
  19016. /** @hidden */
  19017. _decideIfNeedsToMove(): boolean;
  19018. /** @hidden */
  19019. _updatePosition(): void;
  19020. /**
  19021. * Destroy the camera and release the current resources hold by it.
  19022. */
  19023. dispose(): void;
  19024. /**
  19025. * Gets the current object class name.
  19026. * @return the class name
  19027. */
  19028. getClassName(): string;
  19029. }
  19030. }
  19031. declare module BABYLON {
  19032. /**
  19033. * Represents a gamepad control stick position
  19034. */
  19035. export class StickValues {
  19036. /**
  19037. * The x component of the control stick
  19038. */
  19039. x: number;
  19040. /**
  19041. * The y component of the control stick
  19042. */
  19043. y: number;
  19044. /**
  19045. * Initializes the gamepad x and y control stick values
  19046. * @param x The x component of the gamepad control stick value
  19047. * @param y The y component of the gamepad control stick value
  19048. */
  19049. constructor(
  19050. /**
  19051. * The x component of the control stick
  19052. */
  19053. x: number,
  19054. /**
  19055. * The y component of the control stick
  19056. */
  19057. y: number);
  19058. }
  19059. /**
  19060. * An interface which manages callbacks for gamepad button changes
  19061. */
  19062. export interface GamepadButtonChanges {
  19063. /**
  19064. * Called when a gamepad has been changed
  19065. */
  19066. changed: boolean;
  19067. /**
  19068. * Called when a gamepad press event has been triggered
  19069. */
  19070. pressChanged: boolean;
  19071. /**
  19072. * Called when a touch event has been triggered
  19073. */
  19074. touchChanged: boolean;
  19075. /**
  19076. * Called when a value has changed
  19077. */
  19078. valueChanged: boolean;
  19079. }
  19080. /**
  19081. * Represents a gamepad
  19082. */
  19083. export class Gamepad {
  19084. /**
  19085. * The id of the gamepad
  19086. */
  19087. id: string;
  19088. /**
  19089. * The index of the gamepad
  19090. */
  19091. index: number;
  19092. /**
  19093. * The browser gamepad
  19094. */
  19095. browserGamepad: any;
  19096. /**
  19097. * Specifies what type of gamepad this represents
  19098. */
  19099. type: number;
  19100. private _leftStick;
  19101. private _rightStick;
  19102. /** @hidden */
  19103. _isConnected: boolean;
  19104. private _leftStickAxisX;
  19105. private _leftStickAxisY;
  19106. private _rightStickAxisX;
  19107. private _rightStickAxisY;
  19108. /**
  19109. * Triggered when the left control stick has been changed
  19110. */
  19111. private _onleftstickchanged;
  19112. /**
  19113. * Triggered when the right control stick has been changed
  19114. */
  19115. private _onrightstickchanged;
  19116. /**
  19117. * Represents a gamepad controller
  19118. */
  19119. static GAMEPAD: number;
  19120. /**
  19121. * Represents a generic controller
  19122. */
  19123. static GENERIC: number;
  19124. /**
  19125. * Represents an XBox controller
  19126. */
  19127. static XBOX: number;
  19128. /**
  19129. * Represents a pose-enabled controller
  19130. */
  19131. static POSE_ENABLED: number;
  19132. /**
  19133. * Represents an Dual Shock controller
  19134. */
  19135. static DUALSHOCK: number;
  19136. /**
  19137. * Specifies whether the left control stick should be Y-inverted
  19138. */
  19139. protected _invertLeftStickY: boolean;
  19140. /**
  19141. * Specifies if the gamepad has been connected
  19142. */
  19143. get isConnected(): boolean;
  19144. /**
  19145. * Initializes the gamepad
  19146. * @param id The id of the gamepad
  19147. * @param index The index of the gamepad
  19148. * @param browserGamepad The browser gamepad
  19149. * @param leftStickX The x component of the left joystick
  19150. * @param leftStickY The y component of the left joystick
  19151. * @param rightStickX The x component of the right joystick
  19152. * @param rightStickY The y component of the right joystick
  19153. */
  19154. constructor(
  19155. /**
  19156. * The id of the gamepad
  19157. */
  19158. id: string,
  19159. /**
  19160. * The index of the gamepad
  19161. */
  19162. index: number,
  19163. /**
  19164. * The browser gamepad
  19165. */
  19166. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19167. /**
  19168. * Callback triggered when the left joystick has changed
  19169. * @param callback
  19170. */
  19171. onleftstickchanged(callback: (values: StickValues) => void): void;
  19172. /**
  19173. * Callback triggered when the right joystick has changed
  19174. * @param callback
  19175. */
  19176. onrightstickchanged(callback: (values: StickValues) => void): void;
  19177. /**
  19178. * Gets the left joystick
  19179. */
  19180. get leftStick(): StickValues;
  19181. /**
  19182. * Sets the left joystick values
  19183. */
  19184. set leftStick(newValues: StickValues);
  19185. /**
  19186. * Gets the right joystick
  19187. */
  19188. get rightStick(): StickValues;
  19189. /**
  19190. * Sets the right joystick value
  19191. */
  19192. set rightStick(newValues: StickValues);
  19193. /**
  19194. * Updates the gamepad joystick positions
  19195. */
  19196. update(): void;
  19197. /**
  19198. * Disposes the gamepad
  19199. */
  19200. dispose(): void;
  19201. }
  19202. /**
  19203. * Represents a generic gamepad
  19204. */
  19205. export class GenericPad extends Gamepad {
  19206. private _buttons;
  19207. private _onbuttondown;
  19208. private _onbuttonup;
  19209. /**
  19210. * Observable triggered when a button has been pressed
  19211. */
  19212. onButtonDownObservable: Observable<number>;
  19213. /**
  19214. * Observable triggered when a button has been released
  19215. */
  19216. onButtonUpObservable: Observable<number>;
  19217. /**
  19218. * Callback triggered when a button has been pressed
  19219. * @param callback Called when a button has been pressed
  19220. */
  19221. onbuttondown(callback: (buttonPressed: number) => void): void;
  19222. /**
  19223. * Callback triggered when a button has been released
  19224. * @param callback Called when a button has been released
  19225. */
  19226. onbuttonup(callback: (buttonReleased: number) => void): void;
  19227. /**
  19228. * Initializes the generic gamepad
  19229. * @param id The id of the generic gamepad
  19230. * @param index The index of the generic gamepad
  19231. * @param browserGamepad The browser gamepad
  19232. */
  19233. constructor(id: string, index: number, browserGamepad: any);
  19234. private _setButtonValue;
  19235. /**
  19236. * Updates the generic gamepad
  19237. */
  19238. update(): void;
  19239. /**
  19240. * Disposes the generic gamepad
  19241. */
  19242. dispose(): void;
  19243. }
  19244. }
  19245. declare module BABYLON {
  19246. /**
  19247. * Defines the types of pose enabled controllers that are supported
  19248. */
  19249. export enum PoseEnabledControllerType {
  19250. /**
  19251. * HTC Vive
  19252. */
  19253. VIVE = 0,
  19254. /**
  19255. * Oculus Rift
  19256. */
  19257. OCULUS = 1,
  19258. /**
  19259. * Windows mixed reality
  19260. */
  19261. WINDOWS = 2,
  19262. /**
  19263. * Samsung gear VR
  19264. */
  19265. GEAR_VR = 3,
  19266. /**
  19267. * Google Daydream
  19268. */
  19269. DAYDREAM = 4,
  19270. /**
  19271. * Generic
  19272. */
  19273. GENERIC = 5
  19274. }
  19275. /**
  19276. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19277. */
  19278. export interface MutableGamepadButton {
  19279. /**
  19280. * Value of the button/trigger
  19281. */
  19282. value: number;
  19283. /**
  19284. * If the button/trigger is currently touched
  19285. */
  19286. touched: boolean;
  19287. /**
  19288. * If the button/trigger is currently pressed
  19289. */
  19290. pressed: boolean;
  19291. }
  19292. /**
  19293. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19294. * @hidden
  19295. */
  19296. export interface ExtendedGamepadButton extends GamepadButton {
  19297. /**
  19298. * If the button/trigger is currently pressed
  19299. */
  19300. readonly pressed: boolean;
  19301. /**
  19302. * If the button/trigger is currently touched
  19303. */
  19304. readonly touched: boolean;
  19305. /**
  19306. * Value of the button/trigger
  19307. */
  19308. readonly value: number;
  19309. }
  19310. /** @hidden */
  19311. export interface _GamePadFactory {
  19312. /**
  19313. * Returns whether or not the current gamepad can be created for this type of controller.
  19314. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19315. * @returns true if it can be created, otherwise false
  19316. */
  19317. canCreate(gamepadInfo: any): boolean;
  19318. /**
  19319. * Creates a new instance of the Gamepad.
  19320. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19321. * @returns the new gamepad instance
  19322. */
  19323. create(gamepadInfo: any): Gamepad;
  19324. }
  19325. /**
  19326. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19327. */
  19328. export class PoseEnabledControllerHelper {
  19329. /** @hidden */
  19330. static _ControllerFactories: _GamePadFactory[];
  19331. /** @hidden */
  19332. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19333. /**
  19334. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19335. * @param vrGamepad the gamepad to initialized
  19336. * @returns a vr controller of the type the gamepad identified as
  19337. */
  19338. static InitiateController(vrGamepad: any): Gamepad;
  19339. }
  19340. /**
  19341. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19342. */
  19343. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19344. /**
  19345. * If the controller is used in a webXR session
  19346. */
  19347. isXR: boolean;
  19348. private _deviceRoomPosition;
  19349. private _deviceRoomRotationQuaternion;
  19350. /**
  19351. * The device position in babylon space
  19352. */
  19353. devicePosition: Vector3;
  19354. /**
  19355. * The device rotation in babylon space
  19356. */
  19357. deviceRotationQuaternion: Quaternion;
  19358. /**
  19359. * The scale factor of the device in babylon space
  19360. */
  19361. deviceScaleFactor: number;
  19362. /**
  19363. * (Likely devicePosition should be used instead) The device position in its room space
  19364. */
  19365. position: Vector3;
  19366. /**
  19367. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19368. */
  19369. rotationQuaternion: Quaternion;
  19370. /**
  19371. * The type of controller (Eg. Windows mixed reality)
  19372. */
  19373. controllerType: PoseEnabledControllerType;
  19374. protected _calculatedPosition: Vector3;
  19375. private _calculatedRotation;
  19376. /**
  19377. * The raw pose from the device
  19378. */
  19379. rawPose: DevicePose;
  19380. private _trackPosition;
  19381. private _maxRotationDistFromHeadset;
  19382. private _draggedRoomRotation;
  19383. /**
  19384. * @hidden
  19385. */
  19386. _disableTrackPosition(fixedPosition: Vector3): void;
  19387. /**
  19388. * Internal, the mesh attached to the controller
  19389. * @hidden
  19390. */
  19391. _mesh: Nullable<AbstractMesh>;
  19392. private _poseControlledCamera;
  19393. private _leftHandSystemQuaternion;
  19394. /**
  19395. * Internal, matrix used to convert room space to babylon space
  19396. * @hidden
  19397. */
  19398. _deviceToWorld: Matrix;
  19399. /**
  19400. * Node to be used when casting a ray from the controller
  19401. * @hidden
  19402. */
  19403. _pointingPoseNode: Nullable<TransformNode>;
  19404. /**
  19405. * Name of the child mesh that can be used to cast a ray from the controller
  19406. */
  19407. static readonly POINTING_POSE: string;
  19408. /**
  19409. * Creates a new PoseEnabledController from a gamepad
  19410. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19411. */
  19412. constructor(browserGamepad: any);
  19413. private _workingMatrix;
  19414. /**
  19415. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19416. */
  19417. update(): void;
  19418. /**
  19419. * Updates only the pose device and mesh without doing any button event checking
  19420. */
  19421. protected _updatePoseAndMesh(): void;
  19422. /**
  19423. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19424. * @param poseData raw pose fromthe device
  19425. */
  19426. updateFromDevice(poseData: DevicePose): void;
  19427. /**
  19428. * @hidden
  19429. */
  19430. _meshAttachedObservable: Observable<AbstractMesh>;
  19431. /**
  19432. * Attaches a mesh to the controller
  19433. * @param mesh the mesh to be attached
  19434. */
  19435. attachToMesh(mesh: AbstractMesh): void;
  19436. /**
  19437. * Attaches the controllers mesh to a camera
  19438. * @param camera the camera the mesh should be attached to
  19439. */
  19440. attachToPoseControlledCamera(camera: TargetCamera): void;
  19441. /**
  19442. * Disposes of the controller
  19443. */
  19444. dispose(): void;
  19445. /**
  19446. * The mesh that is attached to the controller
  19447. */
  19448. get mesh(): Nullable<AbstractMesh>;
  19449. /**
  19450. * Gets the ray of the controller in the direction the controller is pointing
  19451. * @param length the length the resulting ray should be
  19452. * @returns a ray in the direction the controller is pointing
  19453. */
  19454. getForwardRay(length?: number): Ray;
  19455. }
  19456. }
  19457. declare module BABYLON {
  19458. /**
  19459. * Defines the WebVRController object that represents controllers tracked in 3D space
  19460. */
  19461. export abstract class WebVRController extends PoseEnabledController {
  19462. /**
  19463. * Internal, the default controller model for the controller
  19464. */
  19465. protected _defaultModel: Nullable<AbstractMesh>;
  19466. /**
  19467. * Fired when the trigger state has changed
  19468. */
  19469. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19470. /**
  19471. * Fired when the main button state has changed
  19472. */
  19473. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19474. /**
  19475. * Fired when the secondary button state has changed
  19476. */
  19477. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19478. /**
  19479. * Fired when the pad state has changed
  19480. */
  19481. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19482. /**
  19483. * Fired when controllers stick values have changed
  19484. */
  19485. onPadValuesChangedObservable: Observable<StickValues>;
  19486. /**
  19487. * Array of button availible on the controller
  19488. */
  19489. protected _buttons: Array<MutableGamepadButton>;
  19490. private _onButtonStateChange;
  19491. /**
  19492. * Fired when a controller button's state has changed
  19493. * @param callback the callback containing the button that was modified
  19494. */
  19495. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19496. /**
  19497. * X and Y axis corresponding to the controllers joystick
  19498. */
  19499. pad: StickValues;
  19500. /**
  19501. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19502. */
  19503. hand: string;
  19504. /**
  19505. * The default controller model for the controller
  19506. */
  19507. get defaultModel(): Nullable<AbstractMesh>;
  19508. /**
  19509. * Creates a new WebVRController from a gamepad
  19510. * @param vrGamepad the gamepad that the WebVRController should be created from
  19511. */
  19512. constructor(vrGamepad: any);
  19513. /**
  19514. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19515. */
  19516. update(): void;
  19517. /**
  19518. * Function to be called when a button is modified
  19519. */
  19520. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19521. /**
  19522. * Loads a mesh and attaches it to the controller
  19523. * @param scene the scene the mesh should be added to
  19524. * @param meshLoaded callback for when the mesh has been loaded
  19525. */
  19526. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19527. private _setButtonValue;
  19528. private _changes;
  19529. private _checkChanges;
  19530. /**
  19531. * Disposes of th webVRCOntroller
  19532. */
  19533. dispose(): void;
  19534. }
  19535. }
  19536. declare module BABYLON {
  19537. /**
  19538. * The HemisphericLight simulates the ambient environment light,
  19539. * so the passed direction is the light reflection direction, not the incoming direction.
  19540. */
  19541. export class HemisphericLight extends Light {
  19542. /**
  19543. * The groundColor is the light in the opposite direction to the one specified during creation.
  19544. * 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.
  19545. */
  19546. groundColor: Color3;
  19547. /**
  19548. * The light reflection direction, not the incoming direction.
  19549. */
  19550. direction: Vector3;
  19551. /**
  19552. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19553. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19554. * The HemisphericLight can't cast shadows.
  19555. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19556. * @param name The friendly name of the light
  19557. * @param direction The direction of the light reflection
  19558. * @param scene The scene the light belongs to
  19559. */
  19560. constructor(name: string, direction: Vector3, scene: Scene);
  19561. protected _buildUniformLayout(): void;
  19562. /**
  19563. * Returns the string "HemisphericLight".
  19564. * @return The class name
  19565. */
  19566. getClassName(): string;
  19567. /**
  19568. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19569. * Returns the updated direction.
  19570. * @param target The target the direction should point to
  19571. * @return The computed direction
  19572. */
  19573. setDirectionToTarget(target: Vector3): Vector3;
  19574. /**
  19575. * Returns the shadow generator associated to the light.
  19576. * @returns Always null for hemispheric lights because it does not support shadows.
  19577. */
  19578. getShadowGenerator(): Nullable<IShadowGenerator>;
  19579. /**
  19580. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19581. * @param effect The effect to update
  19582. * @param lightIndex The index of the light in the effect to update
  19583. * @returns The hemispheric light
  19584. */
  19585. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19586. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19587. /**
  19588. * Computes the world matrix of the node
  19589. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19590. * @param useWasUpdatedFlag defines a reserved property
  19591. * @returns the world matrix
  19592. */
  19593. computeWorldMatrix(): Matrix;
  19594. /**
  19595. * Returns the integer 3.
  19596. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19597. */
  19598. getTypeID(): number;
  19599. /**
  19600. * Prepares the list of defines specific to the light type.
  19601. * @param defines the list of defines
  19602. * @param lightIndex defines the index of the light for the effect
  19603. */
  19604. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19605. }
  19606. }
  19607. declare module BABYLON {
  19608. /** @hidden */
  19609. export var vrMultiviewToSingleviewPixelShader: {
  19610. name: string;
  19611. shader: string;
  19612. };
  19613. }
  19614. declare module BABYLON {
  19615. /**
  19616. * Renders to multiple views with a single draw call
  19617. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19618. */
  19619. export class MultiviewRenderTarget extends RenderTargetTexture {
  19620. /**
  19621. * Creates a multiview render target
  19622. * @param scene scene used with the render target
  19623. * @param size the size of the render target (used for each view)
  19624. */
  19625. constructor(scene: Scene, size?: number | {
  19626. width: number;
  19627. height: number;
  19628. } | {
  19629. ratio: number;
  19630. });
  19631. /**
  19632. * @hidden
  19633. * @param faceIndex the face index, if its a cube texture
  19634. */
  19635. _bindFrameBuffer(faceIndex?: number): void;
  19636. /**
  19637. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19638. * @returns the view count
  19639. */
  19640. getViewCount(): number;
  19641. }
  19642. }
  19643. declare module BABYLON {
  19644. interface Engine {
  19645. /**
  19646. * Creates a new multiview render target
  19647. * @param width defines the width of the texture
  19648. * @param height defines the height of the texture
  19649. * @returns the created multiview texture
  19650. */
  19651. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19652. /**
  19653. * Binds a multiview framebuffer to be drawn to
  19654. * @param multiviewTexture texture to bind
  19655. */
  19656. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19657. }
  19658. interface Camera {
  19659. /**
  19660. * @hidden
  19661. * 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)
  19662. */
  19663. _useMultiviewToSingleView: boolean;
  19664. /**
  19665. * @hidden
  19666. * 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)
  19667. */
  19668. _multiviewTexture: Nullable<RenderTargetTexture>;
  19669. /**
  19670. * @hidden
  19671. * ensures the multiview texture of the camera exists and has the specified width/height
  19672. * @param width height to set on the multiview texture
  19673. * @param height width to set on the multiview texture
  19674. */
  19675. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19676. }
  19677. interface Scene {
  19678. /** @hidden */
  19679. _transformMatrixR: Matrix;
  19680. /** @hidden */
  19681. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19682. /** @hidden */
  19683. _createMultiviewUbo(): void;
  19684. /** @hidden */
  19685. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19686. /** @hidden */
  19687. _renderMultiviewToSingleView(camera: Camera): void;
  19688. }
  19689. }
  19690. declare module BABYLON {
  19691. /**
  19692. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19693. * This will not be used for webXR as it supports displaying texture arrays directly
  19694. */
  19695. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19696. /**
  19697. * Initializes a VRMultiviewToSingleview
  19698. * @param name name of the post process
  19699. * @param camera camera to be applied to
  19700. * @param scaleFactor scaling factor to the size of the output texture
  19701. */
  19702. constructor(name: string, camera: Camera, scaleFactor: number);
  19703. }
  19704. }
  19705. declare module BABYLON {
  19706. /**
  19707. * Interface used to define additional presentation attributes
  19708. */
  19709. export interface IVRPresentationAttributes {
  19710. /**
  19711. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19712. */
  19713. highRefreshRate: boolean;
  19714. /**
  19715. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19716. */
  19717. foveationLevel: number;
  19718. }
  19719. interface Engine {
  19720. /** @hidden */
  19721. _vrDisplay: any;
  19722. /** @hidden */
  19723. _vrSupported: boolean;
  19724. /** @hidden */
  19725. _oldSize: Size;
  19726. /** @hidden */
  19727. _oldHardwareScaleFactor: number;
  19728. /** @hidden */
  19729. _vrExclusivePointerMode: boolean;
  19730. /** @hidden */
  19731. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19732. /** @hidden */
  19733. _onVRDisplayPointerRestricted: () => void;
  19734. /** @hidden */
  19735. _onVRDisplayPointerUnrestricted: () => void;
  19736. /** @hidden */
  19737. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19738. /** @hidden */
  19739. _onVrDisplayDisconnect: Nullable<() => void>;
  19740. /** @hidden */
  19741. _onVrDisplayPresentChange: Nullable<() => void>;
  19742. /**
  19743. * Observable signaled when VR display mode changes
  19744. */
  19745. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19746. /**
  19747. * Observable signaled when VR request present is complete
  19748. */
  19749. onVRRequestPresentComplete: Observable<boolean>;
  19750. /**
  19751. * Observable signaled when VR request present starts
  19752. */
  19753. onVRRequestPresentStart: Observable<Engine>;
  19754. /**
  19755. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19756. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19757. */
  19758. isInVRExclusivePointerMode: boolean;
  19759. /**
  19760. * Gets a boolean indicating if a webVR device was detected
  19761. * @returns true if a webVR device was detected
  19762. */
  19763. isVRDevicePresent(): boolean;
  19764. /**
  19765. * Gets the current webVR device
  19766. * @returns the current webVR device (or null)
  19767. */
  19768. getVRDevice(): any;
  19769. /**
  19770. * Initializes a webVR display and starts listening to display change events
  19771. * The onVRDisplayChangedObservable will be notified upon these changes
  19772. * @returns A promise containing a VRDisplay and if vr is supported
  19773. */
  19774. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19775. /** @hidden */
  19776. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19777. /**
  19778. * Gets or sets the presentation attributes used to configure VR rendering
  19779. */
  19780. vrPresentationAttributes?: IVRPresentationAttributes;
  19781. /**
  19782. * Call this function to switch to webVR mode
  19783. * Will do nothing if webVR is not supported or if there is no webVR device
  19784. * @param options the webvr options provided to the camera. mainly used for multiview
  19785. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19786. */
  19787. enableVR(options: WebVROptions): void;
  19788. /** @hidden */
  19789. _onVRFullScreenTriggered(): void;
  19790. }
  19791. }
  19792. declare module BABYLON {
  19793. /**
  19794. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19795. * IMPORTANT!! The data is right-hand data.
  19796. * @export
  19797. * @interface DevicePose
  19798. */
  19799. export interface DevicePose {
  19800. /**
  19801. * The position of the device, values in array are [x,y,z].
  19802. */
  19803. readonly position: Nullable<Float32Array>;
  19804. /**
  19805. * The linearVelocity of the device, values in array are [x,y,z].
  19806. */
  19807. readonly linearVelocity: Nullable<Float32Array>;
  19808. /**
  19809. * The linearAcceleration of the device, values in array are [x,y,z].
  19810. */
  19811. readonly linearAcceleration: Nullable<Float32Array>;
  19812. /**
  19813. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19814. */
  19815. readonly orientation: Nullable<Float32Array>;
  19816. /**
  19817. * The angularVelocity of the device, values in array are [x,y,z].
  19818. */
  19819. readonly angularVelocity: Nullable<Float32Array>;
  19820. /**
  19821. * The angularAcceleration of the device, values in array are [x,y,z].
  19822. */
  19823. readonly angularAcceleration: Nullable<Float32Array>;
  19824. }
  19825. /**
  19826. * Interface representing a pose controlled object in Babylon.
  19827. * A pose controlled object has both regular pose values as well as pose values
  19828. * from an external device such as a VR head mounted display
  19829. */
  19830. export interface PoseControlled {
  19831. /**
  19832. * The position of the object in babylon space.
  19833. */
  19834. position: Vector3;
  19835. /**
  19836. * The rotation quaternion of the object in babylon space.
  19837. */
  19838. rotationQuaternion: Quaternion;
  19839. /**
  19840. * The position of the device in babylon space.
  19841. */
  19842. devicePosition?: Vector3;
  19843. /**
  19844. * The rotation quaternion of the device in babylon space.
  19845. */
  19846. deviceRotationQuaternion: Quaternion;
  19847. /**
  19848. * The raw pose coming from the device.
  19849. */
  19850. rawPose: Nullable<DevicePose>;
  19851. /**
  19852. * The scale of the device to be used when translating from device space to babylon space.
  19853. */
  19854. deviceScaleFactor: number;
  19855. /**
  19856. * Updates the poseControlled values based on the input device pose.
  19857. * @param poseData the pose data to update the object with
  19858. */
  19859. updateFromDevice(poseData: DevicePose): void;
  19860. }
  19861. /**
  19862. * Set of options to customize the webVRCamera
  19863. */
  19864. export interface WebVROptions {
  19865. /**
  19866. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19867. */
  19868. trackPosition?: boolean;
  19869. /**
  19870. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19871. */
  19872. positionScale?: number;
  19873. /**
  19874. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19875. */
  19876. displayName?: string;
  19877. /**
  19878. * Should the native controller meshes be initialized. (default: true)
  19879. */
  19880. controllerMeshes?: boolean;
  19881. /**
  19882. * Creating a default HemiLight only on controllers. (default: true)
  19883. */
  19884. defaultLightingOnControllers?: boolean;
  19885. /**
  19886. * If you don't want to use the default VR button of the helper. (default: false)
  19887. */
  19888. useCustomVRButton?: boolean;
  19889. /**
  19890. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19891. */
  19892. customVRButton?: HTMLButtonElement;
  19893. /**
  19894. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19895. */
  19896. rayLength?: number;
  19897. /**
  19898. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19899. */
  19900. defaultHeight?: number;
  19901. /**
  19902. * If multiview should be used if availible (default: false)
  19903. */
  19904. useMultiview?: boolean;
  19905. }
  19906. /**
  19907. * This represents a WebVR camera.
  19908. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19909. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19910. */
  19911. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19912. private webVROptions;
  19913. /**
  19914. * @hidden
  19915. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19916. */
  19917. _vrDevice: any;
  19918. /**
  19919. * The rawPose of the vrDevice.
  19920. */
  19921. rawPose: Nullable<DevicePose>;
  19922. private _onVREnabled;
  19923. private _specsVersion;
  19924. private _attached;
  19925. private _frameData;
  19926. protected _descendants: Array<Node>;
  19927. private _deviceRoomPosition;
  19928. /** @hidden */
  19929. _deviceRoomRotationQuaternion: Quaternion;
  19930. private _standingMatrix;
  19931. /**
  19932. * Represents device position in babylon space.
  19933. */
  19934. devicePosition: Vector3;
  19935. /**
  19936. * Represents device rotation in babylon space.
  19937. */
  19938. deviceRotationQuaternion: Quaternion;
  19939. /**
  19940. * The scale of the device to be used when translating from device space to babylon space.
  19941. */
  19942. deviceScaleFactor: number;
  19943. private _deviceToWorld;
  19944. private _worldToDevice;
  19945. /**
  19946. * References to the webVR controllers for the vrDevice.
  19947. */
  19948. controllers: Array<WebVRController>;
  19949. /**
  19950. * Emits an event when a controller is attached.
  19951. */
  19952. onControllersAttachedObservable: Observable<WebVRController[]>;
  19953. /**
  19954. * Emits an event when a controller's mesh has been loaded;
  19955. */
  19956. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19957. /**
  19958. * Emits an event when the HMD's pose has been updated.
  19959. */
  19960. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19961. private _poseSet;
  19962. /**
  19963. * If the rig cameras be used as parent instead of this camera.
  19964. */
  19965. rigParenting: boolean;
  19966. private _lightOnControllers;
  19967. private _defaultHeight?;
  19968. /**
  19969. * Instantiates a WebVRFreeCamera.
  19970. * @param name The name of the WebVRFreeCamera
  19971. * @param position The starting anchor position for the camera
  19972. * @param scene The scene the camera belongs to
  19973. * @param webVROptions a set of customizable options for the webVRCamera
  19974. */
  19975. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19976. /**
  19977. * Gets the device distance from the ground in meters.
  19978. * @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.
  19979. */
  19980. deviceDistanceToRoomGround(): number;
  19981. /**
  19982. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19983. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19984. */
  19985. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19986. /**
  19987. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19988. * @returns A promise with a boolean set to if the standing matrix is supported.
  19989. */
  19990. useStandingMatrixAsync(): Promise<boolean>;
  19991. /**
  19992. * Disposes the camera
  19993. */
  19994. dispose(): void;
  19995. /**
  19996. * Gets a vrController by name.
  19997. * @param name The name of the controller to retreive
  19998. * @returns the controller matching the name specified or null if not found
  19999. */
  20000. getControllerByName(name: string): Nullable<WebVRController>;
  20001. private _leftController;
  20002. /**
  20003. * The controller corresponding to the users left hand.
  20004. */
  20005. get leftController(): Nullable<WebVRController>;
  20006. private _rightController;
  20007. /**
  20008. * The controller corresponding to the users right hand.
  20009. */
  20010. get rightController(): Nullable<WebVRController>;
  20011. /**
  20012. * Casts a ray forward from the vrCamera's gaze.
  20013. * @param length Length of the ray (default: 100)
  20014. * @returns the ray corresponding to the gaze
  20015. */
  20016. getForwardRay(length?: number): Ray;
  20017. /**
  20018. * @hidden
  20019. * Updates the camera based on device's frame data
  20020. */
  20021. _checkInputs(): void;
  20022. /**
  20023. * Updates the poseControlled values based on the input device pose.
  20024. * @param poseData Pose coming from the device
  20025. */
  20026. updateFromDevice(poseData: DevicePose): void;
  20027. private _htmlElementAttached;
  20028. private _detachIfAttached;
  20029. /**
  20030. * WebVR's attach control will start broadcasting frames to the device.
  20031. * Note that in certain browsers (chrome for example) this function must be called
  20032. * within a user-interaction callback. Example:
  20033. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20034. *
  20035. * @param element html element to attach the vrDevice to
  20036. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20037. */
  20038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20039. /**
  20040. * Detaches the camera from the html element and disables VR
  20041. *
  20042. * @param element html element to detach from
  20043. */
  20044. detachControl(element: HTMLElement): void;
  20045. /**
  20046. * @returns the name of this class
  20047. */
  20048. getClassName(): string;
  20049. /**
  20050. * Calls resetPose on the vrDisplay
  20051. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20052. */
  20053. resetToCurrentRotation(): void;
  20054. /**
  20055. * @hidden
  20056. * Updates the rig cameras (left and right eye)
  20057. */
  20058. _updateRigCameras(): void;
  20059. private _workingVector;
  20060. private _oneVector;
  20061. private _workingMatrix;
  20062. private updateCacheCalled;
  20063. private _correctPositionIfNotTrackPosition;
  20064. /**
  20065. * @hidden
  20066. * Updates the cached values of the camera
  20067. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20068. */
  20069. _updateCache(ignoreParentClass?: boolean): void;
  20070. /**
  20071. * @hidden
  20072. * Get current device position in babylon world
  20073. */
  20074. _computeDevicePosition(): void;
  20075. /**
  20076. * Updates the current device position and rotation in the babylon world
  20077. */
  20078. update(): void;
  20079. /**
  20080. * @hidden
  20081. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20082. * @returns an identity matrix
  20083. */
  20084. _getViewMatrix(): Matrix;
  20085. private _tmpMatrix;
  20086. /**
  20087. * This function is called by the two RIG cameras.
  20088. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20089. * @hidden
  20090. */
  20091. _getWebVRViewMatrix(): Matrix;
  20092. /** @hidden */
  20093. _getWebVRProjectionMatrix(): Matrix;
  20094. private _onGamepadConnectedObserver;
  20095. private _onGamepadDisconnectedObserver;
  20096. private _updateCacheWhenTrackingDisabledObserver;
  20097. /**
  20098. * Initializes the controllers and their meshes
  20099. */
  20100. initControllers(): void;
  20101. }
  20102. }
  20103. declare module BABYLON {
  20104. /**
  20105. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20106. *
  20107. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20108. *
  20109. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20110. */
  20111. export class MaterialHelper {
  20112. /**
  20113. * Bind the current view position to an effect.
  20114. * @param effect The effect to be bound
  20115. * @param scene The scene the eyes position is used from
  20116. * @param variableName name of the shader variable that will hold the eye position
  20117. */
  20118. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20119. /**
  20120. * Helps preparing the defines values about the UVs in used in the effect.
  20121. * UVs are shared as much as we can accross channels in the shaders.
  20122. * @param texture The texture we are preparing the UVs for
  20123. * @param defines The defines to update
  20124. * @param key The channel key "diffuse", "specular"... used in the shader
  20125. */
  20126. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20127. /**
  20128. * Binds a texture matrix value to its corrsponding uniform
  20129. * @param texture The texture to bind the matrix for
  20130. * @param uniformBuffer The uniform buffer receivin the data
  20131. * @param key The channel key "diffuse", "specular"... used in the shader
  20132. */
  20133. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20134. /**
  20135. * Gets the current status of the fog (should it be enabled?)
  20136. * @param mesh defines the mesh to evaluate for fog support
  20137. * @param scene defines the hosting scene
  20138. * @returns true if fog must be enabled
  20139. */
  20140. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20141. /**
  20142. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20143. * @param mesh defines the current mesh
  20144. * @param scene defines the current scene
  20145. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20146. * @param pointsCloud defines if point cloud rendering has to be turned on
  20147. * @param fogEnabled defines if fog has to be turned on
  20148. * @param alphaTest defines if alpha testing has to be turned on
  20149. * @param defines defines the current list of defines
  20150. */
  20151. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20152. /**
  20153. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20154. * @param scene defines the current scene
  20155. * @param engine defines the current engine
  20156. * @param defines specifies the list of active defines
  20157. * @param useInstances defines if instances have to be turned on
  20158. * @param useClipPlane defines if clip plane have to be turned on
  20159. * @param useInstances defines if instances have to be turned on
  20160. * @param useThinInstances defines if thin instances have to be turned on
  20161. */
  20162. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20163. /**
  20164. * Prepares the defines for bones
  20165. * @param mesh The mesh containing the geometry data we will draw
  20166. * @param defines The defines to update
  20167. */
  20168. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20169. /**
  20170. * Prepares the defines for morph targets
  20171. * @param mesh The mesh containing the geometry data we will draw
  20172. * @param defines The defines to update
  20173. */
  20174. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20175. /**
  20176. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20177. * @param mesh The mesh containing the geometry data we will draw
  20178. * @param defines The defines to update
  20179. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20180. * @param useBones Precise whether bones should be used or not (override mesh info)
  20181. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20182. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20183. * @returns false if defines are considered not dirty and have not been checked
  20184. */
  20185. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20186. /**
  20187. * Prepares the defines related to multiview
  20188. * @param scene The scene we are intending to draw
  20189. * @param defines The defines to update
  20190. */
  20191. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20192. /**
  20193. * Prepares the defines related to the prepass
  20194. * @param scene The scene we are intending to draw
  20195. * @param defines The defines to update
  20196. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20197. */
  20198. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20199. /**
  20200. * Prepares the defines related to the light information passed in parameter
  20201. * @param scene The scene we are intending to draw
  20202. * @param mesh The mesh the effect is compiling for
  20203. * @param light The light the effect is compiling for
  20204. * @param lightIndex The index of the light
  20205. * @param defines The defines to update
  20206. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20207. * @param state Defines the current state regarding what is needed (normals, etc...)
  20208. */
  20209. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20210. needNormals: boolean;
  20211. needRebuild: boolean;
  20212. shadowEnabled: boolean;
  20213. specularEnabled: boolean;
  20214. lightmapMode: boolean;
  20215. }): void;
  20216. /**
  20217. * Prepares the defines related to the light information passed in parameter
  20218. * @param scene The scene we are intending to draw
  20219. * @param mesh The mesh the effect is compiling for
  20220. * @param defines The defines to update
  20221. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20222. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20223. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20224. * @returns true if normals will be required for the rest of the effect
  20225. */
  20226. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20227. /**
  20228. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20229. * @param lightIndex defines the light index
  20230. * @param uniformsList The uniform list
  20231. * @param samplersList The sampler list
  20232. * @param projectedLightTexture defines if projected texture must be used
  20233. * @param uniformBuffersList defines an optional list of uniform buffers
  20234. */
  20235. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20236. /**
  20237. * Prepares the uniforms and samplers list to be used in the effect
  20238. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20239. * @param samplersList The sampler list
  20240. * @param defines The defines helping in the list generation
  20241. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20242. */
  20243. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20244. /**
  20245. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20246. * @param defines The defines to update while falling back
  20247. * @param fallbacks The authorized effect fallbacks
  20248. * @param maxSimultaneousLights The maximum number of lights allowed
  20249. * @param rank the current rank of the Effect
  20250. * @returns The newly affected rank
  20251. */
  20252. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20253. private static _TmpMorphInfluencers;
  20254. /**
  20255. * Prepares the list of attributes required for morph targets according to the effect defines.
  20256. * @param attribs The current list of supported attribs
  20257. * @param mesh The mesh to prepare the morph targets attributes for
  20258. * @param influencers The number of influencers
  20259. */
  20260. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20261. /**
  20262. * Prepares the list of attributes required for morph targets according to the effect defines.
  20263. * @param attribs The current list of supported attribs
  20264. * @param mesh The mesh to prepare the morph targets attributes for
  20265. * @param defines The current Defines of the effect
  20266. */
  20267. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20268. /**
  20269. * Prepares the list of attributes required for bones according to the effect defines.
  20270. * @param attribs The current list of supported attribs
  20271. * @param mesh The mesh to prepare the bones attributes for
  20272. * @param defines The current Defines of the effect
  20273. * @param fallbacks The current efffect fallback strategy
  20274. */
  20275. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20276. /**
  20277. * Check and prepare the list of attributes required for instances according to the effect defines.
  20278. * @param attribs The current list of supported attribs
  20279. * @param defines The current MaterialDefines of the effect
  20280. */
  20281. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20282. /**
  20283. * Add the list of attributes required for instances to the attribs array.
  20284. * @param attribs The current list of supported attribs
  20285. */
  20286. static PushAttributesForInstances(attribs: string[]): void;
  20287. /**
  20288. * Binds the light information to the effect.
  20289. * @param light The light containing the generator
  20290. * @param effect The effect we are binding the data to
  20291. * @param lightIndex The light index in the effect used to render
  20292. */
  20293. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20294. /**
  20295. * Binds the lights information from the scene to the effect for the given mesh.
  20296. * @param light Light to bind
  20297. * @param lightIndex Light index
  20298. * @param scene The scene where the light belongs to
  20299. * @param effect The effect we are binding the data to
  20300. * @param useSpecular Defines if specular is supported
  20301. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20302. */
  20303. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20304. /**
  20305. * Binds the lights information from the scene to the effect for the given mesh.
  20306. * @param scene The scene the lights belongs to
  20307. * @param mesh The mesh we are binding the information to render
  20308. * @param effect The effect we are binding the data to
  20309. * @param defines The generated defines for the effect
  20310. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20311. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20312. */
  20313. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20314. private static _tempFogColor;
  20315. /**
  20316. * Binds the fog information from the scene to the effect for the given mesh.
  20317. * @param scene The scene the lights belongs to
  20318. * @param mesh The mesh we are binding the information to render
  20319. * @param effect The effect we are binding the data to
  20320. * @param linearSpace Defines if the fog effect is applied in linear space
  20321. */
  20322. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20323. /**
  20324. * Binds the bones information from the mesh to the effect.
  20325. * @param mesh The mesh we are binding the information to render
  20326. * @param effect The effect we are binding the data to
  20327. */
  20328. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20329. /**
  20330. * Binds the morph targets information from the mesh to the effect.
  20331. * @param abstractMesh The mesh we are binding the information to render
  20332. * @param effect The effect we are binding the data to
  20333. */
  20334. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20335. /**
  20336. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20337. * @param defines The generated defines used in the effect
  20338. * @param effect The effect we are binding the data to
  20339. * @param scene The scene we are willing to render with logarithmic scale for
  20340. */
  20341. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20342. /**
  20343. * Binds the clip plane information from the scene to the effect.
  20344. * @param scene The scene the clip plane information are extracted from
  20345. * @param effect The effect we are binding the data to
  20346. */
  20347. static BindClipPlane(effect: Effect, scene: Scene): void;
  20348. }
  20349. }
  20350. declare module BABYLON {
  20351. /**
  20352. * Block used to expose an input value
  20353. */
  20354. export class InputBlock extends NodeMaterialBlock {
  20355. private _mode;
  20356. private _associatedVariableName;
  20357. private _storedValue;
  20358. private _valueCallback;
  20359. private _type;
  20360. private _animationType;
  20361. /** Gets or set a value used to limit the range of float values */
  20362. min: number;
  20363. /** Gets or set a value used to limit the range of float values */
  20364. max: number;
  20365. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20366. isBoolean: boolean;
  20367. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20368. matrixMode: number;
  20369. /** @hidden */
  20370. _systemValue: Nullable<NodeMaterialSystemValues>;
  20371. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20372. visibleInInspector: boolean;
  20373. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20374. isConstant: boolean;
  20375. /** Gets or sets the group to use to display this block in the Inspector */
  20376. groupInInspector: string;
  20377. /** Gets an observable raised when the value is changed */
  20378. onValueChangedObservable: Observable<InputBlock>;
  20379. /**
  20380. * Gets or sets the connection point type (default is float)
  20381. */
  20382. get type(): NodeMaterialBlockConnectionPointTypes;
  20383. /**
  20384. * Creates a new InputBlock
  20385. * @param name defines the block name
  20386. * @param target defines the target of that block (Vertex by default)
  20387. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20388. */
  20389. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20390. /**
  20391. * Validates if a name is a reserve word.
  20392. * @param newName the new name to be given to the node.
  20393. * @returns false if the name is a reserve word, else true.
  20394. */
  20395. validateBlockName(newName: string): boolean;
  20396. /**
  20397. * Gets the output component
  20398. */
  20399. get output(): NodeMaterialConnectionPoint;
  20400. /**
  20401. * Set the source of this connection point to a vertex attribute
  20402. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20403. * @returns the current connection point
  20404. */
  20405. setAsAttribute(attributeName?: string): InputBlock;
  20406. /**
  20407. * Set the source of this connection point to a system value
  20408. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20409. * @returns the current connection point
  20410. */
  20411. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20412. /**
  20413. * Gets or sets the value of that point.
  20414. * Please note that this value will be ignored if valueCallback is defined
  20415. */
  20416. get value(): any;
  20417. set value(value: any);
  20418. /**
  20419. * Gets or sets a callback used to get the value of that point.
  20420. * Please note that setting this value will force the connection point to ignore the value property
  20421. */
  20422. get valueCallback(): () => any;
  20423. set valueCallback(value: () => any);
  20424. /**
  20425. * Gets or sets the associated variable name in the shader
  20426. */
  20427. get associatedVariableName(): string;
  20428. set associatedVariableName(value: string);
  20429. /** Gets or sets the type of animation applied to the input */
  20430. get animationType(): AnimatedInputBlockTypes;
  20431. set animationType(value: AnimatedInputBlockTypes);
  20432. /**
  20433. * Gets a boolean indicating that this connection point not defined yet
  20434. */
  20435. get isUndefined(): boolean;
  20436. /**
  20437. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20438. * In this case the connection point name must be the name of the uniform to use.
  20439. * Can only be set on inputs
  20440. */
  20441. get isUniform(): boolean;
  20442. set isUniform(value: boolean);
  20443. /**
  20444. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20445. * In this case the connection point name must be the name of the attribute to use
  20446. * Can only be set on inputs
  20447. */
  20448. get isAttribute(): boolean;
  20449. set isAttribute(value: boolean);
  20450. /**
  20451. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20452. * Can only be set on exit points
  20453. */
  20454. get isVarying(): boolean;
  20455. set isVarying(value: boolean);
  20456. /**
  20457. * Gets a boolean indicating that the current connection point is a system value
  20458. */
  20459. get isSystemValue(): boolean;
  20460. /**
  20461. * Gets or sets the current well known value or null if not defined as a system value
  20462. */
  20463. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20464. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20465. /**
  20466. * Gets the current class name
  20467. * @returns the class name
  20468. */
  20469. getClassName(): string;
  20470. /**
  20471. * Animate the input if animationType !== None
  20472. * @param scene defines the rendering scene
  20473. */
  20474. animate(scene: Scene): void;
  20475. private _emitDefine;
  20476. initialize(state: NodeMaterialBuildState): void;
  20477. /**
  20478. * Set the input block to its default value (based on its type)
  20479. */
  20480. setDefaultValue(): void;
  20481. private _emitConstant;
  20482. /** @hidden */
  20483. get _noContextSwitch(): boolean;
  20484. private _emit;
  20485. /** @hidden */
  20486. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20487. /** @hidden */
  20488. _transmit(effect: Effect, scene: Scene): void;
  20489. protected _buildBlock(state: NodeMaterialBuildState): void;
  20490. protected _dumpPropertiesCode(): string;
  20491. dispose(): void;
  20492. serialize(): any;
  20493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20494. }
  20495. }
  20496. declare module BABYLON {
  20497. /**
  20498. * Enum used to define the compatibility state between two connection points
  20499. */
  20500. export enum NodeMaterialConnectionPointCompatibilityStates {
  20501. /** Points are compatibles */
  20502. Compatible = 0,
  20503. /** Points are incompatible because of their types */
  20504. TypeIncompatible = 1,
  20505. /** Points are incompatible because of their targets (vertex vs fragment) */
  20506. TargetIncompatible = 2
  20507. }
  20508. /**
  20509. * Defines the direction of a connection point
  20510. */
  20511. export enum NodeMaterialConnectionPointDirection {
  20512. /** Input */
  20513. Input = 0,
  20514. /** Output */
  20515. Output = 1
  20516. }
  20517. /**
  20518. * Defines a connection point for a block
  20519. */
  20520. export class NodeMaterialConnectionPoint {
  20521. /** @hidden */
  20522. _ownerBlock: NodeMaterialBlock;
  20523. /** @hidden */
  20524. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20525. private _endpoints;
  20526. private _associatedVariableName;
  20527. private _direction;
  20528. /** @hidden */
  20529. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20530. /** @hidden */
  20531. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20532. private _type;
  20533. /** @hidden */
  20534. _enforceAssociatedVariableName: boolean;
  20535. /** Gets the direction of the point */
  20536. get direction(): NodeMaterialConnectionPointDirection;
  20537. /** Indicates that this connection point needs dual validation before being connected to another point */
  20538. needDualDirectionValidation: boolean;
  20539. /**
  20540. * Gets or sets the additional types supported by this connection point
  20541. */
  20542. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20543. /**
  20544. * Gets or sets the additional types excluded by this connection point
  20545. */
  20546. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20547. /**
  20548. * Observable triggered when this point is connected
  20549. */
  20550. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20551. /**
  20552. * Gets or sets the associated variable name in the shader
  20553. */
  20554. get associatedVariableName(): string;
  20555. set associatedVariableName(value: string);
  20556. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20557. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20558. /**
  20559. * Gets or sets the connection point type (default is float)
  20560. */
  20561. get type(): NodeMaterialBlockConnectionPointTypes;
  20562. set type(value: NodeMaterialBlockConnectionPointTypes);
  20563. /**
  20564. * Gets or sets the connection point name
  20565. */
  20566. name: string;
  20567. /**
  20568. * Gets or sets the connection point name
  20569. */
  20570. displayName: string;
  20571. /**
  20572. * Gets or sets a boolean indicating that this connection point can be omitted
  20573. */
  20574. isOptional: boolean;
  20575. /**
  20576. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20577. */
  20578. isExposedOnFrame: boolean;
  20579. /**
  20580. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20581. */
  20582. define: string;
  20583. /** @hidden */
  20584. _prioritizeVertex: boolean;
  20585. private _target;
  20586. /** Gets or sets the target of that connection point */
  20587. get target(): NodeMaterialBlockTargets;
  20588. set target(value: NodeMaterialBlockTargets);
  20589. /**
  20590. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20591. */
  20592. get isConnected(): boolean;
  20593. /**
  20594. * Gets a boolean indicating that the current point is connected to an input block
  20595. */
  20596. get isConnectedToInputBlock(): boolean;
  20597. /**
  20598. * Gets a the connected input block (if any)
  20599. */
  20600. get connectInputBlock(): Nullable<InputBlock>;
  20601. /** Get the other side of the connection (if any) */
  20602. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20603. /** Get the block that owns this connection point */
  20604. get ownerBlock(): NodeMaterialBlock;
  20605. /** Get the block connected on the other side of this connection (if any) */
  20606. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20607. /** Get the block connected on the endpoints of this connection (if any) */
  20608. get connectedBlocks(): Array<NodeMaterialBlock>;
  20609. /** Gets the list of connected endpoints */
  20610. get endpoints(): NodeMaterialConnectionPoint[];
  20611. /** Gets a boolean indicating if that output point is connected to at least one input */
  20612. get hasEndpoints(): boolean;
  20613. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20614. get isConnectedInVertexShader(): boolean;
  20615. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20616. get isConnectedInFragmentShader(): boolean;
  20617. /**
  20618. * Creates a block suitable to be used as an input for this input point.
  20619. * If null is returned, a block based on the point type will be created.
  20620. * @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
  20621. */
  20622. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20623. /**
  20624. * Creates a new connection point
  20625. * @param name defines the connection point name
  20626. * @param ownerBlock defines the block hosting this connection point
  20627. * @param direction defines the direction of the connection point
  20628. */
  20629. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20630. /**
  20631. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20632. * @returns the class name
  20633. */
  20634. getClassName(): string;
  20635. /**
  20636. * Gets a boolean indicating if the current point can be connected to another point
  20637. * @param connectionPoint defines the other connection point
  20638. * @returns a boolean
  20639. */
  20640. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20641. /**
  20642. * Gets a number indicating if the current point can be connected to another point
  20643. * @param connectionPoint defines the other connection point
  20644. * @returns a number defining the compatibility state
  20645. */
  20646. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20647. /**
  20648. * Connect this point to another connection point
  20649. * @param connectionPoint defines the other connection point
  20650. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20651. * @returns the current connection point
  20652. */
  20653. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20654. /**
  20655. * Disconnect this point from one of his endpoint
  20656. * @param endpoint defines the other connection point
  20657. * @returns the current connection point
  20658. */
  20659. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20660. /**
  20661. * Serializes this point in a JSON representation
  20662. * @param isInput defines if the connection point is an input (default is true)
  20663. * @returns the serialized point object
  20664. */
  20665. serialize(isInput?: boolean): any;
  20666. /**
  20667. * Release resources
  20668. */
  20669. dispose(): void;
  20670. }
  20671. }
  20672. declare module BABYLON {
  20673. /**
  20674. * Enum used to define the material modes
  20675. */
  20676. export enum NodeMaterialModes {
  20677. /** Regular material */
  20678. Material = 0,
  20679. /** For post process */
  20680. PostProcess = 1,
  20681. /** For particle system */
  20682. Particle = 2
  20683. }
  20684. }
  20685. declare module BABYLON {
  20686. /**
  20687. * Block used to read a texture from a sampler
  20688. */
  20689. export class TextureBlock extends NodeMaterialBlock {
  20690. private _defineName;
  20691. private _linearDefineName;
  20692. private _gammaDefineName;
  20693. private _tempTextureRead;
  20694. private _samplerName;
  20695. private _transformedUVName;
  20696. private _textureTransformName;
  20697. private _textureInfoName;
  20698. private _mainUVName;
  20699. private _mainUVDefineName;
  20700. private _fragmentOnly;
  20701. /**
  20702. * Gets or sets the texture associated with the node
  20703. */
  20704. texture: Nullable<Texture>;
  20705. /**
  20706. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20707. */
  20708. convertToGammaSpace: boolean;
  20709. /**
  20710. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20711. */
  20712. convertToLinearSpace: boolean;
  20713. /**
  20714. * Create a new TextureBlock
  20715. * @param name defines the block name
  20716. */
  20717. constructor(name: string, fragmentOnly?: boolean);
  20718. /**
  20719. * Gets the current class name
  20720. * @returns the class name
  20721. */
  20722. getClassName(): string;
  20723. /**
  20724. * Gets the uv input component
  20725. */
  20726. get uv(): NodeMaterialConnectionPoint;
  20727. /**
  20728. * Gets the rgba output component
  20729. */
  20730. get rgba(): NodeMaterialConnectionPoint;
  20731. /**
  20732. * Gets the rgb output component
  20733. */
  20734. get rgb(): NodeMaterialConnectionPoint;
  20735. /**
  20736. * Gets the r output component
  20737. */
  20738. get r(): NodeMaterialConnectionPoint;
  20739. /**
  20740. * Gets the g output component
  20741. */
  20742. get g(): NodeMaterialConnectionPoint;
  20743. /**
  20744. * Gets the b output component
  20745. */
  20746. get b(): NodeMaterialConnectionPoint;
  20747. /**
  20748. * Gets the a output component
  20749. */
  20750. get a(): NodeMaterialConnectionPoint;
  20751. get target(): NodeMaterialBlockTargets;
  20752. autoConfigure(material: NodeMaterial): void;
  20753. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20754. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20755. isReady(): boolean;
  20756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20757. private get _isMixed();
  20758. private _injectVertexCode;
  20759. private _writeTextureRead;
  20760. private _writeOutput;
  20761. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20762. protected _dumpPropertiesCode(): string;
  20763. serialize(): any;
  20764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20765. }
  20766. }
  20767. declare module BABYLON {
  20768. /** @hidden */
  20769. export var reflectionFunction: {
  20770. name: string;
  20771. shader: string;
  20772. };
  20773. }
  20774. declare module BABYLON {
  20775. /**
  20776. * Base block used to read a reflection texture from a sampler
  20777. */
  20778. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20779. /** @hidden */
  20780. _define3DName: string;
  20781. /** @hidden */
  20782. _defineCubicName: string;
  20783. /** @hidden */
  20784. _defineExplicitName: string;
  20785. /** @hidden */
  20786. _defineProjectionName: string;
  20787. /** @hidden */
  20788. _defineLocalCubicName: string;
  20789. /** @hidden */
  20790. _defineSphericalName: string;
  20791. /** @hidden */
  20792. _definePlanarName: string;
  20793. /** @hidden */
  20794. _defineEquirectangularName: string;
  20795. /** @hidden */
  20796. _defineMirroredEquirectangularFixedName: string;
  20797. /** @hidden */
  20798. _defineEquirectangularFixedName: string;
  20799. /** @hidden */
  20800. _defineSkyboxName: string;
  20801. /** @hidden */
  20802. _defineOppositeZ: string;
  20803. /** @hidden */
  20804. _cubeSamplerName: string;
  20805. /** @hidden */
  20806. _2DSamplerName: string;
  20807. protected _positionUVWName: string;
  20808. protected _directionWName: string;
  20809. protected _reflectionVectorName: string;
  20810. /** @hidden */
  20811. _reflectionCoordsName: string;
  20812. /** @hidden */
  20813. _reflectionMatrixName: string;
  20814. protected _reflectionColorName: string;
  20815. /**
  20816. * Gets or sets the texture associated with the node
  20817. */
  20818. texture: Nullable<BaseTexture>;
  20819. /**
  20820. * Create a new ReflectionTextureBaseBlock
  20821. * @param name defines the block name
  20822. */
  20823. constructor(name: string);
  20824. /**
  20825. * Gets the current class name
  20826. * @returns the class name
  20827. */
  20828. getClassName(): string;
  20829. /**
  20830. * Gets the world position input component
  20831. */
  20832. abstract get position(): NodeMaterialConnectionPoint;
  20833. /**
  20834. * Gets the world position input component
  20835. */
  20836. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20837. /**
  20838. * Gets the world normal input component
  20839. */
  20840. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20841. /**
  20842. * Gets the world input component
  20843. */
  20844. abstract get world(): NodeMaterialConnectionPoint;
  20845. /**
  20846. * Gets the camera (or eye) position component
  20847. */
  20848. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20849. /**
  20850. * Gets the view input component
  20851. */
  20852. abstract get view(): NodeMaterialConnectionPoint;
  20853. protected _getTexture(): Nullable<BaseTexture>;
  20854. autoConfigure(material: NodeMaterial): void;
  20855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20856. isReady(): boolean;
  20857. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20858. /**
  20859. * Gets the code to inject in the vertex shader
  20860. * @param state current state of the node material building
  20861. * @returns the shader code
  20862. */
  20863. handleVertexSide(state: NodeMaterialBuildState): string;
  20864. /**
  20865. * Handles the inits for the fragment code path
  20866. * @param state node material build state
  20867. */
  20868. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20869. /**
  20870. * Generates the reflection coords code for the fragment code path
  20871. * @param worldNormalVarName name of the world normal variable
  20872. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20873. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20874. * @returns the shader code
  20875. */
  20876. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20877. /**
  20878. * Generates the reflection color code for the fragment code path
  20879. * @param lodVarName name of the lod variable
  20880. * @param swizzleLookupTexture swizzle to use for the final color variable
  20881. * @returns the shader code
  20882. */
  20883. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20884. /**
  20885. * Generates the code corresponding to the connected output points
  20886. * @param state node material build state
  20887. * @param varName name of the variable to output
  20888. * @returns the shader code
  20889. */
  20890. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20891. protected _buildBlock(state: NodeMaterialBuildState): this;
  20892. protected _dumpPropertiesCode(): string;
  20893. serialize(): any;
  20894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20895. }
  20896. }
  20897. declare module BABYLON {
  20898. /**
  20899. * Defines a connection point to be used for points with a custom object type
  20900. */
  20901. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20902. private _blockType;
  20903. private _blockName;
  20904. private _nameForCheking?;
  20905. /**
  20906. * Creates a new connection point
  20907. * @param name defines the connection point name
  20908. * @param ownerBlock defines the block hosting this connection point
  20909. * @param direction defines the direction of the connection point
  20910. */
  20911. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20912. /**
  20913. * Gets a number indicating if the current point can be connected to another point
  20914. * @param connectionPoint defines the other connection point
  20915. * @returns a number defining the compatibility state
  20916. */
  20917. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20918. /**
  20919. * Creates a block suitable to be used as an input for this input point.
  20920. * If null is returned, a block based on the point type will be created.
  20921. * @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
  20922. */
  20923. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20924. }
  20925. }
  20926. declare module BABYLON {
  20927. /**
  20928. * Enum defining the type of properties that can be edited in the property pages in the NME
  20929. */
  20930. export enum PropertyTypeForEdition {
  20931. /** property is a boolean */
  20932. Boolean = 0,
  20933. /** property is a float */
  20934. Float = 1,
  20935. /** property is a Vector2 */
  20936. Vector2 = 2,
  20937. /** property is a list of values */
  20938. List = 3
  20939. }
  20940. /**
  20941. * Interface that defines an option in a variable of type list
  20942. */
  20943. export interface IEditablePropertyListOption {
  20944. /** label of the option */
  20945. "label": string;
  20946. /** value of the option */
  20947. "value": number;
  20948. }
  20949. /**
  20950. * Interface that defines the options available for an editable property
  20951. */
  20952. export interface IEditablePropertyOption {
  20953. /** min value */
  20954. "min"?: number;
  20955. /** max value */
  20956. "max"?: number;
  20957. /** notifiers: indicates which actions to take when the property is changed */
  20958. "notifiers"?: {
  20959. /** the material should be rebuilt */
  20960. "rebuild"?: boolean;
  20961. /** the preview should be updated */
  20962. "update"?: boolean;
  20963. };
  20964. /** list of the options for a variable of type list */
  20965. "options"?: IEditablePropertyListOption[];
  20966. }
  20967. /**
  20968. * Interface that describes an editable property
  20969. */
  20970. export interface IPropertyDescriptionForEdition {
  20971. /** name of the property */
  20972. "propertyName": string;
  20973. /** display name of the property */
  20974. "displayName": string;
  20975. /** type of the property */
  20976. "type": PropertyTypeForEdition;
  20977. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20978. "groupName": string;
  20979. /** options for the property */
  20980. "options": IEditablePropertyOption;
  20981. }
  20982. /**
  20983. * Decorator that flags a property in a node material block as being editable
  20984. */
  20985. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20986. }
  20987. declare module BABYLON {
  20988. /**
  20989. * Block used to implement the refraction part of the sub surface module of the PBR material
  20990. */
  20991. export class RefractionBlock extends NodeMaterialBlock {
  20992. /** @hidden */
  20993. _define3DName: string;
  20994. /** @hidden */
  20995. _refractionMatrixName: string;
  20996. /** @hidden */
  20997. _defineLODRefractionAlpha: string;
  20998. /** @hidden */
  20999. _defineLinearSpecularRefraction: string;
  21000. /** @hidden */
  21001. _defineOppositeZ: string;
  21002. /** @hidden */
  21003. _cubeSamplerName: string;
  21004. /** @hidden */
  21005. _2DSamplerName: string;
  21006. /** @hidden */
  21007. _vRefractionMicrosurfaceInfosName: string;
  21008. /** @hidden */
  21009. _vRefractionInfosName: string;
  21010. private _scene;
  21011. /**
  21012. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21013. * Materials half opaque for instance using refraction could benefit from this control.
  21014. */
  21015. linkRefractionWithTransparency: boolean;
  21016. /**
  21017. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21018. */
  21019. invertRefractionY: boolean;
  21020. /**
  21021. * Gets or sets the texture associated with the node
  21022. */
  21023. texture: Nullable<BaseTexture>;
  21024. /**
  21025. * Create a new RefractionBlock
  21026. * @param name defines the block name
  21027. */
  21028. constructor(name: string);
  21029. /**
  21030. * Gets the current class name
  21031. * @returns the class name
  21032. */
  21033. getClassName(): string;
  21034. /**
  21035. * Gets the intensity input component
  21036. */
  21037. get intensity(): NodeMaterialConnectionPoint;
  21038. /**
  21039. * Gets the index of refraction input component
  21040. */
  21041. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21042. /**
  21043. * Gets the tint at distance input component
  21044. */
  21045. get tintAtDistance(): NodeMaterialConnectionPoint;
  21046. /**
  21047. * Gets the view input component
  21048. */
  21049. get view(): NodeMaterialConnectionPoint;
  21050. /**
  21051. * Gets the refraction object output component
  21052. */
  21053. get refraction(): NodeMaterialConnectionPoint;
  21054. /**
  21055. * Returns true if the block has a texture
  21056. */
  21057. get hasTexture(): boolean;
  21058. protected _getTexture(): Nullable<BaseTexture>;
  21059. autoConfigure(material: NodeMaterial): void;
  21060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21061. isReady(): boolean;
  21062. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21063. /**
  21064. * Gets the main code of the block (fragment side)
  21065. * @param state current state of the node material building
  21066. * @returns the shader code
  21067. */
  21068. getCode(state: NodeMaterialBuildState): string;
  21069. protected _buildBlock(state: NodeMaterialBuildState): this;
  21070. protected _dumpPropertiesCode(): string;
  21071. serialize(): any;
  21072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21073. }
  21074. }
  21075. declare module BABYLON {
  21076. /**
  21077. * Base block used as input for post process
  21078. */
  21079. export class CurrentScreenBlock extends NodeMaterialBlock {
  21080. private _samplerName;
  21081. private _linearDefineName;
  21082. private _gammaDefineName;
  21083. private _mainUVName;
  21084. private _tempTextureRead;
  21085. /**
  21086. * Gets or sets the texture associated with the node
  21087. */
  21088. texture: Nullable<BaseTexture>;
  21089. /**
  21090. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21091. */
  21092. convertToGammaSpace: boolean;
  21093. /**
  21094. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21095. */
  21096. convertToLinearSpace: boolean;
  21097. /**
  21098. * Create a new CurrentScreenBlock
  21099. * @param name defines the block name
  21100. */
  21101. constructor(name: string);
  21102. /**
  21103. * Gets the current class name
  21104. * @returns the class name
  21105. */
  21106. getClassName(): string;
  21107. /**
  21108. * Gets the uv input component
  21109. */
  21110. get uv(): NodeMaterialConnectionPoint;
  21111. /**
  21112. * Gets the rgba output component
  21113. */
  21114. get rgba(): NodeMaterialConnectionPoint;
  21115. /**
  21116. * Gets the rgb output component
  21117. */
  21118. get rgb(): NodeMaterialConnectionPoint;
  21119. /**
  21120. * Gets the r output component
  21121. */
  21122. get r(): NodeMaterialConnectionPoint;
  21123. /**
  21124. * Gets the g output component
  21125. */
  21126. get g(): NodeMaterialConnectionPoint;
  21127. /**
  21128. * Gets the b output component
  21129. */
  21130. get b(): NodeMaterialConnectionPoint;
  21131. /**
  21132. * Gets the a output component
  21133. */
  21134. get a(): NodeMaterialConnectionPoint;
  21135. /**
  21136. * Initialize the block and prepare the context for build
  21137. * @param state defines the state that will be used for the build
  21138. */
  21139. initialize(state: NodeMaterialBuildState): void;
  21140. get target(): NodeMaterialBlockTargets;
  21141. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21142. isReady(): boolean;
  21143. private _injectVertexCode;
  21144. private _writeTextureRead;
  21145. private _writeOutput;
  21146. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21147. serialize(): any;
  21148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21149. }
  21150. }
  21151. declare module BABYLON {
  21152. /**
  21153. * Base block used for the particle texture
  21154. */
  21155. export class ParticleTextureBlock extends NodeMaterialBlock {
  21156. private _samplerName;
  21157. private _linearDefineName;
  21158. private _gammaDefineName;
  21159. private _tempTextureRead;
  21160. /**
  21161. * Gets or sets the texture associated with the node
  21162. */
  21163. texture: Nullable<BaseTexture>;
  21164. /**
  21165. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21166. */
  21167. convertToGammaSpace: boolean;
  21168. /**
  21169. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21170. */
  21171. convertToLinearSpace: boolean;
  21172. /**
  21173. * Create a new ParticleTextureBlock
  21174. * @param name defines the block name
  21175. */
  21176. constructor(name: string);
  21177. /**
  21178. * Gets the current class name
  21179. * @returns the class name
  21180. */
  21181. getClassName(): string;
  21182. /**
  21183. * Gets the uv input component
  21184. */
  21185. get uv(): NodeMaterialConnectionPoint;
  21186. /**
  21187. * Gets the rgba output component
  21188. */
  21189. get rgba(): NodeMaterialConnectionPoint;
  21190. /**
  21191. * Gets the rgb output component
  21192. */
  21193. get rgb(): NodeMaterialConnectionPoint;
  21194. /**
  21195. * Gets the r output component
  21196. */
  21197. get r(): NodeMaterialConnectionPoint;
  21198. /**
  21199. * Gets the g output component
  21200. */
  21201. get g(): NodeMaterialConnectionPoint;
  21202. /**
  21203. * Gets the b output component
  21204. */
  21205. get b(): NodeMaterialConnectionPoint;
  21206. /**
  21207. * Gets the a output component
  21208. */
  21209. get a(): NodeMaterialConnectionPoint;
  21210. /**
  21211. * Initialize the block and prepare the context for build
  21212. * @param state defines the state that will be used for the build
  21213. */
  21214. initialize(state: NodeMaterialBuildState): void;
  21215. autoConfigure(material: NodeMaterial): void;
  21216. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21217. isReady(): boolean;
  21218. private _writeOutput;
  21219. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21220. serialize(): any;
  21221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21222. }
  21223. }
  21224. declare module BABYLON {
  21225. /**
  21226. * Class used to store shared data between 2 NodeMaterialBuildState
  21227. */
  21228. export class NodeMaterialBuildStateSharedData {
  21229. /**
  21230. * Gets the list of emitted varyings
  21231. */
  21232. temps: string[];
  21233. /**
  21234. * Gets the list of emitted varyings
  21235. */
  21236. varyings: string[];
  21237. /**
  21238. * Gets the varying declaration string
  21239. */
  21240. varyingDeclaration: string;
  21241. /**
  21242. * Input blocks
  21243. */
  21244. inputBlocks: InputBlock[];
  21245. /**
  21246. * Input blocks
  21247. */
  21248. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21249. /**
  21250. * Bindable blocks (Blocks that need to set data to the effect)
  21251. */
  21252. bindableBlocks: NodeMaterialBlock[];
  21253. /**
  21254. * List of blocks that can provide a compilation fallback
  21255. */
  21256. blocksWithFallbacks: NodeMaterialBlock[];
  21257. /**
  21258. * List of blocks that can provide a define update
  21259. */
  21260. blocksWithDefines: NodeMaterialBlock[];
  21261. /**
  21262. * List of blocks that can provide a repeatable content
  21263. */
  21264. repeatableContentBlocks: NodeMaterialBlock[];
  21265. /**
  21266. * List of blocks that can provide a dynamic list of uniforms
  21267. */
  21268. dynamicUniformBlocks: NodeMaterialBlock[];
  21269. /**
  21270. * List of blocks that can block the isReady function for the material
  21271. */
  21272. blockingBlocks: NodeMaterialBlock[];
  21273. /**
  21274. * Gets the list of animated inputs
  21275. */
  21276. animatedInputs: InputBlock[];
  21277. /**
  21278. * Build Id used to avoid multiple recompilations
  21279. */
  21280. buildId: number;
  21281. /** List of emitted variables */
  21282. variableNames: {
  21283. [key: string]: number;
  21284. };
  21285. /** List of emitted defines */
  21286. defineNames: {
  21287. [key: string]: number;
  21288. };
  21289. /** Should emit comments? */
  21290. emitComments: boolean;
  21291. /** Emit build activity */
  21292. verbose: boolean;
  21293. /** Gets or sets the hosting scene */
  21294. scene: Scene;
  21295. /**
  21296. * Gets the compilation hints emitted at compilation time
  21297. */
  21298. hints: {
  21299. needWorldViewMatrix: boolean;
  21300. needWorldViewProjectionMatrix: boolean;
  21301. needAlphaBlending: boolean;
  21302. needAlphaTesting: boolean;
  21303. };
  21304. /**
  21305. * List of compilation checks
  21306. */
  21307. checks: {
  21308. emitVertex: boolean;
  21309. emitFragment: boolean;
  21310. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21311. };
  21312. /**
  21313. * Is vertex program allowed to be empty?
  21314. */
  21315. allowEmptyVertexProgram: boolean;
  21316. /** Creates a new shared data */
  21317. constructor();
  21318. /**
  21319. * Emits console errors and exceptions if there is a failing check
  21320. */
  21321. emitErrors(): void;
  21322. }
  21323. }
  21324. declare module BABYLON {
  21325. /**
  21326. * Class used to store node based material build state
  21327. */
  21328. export class NodeMaterialBuildState {
  21329. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21330. supportUniformBuffers: boolean;
  21331. /**
  21332. * Gets the list of emitted attributes
  21333. */
  21334. attributes: string[];
  21335. /**
  21336. * Gets the list of emitted uniforms
  21337. */
  21338. uniforms: string[];
  21339. /**
  21340. * Gets the list of emitted constants
  21341. */
  21342. constants: string[];
  21343. /**
  21344. * Gets the list of emitted samplers
  21345. */
  21346. samplers: string[];
  21347. /**
  21348. * Gets the list of emitted functions
  21349. */
  21350. functions: {
  21351. [key: string]: string;
  21352. };
  21353. /**
  21354. * Gets the list of emitted extensions
  21355. */
  21356. extensions: {
  21357. [key: string]: string;
  21358. };
  21359. /**
  21360. * Gets the target of the compilation state
  21361. */
  21362. target: NodeMaterialBlockTargets;
  21363. /**
  21364. * Gets the list of emitted counters
  21365. */
  21366. counters: {
  21367. [key: string]: number;
  21368. };
  21369. /**
  21370. * Shared data between multiple NodeMaterialBuildState instances
  21371. */
  21372. sharedData: NodeMaterialBuildStateSharedData;
  21373. /** @hidden */
  21374. _vertexState: NodeMaterialBuildState;
  21375. /** @hidden */
  21376. _attributeDeclaration: string;
  21377. /** @hidden */
  21378. _uniformDeclaration: string;
  21379. /** @hidden */
  21380. _constantDeclaration: string;
  21381. /** @hidden */
  21382. _samplerDeclaration: string;
  21383. /** @hidden */
  21384. _varyingTransfer: string;
  21385. /** @hidden */
  21386. _injectAtEnd: string;
  21387. private _repeatableContentAnchorIndex;
  21388. /** @hidden */
  21389. _builtCompilationString: string;
  21390. /**
  21391. * Gets the emitted compilation strings
  21392. */
  21393. compilationString: string;
  21394. /**
  21395. * Finalize the compilation strings
  21396. * @param state defines the current compilation state
  21397. */
  21398. finalize(state: NodeMaterialBuildState): void;
  21399. /** @hidden */
  21400. get _repeatableContentAnchor(): string;
  21401. /** @hidden */
  21402. _getFreeVariableName(prefix: string): string;
  21403. /** @hidden */
  21404. _getFreeDefineName(prefix: string): string;
  21405. /** @hidden */
  21406. _excludeVariableName(name: string): void;
  21407. /** @hidden */
  21408. _emit2DSampler(name: string): void;
  21409. /** @hidden */
  21410. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21411. /** @hidden */
  21412. _emitExtension(name: string, extension: string, define?: string): void;
  21413. /** @hidden */
  21414. _emitFunction(name: string, code: string, comments: string): void;
  21415. /** @hidden */
  21416. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21417. replaceStrings?: {
  21418. search: RegExp;
  21419. replace: string;
  21420. }[];
  21421. repeatKey?: string;
  21422. }): string;
  21423. /** @hidden */
  21424. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21425. repeatKey?: string;
  21426. removeAttributes?: boolean;
  21427. removeUniforms?: boolean;
  21428. removeVaryings?: boolean;
  21429. removeIfDef?: boolean;
  21430. replaceStrings?: {
  21431. search: RegExp;
  21432. replace: string;
  21433. }[];
  21434. }, storeKey?: string): void;
  21435. /** @hidden */
  21436. _registerTempVariable(name: string): boolean;
  21437. /** @hidden */
  21438. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21439. /** @hidden */
  21440. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21441. /** @hidden */
  21442. _emitFloat(value: number): string;
  21443. }
  21444. }
  21445. declare module BABYLON {
  21446. /**
  21447. * Helper class used to generate session unique ID
  21448. */
  21449. export class UniqueIdGenerator {
  21450. private static _UniqueIdCounter;
  21451. /**
  21452. * Gets an unique (relatively to the current scene) Id
  21453. */
  21454. static get UniqueId(): number;
  21455. }
  21456. }
  21457. declare module BABYLON {
  21458. /**
  21459. * Defines a block that can be used inside a node based material
  21460. */
  21461. export class NodeMaterialBlock {
  21462. private _buildId;
  21463. private _buildTarget;
  21464. private _target;
  21465. private _isFinalMerger;
  21466. private _isInput;
  21467. private _name;
  21468. protected _isUnique: boolean;
  21469. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21470. inputsAreExclusive: boolean;
  21471. /** @hidden */
  21472. _codeVariableName: string;
  21473. /** @hidden */
  21474. _inputs: NodeMaterialConnectionPoint[];
  21475. /** @hidden */
  21476. _outputs: NodeMaterialConnectionPoint[];
  21477. /** @hidden */
  21478. _preparationId: number;
  21479. /**
  21480. * Gets the name of the block
  21481. */
  21482. get name(): string;
  21483. /**
  21484. * Sets the name of the block. Will check if the name is valid.
  21485. */
  21486. set name(newName: string);
  21487. /**
  21488. * Gets or sets the unique id of the node
  21489. */
  21490. uniqueId: number;
  21491. /**
  21492. * Gets or sets the comments associated with this block
  21493. */
  21494. comments: string;
  21495. /**
  21496. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21497. */
  21498. get isUnique(): boolean;
  21499. /**
  21500. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21501. */
  21502. get isFinalMerger(): boolean;
  21503. /**
  21504. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21505. */
  21506. get isInput(): boolean;
  21507. /**
  21508. * Gets or sets the build Id
  21509. */
  21510. get buildId(): number;
  21511. set buildId(value: number);
  21512. /**
  21513. * Gets or sets the target of the block
  21514. */
  21515. get target(): NodeMaterialBlockTargets;
  21516. set target(value: NodeMaterialBlockTargets);
  21517. /**
  21518. * Gets the list of input points
  21519. */
  21520. get inputs(): NodeMaterialConnectionPoint[];
  21521. /** Gets the list of output points */
  21522. get outputs(): NodeMaterialConnectionPoint[];
  21523. /**
  21524. * Find an input by its name
  21525. * @param name defines the name of the input to look for
  21526. * @returns the input or null if not found
  21527. */
  21528. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21529. /**
  21530. * Find an output by its name
  21531. * @param name defines the name of the outputto look for
  21532. * @returns the output or null if not found
  21533. */
  21534. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21535. /**
  21536. * Creates a new NodeMaterialBlock
  21537. * @param name defines the block name
  21538. * @param target defines the target of that block (Vertex by default)
  21539. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21540. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21541. */
  21542. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21543. /**
  21544. * Initialize the block and prepare the context for build
  21545. * @param state defines the state that will be used for the build
  21546. */
  21547. initialize(state: NodeMaterialBuildState): void;
  21548. /**
  21549. * Bind data to effect. Will only be called for blocks with isBindable === true
  21550. * @param effect defines the effect to bind data to
  21551. * @param nodeMaterial defines the hosting NodeMaterial
  21552. * @param mesh defines the mesh that will be rendered
  21553. * @param subMesh defines the submesh that will be rendered
  21554. */
  21555. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21556. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21557. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21558. protected _writeFloat(value: number): string;
  21559. /**
  21560. * Gets the current class name e.g. "NodeMaterialBlock"
  21561. * @returns the class name
  21562. */
  21563. getClassName(): string;
  21564. /**
  21565. * Register a new input. Must be called inside a block constructor
  21566. * @param name defines the connection point name
  21567. * @param type defines the connection point type
  21568. * @param isOptional defines a boolean indicating that this input can be omitted
  21569. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21570. * @param point an already created connection point. If not provided, create a new one
  21571. * @returns the current block
  21572. */
  21573. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21574. /**
  21575. * Register a new output. Must be called inside a block constructor
  21576. * @param name defines the connection point name
  21577. * @param type defines the connection point type
  21578. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21579. * @param point an already created connection point. If not provided, create a new one
  21580. * @returns the current block
  21581. */
  21582. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21583. /**
  21584. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21585. * @param forOutput defines an optional connection point to check compatibility with
  21586. * @returns the first available input or null
  21587. */
  21588. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21589. /**
  21590. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21591. * @param forBlock defines an optional block to check compatibility with
  21592. * @returns the first available input or null
  21593. */
  21594. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21595. /**
  21596. * Gets the sibling of the given output
  21597. * @param current defines the current output
  21598. * @returns the next output in the list or null
  21599. */
  21600. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21601. /**
  21602. * Connect current block with another block
  21603. * @param other defines the block to connect with
  21604. * @param options define the various options to help pick the right connections
  21605. * @returns the current block
  21606. */
  21607. connectTo(other: NodeMaterialBlock, options?: {
  21608. input?: string;
  21609. output?: string;
  21610. outputSwizzle?: string;
  21611. }): this | undefined;
  21612. protected _buildBlock(state: NodeMaterialBuildState): void;
  21613. /**
  21614. * Add uniforms, samplers and uniform buffers at compilation time
  21615. * @param state defines the state to update
  21616. * @param nodeMaterial defines the node material requesting the update
  21617. * @param defines defines the material defines to update
  21618. * @param uniformBuffers defines the list of uniform buffer names
  21619. */
  21620. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21621. /**
  21622. * Add potential fallbacks if shader compilation fails
  21623. * @param mesh defines the mesh to be rendered
  21624. * @param fallbacks defines the current prioritized list of fallbacks
  21625. */
  21626. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21627. /**
  21628. * Initialize defines for shader compilation
  21629. * @param mesh defines the mesh to be rendered
  21630. * @param nodeMaterial defines the node material requesting the update
  21631. * @param defines defines the material defines to update
  21632. * @param useInstances specifies that instances should be used
  21633. */
  21634. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21635. /**
  21636. * Update defines for shader compilation
  21637. * @param mesh defines the mesh to be rendered
  21638. * @param nodeMaterial defines the node material requesting the update
  21639. * @param defines defines the material defines to update
  21640. * @param useInstances specifies that instances should be used
  21641. * @param subMesh defines which submesh to render
  21642. */
  21643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21644. /**
  21645. * Lets the block try to connect some inputs automatically
  21646. * @param material defines the hosting NodeMaterial
  21647. */
  21648. autoConfigure(material: NodeMaterial): void;
  21649. /**
  21650. * Function called when a block is declared as repeatable content generator
  21651. * @param vertexShaderState defines the current compilation state for the vertex shader
  21652. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21653. * @param mesh defines the mesh to be rendered
  21654. * @param defines defines the material defines to update
  21655. */
  21656. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21657. /**
  21658. * Checks if the block is ready
  21659. * @param mesh defines the mesh to be rendered
  21660. * @param nodeMaterial defines the node material requesting the update
  21661. * @param defines defines the material defines to update
  21662. * @param useInstances specifies that instances should be used
  21663. * @returns true if the block is ready
  21664. */
  21665. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21666. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21667. private _processBuild;
  21668. /**
  21669. * Validates the new name for the block node.
  21670. * @param newName the new name to be given to the node.
  21671. * @returns false if the name is a reserve word, else true.
  21672. */
  21673. validateBlockName(newName: string): boolean;
  21674. /**
  21675. * Compile the current node and generate the shader code
  21676. * @param state defines the current compilation state (uniforms, samplers, current string)
  21677. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21678. * @returns true if already built
  21679. */
  21680. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21681. protected _inputRename(name: string): string;
  21682. protected _outputRename(name: string): string;
  21683. protected _dumpPropertiesCode(): string;
  21684. /** @hidden */
  21685. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21686. /** @hidden */
  21687. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21688. /**
  21689. * Clone the current block to a new identical block
  21690. * @param scene defines the hosting scene
  21691. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21692. * @returns a copy of the current block
  21693. */
  21694. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21695. /**
  21696. * Serializes this block in a JSON representation
  21697. * @returns the serialized block object
  21698. */
  21699. serialize(): any;
  21700. /** @hidden */
  21701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21702. private _deserializePortDisplayNamesAndExposedOnFrame;
  21703. /**
  21704. * Release resources
  21705. */
  21706. dispose(): void;
  21707. }
  21708. }
  21709. declare module BABYLON {
  21710. /**
  21711. * Base class of materials working in push mode in babylon JS
  21712. * @hidden
  21713. */
  21714. export class PushMaterial extends Material {
  21715. protected _activeEffect: Effect;
  21716. protected _normalMatrix: Matrix;
  21717. constructor(name: string, scene: Scene);
  21718. getEffect(): Effect;
  21719. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21720. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21721. /**
  21722. * Binds the given world matrix to the active effect
  21723. *
  21724. * @param world the matrix to bind
  21725. */
  21726. bindOnlyWorldMatrix(world: Matrix): void;
  21727. /**
  21728. * Binds the given normal matrix to the active effect
  21729. *
  21730. * @param normalMatrix the matrix to bind
  21731. */
  21732. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21733. bind(world: Matrix, mesh?: Mesh): void;
  21734. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21735. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21736. }
  21737. }
  21738. declare module BABYLON {
  21739. /**
  21740. * Root class for all node material optimizers
  21741. */
  21742. export class NodeMaterialOptimizer {
  21743. /**
  21744. * Function used to optimize a NodeMaterial graph
  21745. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21746. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21747. */
  21748. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21749. }
  21750. }
  21751. declare module BABYLON {
  21752. /**
  21753. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21754. */
  21755. export class TransformBlock extends NodeMaterialBlock {
  21756. /**
  21757. * Defines the value to use to complement W value to transform it to a Vector4
  21758. */
  21759. complementW: number;
  21760. /**
  21761. * Defines the value to use to complement z value to transform it to a Vector4
  21762. */
  21763. complementZ: number;
  21764. /**
  21765. * Creates a new TransformBlock
  21766. * @param name defines the block name
  21767. */
  21768. constructor(name: string);
  21769. /**
  21770. * Gets the current class name
  21771. * @returns the class name
  21772. */
  21773. getClassName(): string;
  21774. /**
  21775. * Gets the vector input
  21776. */
  21777. get vector(): NodeMaterialConnectionPoint;
  21778. /**
  21779. * Gets the output component
  21780. */
  21781. get output(): NodeMaterialConnectionPoint;
  21782. /**
  21783. * Gets the xyz output component
  21784. */
  21785. get xyz(): NodeMaterialConnectionPoint;
  21786. /**
  21787. * Gets the matrix transform input
  21788. */
  21789. get transform(): NodeMaterialConnectionPoint;
  21790. protected _buildBlock(state: NodeMaterialBuildState): this;
  21791. /**
  21792. * Update defines for shader compilation
  21793. * @param mesh defines the mesh to be rendered
  21794. * @param nodeMaterial defines the node material requesting the update
  21795. * @param defines defines the material defines to update
  21796. * @param useInstances specifies that instances should be used
  21797. * @param subMesh defines which submesh to render
  21798. */
  21799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21800. serialize(): any;
  21801. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21802. protected _dumpPropertiesCode(): string;
  21803. }
  21804. }
  21805. declare module BABYLON {
  21806. /**
  21807. * Block used to output the vertex position
  21808. */
  21809. export class VertexOutputBlock extends NodeMaterialBlock {
  21810. /**
  21811. * Creates a new VertexOutputBlock
  21812. * @param name defines the block name
  21813. */
  21814. constructor(name: string);
  21815. /**
  21816. * Gets the current class name
  21817. * @returns the class name
  21818. */
  21819. getClassName(): string;
  21820. /**
  21821. * Gets the vector input component
  21822. */
  21823. get vector(): NodeMaterialConnectionPoint;
  21824. protected _buildBlock(state: NodeMaterialBuildState): this;
  21825. }
  21826. }
  21827. declare module BABYLON {
  21828. /**
  21829. * Block used to output the final color
  21830. */
  21831. export class FragmentOutputBlock extends NodeMaterialBlock {
  21832. /**
  21833. * Create a new FragmentOutputBlock
  21834. * @param name defines the block name
  21835. */
  21836. constructor(name: string);
  21837. /**
  21838. * Gets the current class name
  21839. * @returns the class name
  21840. */
  21841. getClassName(): string;
  21842. /**
  21843. * Gets the rgba input component
  21844. */
  21845. get rgba(): NodeMaterialConnectionPoint;
  21846. /**
  21847. * Gets the rgb input component
  21848. */
  21849. get rgb(): NodeMaterialConnectionPoint;
  21850. /**
  21851. * Gets the a input component
  21852. */
  21853. get a(): NodeMaterialConnectionPoint;
  21854. protected _buildBlock(state: NodeMaterialBuildState): this;
  21855. }
  21856. }
  21857. declare module BABYLON {
  21858. /**
  21859. * Block used for the particle ramp gradient section
  21860. */
  21861. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21862. /**
  21863. * Create a new ParticleRampGradientBlock
  21864. * @param name defines the block name
  21865. */
  21866. constructor(name: string);
  21867. /**
  21868. * Gets the current class name
  21869. * @returns the class name
  21870. */
  21871. getClassName(): string;
  21872. /**
  21873. * Gets the color input component
  21874. */
  21875. get color(): NodeMaterialConnectionPoint;
  21876. /**
  21877. * Gets the rampColor output component
  21878. */
  21879. get rampColor(): NodeMaterialConnectionPoint;
  21880. /**
  21881. * Initialize the block and prepare the context for build
  21882. * @param state defines the state that will be used for the build
  21883. */
  21884. initialize(state: NodeMaterialBuildState): void;
  21885. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21886. }
  21887. }
  21888. declare module BABYLON {
  21889. /**
  21890. * Block used for the particle blend multiply section
  21891. */
  21892. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21893. /**
  21894. * Create a new ParticleBlendMultiplyBlock
  21895. * @param name defines the block name
  21896. */
  21897. constructor(name: string);
  21898. /**
  21899. * Gets the current class name
  21900. * @returns the class name
  21901. */
  21902. getClassName(): string;
  21903. /**
  21904. * Gets the color input component
  21905. */
  21906. get color(): NodeMaterialConnectionPoint;
  21907. /**
  21908. * Gets the alphaTexture input component
  21909. */
  21910. get alphaTexture(): NodeMaterialConnectionPoint;
  21911. /**
  21912. * Gets the alphaColor input component
  21913. */
  21914. get alphaColor(): NodeMaterialConnectionPoint;
  21915. /**
  21916. * Gets the blendColor output component
  21917. */
  21918. get blendColor(): NodeMaterialConnectionPoint;
  21919. /**
  21920. * Initialize the block and prepare the context for build
  21921. * @param state defines the state that will be used for the build
  21922. */
  21923. initialize(state: NodeMaterialBuildState): void;
  21924. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21925. }
  21926. }
  21927. declare module BABYLON {
  21928. /**
  21929. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21930. */
  21931. export class VectorMergerBlock extends NodeMaterialBlock {
  21932. /**
  21933. * Create a new VectorMergerBlock
  21934. * @param name defines the block name
  21935. */
  21936. constructor(name: string);
  21937. /**
  21938. * Gets the current class name
  21939. * @returns the class name
  21940. */
  21941. getClassName(): string;
  21942. /**
  21943. * Gets the xyz component (input)
  21944. */
  21945. get xyzIn(): NodeMaterialConnectionPoint;
  21946. /**
  21947. * Gets the xy component (input)
  21948. */
  21949. get xyIn(): NodeMaterialConnectionPoint;
  21950. /**
  21951. * Gets the x component (input)
  21952. */
  21953. get x(): NodeMaterialConnectionPoint;
  21954. /**
  21955. * Gets the y component (input)
  21956. */
  21957. get y(): NodeMaterialConnectionPoint;
  21958. /**
  21959. * Gets the z component (input)
  21960. */
  21961. get z(): NodeMaterialConnectionPoint;
  21962. /**
  21963. * Gets the w component (input)
  21964. */
  21965. get w(): NodeMaterialConnectionPoint;
  21966. /**
  21967. * Gets the xyzw component (output)
  21968. */
  21969. get xyzw(): NodeMaterialConnectionPoint;
  21970. /**
  21971. * Gets the xyz component (output)
  21972. */
  21973. get xyzOut(): NodeMaterialConnectionPoint;
  21974. /**
  21975. * Gets the xy component (output)
  21976. */
  21977. get xyOut(): NodeMaterialConnectionPoint;
  21978. /**
  21979. * Gets the xy component (output)
  21980. * @deprecated Please use xyOut instead.
  21981. */
  21982. get xy(): NodeMaterialConnectionPoint;
  21983. /**
  21984. * Gets the xyz component (output)
  21985. * @deprecated Please use xyzOut instead.
  21986. */
  21987. get xyz(): NodeMaterialConnectionPoint;
  21988. protected _buildBlock(state: NodeMaterialBuildState): this;
  21989. }
  21990. }
  21991. declare module BABYLON {
  21992. /**
  21993. * Block used to remap a float from a range to a new one
  21994. */
  21995. export class RemapBlock extends NodeMaterialBlock {
  21996. /**
  21997. * Gets or sets the source range
  21998. */
  21999. sourceRange: Vector2;
  22000. /**
  22001. * Gets or sets the target range
  22002. */
  22003. targetRange: Vector2;
  22004. /**
  22005. * Creates a new RemapBlock
  22006. * @param name defines the block name
  22007. */
  22008. constructor(name: string);
  22009. /**
  22010. * Gets the current class name
  22011. * @returns the class name
  22012. */
  22013. getClassName(): string;
  22014. /**
  22015. * Gets the input component
  22016. */
  22017. get input(): NodeMaterialConnectionPoint;
  22018. /**
  22019. * Gets the source min input component
  22020. */
  22021. get sourceMin(): NodeMaterialConnectionPoint;
  22022. /**
  22023. * Gets the source max input component
  22024. */
  22025. get sourceMax(): NodeMaterialConnectionPoint;
  22026. /**
  22027. * Gets the target min input component
  22028. */
  22029. get targetMin(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Gets the target max input component
  22032. */
  22033. get targetMax(): NodeMaterialConnectionPoint;
  22034. /**
  22035. * Gets the output component
  22036. */
  22037. get output(): NodeMaterialConnectionPoint;
  22038. protected _buildBlock(state: NodeMaterialBuildState): this;
  22039. protected _dumpPropertiesCode(): string;
  22040. serialize(): any;
  22041. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22042. }
  22043. }
  22044. declare module BABYLON {
  22045. /**
  22046. * Block used to multiply 2 values
  22047. */
  22048. export class MultiplyBlock extends NodeMaterialBlock {
  22049. /**
  22050. * Creates a new MultiplyBlock
  22051. * @param name defines the block name
  22052. */
  22053. constructor(name: string);
  22054. /**
  22055. * Gets the current class name
  22056. * @returns the class name
  22057. */
  22058. getClassName(): string;
  22059. /**
  22060. * Gets the left operand input component
  22061. */
  22062. get left(): NodeMaterialConnectionPoint;
  22063. /**
  22064. * Gets the right operand input component
  22065. */
  22066. get right(): NodeMaterialConnectionPoint;
  22067. /**
  22068. * Gets the output component
  22069. */
  22070. get output(): NodeMaterialConnectionPoint;
  22071. protected _buildBlock(state: NodeMaterialBuildState): this;
  22072. }
  22073. }
  22074. declare module BABYLON {
  22075. /**
  22076. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22077. */
  22078. export class ColorSplitterBlock extends NodeMaterialBlock {
  22079. /**
  22080. * Create a new ColorSplitterBlock
  22081. * @param name defines the block name
  22082. */
  22083. constructor(name: string);
  22084. /**
  22085. * Gets the current class name
  22086. * @returns the class name
  22087. */
  22088. getClassName(): string;
  22089. /**
  22090. * Gets the rgba component (input)
  22091. */
  22092. get rgba(): NodeMaterialConnectionPoint;
  22093. /**
  22094. * Gets the rgb component (input)
  22095. */
  22096. get rgbIn(): NodeMaterialConnectionPoint;
  22097. /**
  22098. * Gets the rgb component (output)
  22099. */
  22100. get rgbOut(): NodeMaterialConnectionPoint;
  22101. /**
  22102. * Gets the r component (output)
  22103. */
  22104. get r(): NodeMaterialConnectionPoint;
  22105. /**
  22106. * Gets the g component (output)
  22107. */
  22108. get g(): NodeMaterialConnectionPoint;
  22109. /**
  22110. * Gets the b component (output)
  22111. */
  22112. get b(): NodeMaterialConnectionPoint;
  22113. /**
  22114. * Gets the a component (output)
  22115. */
  22116. get a(): NodeMaterialConnectionPoint;
  22117. protected _inputRename(name: string): string;
  22118. protected _outputRename(name: string): string;
  22119. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22120. }
  22121. }
  22122. declare module BABYLON {
  22123. /**
  22124. * Interface used to configure the node material editor
  22125. */
  22126. export interface INodeMaterialEditorOptions {
  22127. /** Define the URl to load node editor script */
  22128. editorURL?: string;
  22129. }
  22130. /** @hidden */
  22131. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22132. NORMAL: boolean;
  22133. TANGENT: boolean;
  22134. UV1: boolean;
  22135. /** BONES */
  22136. NUM_BONE_INFLUENCERS: number;
  22137. BonesPerMesh: number;
  22138. BONETEXTURE: boolean;
  22139. /** MORPH TARGETS */
  22140. MORPHTARGETS: boolean;
  22141. MORPHTARGETS_NORMAL: boolean;
  22142. MORPHTARGETS_TANGENT: boolean;
  22143. MORPHTARGETS_UV: boolean;
  22144. NUM_MORPH_INFLUENCERS: number;
  22145. /** IMAGE PROCESSING */
  22146. IMAGEPROCESSING: boolean;
  22147. VIGNETTE: boolean;
  22148. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22149. VIGNETTEBLENDMODEOPAQUE: boolean;
  22150. TONEMAPPING: boolean;
  22151. TONEMAPPING_ACES: boolean;
  22152. CONTRAST: boolean;
  22153. EXPOSURE: boolean;
  22154. COLORCURVES: boolean;
  22155. COLORGRADING: boolean;
  22156. COLORGRADING3D: boolean;
  22157. SAMPLER3DGREENDEPTH: boolean;
  22158. SAMPLER3DBGRMAP: boolean;
  22159. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22160. /** MISC. */
  22161. BUMPDIRECTUV: number;
  22162. constructor();
  22163. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22164. }
  22165. /**
  22166. * Class used to configure NodeMaterial
  22167. */
  22168. export interface INodeMaterialOptions {
  22169. /**
  22170. * Defines if blocks should emit comments
  22171. */
  22172. emitComments: boolean;
  22173. }
  22174. /**
  22175. * Class used to create a node based material built by assembling shader blocks
  22176. */
  22177. export class NodeMaterial extends PushMaterial {
  22178. private static _BuildIdGenerator;
  22179. private _options;
  22180. private _vertexCompilationState;
  22181. private _fragmentCompilationState;
  22182. private _sharedData;
  22183. private _buildId;
  22184. private _buildWasSuccessful;
  22185. private _cachedWorldViewMatrix;
  22186. private _cachedWorldViewProjectionMatrix;
  22187. private _optimizers;
  22188. private _animationFrame;
  22189. /** Define the Url to load node editor script */
  22190. static EditorURL: string;
  22191. /** Define the Url to load snippets */
  22192. static SnippetUrl: string;
  22193. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22194. static IgnoreTexturesAtLoadTime: boolean;
  22195. private BJSNODEMATERIALEDITOR;
  22196. /** Get the inspector from bundle or global */
  22197. private _getGlobalNodeMaterialEditor;
  22198. /**
  22199. * Snippet ID if the material was created from the snippet server
  22200. */
  22201. snippetId: string;
  22202. /**
  22203. * Gets or sets data used by visual editor
  22204. * @see https://nme.babylonjs.com
  22205. */
  22206. editorData: any;
  22207. /**
  22208. * 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)
  22209. */
  22210. ignoreAlpha: boolean;
  22211. /**
  22212. * Defines the maximum number of lights that can be used in the material
  22213. */
  22214. maxSimultaneousLights: number;
  22215. /**
  22216. * Observable raised when the material is built
  22217. */
  22218. onBuildObservable: Observable<NodeMaterial>;
  22219. /**
  22220. * Gets or sets the root nodes of the material vertex shader
  22221. */
  22222. _vertexOutputNodes: NodeMaterialBlock[];
  22223. /**
  22224. * Gets or sets the root nodes of the material fragment (pixel) shader
  22225. */
  22226. _fragmentOutputNodes: NodeMaterialBlock[];
  22227. /** Gets or sets options to control the node material overall behavior */
  22228. get options(): INodeMaterialOptions;
  22229. set options(options: INodeMaterialOptions);
  22230. /**
  22231. * Default configuration related to image processing available in the standard Material.
  22232. */
  22233. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22234. /**
  22235. * Gets the image processing configuration used either in this material.
  22236. */
  22237. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22238. /**
  22239. * Sets the Default image processing configuration used either in the this material.
  22240. *
  22241. * If sets to null, the scene one is in use.
  22242. */
  22243. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22244. /**
  22245. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22246. */
  22247. attachedBlocks: NodeMaterialBlock[];
  22248. /**
  22249. * Specifies the mode of the node material
  22250. * @hidden
  22251. */
  22252. _mode: NodeMaterialModes;
  22253. /**
  22254. * Gets the mode property
  22255. */
  22256. get mode(): NodeMaterialModes;
  22257. /**
  22258. * Create a new node based material
  22259. * @param name defines the material name
  22260. * @param scene defines the hosting scene
  22261. * @param options defines creation option
  22262. */
  22263. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22264. /**
  22265. * Gets the current class name of the material e.g. "NodeMaterial"
  22266. * @returns the class name
  22267. */
  22268. getClassName(): string;
  22269. /**
  22270. * Keep track of the image processing observer to allow dispose and replace.
  22271. */
  22272. private _imageProcessingObserver;
  22273. /**
  22274. * Attaches a new image processing configuration to the Standard Material.
  22275. * @param configuration
  22276. */
  22277. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22278. /**
  22279. * Get a block by its name
  22280. * @param name defines the name of the block to retrieve
  22281. * @returns the required block or null if not found
  22282. */
  22283. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22284. /**
  22285. * Get a block by its name
  22286. * @param predicate defines the predicate used to find the good candidate
  22287. * @returns the required block or null if not found
  22288. */
  22289. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22290. /**
  22291. * Get an input block by its name
  22292. * @param predicate defines the predicate used to find the good candidate
  22293. * @returns the required input block or null if not found
  22294. */
  22295. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22296. /**
  22297. * Gets the list of input blocks attached to this material
  22298. * @returns an array of InputBlocks
  22299. */
  22300. getInputBlocks(): InputBlock[];
  22301. /**
  22302. * Adds a new optimizer to the list of optimizers
  22303. * @param optimizer defines the optimizers to add
  22304. * @returns the current material
  22305. */
  22306. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22307. /**
  22308. * Remove an optimizer from the list of optimizers
  22309. * @param optimizer defines the optimizers to remove
  22310. * @returns the current material
  22311. */
  22312. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22313. /**
  22314. * Add a new block to the list of output nodes
  22315. * @param node defines the node to add
  22316. * @returns the current material
  22317. */
  22318. addOutputNode(node: NodeMaterialBlock): this;
  22319. /**
  22320. * Remove a block from the list of root nodes
  22321. * @param node defines the node to remove
  22322. * @returns the current material
  22323. */
  22324. removeOutputNode(node: NodeMaterialBlock): this;
  22325. private _addVertexOutputNode;
  22326. private _removeVertexOutputNode;
  22327. private _addFragmentOutputNode;
  22328. private _removeFragmentOutputNode;
  22329. /**
  22330. * Specifies if the material will require alpha blending
  22331. * @returns a boolean specifying if alpha blending is needed
  22332. */
  22333. needAlphaBlending(): boolean;
  22334. /**
  22335. * Specifies if this material should be rendered in alpha test mode
  22336. * @returns a boolean specifying if an alpha test is needed.
  22337. */
  22338. needAlphaTesting(): boolean;
  22339. private _initializeBlock;
  22340. private _resetDualBlocks;
  22341. /**
  22342. * Remove a block from the current node material
  22343. * @param block defines the block to remove
  22344. */
  22345. removeBlock(block: NodeMaterialBlock): void;
  22346. /**
  22347. * Build the material and generates the inner effect
  22348. * @param verbose defines if the build should log activity
  22349. */
  22350. build(verbose?: boolean): void;
  22351. /**
  22352. * Runs an otpimization phase to try to improve the shader code
  22353. */
  22354. optimize(): void;
  22355. private _prepareDefinesForAttributes;
  22356. /**
  22357. * Create a post process from the material
  22358. * @param camera The camera to apply the render pass to.
  22359. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22361. * @param engine The engine which the post process will be applied. (default: current engine)
  22362. * @param reusable If the post process can be reused on the same frame. (default: false)
  22363. * @param textureType Type of textures used when performing the post process. (default: 0)
  22364. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22365. * @returns the post process created
  22366. */
  22367. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22368. /**
  22369. * Create the post process effect from the material
  22370. * @param postProcess The post process to create the effect for
  22371. */
  22372. createEffectForPostProcess(postProcess: PostProcess): void;
  22373. private _createEffectOrPostProcess;
  22374. private _createEffectForParticles;
  22375. /**
  22376. * Create the effect to be used as the custom effect for a particle system
  22377. * @param particleSystem Particle system to create the effect for
  22378. * @param onCompiled defines a function to call when the effect creation is successful
  22379. * @param onError defines a function to call when the effect creation has failed
  22380. */
  22381. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22382. private _processDefines;
  22383. /**
  22384. * Get if the submesh is ready to be used and all its information available.
  22385. * Child classes can use it to update shaders
  22386. * @param mesh defines the mesh to check
  22387. * @param subMesh defines which submesh to check
  22388. * @param useInstances specifies that instances should be used
  22389. * @returns a boolean indicating that the submesh is ready or not
  22390. */
  22391. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22392. /**
  22393. * Get a string representing the shaders built by the current node graph
  22394. */
  22395. get compiledShaders(): string;
  22396. /**
  22397. * Binds the world matrix to the material
  22398. * @param world defines the world transformation matrix
  22399. */
  22400. bindOnlyWorldMatrix(world: Matrix): void;
  22401. /**
  22402. * Binds the submesh to this material by preparing the effect and shader to draw
  22403. * @param world defines the world transformation matrix
  22404. * @param mesh defines the mesh containing the submesh
  22405. * @param subMesh defines the submesh to bind the material to
  22406. */
  22407. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22408. /**
  22409. * Gets the active textures from the material
  22410. * @returns an array of textures
  22411. */
  22412. getActiveTextures(): BaseTexture[];
  22413. /**
  22414. * Gets the list of texture blocks
  22415. * @returns an array of texture blocks
  22416. */
  22417. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22418. /**
  22419. * Specifies if the material uses a texture
  22420. * @param texture defines the texture to check against the material
  22421. * @returns a boolean specifying if the material uses the texture
  22422. */
  22423. hasTexture(texture: BaseTexture): boolean;
  22424. /**
  22425. * Disposes the material
  22426. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22427. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22428. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22429. */
  22430. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22431. /** Creates the node editor window. */
  22432. private _createNodeEditor;
  22433. /**
  22434. * Launch the node material editor
  22435. * @param config Define the configuration of the editor
  22436. * @return a promise fulfilled when the node editor is visible
  22437. */
  22438. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22439. /**
  22440. * Clear the current material
  22441. */
  22442. clear(): void;
  22443. /**
  22444. * Clear the current material and set it to a default state
  22445. */
  22446. setToDefault(): void;
  22447. /**
  22448. * Clear the current material and set it to a default state for post process
  22449. */
  22450. setToDefaultPostProcess(): void;
  22451. /**
  22452. * Clear the current material and set it to a default state for particle
  22453. */
  22454. setToDefaultParticle(): void;
  22455. /**
  22456. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22457. * @param url defines the url to load from
  22458. * @returns a promise that will fullfil when the material is fully loaded
  22459. */
  22460. loadAsync(url: string): Promise<void>;
  22461. private _gatherBlocks;
  22462. /**
  22463. * Generate a string containing the code declaration required to create an equivalent of this material
  22464. * @returns a string
  22465. */
  22466. generateCode(): string;
  22467. /**
  22468. * Serializes this material in a JSON representation
  22469. * @returns the serialized material object
  22470. */
  22471. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22472. private _restoreConnections;
  22473. /**
  22474. * Clear the current graph and load a new one from a serialization object
  22475. * @param source defines the JSON representation of the material
  22476. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22477. * @param merge defines whether or not the source must be merged or replace the current content
  22478. */
  22479. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22480. /**
  22481. * Makes a duplicate of the current material.
  22482. * @param name - name to use for the new material.
  22483. */
  22484. clone(name: string): NodeMaterial;
  22485. /**
  22486. * Creates a node material from parsed material data
  22487. * @param source defines the JSON representation of the material
  22488. * @param scene defines the hosting scene
  22489. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22490. * @returns a new node material
  22491. */
  22492. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22493. /**
  22494. * Creates a node material from a snippet saved in a remote file
  22495. * @param name defines the name of the material to create
  22496. * @param url defines the url to load from
  22497. * @param scene defines the hosting scene
  22498. * @returns a promise that will resolve to the new node material
  22499. */
  22500. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22501. /**
  22502. * Creates a node material from a snippet saved by the node material editor
  22503. * @param snippetId defines the snippet to load
  22504. * @param scene defines the hosting scene
  22505. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22506. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22507. * @returns a promise that will resolve to the new node material
  22508. */
  22509. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22510. /**
  22511. * Creates a new node material set to default basic configuration
  22512. * @param name defines the name of the material
  22513. * @param scene defines the hosting scene
  22514. * @returns a new NodeMaterial
  22515. */
  22516. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22517. }
  22518. }
  22519. declare module BABYLON {
  22520. /**
  22521. * Size options for a post process
  22522. */
  22523. export type PostProcessOptions = {
  22524. width: number;
  22525. height: number;
  22526. };
  22527. /**
  22528. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22529. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22530. */
  22531. export class PostProcess {
  22532. /** Name of the PostProcess. */
  22533. name: string;
  22534. /**
  22535. * Gets or sets the unique id of the post process
  22536. */
  22537. uniqueId: number;
  22538. /**
  22539. * Width of the texture to apply the post process on
  22540. */
  22541. width: number;
  22542. /**
  22543. * Height of the texture to apply the post process on
  22544. */
  22545. height: number;
  22546. /**
  22547. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22548. */
  22549. nodeMaterialSource: Nullable<NodeMaterial>;
  22550. /**
  22551. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22552. * @hidden
  22553. */
  22554. _outputTexture: Nullable<InternalTexture>;
  22555. /**
  22556. * Sampling mode used by the shader
  22557. * See https://doc.babylonjs.com/classes/3.1/texture
  22558. */
  22559. renderTargetSamplingMode: number;
  22560. /**
  22561. * Clear color to use when screen clearing
  22562. */
  22563. clearColor: Color4;
  22564. /**
  22565. * If the buffer needs to be cleared before applying the post process. (default: true)
  22566. * Should be set to false if shader will overwrite all previous pixels.
  22567. */
  22568. autoClear: boolean;
  22569. /**
  22570. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22571. */
  22572. alphaMode: number;
  22573. /**
  22574. * Sets the setAlphaBlendConstants of the babylon engine
  22575. */
  22576. alphaConstants: Color4;
  22577. /**
  22578. * Animations to be used for the post processing
  22579. */
  22580. animations: Animation[];
  22581. /**
  22582. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22583. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22584. */
  22585. enablePixelPerfectMode: boolean;
  22586. /**
  22587. * Force the postprocess to be applied without taking in account viewport
  22588. */
  22589. forceFullscreenViewport: boolean;
  22590. /**
  22591. * List of inspectable custom properties (used by the Inspector)
  22592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22593. */
  22594. inspectableCustomProperties: IInspectable[];
  22595. /**
  22596. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22597. *
  22598. * | Value | Type | Description |
  22599. * | ----- | ----------------------------------- | ----------- |
  22600. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22601. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22602. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22603. *
  22604. */
  22605. scaleMode: number;
  22606. /**
  22607. * Force textures to be a power of two (default: false)
  22608. */
  22609. alwaysForcePOT: boolean;
  22610. private _samples;
  22611. /**
  22612. * Number of sample textures (default: 1)
  22613. */
  22614. get samples(): number;
  22615. set samples(n: number);
  22616. /**
  22617. * Modify the scale of the post process to be the same as the viewport (default: false)
  22618. */
  22619. adaptScaleToCurrentViewport: boolean;
  22620. private _camera;
  22621. protected _scene: Scene;
  22622. private _engine;
  22623. private _options;
  22624. private _reusable;
  22625. private _textureType;
  22626. private _textureFormat;
  22627. /**
  22628. * Smart array of input and output textures for the post process.
  22629. * @hidden
  22630. */
  22631. _textures: SmartArray<InternalTexture>;
  22632. /**
  22633. * The index in _textures that corresponds to the output texture.
  22634. * @hidden
  22635. */
  22636. _currentRenderTextureInd: number;
  22637. private _effect;
  22638. private _samplers;
  22639. private _fragmentUrl;
  22640. private _vertexUrl;
  22641. private _parameters;
  22642. private _scaleRatio;
  22643. protected _indexParameters: any;
  22644. private _shareOutputWithPostProcess;
  22645. private _texelSize;
  22646. private _forcedOutputTexture;
  22647. /**
  22648. * Returns the fragment url or shader name used in the post process.
  22649. * @returns the fragment url or name in the shader store.
  22650. */
  22651. getEffectName(): string;
  22652. /**
  22653. * An event triggered when the postprocess is activated.
  22654. */
  22655. onActivateObservable: Observable<Camera>;
  22656. private _onActivateObserver;
  22657. /**
  22658. * A function that is added to the onActivateObservable
  22659. */
  22660. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22661. /**
  22662. * An event triggered when the postprocess changes its size.
  22663. */
  22664. onSizeChangedObservable: Observable<PostProcess>;
  22665. private _onSizeChangedObserver;
  22666. /**
  22667. * A function that is added to the onSizeChangedObservable
  22668. */
  22669. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22670. /**
  22671. * An event triggered when the postprocess applies its effect.
  22672. */
  22673. onApplyObservable: Observable<Effect>;
  22674. private _onApplyObserver;
  22675. /**
  22676. * A function that is added to the onApplyObservable
  22677. */
  22678. set onApply(callback: (effect: Effect) => void);
  22679. /**
  22680. * An event triggered before rendering the postprocess
  22681. */
  22682. onBeforeRenderObservable: Observable<Effect>;
  22683. private _onBeforeRenderObserver;
  22684. /**
  22685. * A function that is added to the onBeforeRenderObservable
  22686. */
  22687. set onBeforeRender(callback: (effect: Effect) => void);
  22688. /**
  22689. * An event triggered after rendering the postprocess
  22690. */
  22691. onAfterRenderObservable: Observable<Effect>;
  22692. private _onAfterRenderObserver;
  22693. /**
  22694. * A function that is added to the onAfterRenderObservable
  22695. */
  22696. set onAfterRender(callback: (efect: Effect) => void);
  22697. /**
  22698. * 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
  22699. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22700. */
  22701. get inputTexture(): InternalTexture;
  22702. set inputTexture(value: InternalTexture);
  22703. /**
  22704. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22705. * the only way to unset it is to use this function to restore its internal state
  22706. */
  22707. restoreDefaultInputTexture(): void;
  22708. /**
  22709. * Gets the camera which post process is applied to.
  22710. * @returns The camera the post process is applied to.
  22711. */
  22712. getCamera(): Camera;
  22713. /**
  22714. * Gets the texel size of the postprocess.
  22715. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22716. */
  22717. get texelSize(): Vector2;
  22718. /**
  22719. * Creates a new instance PostProcess
  22720. * @param name The name of the PostProcess.
  22721. * @param fragmentUrl The url of the fragment shader to be used.
  22722. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22723. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22724. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22725. * @param camera The camera to apply the render pass to.
  22726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22727. * @param engine The engine which the post process will be applied. (default: current engine)
  22728. * @param reusable If the post process can be reused on the same frame. (default: false)
  22729. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22730. * @param textureType Type of textures used when performing the post process. (default: 0)
  22731. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22732. * @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
  22733. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22734. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22735. */
  22736. constructor(
  22737. /** Name of the PostProcess. */
  22738. 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);
  22739. /**
  22740. * Gets a string idenfifying the name of the class
  22741. * @returns "PostProcess" string
  22742. */
  22743. getClassName(): string;
  22744. /**
  22745. * Gets the engine which this post process belongs to.
  22746. * @returns The engine the post process was enabled with.
  22747. */
  22748. getEngine(): Engine;
  22749. /**
  22750. * The effect that is created when initializing the post process.
  22751. * @returns The created effect corresponding the the postprocess.
  22752. */
  22753. getEffect(): Effect;
  22754. /**
  22755. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22756. * @param postProcess The post process to share the output with.
  22757. * @returns This post process.
  22758. */
  22759. shareOutputWith(postProcess: PostProcess): PostProcess;
  22760. /**
  22761. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22762. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22763. */
  22764. useOwnOutput(): void;
  22765. /**
  22766. * Updates the effect with the current post process compile time values and recompiles the shader.
  22767. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22768. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22769. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22770. * @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
  22771. * @param onCompiled Called when the shader has been compiled.
  22772. * @param onError Called if there is an error when compiling a shader.
  22773. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22774. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22775. */
  22776. 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;
  22777. /**
  22778. * The post process is reusable if it can be used multiple times within one frame.
  22779. * @returns If the post process is reusable
  22780. */
  22781. isReusable(): boolean;
  22782. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22783. markTextureDirty(): void;
  22784. /**
  22785. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22786. * 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.
  22787. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22788. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22789. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22790. * @returns The target texture that was bound to be written to.
  22791. */
  22792. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22793. /**
  22794. * If the post process is supported.
  22795. */
  22796. get isSupported(): boolean;
  22797. /**
  22798. * The aspect ratio of the output texture.
  22799. */
  22800. get aspectRatio(): number;
  22801. /**
  22802. * Get a value indicating if the post-process is ready to be used
  22803. * @returns true if the post-process is ready (shader is compiled)
  22804. */
  22805. isReady(): boolean;
  22806. /**
  22807. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22808. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22809. */
  22810. apply(): Nullable<Effect>;
  22811. private _disposeTextures;
  22812. /**
  22813. * Disposes the post process.
  22814. * @param camera The camera to dispose the post process on.
  22815. */
  22816. dispose(camera?: Camera): void;
  22817. }
  22818. }
  22819. declare module BABYLON {
  22820. /** @hidden */
  22821. export var kernelBlurVaryingDeclaration: {
  22822. name: string;
  22823. shader: string;
  22824. };
  22825. }
  22826. declare module BABYLON {
  22827. /** @hidden */
  22828. export var kernelBlurFragment: {
  22829. name: string;
  22830. shader: string;
  22831. };
  22832. }
  22833. declare module BABYLON {
  22834. /** @hidden */
  22835. export var kernelBlurFragment2: {
  22836. name: string;
  22837. shader: string;
  22838. };
  22839. }
  22840. declare module BABYLON {
  22841. /** @hidden */
  22842. export var kernelBlurPixelShader: {
  22843. name: string;
  22844. shader: string;
  22845. };
  22846. }
  22847. declare module BABYLON {
  22848. /** @hidden */
  22849. export var kernelBlurVertex: {
  22850. name: string;
  22851. shader: string;
  22852. };
  22853. }
  22854. declare module BABYLON {
  22855. /** @hidden */
  22856. export var kernelBlurVertexShader: {
  22857. name: string;
  22858. shader: string;
  22859. };
  22860. }
  22861. declare module BABYLON {
  22862. /**
  22863. * The Blur Post Process which blurs an image based on a kernel and direction.
  22864. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22865. */
  22866. export class BlurPostProcess extends PostProcess {
  22867. /** The direction in which to blur the image. */
  22868. direction: Vector2;
  22869. private blockCompilation;
  22870. protected _kernel: number;
  22871. protected _idealKernel: number;
  22872. protected _packedFloat: boolean;
  22873. private _staticDefines;
  22874. /**
  22875. * Sets the length in pixels of the blur sample region
  22876. */
  22877. set kernel(v: number);
  22878. /**
  22879. * Gets the length in pixels of the blur sample region
  22880. */
  22881. get kernel(): number;
  22882. /**
  22883. * Sets wether or not the blur needs to unpack/repack floats
  22884. */
  22885. set packedFloat(v: boolean);
  22886. /**
  22887. * Gets wether or not the blur is unpacking/repacking floats
  22888. */
  22889. get packedFloat(): boolean;
  22890. /**
  22891. * Creates a new instance BlurPostProcess
  22892. * @param name The name of the effect.
  22893. * @param direction The direction in which to blur the image.
  22894. * @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.
  22895. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22896. * @param camera The camera to apply the render pass to.
  22897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22898. * @param engine The engine which the post process will be applied. (default: current engine)
  22899. * @param reusable If the post process can be reused on the same frame. (default: false)
  22900. * @param textureType Type of textures used when performing the post process. (default: 0)
  22901. * @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)
  22902. */
  22903. constructor(name: string,
  22904. /** The direction in which to blur the image. */
  22905. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22906. /**
  22907. * Updates the effect with the current post process compile time values and recompiles the shader.
  22908. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22909. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22910. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22911. * @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
  22912. * @param onCompiled Called when the shader has been compiled.
  22913. * @param onError Called if there is an error when compiling a shader.
  22914. */
  22915. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22916. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22917. /**
  22918. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22919. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22920. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22921. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22922. * The gaps between physical kernels are compensated for in the weighting of the samples
  22923. * @param idealKernel Ideal blur kernel.
  22924. * @return Nearest best kernel.
  22925. */
  22926. protected _nearestBestKernel(idealKernel: number): number;
  22927. /**
  22928. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22929. * @param x The point on the Gaussian distribution to sample.
  22930. * @return the value of the Gaussian function at x.
  22931. */
  22932. protected _gaussianWeight(x: number): number;
  22933. /**
  22934. * Generates a string that can be used as a floating point number in GLSL.
  22935. * @param x Value to print.
  22936. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22937. * @return GLSL float string.
  22938. */
  22939. protected _glslFloat(x: number, decimalFigures?: number): string;
  22940. }
  22941. }
  22942. declare module BABYLON {
  22943. /**
  22944. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22945. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22946. * You can then easily use it as a reflectionTexture on a flat surface.
  22947. * In case the surface is not a plane, please consider relying on reflection probes.
  22948. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22949. */
  22950. export class MirrorTexture extends RenderTargetTexture {
  22951. private scene;
  22952. /**
  22953. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22954. * 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.
  22955. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22956. */
  22957. mirrorPlane: Plane;
  22958. /**
  22959. * Define the blur ratio used to blur the reflection if needed.
  22960. */
  22961. set blurRatio(value: number);
  22962. get blurRatio(): number;
  22963. /**
  22964. * Define the adaptive blur kernel used to blur the reflection if needed.
  22965. * This will autocompute the closest best match for the `blurKernel`
  22966. */
  22967. set adaptiveBlurKernel(value: number);
  22968. /**
  22969. * Define the blur kernel used to blur the reflection if needed.
  22970. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22971. */
  22972. set blurKernel(value: number);
  22973. /**
  22974. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22975. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22976. */
  22977. set blurKernelX(value: number);
  22978. get blurKernelX(): number;
  22979. /**
  22980. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22981. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22982. */
  22983. set blurKernelY(value: number);
  22984. get blurKernelY(): number;
  22985. private _autoComputeBlurKernel;
  22986. protected _onRatioRescale(): void;
  22987. private _updateGammaSpace;
  22988. private _imageProcessingConfigChangeObserver;
  22989. private _transformMatrix;
  22990. private _mirrorMatrix;
  22991. private _savedViewMatrix;
  22992. private _blurX;
  22993. private _blurY;
  22994. private _adaptiveBlurKernel;
  22995. private _blurKernelX;
  22996. private _blurKernelY;
  22997. private _blurRatio;
  22998. /**
  22999. * Instantiates a Mirror Texture.
  23000. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23001. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23002. * You can then easily use it as a reflectionTexture on a flat surface.
  23003. * In case the surface is not a plane, please consider relying on reflection probes.
  23004. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23005. * @param name
  23006. * @param size
  23007. * @param scene
  23008. * @param generateMipMaps
  23009. * @param type
  23010. * @param samplingMode
  23011. * @param generateDepthBuffer
  23012. */
  23013. constructor(name: string, size: number | {
  23014. width: number;
  23015. height: number;
  23016. } | {
  23017. ratio: number;
  23018. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23019. private _preparePostProcesses;
  23020. /**
  23021. * Clone the mirror texture.
  23022. * @returns the cloned texture
  23023. */
  23024. clone(): MirrorTexture;
  23025. /**
  23026. * Serialize the texture to a JSON representation you could use in Parse later on
  23027. * @returns the serialized JSON representation
  23028. */
  23029. serialize(): any;
  23030. /**
  23031. * Dispose the texture and release its associated resources.
  23032. */
  23033. dispose(): void;
  23034. }
  23035. }
  23036. declare module BABYLON {
  23037. /**
  23038. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23039. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23040. */
  23041. export class Texture extends BaseTexture {
  23042. /**
  23043. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23044. */
  23045. static SerializeBuffers: boolean;
  23046. /** @hidden */
  23047. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23048. /** @hidden */
  23049. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23050. /** @hidden */
  23051. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23052. /** nearest is mag = nearest and min = nearest and mip = linear */
  23053. static readonly NEAREST_SAMPLINGMODE: number;
  23054. /** nearest is mag = nearest and min = nearest and mip = linear */
  23055. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23056. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23057. static readonly BILINEAR_SAMPLINGMODE: number;
  23058. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23059. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23060. /** Trilinear is mag = linear and min = linear and mip = linear */
  23061. static readonly TRILINEAR_SAMPLINGMODE: number;
  23062. /** Trilinear is mag = linear and min = linear and mip = linear */
  23063. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23064. /** mag = nearest and min = nearest and mip = nearest */
  23065. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23066. /** mag = nearest and min = linear and mip = nearest */
  23067. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23068. /** mag = nearest and min = linear and mip = linear */
  23069. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23070. /** mag = nearest and min = linear and mip = none */
  23071. static readonly NEAREST_LINEAR: number;
  23072. /** mag = nearest and min = nearest and mip = none */
  23073. static readonly NEAREST_NEAREST: number;
  23074. /** mag = linear and min = nearest and mip = nearest */
  23075. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23076. /** mag = linear and min = nearest and mip = linear */
  23077. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23078. /** mag = linear and min = linear and mip = none */
  23079. static readonly LINEAR_LINEAR: number;
  23080. /** mag = linear and min = nearest and mip = none */
  23081. static readonly LINEAR_NEAREST: number;
  23082. /** Explicit coordinates mode */
  23083. static readonly EXPLICIT_MODE: number;
  23084. /** Spherical coordinates mode */
  23085. static readonly SPHERICAL_MODE: number;
  23086. /** Planar coordinates mode */
  23087. static readonly PLANAR_MODE: number;
  23088. /** Cubic coordinates mode */
  23089. static readonly CUBIC_MODE: number;
  23090. /** Projection coordinates mode */
  23091. static readonly PROJECTION_MODE: number;
  23092. /** Inverse Cubic coordinates mode */
  23093. static readonly SKYBOX_MODE: number;
  23094. /** Inverse Cubic coordinates mode */
  23095. static readonly INVCUBIC_MODE: number;
  23096. /** Equirectangular coordinates mode */
  23097. static readonly EQUIRECTANGULAR_MODE: number;
  23098. /** Equirectangular Fixed coordinates mode */
  23099. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23100. /** Equirectangular Fixed Mirrored coordinates mode */
  23101. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23102. /** Texture is not repeating outside of 0..1 UVs */
  23103. static readonly CLAMP_ADDRESSMODE: number;
  23104. /** Texture is repeating outside of 0..1 UVs */
  23105. static readonly WRAP_ADDRESSMODE: number;
  23106. /** Texture is repeating and mirrored */
  23107. static readonly MIRROR_ADDRESSMODE: number;
  23108. /**
  23109. * 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
  23110. */
  23111. static UseSerializedUrlIfAny: boolean;
  23112. /**
  23113. * Define the url of the texture.
  23114. */
  23115. url: Nullable<string>;
  23116. /**
  23117. * Define an offset on the texture to offset the u coordinates of the UVs
  23118. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23119. */
  23120. uOffset: number;
  23121. /**
  23122. * Define an offset on the texture to offset the v coordinates of the UVs
  23123. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23124. */
  23125. vOffset: number;
  23126. /**
  23127. * Define an offset on the texture to scale the u coordinates of the UVs
  23128. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23129. */
  23130. uScale: number;
  23131. /**
  23132. * Define an offset on the texture to scale the v coordinates of the UVs
  23133. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23134. */
  23135. vScale: number;
  23136. /**
  23137. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23138. * @see https://doc.babylonjs.com/how_to/more_materials
  23139. */
  23140. uAng: number;
  23141. /**
  23142. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23143. * @see https://doc.babylonjs.com/how_to/more_materials
  23144. */
  23145. vAng: number;
  23146. /**
  23147. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23148. * @see https://doc.babylonjs.com/how_to/more_materials
  23149. */
  23150. wAng: number;
  23151. /**
  23152. * Defines the center of rotation (U)
  23153. */
  23154. uRotationCenter: number;
  23155. /**
  23156. * Defines the center of rotation (V)
  23157. */
  23158. vRotationCenter: number;
  23159. /**
  23160. * Defines the center of rotation (W)
  23161. */
  23162. wRotationCenter: number;
  23163. /**
  23164. * Are mip maps generated for this texture or not.
  23165. */
  23166. get noMipmap(): boolean;
  23167. /**
  23168. * List of inspectable custom properties (used by the Inspector)
  23169. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23170. */
  23171. inspectableCustomProperties: Nullable<IInspectable[]>;
  23172. private _noMipmap;
  23173. /** @hidden */
  23174. _invertY: boolean;
  23175. private _rowGenerationMatrix;
  23176. private _cachedTextureMatrix;
  23177. private _projectionModeMatrix;
  23178. private _t0;
  23179. private _t1;
  23180. private _t2;
  23181. private _cachedUOffset;
  23182. private _cachedVOffset;
  23183. private _cachedUScale;
  23184. private _cachedVScale;
  23185. private _cachedUAng;
  23186. private _cachedVAng;
  23187. private _cachedWAng;
  23188. private _cachedProjectionMatrixId;
  23189. private _cachedCoordinatesMode;
  23190. /** @hidden */
  23191. protected _initialSamplingMode: number;
  23192. /** @hidden */
  23193. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23194. private _deleteBuffer;
  23195. protected _format: Nullable<number>;
  23196. private _delayedOnLoad;
  23197. private _delayedOnError;
  23198. private _mimeType?;
  23199. /**
  23200. * Observable triggered once the texture has been loaded.
  23201. */
  23202. onLoadObservable: Observable<Texture>;
  23203. protected _isBlocking: boolean;
  23204. /**
  23205. * Is the texture preventing material to render while loading.
  23206. * If false, a default texture will be used instead of the loading one during the preparation step.
  23207. */
  23208. set isBlocking(value: boolean);
  23209. get isBlocking(): boolean;
  23210. /**
  23211. * Get the current sampling mode associated with the texture.
  23212. */
  23213. get samplingMode(): number;
  23214. /**
  23215. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23216. */
  23217. get invertY(): boolean;
  23218. /**
  23219. * Instantiates a new texture.
  23220. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23221. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23222. * @param url defines the url of the picture to load as a texture
  23223. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23224. * @param noMipmap defines if the texture will require mip maps or not
  23225. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23226. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23227. * @param onLoad defines a callback triggered when the texture has been loaded
  23228. * @param onError defines a callback triggered when an error occurred during the loading session
  23229. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23230. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23231. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23232. * @param mimeType defines an optional mime type information
  23233. */
  23234. 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);
  23235. /**
  23236. * Update the url (and optional buffer) of this texture if url was null during construction.
  23237. * @param url the url of the texture
  23238. * @param buffer the buffer of the texture (defaults to null)
  23239. * @param onLoad callback called when the texture is loaded (defaults to null)
  23240. */
  23241. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23242. /**
  23243. * Finish the loading sequence of a texture flagged as delayed load.
  23244. * @hidden
  23245. */
  23246. delayLoad(): void;
  23247. private _prepareRowForTextureGeneration;
  23248. /**
  23249. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23250. * @returns the transform matrix of the texture.
  23251. */
  23252. getTextureMatrix(uBase?: number): Matrix;
  23253. /**
  23254. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23255. * @returns The reflection texture transform
  23256. */
  23257. getReflectionTextureMatrix(): Matrix;
  23258. /**
  23259. * Clones the texture.
  23260. * @returns the cloned texture
  23261. */
  23262. clone(): Texture;
  23263. /**
  23264. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23265. * @returns The JSON representation of the texture
  23266. */
  23267. serialize(): any;
  23268. /**
  23269. * Get the current class name of the texture useful for serialization or dynamic coding.
  23270. * @returns "Texture"
  23271. */
  23272. getClassName(): string;
  23273. /**
  23274. * Dispose the texture and release its associated resources.
  23275. */
  23276. dispose(): void;
  23277. /**
  23278. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23279. * @param parsedTexture Define the JSON representation of the texture
  23280. * @param scene Define the scene the parsed texture should be instantiated in
  23281. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23282. * @returns The parsed texture if successful
  23283. */
  23284. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23285. /**
  23286. * Creates a texture from its base 64 representation.
  23287. * @param data Define the base64 payload without the data: prefix
  23288. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23289. * @param scene Define the scene the texture should belong to
  23290. * @param noMipmap Forces the texture to not create mip map information if true
  23291. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23292. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23293. * @param onLoad define a callback triggered when the texture has been loaded
  23294. * @param onError define a callback triggered when an error occurred during the loading session
  23295. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23296. * @returns the created texture
  23297. */
  23298. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23299. /**
  23300. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23301. * @param data Define the base64 payload without the data: prefix
  23302. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23303. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23304. * @param scene Define the scene the texture should belong to
  23305. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23306. * @param noMipmap Forces the texture to not create mip map information if true
  23307. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23308. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23309. * @param onLoad define a callback triggered when the texture has been loaded
  23310. * @param onError define a callback triggered when an error occurred during the loading session
  23311. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23312. * @returns the created texture
  23313. */
  23314. 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;
  23315. }
  23316. }
  23317. declare module BABYLON {
  23318. /**
  23319. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23320. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23321. */
  23322. export class PostProcessManager {
  23323. private _scene;
  23324. private _indexBuffer;
  23325. private _vertexBuffers;
  23326. /**
  23327. * Creates a new instance PostProcess
  23328. * @param scene The scene that the post process is associated with.
  23329. */
  23330. constructor(scene: Scene);
  23331. private _prepareBuffers;
  23332. private _buildIndexBuffer;
  23333. /**
  23334. * Rebuilds the vertex buffers of the manager.
  23335. * @hidden
  23336. */
  23337. _rebuild(): void;
  23338. /**
  23339. * Prepares a frame to be run through a post process.
  23340. * @param sourceTexture The input texture to the post procesess. (default: null)
  23341. * @param postProcesses An array of post processes to be run. (default: null)
  23342. * @returns True if the post processes were able to be run.
  23343. * @hidden
  23344. */
  23345. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23346. /**
  23347. * Manually render a set of post processes to a texture.
  23348. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23349. * @param postProcesses An array of post processes to be run.
  23350. * @param targetTexture The target texture to render to.
  23351. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23352. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23353. * @param lodLevel defines which lod of the texture to render to
  23354. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23355. */
  23356. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23357. /**
  23358. * Finalize the result of the output of the postprocesses.
  23359. * @param doNotPresent If true the result will not be displayed to the screen.
  23360. * @param targetTexture The target texture to render to.
  23361. * @param faceIndex The index of the face to bind the target texture to.
  23362. * @param postProcesses The array of post processes to render.
  23363. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23364. * @hidden
  23365. */
  23366. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23367. /**
  23368. * Disposes of the post process manager.
  23369. */
  23370. dispose(): void;
  23371. }
  23372. }
  23373. declare module BABYLON {
  23374. /**
  23375. * This Helps creating a texture that will be created from a camera in your scene.
  23376. * It is basically a dynamic texture that could be used to create special effects for instance.
  23377. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23378. */
  23379. export class RenderTargetTexture extends Texture {
  23380. isCube: boolean;
  23381. /**
  23382. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23383. */
  23384. static readonly REFRESHRATE_RENDER_ONCE: number;
  23385. /**
  23386. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23387. */
  23388. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23389. /**
  23390. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23391. * the central point of your effect and can save a lot of performances.
  23392. */
  23393. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23394. /**
  23395. * Use this predicate to dynamically define the list of mesh you want to render.
  23396. * If set, the renderList property will be overwritten.
  23397. */
  23398. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23399. private _renderList;
  23400. /**
  23401. * Use this list to define the list of mesh you want to render.
  23402. */
  23403. get renderList(): Nullable<Array<AbstractMesh>>;
  23404. set renderList(value: Nullable<Array<AbstractMesh>>);
  23405. /**
  23406. * Use this function to overload the renderList array at rendering time.
  23407. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23408. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23409. * the cube (if the RTT is a cube, else layerOrFace=0).
  23410. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23411. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23412. * hold dummy elements!
  23413. */
  23414. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23415. private _hookArray;
  23416. /**
  23417. * Define if particles should be rendered in your texture.
  23418. */
  23419. renderParticles: boolean;
  23420. /**
  23421. * Define if sprites should be rendered in your texture.
  23422. */
  23423. renderSprites: boolean;
  23424. /**
  23425. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23426. */
  23427. coordinatesMode: number;
  23428. /**
  23429. * Define the camera used to render the texture.
  23430. */
  23431. activeCamera: Nullable<Camera>;
  23432. /**
  23433. * Override the mesh isReady function with your own one.
  23434. */
  23435. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23436. /**
  23437. * Override the render function of the texture with your own one.
  23438. */
  23439. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23440. /**
  23441. * Define if camera post processes should be use while rendering the texture.
  23442. */
  23443. useCameraPostProcesses: boolean;
  23444. /**
  23445. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23446. */
  23447. ignoreCameraViewport: boolean;
  23448. private _postProcessManager;
  23449. private _postProcesses;
  23450. private _resizeObserver;
  23451. /**
  23452. * An event triggered when the texture is unbind.
  23453. */
  23454. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23455. /**
  23456. * An event triggered when the texture is unbind.
  23457. */
  23458. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23459. private _onAfterUnbindObserver;
  23460. /**
  23461. * Set a after unbind callback in the texture.
  23462. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23463. */
  23464. set onAfterUnbind(callback: () => void);
  23465. /**
  23466. * An event triggered before rendering the texture
  23467. */
  23468. onBeforeRenderObservable: Observable<number>;
  23469. private _onBeforeRenderObserver;
  23470. /**
  23471. * Set a before render callback in the texture.
  23472. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23473. */
  23474. set onBeforeRender(callback: (faceIndex: number) => void);
  23475. /**
  23476. * An event triggered after rendering the texture
  23477. */
  23478. onAfterRenderObservable: Observable<number>;
  23479. private _onAfterRenderObserver;
  23480. /**
  23481. * Set a after render callback in the texture.
  23482. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23483. */
  23484. set onAfterRender(callback: (faceIndex: number) => void);
  23485. /**
  23486. * An event triggered after the texture clear
  23487. */
  23488. onClearObservable: Observable<Engine>;
  23489. private _onClearObserver;
  23490. /**
  23491. * Set a clear callback in the texture.
  23492. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23493. */
  23494. set onClear(callback: (Engine: Engine) => void);
  23495. /**
  23496. * An event triggered when the texture is resized.
  23497. */
  23498. onResizeObservable: Observable<RenderTargetTexture>;
  23499. /**
  23500. * Define the clear color of the Render Target if it should be different from the scene.
  23501. */
  23502. clearColor: Color4;
  23503. protected _size: number | {
  23504. width: number;
  23505. height: number;
  23506. layers?: number;
  23507. };
  23508. protected _initialSizeParameter: number | {
  23509. width: number;
  23510. height: number;
  23511. } | {
  23512. ratio: number;
  23513. };
  23514. protected _sizeRatio: Nullable<number>;
  23515. /** @hidden */
  23516. _generateMipMaps: boolean;
  23517. protected _renderingManager: RenderingManager;
  23518. /** @hidden */
  23519. _waitingRenderList: string[];
  23520. protected _doNotChangeAspectRatio: boolean;
  23521. protected _currentRefreshId: number;
  23522. protected _refreshRate: number;
  23523. protected _textureMatrix: Matrix;
  23524. protected _samples: number;
  23525. protected _renderTargetOptions: RenderTargetCreationOptions;
  23526. /**
  23527. * Gets render target creation options that were used.
  23528. */
  23529. get renderTargetOptions(): RenderTargetCreationOptions;
  23530. protected _onRatioRescale(): void;
  23531. /**
  23532. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23533. * It must define where the camera used to render the texture is set
  23534. */
  23535. boundingBoxPosition: Vector3;
  23536. private _boundingBoxSize;
  23537. /**
  23538. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23539. * When defined, the cubemap will switch to local mode
  23540. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23541. * @example https://www.babylonjs-playground.com/#RNASML
  23542. */
  23543. set boundingBoxSize(value: Vector3);
  23544. get boundingBoxSize(): Vector3;
  23545. /**
  23546. * In case the RTT has been created with a depth texture, get the associated
  23547. * depth texture.
  23548. * Otherwise, return null.
  23549. */
  23550. get depthStencilTexture(): Nullable<InternalTexture>;
  23551. /**
  23552. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23553. * or used a shadow, depth texture...
  23554. * @param name The friendly name of the texture
  23555. * @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)
  23556. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23557. * @param generateMipMaps True if mip maps need to be generated after render.
  23558. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23559. * @param type The type of the buffer in the RTT (int, half float, float...)
  23560. * @param isCube True if a cube texture needs to be created
  23561. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23562. * @param generateDepthBuffer True to generate a depth buffer
  23563. * @param generateStencilBuffer True to generate a stencil buffer
  23564. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23565. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23566. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23567. */
  23568. constructor(name: string, size: number | {
  23569. width: number;
  23570. height: number;
  23571. layers?: number;
  23572. } | {
  23573. ratio: number;
  23574. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23575. /**
  23576. * Creates a depth stencil texture.
  23577. * This is only available in WebGL 2 or with the depth texture extension available.
  23578. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23579. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23580. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23581. */
  23582. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23583. private _processSizeParameter;
  23584. /**
  23585. * Define the number of samples to use in case of MSAA.
  23586. * It defaults to one meaning no MSAA has been enabled.
  23587. */
  23588. get samples(): number;
  23589. set samples(value: number);
  23590. /**
  23591. * Resets the refresh counter of the texture and start bak from scratch.
  23592. * Could be useful to regenerate the texture if it is setup to render only once.
  23593. */
  23594. resetRefreshCounter(): void;
  23595. /**
  23596. * Define the refresh rate of the texture or the rendering frequency.
  23597. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23598. */
  23599. get refreshRate(): number;
  23600. set refreshRate(value: number);
  23601. /**
  23602. * Adds a post process to the render target rendering passes.
  23603. * @param postProcess define the post process to add
  23604. */
  23605. addPostProcess(postProcess: PostProcess): void;
  23606. /**
  23607. * Clear all the post processes attached to the render target
  23608. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23609. */
  23610. clearPostProcesses(dispose?: boolean): void;
  23611. /**
  23612. * Remove one of the post process from the list of attached post processes to the texture
  23613. * @param postProcess define the post process to remove from the list
  23614. */
  23615. removePostProcess(postProcess: PostProcess): void;
  23616. /** @hidden */
  23617. _shouldRender(): boolean;
  23618. /**
  23619. * Gets the actual render size of the texture.
  23620. * @returns the width of the render size
  23621. */
  23622. getRenderSize(): number;
  23623. /**
  23624. * Gets the actual render width of the texture.
  23625. * @returns the width of the render size
  23626. */
  23627. getRenderWidth(): number;
  23628. /**
  23629. * Gets the actual render height of the texture.
  23630. * @returns the height of the render size
  23631. */
  23632. getRenderHeight(): number;
  23633. /**
  23634. * Gets the actual number of layers of the texture.
  23635. * @returns the number of layers
  23636. */
  23637. getRenderLayers(): number;
  23638. /**
  23639. * Get if the texture can be rescaled or not.
  23640. */
  23641. get canRescale(): boolean;
  23642. /**
  23643. * Resize the texture using a ratio.
  23644. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23645. */
  23646. scale(ratio: number): void;
  23647. /**
  23648. * Get the texture reflection matrix used to rotate/transform the reflection.
  23649. * @returns the reflection matrix
  23650. */
  23651. getReflectionTextureMatrix(): Matrix;
  23652. /**
  23653. * Resize the texture to a new desired size.
  23654. * Be carrefull as it will recreate all the data in the new texture.
  23655. * @param size Define the new size. It can be:
  23656. * - a number for squared texture,
  23657. * - an object containing { width: number, height: number }
  23658. * - or an object containing a ratio { ratio: number }
  23659. */
  23660. resize(size: number | {
  23661. width: number;
  23662. height: number;
  23663. } | {
  23664. ratio: number;
  23665. }): void;
  23666. private _defaultRenderListPrepared;
  23667. /**
  23668. * Renders all the objects from the render list into the texture.
  23669. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23670. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23671. */
  23672. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23673. private _bestReflectionRenderTargetDimension;
  23674. private _prepareRenderingManager;
  23675. /**
  23676. * @hidden
  23677. * @param faceIndex face index to bind to if this is a cubetexture
  23678. * @param layer defines the index of the texture to bind in the array
  23679. */
  23680. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23681. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23682. private renderToTarget;
  23683. /**
  23684. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23685. * This allowed control for front to back rendering or reversly depending of the special needs.
  23686. *
  23687. * @param renderingGroupId The rendering group id corresponding to its index
  23688. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23689. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23690. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23691. */
  23692. 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;
  23693. /**
  23694. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23695. *
  23696. * @param renderingGroupId The rendering group id corresponding to its index
  23697. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23698. */
  23699. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23700. /**
  23701. * Clones the texture.
  23702. * @returns the cloned texture
  23703. */
  23704. clone(): RenderTargetTexture;
  23705. /**
  23706. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23707. * @returns The JSON representation of the texture
  23708. */
  23709. serialize(): any;
  23710. /**
  23711. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23712. */
  23713. disposeFramebufferObjects(): void;
  23714. /**
  23715. * Dispose the texture and release its associated resources.
  23716. */
  23717. dispose(): void;
  23718. /** @hidden */
  23719. _rebuild(): void;
  23720. /**
  23721. * Clear the info related to rendering groups preventing retention point in material dispose.
  23722. */
  23723. freeRenderingGroups(): void;
  23724. /**
  23725. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23726. * @returns the view count
  23727. */
  23728. getViewCount(): number;
  23729. }
  23730. }
  23731. declare module BABYLON {
  23732. /**
  23733. * Class used to manipulate GUIDs
  23734. */
  23735. export class GUID {
  23736. /**
  23737. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23738. * Be aware Math.random() could cause collisions, but:
  23739. * "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"
  23740. * @returns a pseudo random id
  23741. */
  23742. static RandomId(): string;
  23743. }
  23744. }
  23745. declare module BABYLON {
  23746. /**
  23747. * Options to be used when creating a shadow depth material
  23748. */
  23749. export interface IIOptionShadowDepthMaterial {
  23750. /** Variables in the vertex shader code that need to have their names remapped.
  23751. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23752. * "var_name" should be either: worldPos or vNormalW
  23753. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23754. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23755. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23756. */
  23757. remappedVariables?: string[];
  23758. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23759. standalone?: boolean;
  23760. }
  23761. /**
  23762. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23763. */
  23764. export class ShadowDepthWrapper {
  23765. private _scene;
  23766. private _options?;
  23767. private _baseMaterial;
  23768. private _onEffectCreatedObserver;
  23769. private _subMeshToEffect;
  23770. private _subMeshToDepthEffect;
  23771. private _meshes;
  23772. /** @hidden */
  23773. _matriceNames: any;
  23774. /** Gets the standalone status of the wrapper */
  23775. get standalone(): boolean;
  23776. /** Gets the base material the wrapper is built upon */
  23777. get baseMaterial(): Material;
  23778. /**
  23779. * Instantiate a new shadow depth wrapper.
  23780. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23781. * generate the shadow depth map. For more information, please refer to the documentation:
  23782. * https://doc.babylonjs.com/babylon101/shadows
  23783. * @param baseMaterial Material to wrap
  23784. * @param scene Define the scene the material belongs to
  23785. * @param options Options used to create the wrapper
  23786. */
  23787. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23788. /**
  23789. * Gets the effect to use to generate the depth map
  23790. * @param subMesh subMesh to get the effect for
  23791. * @param shadowGenerator shadow generator to get the effect for
  23792. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23793. */
  23794. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23795. /**
  23796. * Specifies that the submesh is ready to be used for depth rendering
  23797. * @param subMesh submesh to check
  23798. * @param defines the list of defines to take into account when checking the effect
  23799. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23800. * @param useInstances specifies that instances should be used
  23801. * @returns a boolean indicating that the submesh is ready or not
  23802. */
  23803. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23804. /**
  23805. * Disposes the resources
  23806. */
  23807. dispose(): void;
  23808. private _makeEffect;
  23809. }
  23810. }
  23811. declare module BABYLON {
  23812. interface ThinEngine {
  23813. /**
  23814. * Unbind a list of render target textures from the webGL context
  23815. * This is used only when drawBuffer extension or webGL2 are active
  23816. * @param textures defines the render target textures to unbind
  23817. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23818. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23819. */
  23820. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23821. /**
  23822. * Create a multi render target texture
  23823. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23824. * @param size defines the size of the texture
  23825. * @param options defines the creation options
  23826. * @returns the cube texture as an InternalTexture
  23827. */
  23828. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23829. /**
  23830. * Update the sample count for a given multiple render target texture
  23831. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23832. * @param textures defines the textures to update
  23833. * @param samples defines the sample count to set
  23834. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23835. */
  23836. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23837. /**
  23838. * Select a subsets of attachments to draw to.
  23839. * @param attachments gl attachments
  23840. */
  23841. bindAttachments(attachments: number[]): void;
  23842. }
  23843. }
  23844. declare module BABYLON {
  23845. /**
  23846. * Creation options of the multi render target texture.
  23847. */
  23848. export interface IMultiRenderTargetOptions {
  23849. /**
  23850. * Define if the texture needs to create mip maps after render.
  23851. */
  23852. generateMipMaps?: boolean;
  23853. /**
  23854. * Define the types of all the draw buffers we want to create
  23855. */
  23856. types?: number[];
  23857. /**
  23858. * Define the sampling modes of all the draw buffers we want to create
  23859. */
  23860. samplingModes?: number[];
  23861. /**
  23862. * Define if a depth buffer is required
  23863. */
  23864. generateDepthBuffer?: boolean;
  23865. /**
  23866. * Define if a stencil buffer is required
  23867. */
  23868. generateStencilBuffer?: boolean;
  23869. /**
  23870. * Define if a depth texture is required instead of a depth buffer
  23871. */
  23872. generateDepthTexture?: boolean;
  23873. /**
  23874. * Define the number of desired draw buffers
  23875. */
  23876. textureCount?: number;
  23877. /**
  23878. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23879. */
  23880. doNotChangeAspectRatio?: boolean;
  23881. /**
  23882. * Define the default type of the buffers we are creating
  23883. */
  23884. defaultType?: number;
  23885. }
  23886. /**
  23887. * A multi render target, like a render target provides the ability to render to a texture.
  23888. * Unlike the render target, it can render to several draw buffers in one draw.
  23889. * This is specially interesting in deferred rendering or for any effects requiring more than
  23890. * just one color from a single pass.
  23891. */
  23892. export class MultiRenderTarget extends RenderTargetTexture {
  23893. private _internalTextures;
  23894. private _textures;
  23895. private _multiRenderTargetOptions;
  23896. private _count;
  23897. /**
  23898. * Get if draw buffers are currently supported by the used hardware and browser.
  23899. */
  23900. get isSupported(): boolean;
  23901. /**
  23902. * Get the list of textures generated by the multi render target.
  23903. */
  23904. get textures(): Texture[];
  23905. /**
  23906. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23907. */
  23908. get count(): number;
  23909. /**
  23910. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23911. */
  23912. get depthTexture(): Texture;
  23913. /**
  23914. * Set the wrapping mode on U of all the textures we are rendering to.
  23915. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23916. */
  23917. set wrapU(wrap: number);
  23918. /**
  23919. * Set the wrapping mode on V of all the textures we are rendering to.
  23920. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23921. */
  23922. set wrapV(wrap: number);
  23923. /**
  23924. * Instantiate a new multi render target texture.
  23925. * A multi render target, like a render target provides the ability to render to a texture.
  23926. * Unlike the render target, it can render to several draw buffers in one draw.
  23927. * This is specially interesting in deferred rendering or for any effects requiring more than
  23928. * just one color from a single pass.
  23929. * @param name Define the name of the texture
  23930. * @param size Define the size of the buffers to render to
  23931. * @param count Define the number of target we are rendering into
  23932. * @param scene Define the scene the texture belongs to
  23933. * @param options Define the options used to create the multi render target
  23934. */
  23935. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23936. /** @hidden */
  23937. _rebuild(): void;
  23938. private _createInternalTextures;
  23939. private _createTextures;
  23940. /**
  23941. * Define the number of samples used if MSAA is enabled.
  23942. */
  23943. get samples(): number;
  23944. set samples(value: number);
  23945. /**
  23946. * Resize all the textures in the multi render target.
  23947. * Be carrefull as it will recreate all the data in the new texture.
  23948. * @param size Define the new size
  23949. */
  23950. resize(size: any): void;
  23951. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23952. /**
  23953. * Dispose the render targets and their associated resources
  23954. */
  23955. dispose(): void;
  23956. /**
  23957. * Release all the underlying texture used as draw buffers.
  23958. */
  23959. releaseInternalTextures(): void;
  23960. }
  23961. }
  23962. declare module BABYLON {
  23963. /** @hidden */
  23964. export var imageProcessingPixelShader: {
  23965. name: string;
  23966. shader: string;
  23967. };
  23968. }
  23969. declare module BABYLON {
  23970. /**
  23971. * ImageProcessingPostProcess
  23972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23973. */
  23974. export class ImageProcessingPostProcess extends PostProcess {
  23975. /**
  23976. * Default configuration related to image processing available in the PBR Material.
  23977. */
  23978. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23979. /**
  23980. * Gets the image processing configuration used either in this material.
  23981. */
  23982. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23983. /**
  23984. * Sets the Default image processing configuration used either in the this material.
  23985. *
  23986. * If sets to null, the scene one is in use.
  23987. */
  23988. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23989. /**
  23990. * Keep track of the image processing observer to allow dispose and replace.
  23991. */
  23992. private _imageProcessingObserver;
  23993. /**
  23994. * Attaches a new image processing configuration to the PBR Material.
  23995. * @param configuration
  23996. */
  23997. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23998. /**
  23999. * If the post process is supported.
  24000. */
  24001. get isSupported(): boolean;
  24002. /**
  24003. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24004. */
  24005. get colorCurves(): Nullable<ColorCurves>;
  24006. /**
  24007. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24008. */
  24009. set colorCurves(value: Nullable<ColorCurves>);
  24010. /**
  24011. * Gets wether the color curves effect is enabled.
  24012. */
  24013. get colorCurvesEnabled(): boolean;
  24014. /**
  24015. * Sets wether the color curves effect is enabled.
  24016. */
  24017. set colorCurvesEnabled(value: boolean);
  24018. /**
  24019. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24020. */
  24021. get colorGradingTexture(): Nullable<BaseTexture>;
  24022. /**
  24023. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24024. */
  24025. set colorGradingTexture(value: Nullable<BaseTexture>);
  24026. /**
  24027. * Gets wether the color grading effect is enabled.
  24028. */
  24029. get colorGradingEnabled(): boolean;
  24030. /**
  24031. * Gets wether the color grading effect is enabled.
  24032. */
  24033. set colorGradingEnabled(value: boolean);
  24034. /**
  24035. * Gets exposure used in the effect.
  24036. */
  24037. get exposure(): number;
  24038. /**
  24039. * Sets exposure used in the effect.
  24040. */
  24041. set exposure(value: number);
  24042. /**
  24043. * Gets wether tonemapping is enabled or not.
  24044. */
  24045. get toneMappingEnabled(): boolean;
  24046. /**
  24047. * Sets wether tonemapping is enabled or not
  24048. */
  24049. set toneMappingEnabled(value: boolean);
  24050. /**
  24051. * Gets the type of tone mapping effect.
  24052. */
  24053. get toneMappingType(): number;
  24054. /**
  24055. * Sets the type of tone mapping effect.
  24056. */
  24057. set toneMappingType(value: number);
  24058. /**
  24059. * Gets contrast used in the effect.
  24060. */
  24061. get contrast(): number;
  24062. /**
  24063. * Sets contrast used in the effect.
  24064. */
  24065. set contrast(value: number);
  24066. /**
  24067. * Gets Vignette stretch size.
  24068. */
  24069. get vignetteStretch(): number;
  24070. /**
  24071. * Sets Vignette stretch size.
  24072. */
  24073. set vignetteStretch(value: number);
  24074. /**
  24075. * Gets Vignette centre X Offset.
  24076. */
  24077. get vignetteCentreX(): number;
  24078. /**
  24079. * Sets Vignette centre X Offset.
  24080. */
  24081. set vignetteCentreX(value: number);
  24082. /**
  24083. * Gets Vignette centre Y Offset.
  24084. */
  24085. get vignetteCentreY(): number;
  24086. /**
  24087. * Sets Vignette centre Y Offset.
  24088. */
  24089. set vignetteCentreY(value: number);
  24090. /**
  24091. * Gets Vignette weight or intensity of the vignette effect.
  24092. */
  24093. get vignetteWeight(): number;
  24094. /**
  24095. * Sets Vignette weight or intensity of the vignette effect.
  24096. */
  24097. set vignetteWeight(value: number);
  24098. /**
  24099. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24100. * if vignetteEnabled is set to true.
  24101. */
  24102. get vignetteColor(): Color4;
  24103. /**
  24104. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24105. * if vignetteEnabled is set to true.
  24106. */
  24107. set vignetteColor(value: Color4);
  24108. /**
  24109. * Gets Camera field of view used by the Vignette effect.
  24110. */
  24111. get vignetteCameraFov(): number;
  24112. /**
  24113. * Sets Camera field of view used by the Vignette effect.
  24114. */
  24115. set vignetteCameraFov(value: number);
  24116. /**
  24117. * Gets the vignette blend mode allowing different kind of effect.
  24118. */
  24119. get vignetteBlendMode(): number;
  24120. /**
  24121. * Sets the vignette blend mode allowing different kind of effect.
  24122. */
  24123. set vignetteBlendMode(value: number);
  24124. /**
  24125. * Gets wether the vignette effect is enabled.
  24126. */
  24127. get vignetteEnabled(): boolean;
  24128. /**
  24129. * Sets wether the vignette effect is enabled.
  24130. */
  24131. set vignetteEnabled(value: boolean);
  24132. private _fromLinearSpace;
  24133. /**
  24134. * Gets wether the input of the processing is in Gamma or Linear Space.
  24135. */
  24136. get fromLinearSpace(): boolean;
  24137. /**
  24138. * Sets wether the input of the processing is in Gamma or Linear Space.
  24139. */
  24140. set fromLinearSpace(value: boolean);
  24141. /**
  24142. * Defines cache preventing GC.
  24143. */
  24144. private _defines;
  24145. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24146. /**
  24147. * "ImageProcessingPostProcess"
  24148. * @returns "ImageProcessingPostProcess"
  24149. */
  24150. getClassName(): string;
  24151. /**
  24152. * @hidden
  24153. */
  24154. _updateParameters(): void;
  24155. dispose(camera?: Camera): void;
  24156. }
  24157. }
  24158. declare module BABYLON {
  24159. /** @hidden */
  24160. export var fibonacci: {
  24161. name: string;
  24162. shader: string;
  24163. };
  24164. }
  24165. declare module BABYLON {
  24166. /** @hidden */
  24167. export var subSurfaceScatteringFunctions: {
  24168. name: string;
  24169. shader: string;
  24170. };
  24171. }
  24172. declare module BABYLON {
  24173. /** @hidden */
  24174. export var diffusionProfile: {
  24175. name: string;
  24176. shader: string;
  24177. };
  24178. }
  24179. declare module BABYLON {
  24180. /** @hidden */
  24181. export var subSurfaceScatteringPixelShader: {
  24182. name: string;
  24183. shader: string;
  24184. };
  24185. }
  24186. declare module BABYLON {
  24187. /**
  24188. * Sub surface scattering post process
  24189. */
  24190. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24191. /** @hidden */
  24192. texelWidth: number;
  24193. /** @hidden */
  24194. texelHeight: number;
  24195. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24196. }
  24197. }
  24198. declare module BABYLON {
  24199. /**
  24200. * Interface for defining prepass effects in the prepass post-process pipeline
  24201. */
  24202. export interface PrePassEffectConfiguration {
  24203. /**
  24204. * Post process to attach for this effect
  24205. */
  24206. postProcess: PostProcess;
  24207. /**
  24208. * Is the effect enabled
  24209. */
  24210. enabled: boolean;
  24211. /**
  24212. * Disposes the effect configuration
  24213. */
  24214. dispose(): void;
  24215. /**
  24216. * Disposes the effect configuration
  24217. */
  24218. createPostProcess: () => PostProcess;
  24219. }
  24220. }
  24221. declare module BABYLON {
  24222. /**
  24223. * Contains all parameters needed for the prepass to perform
  24224. * screen space subsurface scattering
  24225. */
  24226. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24227. private _ssDiffusionS;
  24228. private _ssFilterRadii;
  24229. private _ssDiffusionD;
  24230. /**
  24231. * Post process to attach for screen space subsurface scattering
  24232. */
  24233. postProcess: SubSurfaceScatteringPostProcess;
  24234. /**
  24235. * Diffusion profile color for subsurface scattering
  24236. */
  24237. get ssDiffusionS(): number[];
  24238. /**
  24239. * Diffusion profile max color channel value for subsurface scattering
  24240. */
  24241. get ssDiffusionD(): number[];
  24242. /**
  24243. * Diffusion profile filter radius for subsurface scattering
  24244. */
  24245. get ssFilterRadii(): number[];
  24246. /**
  24247. * Is subsurface enabled
  24248. */
  24249. enabled: boolean;
  24250. /**
  24251. * Diffusion profile colors for subsurface scattering
  24252. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24253. * See ...
  24254. * Note that you can only store up to 5 of them
  24255. */
  24256. ssDiffusionProfileColors: Color3[];
  24257. /**
  24258. * Defines the ratio real world => scene units.
  24259. * Used for subsurface scattering
  24260. */
  24261. metersPerUnit: number;
  24262. private _scene;
  24263. /**
  24264. * Builds a subsurface configuration object
  24265. * @param scene The scene
  24266. */
  24267. constructor(scene: Scene);
  24268. /**
  24269. * Adds a new diffusion profile.
  24270. * Useful for more realistic subsurface scattering on diverse materials.
  24271. * @param color The color of the diffusion profile. Should be the average color of the material.
  24272. * @return The index of the diffusion profile for the material subsurface configuration
  24273. */
  24274. addDiffusionProfile(color: Color3): number;
  24275. /**
  24276. * Creates the sss post process
  24277. * @return The created post process
  24278. */
  24279. createPostProcess(): SubSurfaceScatteringPostProcess;
  24280. /**
  24281. * Deletes all diffusion profiles.
  24282. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24283. */
  24284. clearAllDiffusionProfiles(): void;
  24285. /**
  24286. * Disposes this object
  24287. */
  24288. dispose(): void;
  24289. /**
  24290. * @hidden
  24291. * https://zero-radiance.github.io/post/sampling-diffusion/
  24292. *
  24293. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24294. * ------------------------------------------------------------------------------------
  24295. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24296. * PDF[r, phi, s] = r * R[r, phi, s]
  24297. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24298. * ------------------------------------------------------------------------------------
  24299. * We importance sample the color channel with the widest scattering distance.
  24300. */
  24301. getDiffusionProfileParameters(color: Color3): number;
  24302. /**
  24303. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24304. * 'u' is the random number (the value of the CDF): [0, 1).
  24305. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24306. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24307. */
  24308. private _sampleBurleyDiffusionProfile;
  24309. }
  24310. }
  24311. declare module BABYLON {
  24312. /**
  24313. * Renders a pre pass of the scene
  24314. * This means every mesh in the scene will be rendered to a render target texture
  24315. * And then this texture will be composited to the rendering canvas with post processes
  24316. * It is necessary for effects like subsurface scattering or deferred shading
  24317. */
  24318. export class PrePassRenderer {
  24319. /** @hidden */
  24320. static _SceneComponentInitialization: (scene: Scene) => void;
  24321. private _scene;
  24322. private _engine;
  24323. private _isDirty;
  24324. /**
  24325. * Number of textures in the multi render target texture where the scene is directly rendered
  24326. */
  24327. readonly mrtCount: number;
  24328. /**
  24329. * The render target where the scene is directly rendered
  24330. */
  24331. prePassRT: MultiRenderTarget;
  24332. private _mrtTypes;
  24333. private _multiRenderAttachments;
  24334. private _defaultAttachments;
  24335. private _clearAttachments;
  24336. private _postProcesses;
  24337. private readonly _clearColor;
  24338. /**
  24339. * Image processing post process for composition
  24340. */
  24341. imageProcessingPostProcess: ImageProcessingPostProcess;
  24342. /**
  24343. * Configuration for sub surface scattering post process
  24344. */
  24345. subSurfaceConfiguration: SubSurfaceConfiguration;
  24346. /**
  24347. * Should materials render their geometry on the MRT
  24348. */
  24349. materialsShouldRenderGeometry: boolean;
  24350. /**
  24351. * Should materials render the irradiance information on the MRT
  24352. */
  24353. materialsShouldRenderIrradiance: boolean;
  24354. private _enabled;
  24355. /**
  24356. * Indicates if the prepass is enabled
  24357. */
  24358. get enabled(): boolean;
  24359. /**
  24360. * How many samples are used for MSAA of the scene render target
  24361. */
  24362. get samples(): number;
  24363. set samples(n: number);
  24364. /**
  24365. * Instanciates a prepass renderer
  24366. * @param scene The scene
  24367. */
  24368. constructor(scene: Scene);
  24369. private _initializeAttachments;
  24370. private _createCompositionEffect;
  24371. /**
  24372. * Indicates if rendering a prepass is supported
  24373. */
  24374. get isSupported(): boolean;
  24375. /**
  24376. * Sets the proper output textures to draw in the engine.
  24377. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24378. */
  24379. bindAttachmentsForEffect(effect: Effect): void;
  24380. /**
  24381. * @hidden
  24382. */
  24383. _beforeCameraDraw(): void;
  24384. /**
  24385. * @hidden
  24386. */
  24387. _afterCameraDraw(): void;
  24388. private _checkRTSize;
  24389. private _bindFrameBuffer;
  24390. /**
  24391. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24392. */
  24393. clear(): void;
  24394. private _setState;
  24395. private _enable;
  24396. private _disable;
  24397. private _resetPostProcessChain;
  24398. private _bindPostProcessChain;
  24399. /**
  24400. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24401. */
  24402. markAsDirty(): void;
  24403. private _update;
  24404. /**
  24405. * Disposes the prepass renderer.
  24406. */
  24407. dispose(): void;
  24408. }
  24409. }
  24410. declare module BABYLON {
  24411. /**
  24412. * Options for compiling materials.
  24413. */
  24414. export interface IMaterialCompilationOptions {
  24415. /**
  24416. * Defines whether clip planes are enabled.
  24417. */
  24418. clipPlane: boolean;
  24419. /**
  24420. * Defines whether instances are enabled.
  24421. */
  24422. useInstances: boolean;
  24423. }
  24424. /**
  24425. * Options passed when calling customShaderNameResolve
  24426. */
  24427. export interface ICustomShaderNameResolveOptions {
  24428. /**
  24429. * 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
  24430. */
  24431. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24432. }
  24433. /**
  24434. * Base class for the main features of a material in Babylon.js
  24435. */
  24436. export class Material implements IAnimatable {
  24437. /**
  24438. * Returns the triangle fill mode
  24439. */
  24440. static readonly TriangleFillMode: number;
  24441. /**
  24442. * Returns the wireframe mode
  24443. */
  24444. static readonly WireFrameFillMode: number;
  24445. /**
  24446. * Returns the point fill mode
  24447. */
  24448. static readonly PointFillMode: number;
  24449. /**
  24450. * Returns the point list draw mode
  24451. */
  24452. static readonly PointListDrawMode: number;
  24453. /**
  24454. * Returns the line list draw mode
  24455. */
  24456. static readonly LineListDrawMode: number;
  24457. /**
  24458. * Returns the line loop draw mode
  24459. */
  24460. static readonly LineLoopDrawMode: number;
  24461. /**
  24462. * Returns the line strip draw mode
  24463. */
  24464. static readonly LineStripDrawMode: number;
  24465. /**
  24466. * Returns the triangle strip draw mode
  24467. */
  24468. static readonly TriangleStripDrawMode: number;
  24469. /**
  24470. * Returns the triangle fan draw mode
  24471. */
  24472. static readonly TriangleFanDrawMode: number;
  24473. /**
  24474. * Stores the clock-wise side orientation
  24475. */
  24476. static readonly ClockWiseSideOrientation: number;
  24477. /**
  24478. * Stores the counter clock-wise side orientation
  24479. */
  24480. static readonly CounterClockWiseSideOrientation: number;
  24481. /**
  24482. * The dirty texture flag value
  24483. */
  24484. static readonly TextureDirtyFlag: number;
  24485. /**
  24486. * The dirty light flag value
  24487. */
  24488. static readonly LightDirtyFlag: number;
  24489. /**
  24490. * The dirty fresnel flag value
  24491. */
  24492. static readonly FresnelDirtyFlag: number;
  24493. /**
  24494. * The dirty attribute flag value
  24495. */
  24496. static readonly AttributesDirtyFlag: number;
  24497. /**
  24498. * The dirty misc flag value
  24499. */
  24500. static readonly MiscDirtyFlag: number;
  24501. /**
  24502. * The all dirty flag value
  24503. */
  24504. static readonly AllDirtyFlag: number;
  24505. /**
  24506. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24507. */
  24508. static readonly MATERIAL_OPAQUE: number;
  24509. /**
  24510. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24511. */
  24512. static readonly MATERIAL_ALPHATEST: number;
  24513. /**
  24514. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24515. */
  24516. static readonly MATERIAL_ALPHABLEND: number;
  24517. /**
  24518. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24519. * They are also discarded below the alpha cutoff threshold to improve performances.
  24520. */
  24521. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24522. /**
  24523. * The Whiteout method is used to blend normals.
  24524. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24525. */
  24526. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24527. /**
  24528. * The Reoriented Normal Mapping method is used to blend normals.
  24529. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24530. */
  24531. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24532. /**
  24533. * Custom callback helping to override the default shader used in the material.
  24534. */
  24535. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24536. /**
  24537. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24538. */
  24539. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24540. /**
  24541. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24542. * This means that the material can keep using a previous shader while a new one is being compiled.
  24543. * This is mostly used when shader parallel compilation is supported (true by default)
  24544. */
  24545. allowShaderHotSwapping: boolean;
  24546. /**
  24547. * The ID of the material
  24548. */
  24549. id: string;
  24550. /**
  24551. * Gets or sets the unique id of the material
  24552. */
  24553. uniqueId: number;
  24554. /**
  24555. * The name of the material
  24556. */
  24557. name: string;
  24558. /**
  24559. * Gets or sets user defined metadata
  24560. */
  24561. metadata: any;
  24562. /**
  24563. * For internal use only. Please do not use.
  24564. */
  24565. reservedDataStore: any;
  24566. /**
  24567. * Specifies if the ready state should be checked on each call
  24568. */
  24569. checkReadyOnEveryCall: boolean;
  24570. /**
  24571. * Specifies if the ready state should be checked once
  24572. */
  24573. checkReadyOnlyOnce: boolean;
  24574. /**
  24575. * The state of the material
  24576. */
  24577. state: string;
  24578. /**
  24579. * If the material can be rendered to several textures with MRT extension
  24580. */
  24581. get canRenderToMRT(): boolean;
  24582. /**
  24583. * The alpha value of the material
  24584. */
  24585. protected _alpha: number;
  24586. /**
  24587. * List of inspectable custom properties (used by the Inspector)
  24588. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24589. */
  24590. inspectableCustomProperties: IInspectable[];
  24591. /**
  24592. * Sets the alpha value of the material
  24593. */
  24594. set alpha(value: number);
  24595. /**
  24596. * Gets the alpha value of the material
  24597. */
  24598. get alpha(): number;
  24599. /**
  24600. * Specifies if back face culling is enabled
  24601. */
  24602. protected _backFaceCulling: boolean;
  24603. /**
  24604. * Sets the back-face culling state
  24605. */
  24606. set backFaceCulling(value: boolean);
  24607. /**
  24608. * Gets the back-face culling state
  24609. */
  24610. get backFaceCulling(): boolean;
  24611. /**
  24612. * Stores the value for side orientation
  24613. */
  24614. sideOrientation: number;
  24615. /**
  24616. * Callback triggered when the material is compiled
  24617. */
  24618. onCompiled: Nullable<(effect: Effect) => void>;
  24619. /**
  24620. * Callback triggered when an error occurs
  24621. */
  24622. onError: Nullable<(effect: Effect, errors: string) => void>;
  24623. /**
  24624. * Callback triggered to get the render target textures
  24625. */
  24626. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24627. /**
  24628. * Gets a boolean indicating that current material needs to register RTT
  24629. */
  24630. get hasRenderTargetTextures(): boolean;
  24631. /**
  24632. * Specifies if the material should be serialized
  24633. */
  24634. doNotSerialize: boolean;
  24635. /**
  24636. * @hidden
  24637. */
  24638. _storeEffectOnSubMeshes: boolean;
  24639. /**
  24640. * Stores the animations for the material
  24641. */
  24642. animations: Nullable<Array<Animation>>;
  24643. /**
  24644. * An event triggered when the material is disposed
  24645. */
  24646. onDisposeObservable: Observable<Material>;
  24647. /**
  24648. * An observer which watches for dispose events
  24649. */
  24650. private _onDisposeObserver;
  24651. private _onUnBindObservable;
  24652. /**
  24653. * Called during a dispose event
  24654. */
  24655. set onDispose(callback: () => void);
  24656. private _onBindObservable;
  24657. /**
  24658. * An event triggered when the material is bound
  24659. */
  24660. get onBindObservable(): Observable<AbstractMesh>;
  24661. /**
  24662. * An observer which watches for bind events
  24663. */
  24664. private _onBindObserver;
  24665. /**
  24666. * Called during a bind event
  24667. */
  24668. set onBind(callback: (Mesh: AbstractMesh) => void);
  24669. /**
  24670. * An event triggered when the material is unbound
  24671. */
  24672. get onUnBindObservable(): Observable<Material>;
  24673. protected _onEffectCreatedObservable: Nullable<Observable<{
  24674. effect: Effect;
  24675. subMesh: Nullable<SubMesh>;
  24676. }>>;
  24677. /**
  24678. * An event triggered when the effect is (re)created
  24679. */
  24680. get onEffectCreatedObservable(): Observable<{
  24681. effect: Effect;
  24682. subMesh: Nullable<SubMesh>;
  24683. }>;
  24684. /**
  24685. * Stores the value of the alpha mode
  24686. */
  24687. private _alphaMode;
  24688. /**
  24689. * Sets the value of the alpha mode.
  24690. *
  24691. * | Value | Type | Description |
  24692. * | --- | --- | --- |
  24693. * | 0 | ALPHA_DISABLE | |
  24694. * | 1 | ALPHA_ADD | |
  24695. * | 2 | ALPHA_COMBINE | |
  24696. * | 3 | ALPHA_SUBTRACT | |
  24697. * | 4 | ALPHA_MULTIPLY | |
  24698. * | 5 | ALPHA_MAXIMIZED | |
  24699. * | 6 | ALPHA_ONEONE | |
  24700. * | 7 | ALPHA_PREMULTIPLIED | |
  24701. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24702. * | 9 | ALPHA_INTERPOLATE | |
  24703. * | 10 | ALPHA_SCREENMODE | |
  24704. *
  24705. */
  24706. set alphaMode(value: number);
  24707. /**
  24708. * Gets the value of the alpha mode
  24709. */
  24710. get alphaMode(): number;
  24711. /**
  24712. * Stores the state of the need depth pre-pass value
  24713. */
  24714. private _needDepthPrePass;
  24715. /**
  24716. * Sets the need depth pre-pass value
  24717. */
  24718. set needDepthPrePass(value: boolean);
  24719. /**
  24720. * Gets the depth pre-pass value
  24721. */
  24722. get needDepthPrePass(): boolean;
  24723. /**
  24724. * Specifies if depth writing should be disabled
  24725. */
  24726. disableDepthWrite: boolean;
  24727. /**
  24728. * Specifies if color writing should be disabled
  24729. */
  24730. disableColorWrite: boolean;
  24731. /**
  24732. * Specifies if depth writing should be forced
  24733. */
  24734. forceDepthWrite: boolean;
  24735. /**
  24736. * Specifies the depth function that should be used. 0 means the default engine function
  24737. */
  24738. depthFunction: number;
  24739. /**
  24740. * Specifies if there should be a separate pass for culling
  24741. */
  24742. separateCullingPass: boolean;
  24743. /**
  24744. * Stores the state specifing if fog should be enabled
  24745. */
  24746. private _fogEnabled;
  24747. /**
  24748. * Sets the state for enabling fog
  24749. */
  24750. set fogEnabled(value: boolean);
  24751. /**
  24752. * Gets the value of the fog enabled state
  24753. */
  24754. get fogEnabled(): boolean;
  24755. /**
  24756. * Stores the size of points
  24757. */
  24758. pointSize: number;
  24759. /**
  24760. * Stores the z offset value
  24761. */
  24762. zOffset: number;
  24763. get wireframe(): boolean;
  24764. /**
  24765. * Sets the state of wireframe mode
  24766. */
  24767. set wireframe(value: boolean);
  24768. /**
  24769. * Gets the value specifying if point clouds are enabled
  24770. */
  24771. get pointsCloud(): boolean;
  24772. /**
  24773. * Sets the state of point cloud mode
  24774. */
  24775. set pointsCloud(value: boolean);
  24776. /**
  24777. * Gets the material fill mode
  24778. */
  24779. get fillMode(): number;
  24780. /**
  24781. * Sets the material fill mode
  24782. */
  24783. set fillMode(value: number);
  24784. /**
  24785. * @hidden
  24786. * Stores the effects for the material
  24787. */
  24788. _effect: Nullable<Effect>;
  24789. /**
  24790. * Specifies if uniform buffers should be used
  24791. */
  24792. private _useUBO;
  24793. /**
  24794. * Stores a reference to the scene
  24795. */
  24796. private _scene;
  24797. /**
  24798. * Stores the fill mode state
  24799. */
  24800. private _fillMode;
  24801. /**
  24802. * Specifies if the depth write state should be cached
  24803. */
  24804. private _cachedDepthWriteState;
  24805. /**
  24806. * Specifies if the color write state should be cached
  24807. */
  24808. private _cachedColorWriteState;
  24809. /**
  24810. * Specifies if the depth function state should be cached
  24811. */
  24812. private _cachedDepthFunctionState;
  24813. /**
  24814. * Stores the uniform buffer
  24815. */
  24816. protected _uniformBuffer: UniformBuffer;
  24817. /** @hidden */
  24818. _indexInSceneMaterialArray: number;
  24819. /** @hidden */
  24820. meshMap: Nullable<{
  24821. [id: string]: AbstractMesh | undefined;
  24822. }>;
  24823. /**
  24824. * Creates a material instance
  24825. * @param name defines the name of the material
  24826. * @param scene defines the scene to reference
  24827. * @param doNotAdd specifies if the material should be added to the scene
  24828. */
  24829. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24830. /**
  24831. * Returns a string representation of the current material
  24832. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24833. * @returns a string with material information
  24834. */
  24835. toString(fullDetails?: boolean): string;
  24836. /**
  24837. * Gets the class name of the material
  24838. * @returns a string with the class name of the material
  24839. */
  24840. getClassName(): string;
  24841. /**
  24842. * Specifies if updates for the material been locked
  24843. */
  24844. get isFrozen(): boolean;
  24845. /**
  24846. * Locks updates for the material
  24847. */
  24848. freeze(): void;
  24849. /**
  24850. * Unlocks updates for the material
  24851. */
  24852. unfreeze(): void;
  24853. /**
  24854. * Specifies if the material is ready to be used
  24855. * @param mesh defines the mesh to check
  24856. * @param useInstances specifies if instances should be used
  24857. * @returns a boolean indicating if the material is ready to be used
  24858. */
  24859. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24860. /**
  24861. * Specifies that the submesh is ready to be used
  24862. * @param mesh defines the mesh to check
  24863. * @param subMesh defines which submesh to check
  24864. * @param useInstances specifies that instances should be used
  24865. * @returns a boolean indicating that the submesh is ready or not
  24866. */
  24867. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24868. /**
  24869. * Returns the material effect
  24870. * @returns the effect associated with the material
  24871. */
  24872. getEffect(): Nullable<Effect>;
  24873. /**
  24874. * Returns the current scene
  24875. * @returns a Scene
  24876. */
  24877. getScene(): Scene;
  24878. /**
  24879. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24880. */
  24881. protected _forceAlphaTest: boolean;
  24882. /**
  24883. * The transparency mode of the material.
  24884. */
  24885. protected _transparencyMode: Nullable<number>;
  24886. /**
  24887. * Gets the current transparency mode.
  24888. */
  24889. get transparencyMode(): Nullable<number>;
  24890. /**
  24891. * Sets the transparency mode of the material.
  24892. *
  24893. * | Value | Type | Description |
  24894. * | ----- | ----------------------------------- | ----------- |
  24895. * | 0 | OPAQUE | |
  24896. * | 1 | ALPHATEST | |
  24897. * | 2 | ALPHABLEND | |
  24898. * | 3 | ALPHATESTANDBLEND | |
  24899. *
  24900. */
  24901. set transparencyMode(value: Nullable<number>);
  24902. /**
  24903. * Returns true if alpha blending should be disabled.
  24904. */
  24905. protected get _disableAlphaBlending(): boolean;
  24906. /**
  24907. * Specifies whether or not this material should be rendered in alpha blend mode.
  24908. * @returns a boolean specifying if alpha blending is needed
  24909. */
  24910. needAlphaBlending(): boolean;
  24911. /**
  24912. * Specifies if the mesh will require alpha blending
  24913. * @param mesh defines the mesh to check
  24914. * @returns a boolean specifying if alpha blending is needed for the mesh
  24915. */
  24916. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24917. /**
  24918. * Specifies whether or not this material should be rendered in alpha test mode.
  24919. * @returns a boolean specifying if an alpha test is needed.
  24920. */
  24921. needAlphaTesting(): boolean;
  24922. /**
  24923. * Specifies if material alpha testing should be turned on for the mesh
  24924. * @param mesh defines the mesh to check
  24925. */
  24926. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24927. /**
  24928. * Gets the texture used for the alpha test
  24929. * @returns the texture to use for alpha testing
  24930. */
  24931. getAlphaTestTexture(): Nullable<BaseTexture>;
  24932. /**
  24933. * Marks the material to indicate that it needs to be re-calculated
  24934. */
  24935. markDirty(): void;
  24936. /** @hidden */
  24937. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24938. /**
  24939. * Binds the material to the mesh
  24940. * @param world defines the world transformation matrix
  24941. * @param mesh defines the mesh to bind the material to
  24942. */
  24943. bind(world: Matrix, mesh?: Mesh): void;
  24944. /**
  24945. * Binds the submesh to the material
  24946. * @param world defines the world transformation matrix
  24947. * @param mesh defines the mesh containing the submesh
  24948. * @param subMesh defines the submesh to bind the material to
  24949. */
  24950. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24951. /**
  24952. * Binds the world matrix to the material
  24953. * @param world defines the world transformation matrix
  24954. */
  24955. bindOnlyWorldMatrix(world: Matrix): void;
  24956. /**
  24957. * Binds the scene's uniform buffer to the effect.
  24958. * @param effect defines the effect to bind to the scene uniform buffer
  24959. * @param sceneUbo defines the uniform buffer storing scene data
  24960. */
  24961. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24962. /**
  24963. * Binds the view matrix to the effect
  24964. * @param effect defines the effect to bind the view matrix to
  24965. */
  24966. bindView(effect: Effect): void;
  24967. /**
  24968. * Binds the view projection matrix to the effect
  24969. * @param effect defines the effect to bind the view projection matrix to
  24970. */
  24971. bindViewProjection(effect: Effect): void;
  24972. /**
  24973. * Processes to execute after binding the material to a mesh
  24974. * @param mesh defines the rendered mesh
  24975. */
  24976. protected _afterBind(mesh?: Mesh): void;
  24977. /**
  24978. * Unbinds the material from the mesh
  24979. */
  24980. unbind(): void;
  24981. /**
  24982. * Gets the active textures from the material
  24983. * @returns an array of textures
  24984. */
  24985. getActiveTextures(): BaseTexture[];
  24986. /**
  24987. * Specifies if the material uses a texture
  24988. * @param texture defines the texture to check against the material
  24989. * @returns a boolean specifying if the material uses the texture
  24990. */
  24991. hasTexture(texture: BaseTexture): boolean;
  24992. /**
  24993. * Makes a duplicate of the material, and gives it a new name
  24994. * @param name defines the new name for the duplicated material
  24995. * @returns the cloned material
  24996. */
  24997. clone(name: string): Nullable<Material>;
  24998. /**
  24999. * Gets the meshes bound to the material
  25000. * @returns an array of meshes bound to the material
  25001. */
  25002. getBindedMeshes(): AbstractMesh[];
  25003. /**
  25004. * Force shader compilation
  25005. * @param mesh defines the mesh associated with this material
  25006. * @param onCompiled defines a function to execute once the material is compiled
  25007. * @param options defines the options to configure the compilation
  25008. * @param onError defines a function to execute if the material fails compiling
  25009. */
  25010. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25011. /**
  25012. * Force shader compilation
  25013. * @param mesh defines the mesh that will use this material
  25014. * @param options defines additional options for compiling the shaders
  25015. * @returns a promise that resolves when the compilation completes
  25016. */
  25017. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25018. private static readonly _AllDirtyCallBack;
  25019. private static readonly _ImageProcessingDirtyCallBack;
  25020. private static readonly _TextureDirtyCallBack;
  25021. private static readonly _FresnelDirtyCallBack;
  25022. private static readonly _MiscDirtyCallBack;
  25023. private static readonly _LightsDirtyCallBack;
  25024. private static readonly _AttributeDirtyCallBack;
  25025. private static _FresnelAndMiscDirtyCallBack;
  25026. private static _TextureAndMiscDirtyCallBack;
  25027. private static readonly _DirtyCallbackArray;
  25028. private static readonly _RunDirtyCallBacks;
  25029. /**
  25030. * Marks a define in the material to indicate that it needs to be re-computed
  25031. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25032. */
  25033. markAsDirty(flag: number): void;
  25034. /**
  25035. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25036. * @param func defines a function which checks material defines against the submeshes
  25037. */
  25038. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25039. /**
  25040. * Indicates that the scene should check if the rendering now needs a prepass
  25041. */
  25042. protected _markScenePrePassDirty(): void;
  25043. /**
  25044. * Indicates that we need to re-calculated for all submeshes
  25045. */
  25046. protected _markAllSubMeshesAsAllDirty(): void;
  25047. /**
  25048. * Indicates that image processing needs to be re-calculated for all submeshes
  25049. */
  25050. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25051. /**
  25052. * Indicates that textures need to be re-calculated for all submeshes
  25053. */
  25054. protected _markAllSubMeshesAsTexturesDirty(): void;
  25055. /**
  25056. * Indicates that fresnel needs to be re-calculated for all submeshes
  25057. */
  25058. protected _markAllSubMeshesAsFresnelDirty(): void;
  25059. /**
  25060. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25061. */
  25062. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25063. /**
  25064. * Indicates that lights need to be re-calculated for all submeshes
  25065. */
  25066. protected _markAllSubMeshesAsLightsDirty(): void;
  25067. /**
  25068. * Indicates that attributes need to be re-calculated for all submeshes
  25069. */
  25070. protected _markAllSubMeshesAsAttributesDirty(): void;
  25071. /**
  25072. * Indicates that misc needs to be re-calculated for all submeshes
  25073. */
  25074. protected _markAllSubMeshesAsMiscDirty(): void;
  25075. /**
  25076. * Indicates that textures and misc need to be re-calculated for all submeshes
  25077. */
  25078. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25079. /**
  25080. * Sets the required values to the prepass renderer.
  25081. * @param prePassRenderer defines the prepass renderer to setup.
  25082. * @returns true if the pre pass is needed.
  25083. */
  25084. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25085. /**
  25086. * Disposes the material
  25087. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25088. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25089. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25090. */
  25091. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25092. /** @hidden */
  25093. private releaseVertexArrayObject;
  25094. /**
  25095. * Serializes this material
  25096. * @returns the serialized material object
  25097. */
  25098. serialize(): any;
  25099. /**
  25100. * Creates a material from parsed material data
  25101. * @param parsedMaterial defines parsed material data
  25102. * @param scene defines the hosting scene
  25103. * @param rootUrl defines the root URL to use to load textures
  25104. * @returns a new material
  25105. */
  25106. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25107. }
  25108. }
  25109. declare module BABYLON {
  25110. /**
  25111. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25112. * separate meshes. This can be use to improve performances.
  25113. * @see https://doc.babylonjs.com/how_to/multi_materials
  25114. */
  25115. export class MultiMaterial extends Material {
  25116. private _subMaterials;
  25117. /**
  25118. * Gets or Sets the list of Materials used within the multi material.
  25119. * They need to be ordered according to the submeshes order in the associated mesh
  25120. */
  25121. get subMaterials(): Nullable<Material>[];
  25122. set subMaterials(value: Nullable<Material>[]);
  25123. /**
  25124. * Function used to align with Node.getChildren()
  25125. * @returns the list of Materials used within the multi material
  25126. */
  25127. getChildren(): Nullable<Material>[];
  25128. /**
  25129. * Instantiates a new Multi Material
  25130. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25131. * separate meshes. This can be use to improve performances.
  25132. * @see https://doc.babylonjs.com/how_to/multi_materials
  25133. * @param name Define the name in the scene
  25134. * @param scene Define the scene the material belongs to
  25135. */
  25136. constructor(name: string, scene: Scene);
  25137. private _hookArray;
  25138. /**
  25139. * Get one of the submaterial by its index in the submaterials array
  25140. * @param index The index to look the sub material at
  25141. * @returns The Material if the index has been defined
  25142. */
  25143. getSubMaterial(index: number): Nullable<Material>;
  25144. /**
  25145. * Get the list of active textures for the whole sub materials list.
  25146. * @returns All the textures that will be used during the rendering
  25147. */
  25148. getActiveTextures(): BaseTexture[];
  25149. /**
  25150. * Gets the current class name of the material e.g. "MultiMaterial"
  25151. * Mainly use in serialization.
  25152. * @returns the class name
  25153. */
  25154. getClassName(): string;
  25155. /**
  25156. * Checks if the material is ready to render the requested sub mesh
  25157. * @param mesh Define the mesh the submesh belongs to
  25158. * @param subMesh Define the sub mesh to look readyness for
  25159. * @param useInstances Define whether or not the material is used with instances
  25160. * @returns true if ready, otherwise false
  25161. */
  25162. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25163. /**
  25164. * Clones the current material and its related sub materials
  25165. * @param name Define the name of the newly cloned material
  25166. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25167. * @returns the cloned material
  25168. */
  25169. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25170. /**
  25171. * Serializes the materials into a JSON representation.
  25172. * @returns the JSON representation
  25173. */
  25174. serialize(): any;
  25175. /**
  25176. * Dispose the material and release its associated resources
  25177. * @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)
  25178. * @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)
  25179. * @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)
  25180. */
  25181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25182. /**
  25183. * Creates a MultiMaterial from parsed MultiMaterial data.
  25184. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25185. * @param scene defines the hosting scene
  25186. * @returns a new MultiMaterial
  25187. */
  25188. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25189. }
  25190. }
  25191. declare module BABYLON {
  25192. /**
  25193. * Defines a subdivision inside a mesh
  25194. */
  25195. export class SubMesh implements ICullable {
  25196. /** the material index to use */
  25197. materialIndex: number;
  25198. /** vertex index start */
  25199. verticesStart: number;
  25200. /** vertices count */
  25201. verticesCount: number;
  25202. /** index start */
  25203. indexStart: number;
  25204. /** indices count */
  25205. indexCount: number;
  25206. /** @hidden */
  25207. _materialDefines: Nullable<MaterialDefines>;
  25208. /** @hidden */
  25209. _materialEffect: Nullable<Effect>;
  25210. /** @hidden */
  25211. _effectOverride: Nullable<Effect>;
  25212. /**
  25213. * Gets material defines used by the effect associated to the sub mesh
  25214. */
  25215. get materialDefines(): Nullable<MaterialDefines>;
  25216. /**
  25217. * Sets material defines used by the effect associated to the sub mesh
  25218. */
  25219. set materialDefines(defines: Nullable<MaterialDefines>);
  25220. /**
  25221. * Gets associated effect
  25222. */
  25223. get effect(): Nullable<Effect>;
  25224. /**
  25225. * Sets associated effect (effect used to render this submesh)
  25226. * @param effect defines the effect to associate with
  25227. * @param defines defines the set of defines used to compile this effect
  25228. */
  25229. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25230. /** @hidden */
  25231. _linesIndexCount: number;
  25232. private _mesh;
  25233. private _renderingMesh;
  25234. private _boundingInfo;
  25235. private _linesIndexBuffer;
  25236. /** @hidden */
  25237. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25238. /** @hidden */
  25239. _trianglePlanes: Plane[];
  25240. /** @hidden */
  25241. _lastColliderTransformMatrix: Nullable<Matrix>;
  25242. /** @hidden */
  25243. _renderId: number;
  25244. /** @hidden */
  25245. _alphaIndex: number;
  25246. /** @hidden */
  25247. _distanceToCamera: number;
  25248. /** @hidden */
  25249. _id: number;
  25250. private _currentMaterial;
  25251. /**
  25252. * Add a new submesh to a mesh
  25253. * @param materialIndex defines the material index to use
  25254. * @param verticesStart defines vertex index start
  25255. * @param verticesCount defines vertices count
  25256. * @param indexStart defines index start
  25257. * @param indexCount defines indices count
  25258. * @param mesh defines the parent mesh
  25259. * @param renderingMesh defines an optional rendering mesh
  25260. * @param createBoundingBox defines if bounding box should be created for this submesh
  25261. * @returns the new submesh
  25262. */
  25263. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25264. /**
  25265. * Creates a new submesh
  25266. * @param materialIndex defines the material index to use
  25267. * @param verticesStart defines vertex index start
  25268. * @param verticesCount defines vertices count
  25269. * @param indexStart defines index start
  25270. * @param indexCount defines indices count
  25271. * @param mesh defines the parent mesh
  25272. * @param renderingMesh defines an optional rendering mesh
  25273. * @param createBoundingBox defines if bounding box should be created for this submesh
  25274. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25275. */
  25276. constructor(
  25277. /** the material index to use */
  25278. materialIndex: number,
  25279. /** vertex index start */
  25280. verticesStart: number,
  25281. /** vertices count */
  25282. verticesCount: number,
  25283. /** index start */
  25284. indexStart: number,
  25285. /** indices count */
  25286. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25287. /**
  25288. * Returns true if this submesh covers the entire parent mesh
  25289. * @ignorenaming
  25290. */
  25291. get IsGlobal(): boolean;
  25292. /**
  25293. * Returns the submesh BoudingInfo object
  25294. * @returns current bounding info (or mesh's one if the submesh is global)
  25295. */
  25296. getBoundingInfo(): BoundingInfo;
  25297. /**
  25298. * Sets the submesh BoundingInfo
  25299. * @param boundingInfo defines the new bounding info to use
  25300. * @returns the SubMesh
  25301. */
  25302. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25303. /**
  25304. * Returns the mesh of the current submesh
  25305. * @return the parent mesh
  25306. */
  25307. getMesh(): AbstractMesh;
  25308. /**
  25309. * Returns the rendering mesh of the submesh
  25310. * @returns the rendering mesh (could be different from parent mesh)
  25311. */
  25312. getRenderingMesh(): Mesh;
  25313. /**
  25314. * Returns the replacement mesh of the submesh
  25315. * @returns the replacement mesh (could be different from parent mesh)
  25316. */
  25317. getReplacementMesh(): Nullable<AbstractMesh>;
  25318. /**
  25319. * Returns the effective mesh of the submesh
  25320. * @returns the effective mesh (could be different from parent mesh)
  25321. */
  25322. getEffectiveMesh(): AbstractMesh;
  25323. /**
  25324. * Returns the submesh material
  25325. * @returns null or the current material
  25326. */
  25327. getMaterial(): Nullable<Material>;
  25328. private _IsMultiMaterial;
  25329. /**
  25330. * Sets a new updated BoundingInfo object to the submesh
  25331. * @param data defines an optional position array to use to determine the bounding info
  25332. * @returns the SubMesh
  25333. */
  25334. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25335. /** @hidden */
  25336. _checkCollision(collider: Collider): boolean;
  25337. /**
  25338. * Updates the submesh BoundingInfo
  25339. * @param world defines the world matrix to use to update the bounding info
  25340. * @returns the submesh
  25341. */
  25342. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25343. /**
  25344. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25345. * @param frustumPlanes defines the frustum planes
  25346. * @returns true if the submesh is intersecting with the frustum
  25347. */
  25348. isInFrustum(frustumPlanes: Plane[]): boolean;
  25349. /**
  25350. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25351. * @param frustumPlanes defines the frustum planes
  25352. * @returns true if the submesh is inside the frustum
  25353. */
  25354. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25355. /**
  25356. * Renders the submesh
  25357. * @param enableAlphaMode defines if alpha needs to be used
  25358. * @returns the submesh
  25359. */
  25360. render(enableAlphaMode: boolean): SubMesh;
  25361. /**
  25362. * @hidden
  25363. */
  25364. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25365. /**
  25366. * Checks if the submesh intersects with a ray
  25367. * @param ray defines the ray to test
  25368. * @returns true is the passed ray intersects the submesh bounding box
  25369. */
  25370. canIntersects(ray: Ray): boolean;
  25371. /**
  25372. * Intersects current submesh with a ray
  25373. * @param ray defines the ray to test
  25374. * @param positions defines mesh's positions array
  25375. * @param indices defines mesh's indices array
  25376. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25377. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25378. * @returns intersection info or null if no intersection
  25379. */
  25380. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25381. /** @hidden */
  25382. private _intersectLines;
  25383. /** @hidden */
  25384. private _intersectUnIndexedLines;
  25385. /** @hidden */
  25386. private _intersectTriangles;
  25387. /** @hidden */
  25388. private _intersectUnIndexedTriangles;
  25389. /** @hidden */
  25390. _rebuild(): void;
  25391. /**
  25392. * Creates a new submesh from the passed mesh
  25393. * @param newMesh defines the new hosting mesh
  25394. * @param newRenderingMesh defines an optional rendering mesh
  25395. * @returns the new submesh
  25396. */
  25397. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25398. /**
  25399. * Release associated resources
  25400. */
  25401. dispose(): void;
  25402. /**
  25403. * Gets the class name
  25404. * @returns the string "SubMesh".
  25405. */
  25406. getClassName(): string;
  25407. /**
  25408. * Creates a new submesh from indices data
  25409. * @param materialIndex the index of the main mesh material
  25410. * @param startIndex the index where to start the copy in the mesh indices array
  25411. * @param indexCount the number of indices to copy then from the startIndex
  25412. * @param mesh the main mesh to create the submesh from
  25413. * @param renderingMesh the optional rendering mesh
  25414. * @returns a new submesh
  25415. */
  25416. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25417. }
  25418. }
  25419. declare module BABYLON {
  25420. /**
  25421. * Class used to represent data loading progression
  25422. */
  25423. export class SceneLoaderFlags {
  25424. private static _ForceFullSceneLoadingForIncremental;
  25425. private static _ShowLoadingScreen;
  25426. private static _CleanBoneMatrixWeights;
  25427. private static _loggingLevel;
  25428. /**
  25429. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25430. */
  25431. static get ForceFullSceneLoadingForIncremental(): boolean;
  25432. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25433. /**
  25434. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25435. */
  25436. static get ShowLoadingScreen(): boolean;
  25437. static set ShowLoadingScreen(value: boolean);
  25438. /**
  25439. * Defines the current logging level (while loading the scene)
  25440. * @ignorenaming
  25441. */
  25442. static get loggingLevel(): number;
  25443. static set loggingLevel(value: number);
  25444. /**
  25445. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25446. */
  25447. static get CleanBoneMatrixWeights(): boolean;
  25448. static set CleanBoneMatrixWeights(value: boolean);
  25449. }
  25450. }
  25451. declare module BABYLON {
  25452. /**
  25453. * Class used to store geometry data (vertex buffers + index buffer)
  25454. */
  25455. export class Geometry implements IGetSetVerticesData {
  25456. /**
  25457. * Gets or sets the ID of the geometry
  25458. */
  25459. id: string;
  25460. /**
  25461. * Gets or sets the unique ID of the geometry
  25462. */
  25463. uniqueId: number;
  25464. /**
  25465. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25466. */
  25467. delayLoadState: number;
  25468. /**
  25469. * Gets the file containing the data to load when running in delay load state
  25470. */
  25471. delayLoadingFile: Nullable<string>;
  25472. /**
  25473. * Callback called when the geometry is updated
  25474. */
  25475. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25476. private _scene;
  25477. private _engine;
  25478. private _meshes;
  25479. private _totalVertices;
  25480. /** @hidden */
  25481. _indices: IndicesArray;
  25482. /** @hidden */
  25483. _vertexBuffers: {
  25484. [key: string]: VertexBuffer;
  25485. };
  25486. private _isDisposed;
  25487. private _extend;
  25488. private _boundingBias;
  25489. /** @hidden */
  25490. _delayInfo: Array<string>;
  25491. private _indexBuffer;
  25492. private _indexBufferIsUpdatable;
  25493. /** @hidden */
  25494. _boundingInfo: Nullable<BoundingInfo>;
  25495. /** @hidden */
  25496. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25497. /** @hidden */
  25498. _softwareSkinningFrameId: number;
  25499. private _vertexArrayObjects;
  25500. private _updatable;
  25501. /** @hidden */
  25502. _positions: Nullable<Vector3[]>;
  25503. /**
  25504. * 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
  25505. */
  25506. get boundingBias(): Vector2;
  25507. /**
  25508. * 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
  25509. */
  25510. set boundingBias(value: Vector2);
  25511. /**
  25512. * Static function used to attach a new empty geometry to a mesh
  25513. * @param mesh defines the mesh to attach the geometry to
  25514. * @returns the new Geometry
  25515. */
  25516. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25517. /** Get the list of meshes using this geometry */
  25518. get meshes(): Mesh[];
  25519. /**
  25520. * 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
  25521. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25522. */
  25523. useBoundingInfoFromGeometry: boolean;
  25524. /**
  25525. * Creates a new geometry
  25526. * @param id defines the unique ID
  25527. * @param scene defines the hosting scene
  25528. * @param vertexData defines the VertexData used to get geometry data
  25529. * @param updatable defines if geometry must be updatable (false by default)
  25530. * @param mesh defines the mesh that will be associated with the geometry
  25531. */
  25532. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25533. /**
  25534. * Gets the current extend of the geometry
  25535. */
  25536. get extend(): {
  25537. minimum: Vector3;
  25538. maximum: Vector3;
  25539. };
  25540. /**
  25541. * Gets the hosting scene
  25542. * @returns the hosting Scene
  25543. */
  25544. getScene(): Scene;
  25545. /**
  25546. * Gets the hosting engine
  25547. * @returns the hosting Engine
  25548. */
  25549. getEngine(): Engine;
  25550. /**
  25551. * Defines if the geometry is ready to use
  25552. * @returns true if the geometry is ready to be used
  25553. */
  25554. isReady(): boolean;
  25555. /**
  25556. * Gets a value indicating that the geometry should not be serialized
  25557. */
  25558. get doNotSerialize(): boolean;
  25559. /** @hidden */
  25560. _rebuild(): void;
  25561. /**
  25562. * Affects all geometry data in one call
  25563. * @param vertexData defines the geometry data
  25564. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25565. */
  25566. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25567. /**
  25568. * Set specific vertex data
  25569. * @param kind defines the data kind (Position, normal, etc...)
  25570. * @param data defines the vertex data to use
  25571. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25572. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25573. */
  25574. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25575. /**
  25576. * Removes a specific vertex data
  25577. * @param kind defines the data kind (Position, normal, etc...)
  25578. */
  25579. removeVerticesData(kind: string): void;
  25580. /**
  25581. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25582. * @param buffer defines the vertex buffer to use
  25583. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25584. */
  25585. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25586. /**
  25587. * Update a specific vertex buffer
  25588. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25589. * It will do nothing if the buffer is not updatable
  25590. * @param kind defines the data kind (Position, normal, etc...)
  25591. * @param data defines the data to use
  25592. * @param offset defines the offset in the target buffer where to store the data
  25593. * @param useBytes set to true if the offset is in bytes
  25594. */
  25595. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25596. /**
  25597. * Update a specific vertex buffer
  25598. * This function will create a new buffer if the current one is not updatable
  25599. * @param kind defines the data kind (Position, normal, etc...)
  25600. * @param data defines the data to use
  25601. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25602. */
  25603. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25604. private _updateBoundingInfo;
  25605. /** @hidden */
  25606. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25607. /**
  25608. * Gets total number of vertices
  25609. * @returns the total number of vertices
  25610. */
  25611. getTotalVertices(): number;
  25612. /**
  25613. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25614. * @param kind defines the data kind (Position, normal, etc...)
  25615. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25616. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25617. * @returns a float array containing vertex data
  25618. */
  25619. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25620. /**
  25621. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25622. * @param kind defines the data kind (Position, normal, etc...)
  25623. * @returns true if the vertex buffer with the specified kind is updatable
  25624. */
  25625. isVertexBufferUpdatable(kind: string): boolean;
  25626. /**
  25627. * Gets a specific vertex buffer
  25628. * @param kind defines the data kind (Position, normal, etc...)
  25629. * @returns a VertexBuffer
  25630. */
  25631. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25632. /**
  25633. * Returns all vertex buffers
  25634. * @return an object holding all vertex buffers indexed by kind
  25635. */
  25636. getVertexBuffers(): Nullable<{
  25637. [key: string]: VertexBuffer;
  25638. }>;
  25639. /**
  25640. * Gets a boolean indicating if specific vertex buffer is present
  25641. * @param kind defines the data kind (Position, normal, etc...)
  25642. * @returns true if data is present
  25643. */
  25644. isVerticesDataPresent(kind: string): boolean;
  25645. /**
  25646. * Gets a list of all attached data kinds (Position, normal, etc...)
  25647. * @returns a list of string containing all kinds
  25648. */
  25649. getVerticesDataKinds(): string[];
  25650. /**
  25651. * Update index buffer
  25652. * @param indices defines the indices to store in the index buffer
  25653. * @param offset defines the offset in the target buffer where to store the data
  25654. * @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)
  25655. */
  25656. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25657. /**
  25658. * Creates a new index buffer
  25659. * @param indices defines the indices to store in the index buffer
  25660. * @param totalVertices defines the total number of vertices (could be null)
  25661. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25662. */
  25663. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25664. /**
  25665. * Return the total number of indices
  25666. * @returns the total number of indices
  25667. */
  25668. getTotalIndices(): number;
  25669. /**
  25670. * Gets the index buffer array
  25671. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25672. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25673. * @returns the index buffer array
  25674. */
  25675. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25676. /**
  25677. * Gets the index buffer
  25678. * @return the index buffer
  25679. */
  25680. getIndexBuffer(): Nullable<DataBuffer>;
  25681. /** @hidden */
  25682. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25683. /**
  25684. * Release the associated resources for a specific mesh
  25685. * @param mesh defines the source mesh
  25686. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25687. */
  25688. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25689. /**
  25690. * Apply current geometry to a given mesh
  25691. * @param mesh defines the mesh to apply geometry to
  25692. */
  25693. applyToMesh(mesh: Mesh): void;
  25694. private _updateExtend;
  25695. private _applyToMesh;
  25696. private notifyUpdate;
  25697. /**
  25698. * Load the geometry if it was flagged as delay loaded
  25699. * @param scene defines the hosting scene
  25700. * @param onLoaded defines a callback called when the geometry is loaded
  25701. */
  25702. load(scene: Scene, onLoaded?: () => void): void;
  25703. private _queueLoad;
  25704. /**
  25705. * Invert the geometry to move from a right handed system to a left handed one.
  25706. */
  25707. toLeftHanded(): void;
  25708. /** @hidden */
  25709. _resetPointsArrayCache(): void;
  25710. /** @hidden */
  25711. _generatePointsArray(): boolean;
  25712. /**
  25713. * Gets a value indicating if the geometry is disposed
  25714. * @returns true if the geometry was disposed
  25715. */
  25716. isDisposed(): boolean;
  25717. private _disposeVertexArrayObjects;
  25718. /**
  25719. * Free all associated resources
  25720. */
  25721. dispose(): void;
  25722. /**
  25723. * Clone the current geometry into a new geometry
  25724. * @param id defines the unique ID of the new geometry
  25725. * @returns a new geometry object
  25726. */
  25727. copy(id: string): Geometry;
  25728. /**
  25729. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25730. * @return a JSON representation of the current geometry data (without the vertices data)
  25731. */
  25732. serialize(): any;
  25733. private toNumberArray;
  25734. /**
  25735. * Serialize all vertices data into a JSON oject
  25736. * @returns a JSON representation of the current geometry data
  25737. */
  25738. serializeVerticeData(): any;
  25739. /**
  25740. * Extracts a clone of a mesh geometry
  25741. * @param mesh defines the source mesh
  25742. * @param id defines the unique ID of the new geometry object
  25743. * @returns the new geometry object
  25744. */
  25745. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25746. /**
  25747. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25748. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25749. * Be aware Math.random() could cause collisions, but:
  25750. * "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"
  25751. * @returns a string containing a new GUID
  25752. */
  25753. static RandomId(): string;
  25754. /** @hidden */
  25755. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25756. private static _CleanMatricesWeights;
  25757. /**
  25758. * Create a new geometry from persisted data (Using .babylon file format)
  25759. * @param parsedVertexData defines the persisted data
  25760. * @param scene defines the hosting scene
  25761. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25762. * @returns the new geometry object
  25763. */
  25764. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25765. }
  25766. }
  25767. declare module BABYLON {
  25768. /**
  25769. * Define an interface for all classes that will get and set the data on vertices
  25770. */
  25771. export interface IGetSetVerticesData {
  25772. /**
  25773. * Gets a boolean indicating if specific vertex data is present
  25774. * @param kind defines the vertex data kind to use
  25775. * @returns true is data kind is present
  25776. */
  25777. isVerticesDataPresent(kind: string): boolean;
  25778. /**
  25779. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25780. * @param kind defines the data kind (Position, normal, etc...)
  25781. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25782. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25783. * @returns a float array containing vertex data
  25784. */
  25785. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25786. /**
  25787. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25788. * @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.
  25789. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25790. * @returns the indices array or an empty array if the mesh has no geometry
  25791. */
  25792. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25793. /**
  25794. * Set specific vertex data
  25795. * @param kind defines the data kind (Position, normal, etc...)
  25796. * @param data defines the vertex data to use
  25797. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25798. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25799. */
  25800. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25801. /**
  25802. * Update a specific associated vertex buffer
  25803. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25804. * - VertexBuffer.PositionKind
  25805. * - VertexBuffer.UVKind
  25806. * - VertexBuffer.UV2Kind
  25807. * - VertexBuffer.UV3Kind
  25808. * - VertexBuffer.UV4Kind
  25809. * - VertexBuffer.UV5Kind
  25810. * - VertexBuffer.UV6Kind
  25811. * - VertexBuffer.ColorKind
  25812. * - VertexBuffer.MatricesIndicesKind
  25813. * - VertexBuffer.MatricesIndicesExtraKind
  25814. * - VertexBuffer.MatricesWeightsKind
  25815. * - VertexBuffer.MatricesWeightsExtraKind
  25816. * @param data defines the data source
  25817. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25818. * @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)
  25819. */
  25820. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25821. /**
  25822. * Creates a new index buffer
  25823. * @param indices defines the indices to store in the index buffer
  25824. * @param totalVertices defines the total number of vertices (could be null)
  25825. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25826. */
  25827. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25828. }
  25829. /**
  25830. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25831. */
  25832. export class VertexData {
  25833. /**
  25834. * Mesh side orientation : usually the external or front surface
  25835. */
  25836. static readonly FRONTSIDE: number;
  25837. /**
  25838. * Mesh side orientation : usually the internal or back surface
  25839. */
  25840. static readonly BACKSIDE: number;
  25841. /**
  25842. * Mesh side orientation : both internal and external or front and back surfaces
  25843. */
  25844. static readonly DOUBLESIDE: number;
  25845. /**
  25846. * Mesh side orientation : by default, `FRONTSIDE`
  25847. */
  25848. static readonly DEFAULTSIDE: number;
  25849. /**
  25850. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25851. */
  25852. positions: Nullable<FloatArray>;
  25853. /**
  25854. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25855. */
  25856. normals: Nullable<FloatArray>;
  25857. /**
  25858. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25859. */
  25860. tangents: Nullable<FloatArray>;
  25861. /**
  25862. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25863. */
  25864. uvs: Nullable<FloatArray>;
  25865. /**
  25866. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25867. */
  25868. uvs2: Nullable<FloatArray>;
  25869. /**
  25870. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25871. */
  25872. uvs3: Nullable<FloatArray>;
  25873. /**
  25874. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25875. */
  25876. uvs4: Nullable<FloatArray>;
  25877. /**
  25878. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25879. */
  25880. uvs5: Nullable<FloatArray>;
  25881. /**
  25882. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25883. */
  25884. uvs6: Nullable<FloatArray>;
  25885. /**
  25886. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25887. */
  25888. colors: Nullable<FloatArray>;
  25889. /**
  25890. * 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).
  25891. */
  25892. matricesIndices: Nullable<FloatArray>;
  25893. /**
  25894. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25895. */
  25896. matricesWeights: Nullable<FloatArray>;
  25897. /**
  25898. * An array extending the number of possible indices
  25899. */
  25900. matricesIndicesExtra: Nullable<FloatArray>;
  25901. /**
  25902. * An array extending the number of possible weights when the number of indices is extended
  25903. */
  25904. matricesWeightsExtra: Nullable<FloatArray>;
  25905. /**
  25906. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25907. */
  25908. indices: Nullable<IndicesArray>;
  25909. /**
  25910. * Uses the passed data array to set the set the values for the specified kind of data
  25911. * @param data a linear array of floating numbers
  25912. * @param kind the type of data that is being set, eg positions, colors etc
  25913. */
  25914. set(data: FloatArray, kind: string): void;
  25915. /**
  25916. * Associates the vertexData to the passed Mesh.
  25917. * Sets it as updatable or not (default `false`)
  25918. * @param mesh the mesh the vertexData is applied to
  25919. * @param updatable when used and having the value true allows new data to update the vertexData
  25920. * @returns the VertexData
  25921. */
  25922. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25923. /**
  25924. * Associates the vertexData to the passed Geometry.
  25925. * Sets it as updatable or not (default `false`)
  25926. * @param geometry the geometry the vertexData is applied to
  25927. * @param updatable when used and having the value true allows new data to update the vertexData
  25928. * @returns VertexData
  25929. */
  25930. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25931. /**
  25932. * Updates the associated mesh
  25933. * @param mesh the mesh to be updated
  25934. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25935. * @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
  25936. * @returns VertexData
  25937. */
  25938. updateMesh(mesh: Mesh): VertexData;
  25939. /**
  25940. * Updates the associated geometry
  25941. * @param geometry the geometry to be updated
  25942. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25943. * @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
  25944. * @returns VertexData.
  25945. */
  25946. updateGeometry(geometry: Geometry): VertexData;
  25947. private _applyTo;
  25948. private _update;
  25949. /**
  25950. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25951. * @param matrix the transforming matrix
  25952. * @returns the VertexData
  25953. */
  25954. transform(matrix: Matrix): VertexData;
  25955. /**
  25956. * Merges the passed VertexData into the current one
  25957. * @param other the VertexData to be merged into the current one
  25958. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25959. * @returns the modified VertexData
  25960. */
  25961. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25962. private _mergeElement;
  25963. private _validate;
  25964. /**
  25965. * Serializes the VertexData
  25966. * @returns a serialized object
  25967. */
  25968. serialize(): any;
  25969. /**
  25970. * Extracts the vertexData from a mesh
  25971. * @param mesh the mesh from which to extract the VertexData
  25972. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25973. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25974. * @returns the object VertexData associated to the passed mesh
  25975. */
  25976. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25977. /**
  25978. * Extracts the vertexData from the geometry
  25979. * @param geometry the geometry from which to extract the VertexData
  25980. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25981. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25982. * @returns the object VertexData associated to the passed mesh
  25983. */
  25984. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25985. private static _ExtractFrom;
  25986. /**
  25987. * Creates the VertexData for a Ribbon
  25988. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25989. * * pathArray array of paths, each of which an array of successive Vector3
  25990. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25991. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25992. * * 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
  25993. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25994. * * 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)
  25995. * * 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)
  25996. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25997. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25998. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25999. * @returns the VertexData of the ribbon
  26000. */
  26001. static CreateRibbon(options: {
  26002. pathArray: Vector3[][];
  26003. closeArray?: boolean;
  26004. closePath?: boolean;
  26005. offset?: number;
  26006. sideOrientation?: number;
  26007. frontUVs?: Vector4;
  26008. backUVs?: Vector4;
  26009. invertUV?: boolean;
  26010. uvs?: Vector2[];
  26011. colors?: Color4[];
  26012. }): VertexData;
  26013. /**
  26014. * Creates the VertexData for a box
  26015. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26016. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26017. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26018. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26019. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26020. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26021. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26022. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26023. * * 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)
  26024. * * 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)
  26025. * @returns the VertexData of the box
  26026. */
  26027. static CreateBox(options: {
  26028. size?: number;
  26029. width?: number;
  26030. height?: number;
  26031. depth?: number;
  26032. faceUV?: Vector4[];
  26033. faceColors?: Color4[];
  26034. sideOrientation?: number;
  26035. frontUVs?: Vector4;
  26036. backUVs?: Vector4;
  26037. }): VertexData;
  26038. /**
  26039. * Creates the VertexData for a tiled box
  26040. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26041. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26042. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26043. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26044. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26045. * @returns the VertexData of the box
  26046. */
  26047. static CreateTiledBox(options: {
  26048. pattern?: number;
  26049. width?: number;
  26050. height?: number;
  26051. depth?: number;
  26052. tileSize?: number;
  26053. tileWidth?: number;
  26054. tileHeight?: number;
  26055. alignHorizontal?: number;
  26056. alignVertical?: number;
  26057. faceUV?: Vector4[];
  26058. faceColors?: Color4[];
  26059. sideOrientation?: number;
  26060. }): VertexData;
  26061. /**
  26062. * Creates the VertexData for a tiled plane
  26063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26064. * * pattern a limited pattern arrangement depending on the number
  26065. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26066. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26067. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26068. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26069. * * 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)
  26070. * * 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)
  26071. * @returns the VertexData of the tiled plane
  26072. */
  26073. static CreateTiledPlane(options: {
  26074. pattern?: number;
  26075. tileSize?: number;
  26076. tileWidth?: number;
  26077. tileHeight?: number;
  26078. size?: number;
  26079. width?: number;
  26080. height?: number;
  26081. alignHorizontal?: number;
  26082. alignVertical?: number;
  26083. sideOrientation?: number;
  26084. frontUVs?: Vector4;
  26085. backUVs?: Vector4;
  26086. }): VertexData;
  26087. /**
  26088. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26089. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26090. * * segments sets the number of horizontal strips optional, default 32
  26091. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26092. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26093. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26094. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26095. * * 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
  26096. * * 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
  26097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26098. * * 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)
  26099. * * 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)
  26100. * @returns the VertexData of the ellipsoid
  26101. */
  26102. static CreateSphere(options: {
  26103. segments?: number;
  26104. diameter?: number;
  26105. diameterX?: number;
  26106. diameterY?: number;
  26107. diameterZ?: number;
  26108. arc?: number;
  26109. slice?: number;
  26110. sideOrientation?: number;
  26111. frontUVs?: Vector4;
  26112. backUVs?: Vector4;
  26113. }): VertexData;
  26114. /**
  26115. * Creates the VertexData for a cylinder, cone or prism
  26116. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26117. * * height sets the height (y direction) of the cylinder, optional, default 2
  26118. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26119. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26120. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26121. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26122. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26123. * * 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
  26124. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26125. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26126. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26127. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26129. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26130. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26131. * @returns the VertexData of the cylinder, cone or prism
  26132. */
  26133. static CreateCylinder(options: {
  26134. height?: number;
  26135. diameterTop?: number;
  26136. diameterBottom?: number;
  26137. diameter?: number;
  26138. tessellation?: number;
  26139. subdivisions?: number;
  26140. arc?: number;
  26141. faceColors?: Color4[];
  26142. faceUV?: Vector4[];
  26143. hasRings?: boolean;
  26144. enclose?: boolean;
  26145. sideOrientation?: number;
  26146. frontUVs?: Vector4;
  26147. backUVs?: Vector4;
  26148. }): VertexData;
  26149. /**
  26150. * Creates the VertexData for a torus
  26151. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26152. * * diameter the diameter of the torus, optional default 1
  26153. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26154. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26156. * * 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)
  26157. * * 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)
  26158. * @returns the VertexData of the torus
  26159. */
  26160. static CreateTorus(options: {
  26161. diameter?: number;
  26162. thickness?: number;
  26163. tessellation?: number;
  26164. sideOrientation?: number;
  26165. frontUVs?: Vector4;
  26166. backUVs?: Vector4;
  26167. }): VertexData;
  26168. /**
  26169. * Creates the VertexData of the LineSystem
  26170. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26171. * - lines an array of lines, each line being an array of successive Vector3
  26172. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26173. * @returns the VertexData of the LineSystem
  26174. */
  26175. static CreateLineSystem(options: {
  26176. lines: Vector3[][];
  26177. colors?: Nullable<Color4[][]>;
  26178. }): VertexData;
  26179. /**
  26180. * Create the VertexData for a DashedLines
  26181. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26182. * - points an array successive Vector3
  26183. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26184. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26185. * - dashNb the intended total number of dashes, optional, default 200
  26186. * @returns the VertexData for the DashedLines
  26187. */
  26188. static CreateDashedLines(options: {
  26189. points: Vector3[];
  26190. dashSize?: number;
  26191. gapSize?: number;
  26192. dashNb?: number;
  26193. }): VertexData;
  26194. /**
  26195. * Creates the VertexData for a Ground
  26196. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26197. * - width the width (x direction) of the ground, optional, default 1
  26198. * - height the height (z direction) of the ground, optional, default 1
  26199. * - subdivisions the number of subdivisions per side, optional, default 1
  26200. * @returns the VertexData of the Ground
  26201. */
  26202. static CreateGround(options: {
  26203. width?: number;
  26204. height?: number;
  26205. subdivisions?: number;
  26206. subdivisionsX?: number;
  26207. subdivisionsY?: number;
  26208. }): VertexData;
  26209. /**
  26210. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26211. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26212. * * xmin the ground minimum X coordinate, optional, default -1
  26213. * * zmin the ground minimum Z coordinate, optional, default -1
  26214. * * xmax the ground maximum X coordinate, optional, default 1
  26215. * * zmax the ground maximum Z coordinate, optional, default 1
  26216. * * 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}
  26217. * * 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}
  26218. * @returns the VertexData of the TiledGround
  26219. */
  26220. static CreateTiledGround(options: {
  26221. xmin: number;
  26222. zmin: number;
  26223. xmax: number;
  26224. zmax: number;
  26225. subdivisions?: {
  26226. w: number;
  26227. h: number;
  26228. };
  26229. precision?: {
  26230. w: number;
  26231. h: number;
  26232. };
  26233. }): VertexData;
  26234. /**
  26235. * Creates the VertexData of the Ground designed from a heightmap
  26236. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26237. * * width the width (x direction) of the ground
  26238. * * height the height (z direction) of the ground
  26239. * * subdivisions the number of subdivisions per side
  26240. * * minHeight the minimum altitude on the ground, optional, default 0
  26241. * * maxHeight the maximum altitude on the ground, optional default 1
  26242. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26243. * * buffer the array holding the image color data
  26244. * * bufferWidth the width of image
  26245. * * bufferHeight the height of image
  26246. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26247. * @returns the VertexData of the Ground designed from a heightmap
  26248. */
  26249. static CreateGroundFromHeightMap(options: {
  26250. width: number;
  26251. height: number;
  26252. subdivisions: number;
  26253. minHeight: number;
  26254. maxHeight: number;
  26255. colorFilter: Color3;
  26256. buffer: Uint8Array;
  26257. bufferWidth: number;
  26258. bufferHeight: number;
  26259. alphaFilter: number;
  26260. }): VertexData;
  26261. /**
  26262. * Creates the VertexData for a Plane
  26263. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26264. * * size sets the width and height of the plane to the value of size, optional default 1
  26265. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26266. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  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 box
  26271. */
  26272. static CreatePlane(options: {
  26273. size?: number;
  26274. width?: number;
  26275. height?: number;
  26276. sideOrientation?: number;
  26277. frontUVs?: Vector4;
  26278. backUVs?: Vector4;
  26279. }): VertexData;
  26280. /**
  26281. * Creates the VertexData of the Disc or regular Polygon
  26282. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26283. * * radius the radius of the disc, optional default 0.5
  26284. * * tessellation the number of polygon sides, optional, default 64
  26285. * * 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
  26286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26287. * * 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)
  26288. * * 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)
  26289. * @returns the VertexData of the box
  26290. */
  26291. static CreateDisc(options: {
  26292. radius?: number;
  26293. tessellation?: number;
  26294. arc?: number;
  26295. sideOrientation?: number;
  26296. frontUVs?: Vector4;
  26297. backUVs?: Vector4;
  26298. }): VertexData;
  26299. /**
  26300. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26301. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26302. * @param polygon a mesh built from polygonTriangulation.build()
  26303. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26304. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26305. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26306. * @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)
  26307. * @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)
  26308. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26309. * @returns the VertexData of the Polygon
  26310. */
  26311. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26312. /**
  26313. * Creates the VertexData of the IcoSphere
  26314. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26315. * * radius the radius of the IcoSphere, optional default 1
  26316. * * radiusX allows stretching in the x direction, optional, default radius
  26317. * * radiusY allows stretching in the y direction, optional, default radius
  26318. * * radiusZ allows stretching in the z direction, optional, default radius
  26319. * * flat when true creates a flat shaded mesh, optional, default true
  26320. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26322. * * 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)
  26323. * * 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)
  26324. * @returns the VertexData of the IcoSphere
  26325. */
  26326. static CreateIcoSphere(options: {
  26327. radius?: number;
  26328. radiusX?: number;
  26329. radiusY?: number;
  26330. radiusZ?: number;
  26331. flat?: boolean;
  26332. subdivisions?: number;
  26333. sideOrientation?: number;
  26334. frontUVs?: Vector4;
  26335. backUVs?: Vector4;
  26336. }): VertexData;
  26337. /**
  26338. * Creates the VertexData for a Polyhedron
  26339. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26340. * * type provided types are:
  26341. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26342. * * 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)
  26343. * * size the size of the IcoSphere, optional default 1
  26344. * * sizeX allows stretching in the x direction, optional, default size
  26345. * * sizeY allows stretching in the y direction, optional, default size
  26346. * * sizeZ allows stretching in the z direction, optional, default size
  26347. * * 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
  26348. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26349. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26350. * * flat when true creates a flat shaded mesh, optional, default true
  26351. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26352. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26353. * * 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)
  26354. * * 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)
  26355. * @returns the VertexData of the Polyhedron
  26356. */
  26357. static CreatePolyhedron(options: {
  26358. type?: number;
  26359. size?: number;
  26360. sizeX?: number;
  26361. sizeY?: number;
  26362. sizeZ?: number;
  26363. custom?: any;
  26364. faceUV?: Vector4[];
  26365. faceColors?: Color4[];
  26366. flat?: boolean;
  26367. sideOrientation?: number;
  26368. frontUVs?: Vector4;
  26369. backUVs?: Vector4;
  26370. }): VertexData;
  26371. /**
  26372. * Creates the VertexData for a TorusKnot
  26373. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26374. * * radius the radius of the torus knot, optional, default 2
  26375. * * tube the thickness of the tube, optional, default 0.5
  26376. * * radialSegments the number of sides on each tube segments, optional, default 32
  26377. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26378. * * p the number of windings around the z axis, optional, default 2
  26379. * * q the number of windings around the x axis, optional, default 3
  26380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26381. * * 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)
  26382. * * 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)
  26383. * @returns the VertexData of the Torus Knot
  26384. */
  26385. static CreateTorusKnot(options: {
  26386. radius?: number;
  26387. tube?: number;
  26388. radialSegments?: number;
  26389. tubularSegments?: number;
  26390. p?: number;
  26391. q?: number;
  26392. sideOrientation?: number;
  26393. frontUVs?: Vector4;
  26394. backUVs?: Vector4;
  26395. }): VertexData;
  26396. /**
  26397. * Compute normals for given positions and indices
  26398. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26399. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26400. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26401. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26402. * * facetNormals : optional array of facet normals (vector3)
  26403. * * facetPositions : optional array of facet positions (vector3)
  26404. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26405. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26406. * * bInfo : optional bounding info, required for facetPartitioning computation
  26407. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26408. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26409. * * useRightHandedSystem: optional boolean to for right handed system computation
  26410. * * depthSort : optional boolean to enable the facet depth sort computation
  26411. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26412. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26413. */
  26414. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26415. facetNormals?: any;
  26416. facetPositions?: any;
  26417. facetPartitioning?: any;
  26418. ratio?: number;
  26419. bInfo?: any;
  26420. bbSize?: Vector3;
  26421. subDiv?: any;
  26422. useRightHandedSystem?: boolean;
  26423. depthSort?: boolean;
  26424. distanceTo?: Vector3;
  26425. depthSortedFacets?: any;
  26426. }): void;
  26427. /** @hidden */
  26428. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26429. /**
  26430. * Applies VertexData created from the imported parameters to the geometry
  26431. * @param parsedVertexData the parsed data from an imported file
  26432. * @param geometry the geometry to apply the VertexData to
  26433. */
  26434. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26435. }
  26436. }
  26437. declare module BABYLON {
  26438. /**
  26439. * Defines a target to use with MorphTargetManager
  26440. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26441. */
  26442. export class MorphTarget implements IAnimatable {
  26443. /** defines the name of the target */
  26444. name: string;
  26445. /**
  26446. * Gets or sets the list of animations
  26447. */
  26448. animations: Animation[];
  26449. private _scene;
  26450. private _positions;
  26451. private _normals;
  26452. private _tangents;
  26453. private _uvs;
  26454. private _influence;
  26455. private _uniqueId;
  26456. /**
  26457. * Observable raised when the influence changes
  26458. */
  26459. onInfluenceChanged: Observable<boolean>;
  26460. /** @hidden */
  26461. _onDataLayoutChanged: Observable<void>;
  26462. /**
  26463. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26464. */
  26465. get influence(): number;
  26466. set influence(influence: number);
  26467. /**
  26468. * Gets or sets the id of the morph Target
  26469. */
  26470. id: string;
  26471. private _animationPropertiesOverride;
  26472. /**
  26473. * Gets or sets the animation properties override
  26474. */
  26475. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26476. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26477. /**
  26478. * Creates a new MorphTarget
  26479. * @param name defines the name of the target
  26480. * @param influence defines the influence to use
  26481. * @param scene defines the scene the morphtarget belongs to
  26482. */
  26483. constructor(
  26484. /** defines the name of the target */
  26485. name: string, influence?: number, scene?: Nullable<Scene>);
  26486. /**
  26487. * Gets the unique ID of this manager
  26488. */
  26489. get uniqueId(): number;
  26490. /**
  26491. * Gets a boolean defining if the target contains position data
  26492. */
  26493. get hasPositions(): boolean;
  26494. /**
  26495. * Gets a boolean defining if the target contains normal data
  26496. */
  26497. get hasNormals(): boolean;
  26498. /**
  26499. * Gets a boolean defining if the target contains tangent data
  26500. */
  26501. get hasTangents(): boolean;
  26502. /**
  26503. * Gets a boolean defining if the target contains texture coordinates data
  26504. */
  26505. get hasUVs(): boolean;
  26506. /**
  26507. * Affects position data to this target
  26508. * @param data defines the position data to use
  26509. */
  26510. setPositions(data: Nullable<FloatArray>): void;
  26511. /**
  26512. * Gets the position data stored in this target
  26513. * @returns a FloatArray containing the position data (or null if not present)
  26514. */
  26515. getPositions(): Nullable<FloatArray>;
  26516. /**
  26517. * Affects normal data to this target
  26518. * @param data defines the normal data to use
  26519. */
  26520. setNormals(data: Nullable<FloatArray>): void;
  26521. /**
  26522. * Gets the normal data stored in this target
  26523. * @returns a FloatArray containing the normal data (or null if not present)
  26524. */
  26525. getNormals(): Nullable<FloatArray>;
  26526. /**
  26527. * Affects tangent data to this target
  26528. * @param data defines the tangent data to use
  26529. */
  26530. setTangents(data: Nullable<FloatArray>): void;
  26531. /**
  26532. * Gets the tangent data stored in this target
  26533. * @returns a FloatArray containing the tangent data (or null if not present)
  26534. */
  26535. getTangents(): Nullable<FloatArray>;
  26536. /**
  26537. * Affects texture coordinates data to this target
  26538. * @param data defines the texture coordinates data to use
  26539. */
  26540. setUVs(data: Nullable<FloatArray>): void;
  26541. /**
  26542. * Gets the texture coordinates data stored in this target
  26543. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26544. */
  26545. getUVs(): Nullable<FloatArray>;
  26546. /**
  26547. * Clone the current target
  26548. * @returns a new MorphTarget
  26549. */
  26550. clone(): MorphTarget;
  26551. /**
  26552. * Serializes the current target into a Serialization object
  26553. * @returns the serialized object
  26554. */
  26555. serialize(): any;
  26556. /**
  26557. * Returns the string "MorphTarget"
  26558. * @returns "MorphTarget"
  26559. */
  26560. getClassName(): string;
  26561. /**
  26562. * Creates a new target from serialized data
  26563. * @param serializationObject defines the serialized data to use
  26564. * @returns a new MorphTarget
  26565. */
  26566. static Parse(serializationObject: any): MorphTarget;
  26567. /**
  26568. * Creates a MorphTarget from mesh data
  26569. * @param mesh defines the source mesh
  26570. * @param name defines the name to use for the new target
  26571. * @param influence defines the influence to attach to the target
  26572. * @returns a new MorphTarget
  26573. */
  26574. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26575. }
  26576. }
  26577. declare module BABYLON {
  26578. /**
  26579. * This class is used to deform meshes using morphing between different targets
  26580. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26581. */
  26582. export class MorphTargetManager {
  26583. private _targets;
  26584. private _targetInfluenceChangedObservers;
  26585. private _targetDataLayoutChangedObservers;
  26586. private _activeTargets;
  26587. private _scene;
  26588. private _influences;
  26589. private _supportsNormals;
  26590. private _supportsTangents;
  26591. private _supportsUVs;
  26592. private _vertexCount;
  26593. private _uniqueId;
  26594. private _tempInfluences;
  26595. /**
  26596. * Gets or sets a boolean indicating if normals must be morphed
  26597. */
  26598. enableNormalMorphing: boolean;
  26599. /**
  26600. * Gets or sets a boolean indicating if tangents must be morphed
  26601. */
  26602. enableTangentMorphing: boolean;
  26603. /**
  26604. * Gets or sets a boolean indicating if UV must be morphed
  26605. */
  26606. enableUVMorphing: boolean;
  26607. /**
  26608. * Creates a new MorphTargetManager
  26609. * @param scene defines the current scene
  26610. */
  26611. constructor(scene?: Nullable<Scene>);
  26612. /**
  26613. * Gets the unique ID of this manager
  26614. */
  26615. get uniqueId(): number;
  26616. /**
  26617. * Gets the number of vertices handled by this manager
  26618. */
  26619. get vertexCount(): number;
  26620. /**
  26621. * Gets a boolean indicating if this manager supports morphing of normals
  26622. */
  26623. get supportsNormals(): boolean;
  26624. /**
  26625. * Gets a boolean indicating if this manager supports morphing of tangents
  26626. */
  26627. get supportsTangents(): boolean;
  26628. /**
  26629. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26630. */
  26631. get supportsUVs(): boolean;
  26632. /**
  26633. * Gets the number of targets stored in this manager
  26634. */
  26635. get numTargets(): number;
  26636. /**
  26637. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26638. */
  26639. get numInfluencers(): number;
  26640. /**
  26641. * Gets the list of influences (one per target)
  26642. */
  26643. get influences(): Float32Array;
  26644. /**
  26645. * Gets the active target at specified index. An active target is a target with an influence > 0
  26646. * @param index defines the index to check
  26647. * @returns the requested target
  26648. */
  26649. getActiveTarget(index: number): MorphTarget;
  26650. /**
  26651. * Gets the target at specified index
  26652. * @param index defines the index to check
  26653. * @returns the requested target
  26654. */
  26655. getTarget(index: number): MorphTarget;
  26656. /**
  26657. * Add a new target to this manager
  26658. * @param target defines the target to add
  26659. */
  26660. addTarget(target: MorphTarget): void;
  26661. /**
  26662. * Removes a target from the manager
  26663. * @param target defines the target to remove
  26664. */
  26665. removeTarget(target: MorphTarget): void;
  26666. /**
  26667. * Clone the current manager
  26668. * @returns a new MorphTargetManager
  26669. */
  26670. clone(): MorphTargetManager;
  26671. /**
  26672. * Serializes the current manager into a Serialization object
  26673. * @returns the serialized object
  26674. */
  26675. serialize(): any;
  26676. private _syncActiveTargets;
  26677. /**
  26678. * Syncrhonize the targets with all the meshes using this morph target manager
  26679. */
  26680. synchronize(): void;
  26681. /**
  26682. * Creates a new MorphTargetManager from serialized data
  26683. * @param serializationObject defines the serialized data
  26684. * @param scene defines the hosting scene
  26685. * @returns the new MorphTargetManager
  26686. */
  26687. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26688. }
  26689. }
  26690. declare module BABYLON {
  26691. /**
  26692. * Class used to represent a specific level of detail of a mesh
  26693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26694. */
  26695. export class MeshLODLevel {
  26696. /** Defines the distance where this level should start being displayed */
  26697. distance: number;
  26698. /** Defines the mesh to use to render this level */
  26699. mesh: Nullable<Mesh>;
  26700. /**
  26701. * Creates a new LOD level
  26702. * @param distance defines the distance where this level should star being displayed
  26703. * @param mesh defines the mesh to use to render this level
  26704. */
  26705. constructor(
  26706. /** Defines the distance where this level should start being displayed */
  26707. distance: number,
  26708. /** Defines the mesh to use to render this level */
  26709. mesh: Nullable<Mesh>);
  26710. }
  26711. }
  26712. declare module BABYLON {
  26713. /**
  26714. * Helper class used to generate a canvas to manipulate images
  26715. */
  26716. export class CanvasGenerator {
  26717. /**
  26718. * Create a new canvas (or offscreen canvas depending on the context)
  26719. * @param width defines the expected width
  26720. * @param height defines the expected height
  26721. * @return a new canvas or offscreen canvas
  26722. */
  26723. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26724. }
  26725. }
  26726. declare module BABYLON {
  26727. /**
  26728. * Mesh representing the gorund
  26729. */
  26730. export class GroundMesh extends Mesh {
  26731. /** If octree should be generated */
  26732. generateOctree: boolean;
  26733. private _heightQuads;
  26734. /** @hidden */
  26735. _subdivisionsX: number;
  26736. /** @hidden */
  26737. _subdivisionsY: number;
  26738. /** @hidden */
  26739. _width: number;
  26740. /** @hidden */
  26741. _height: number;
  26742. /** @hidden */
  26743. _minX: number;
  26744. /** @hidden */
  26745. _maxX: number;
  26746. /** @hidden */
  26747. _minZ: number;
  26748. /** @hidden */
  26749. _maxZ: number;
  26750. constructor(name: string, scene: Scene);
  26751. /**
  26752. * "GroundMesh"
  26753. * @returns "GroundMesh"
  26754. */
  26755. getClassName(): string;
  26756. /**
  26757. * The minimum of x and y subdivisions
  26758. */
  26759. get subdivisions(): number;
  26760. /**
  26761. * X subdivisions
  26762. */
  26763. get subdivisionsX(): number;
  26764. /**
  26765. * Y subdivisions
  26766. */
  26767. get subdivisionsY(): number;
  26768. /**
  26769. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26770. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26771. * @param chunksCount the number of subdivisions for x and y
  26772. * @param octreeBlocksSize (Default: 32)
  26773. */
  26774. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26775. /**
  26776. * Returns a height (y) value in the Worl system :
  26777. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26778. * @param x x coordinate
  26779. * @param z z coordinate
  26780. * @returns the ground y position if (x, z) are outside the ground surface.
  26781. */
  26782. getHeightAtCoordinates(x: number, z: number): number;
  26783. /**
  26784. * Returns a normalized vector (Vector3) orthogonal to the ground
  26785. * at the ground coordinates (x, z) expressed in the World system.
  26786. * @param x x coordinate
  26787. * @param z z coordinate
  26788. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26789. */
  26790. getNormalAtCoordinates(x: number, z: number): Vector3;
  26791. /**
  26792. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26793. * at the ground coordinates (x, z) expressed in the World system.
  26794. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26795. * @param x x coordinate
  26796. * @param z z coordinate
  26797. * @param ref vector to store the result
  26798. * @returns the GroundMesh.
  26799. */
  26800. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26801. /**
  26802. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26803. * if the ground has been updated.
  26804. * This can be used in the render loop.
  26805. * @returns the GroundMesh.
  26806. */
  26807. updateCoordinateHeights(): GroundMesh;
  26808. private _getFacetAt;
  26809. private _initHeightQuads;
  26810. private _computeHeightQuads;
  26811. /**
  26812. * Serializes this ground mesh
  26813. * @param serializationObject object to write serialization to
  26814. */
  26815. serialize(serializationObject: any): void;
  26816. /**
  26817. * Parses a serialized ground mesh
  26818. * @param parsedMesh the serialized mesh
  26819. * @param scene the scene to create the ground mesh in
  26820. * @returns the created ground mesh
  26821. */
  26822. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26823. }
  26824. }
  26825. declare module BABYLON {
  26826. /**
  26827. * Interface for Physics-Joint data
  26828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26829. */
  26830. export interface PhysicsJointData {
  26831. /**
  26832. * The main pivot of the joint
  26833. */
  26834. mainPivot?: Vector3;
  26835. /**
  26836. * The connected pivot of the joint
  26837. */
  26838. connectedPivot?: Vector3;
  26839. /**
  26840. * The main axis of the joint
  26841. */
  26842. mainAxis?: Vector3;
  26843. /**
  26844. * The connected axis of the joint
  26845. */
  26846. connectedAxis?: Vector3;
  26847. /**
  26848. * The collision of the joint
  26849. */
  26850. collision?: boolean;
  26851. /**
  26852. * Native Oimo/Cannon/Energy data
  26853. */
  26854. nativeParams?: any;
  26855. }
  26856. /**
  26857. * This is a holder class for the physics joint created by the physics plugin
  26858. * It holds a set of functions to control the underlying joint
  26859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26860. */
  26861. export class PhysicsJoint {
  26862. /**
  26863. * The type of the physics joint
  26864. */
  26865. type: number;
  26866. /**
  26867. * The data for the physics joint
  26868. */
  26869. jointData: PhysicsJointData;
  26870. private _physicsJoint;
  26871. protected _physicsPlugin: IPhysicsEnginePlugin;
  26872. /**
  26873. * Initializes the physics joint
  26874. * @param type The type of the physics joint
  26875. * @param jointData The data for the physics joint
  26876. */
  26877. constructor(
  26878. /**
  26879. * The type of the physics joint
  26880. */
  26881. type: number,
  26882. /**
  26883. * The data for the physics joint
  26884. */
  26885. jointData: PhysicsJointData);
  26886. /**
  26887. * Gets the physics joint
  26888. */
  26889. get physicsJoint(): any;
  26890. /**
  26891. * Sets the physics joint
  26892. */
  26893. set physicsJoint(newJoint: any);
  26894. /**
  26895. * Sets the physics plugin
  26896. */
  26897. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26898. /**
  26899. * Execute a function that is physics-plugin specific.
  26900. * @param {Function} func the function that will be executed.
  26901. * It accepts two parameters: the physics world and the physics joint
  26902. */
  26903. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26904. /**
  26905. * Distance-Joint type
  26906. */
  26907. static DistanceJoint: number;
  26908. /**
  26909. * Hinge-Joint type
  26910. */
  26911. static HingeJoint: number;
  26912. /**
  26913. * Ball-and-Socket joint type
  26914. */
  26915. static BallAndSocketJoint: number;
  26916. /**
  26917. * Wheel-Joint type
  26918. */
  26919. static WheelJoint: number;
  26920. /**
  26921. * Slider-Joint type
  26922. */
  26923. static SliderJoint: number;
  26924. /**
  26925. * Prismatic-Joint type
  26926. */
  26927. static PrismaticJoint: number;
  26928. /**
  26929. * Universal-Joint type
  26930. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26931. */
  26932. static UniversalJoint: number;
  26933. /**
  26934. * Hinge-Joint 2 type
  26935. */
  26936. static Hinge2Joint: number;
  26937. /**
  26938. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26939. */
  26940. static PointToPointJoint: number;
  26941. /**
  26942. * Spring-Joint type
  26943. */
  26944. static SpringJoint: number;
  26945. /**
  26946. * Lock-Joint type
  26947. */
  26948. static LockJoint: number;
  26949. }
  26950. /**
  26951. * A class representing a physics distance joint
  26952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26953. */
  26954. export class DistanceJoint extends PhysicsJoint {
  26955. /**
  26956. *
  26957. * @param jointData The data for the Distance-Joint
  26958. */
  26959. constructor(jointData: DistanceJointData);
  26960. /**
  26961. * Update the predefined distance.
  26962. * @param maxDistance The maximum preferred distance
  26963. * @param minDistance The minimum preferred distance
  26964. */
  26965. updateDistance(maxDistance: number, minDistance?: number): void;
  26966. }
  26967. /**
  26968. * Represents a Motor-Enabled Joint
  26969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26970. */
  26971. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26972. /**
  26973. * Initializes the Motor-Enabled Joint
  26974. * @param type The type of the joint
  26975. * @param jointData The physica joint data for the joint
  26976. */
  26977. constructor(type: number, jointData: PhysicsJointData);
  26978. /**
  26979. * Set the motor values.
  26980. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26981. * @param force the force to apply
  26982. * @param maxForce max force for this motor.
  26983. */
  26984. setMotor(force?: number, maxForce?: number): void;
  26985. /**
  26986. * Set the motor's limits.
  26987. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26988. * @param upperLimit The upper limit of the motor
  26989. * @param lowerLimit The lower limit of the motor
  26990. */
  26991. setLimit(upperLimit: number, lowerLimit?: number): void;
  26992. }
  26993. /**
  26994. * This class represents a single physics Hinge-Joint
  26995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26996. */
  26997. export class HingeJoint extends MotorEnabledJoint {
  26998. /**
  26999. * Initializes the Hinge-Joint
  27000. * @param jointData The joint data for the Hinge-Joint
  27001. */
  27002. constructor(jointData: PhysicsJointData);
  27003. /**
  27004. * Set the motor values.
  27005. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27006. * @param {number} force the force to apply
  27007. * @param {number} maxForce max force for this motor.
  27008. */
  27009. setMotor(force?: number, maxForce?: number): void;
  27010. /**
  27011. * Set the motor's limits.
  27012. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27013. * @param upperLimit The upper limit of the motor
  27014. * @param lowerLimit The lower limit of the motor
  27015. */
  27016. setLimit(upperLimit: number, lowerLimit?: number): void;
  27017. }
  27018. /**
  27019. * This class represents a dual hinge physics joint (same as wheel joint)
  27020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27021. */
  27022. export class Hinge2Joint extends MotorEnabledJoint {
  27023. /**
  27024. * Initializes the Hinge2-Joint
  27025. * @param jointData The joint data for the Hinge2-Joint
  27026. */
  27027. constructor(jointData: PhysicsJointData);
  27028. /**
  27029. * Set the motor values.
  27030. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27031. * @param {number} targetSpeed the speed the motor is to reach
  27032. * @param {number} maxForce max force for this motor.
  27033. * @param {motorIndex} the motor's index, 0 or 1.
  27034. */
  27035. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27036. /**
  27037. * Set the motor limits.
  27038. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27039. * @param {number} upperLimit the upper limit
  27040. * @param {number} lowerLimit lower limit
  27041. * @param {motorIndex} the motor's index, 0 or 1.
  27042. */
  27043. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27044. }
  27045. /**
  27046. * Interface for a motor enabled joint
  27047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27048. */
  27049. export interface IMotorEnabledJoint {
  27050. /**
  27051. * Physics joint
  27052. */
  27053. physicsJoint: any;
  27054. /**
  27055. * Sets the motor of the motor-enabled joint
  27056. * @param force The force of the motor
  27057. * @param maxForce The maximum force of the motor
  27058. * @param motorIndex The index of the motor
  27059. */
  27060. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27061. /**
  27062. * Sets the limit of the motor
  27063. * @param upperLimit The upper limit of the motor
  27064. * @param lowerLimit The lower limit of the motor
  27065. * @param motorIndex The index of the motor
  27066. */
  27067. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27068. }
  27069. /**
  27070. * Joint data for a Distance-Joint
  27071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27072. */
  27073. export interface DistanceJointData extends PhysicsJointData {
  27074. /**
  27075. * Max distance the 2 joint objects can be apart
  27076. */
  27077. maxDistance: number;
  27078. }
  27079. /**
  27080. * Joint data from a spring joint
  27081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27082. */
  27083. export interface SpringJointData extends PhysicsJointData {
  27084. /**
  27085. * Length of the spring
  27086. */
  27087. length: number;
  27088. /**
  27089. * Stiffness of the spring
  27090. */
  27091. stiffness: number;
  27092. /**
  27093. * Damping of the spring
  27094. */
  27095. damping: number;
  27096. /** this callback will be called when applying the force to the impostors. */
  27097. forceApplicationCallback: () => void;
  27098. }
  27099. }
  27100. declare module BABYLON {
  27101. /**
  27102. * Holds the data for the raycast result
  27103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27104. */
  27105. export class PhysicsRaycastResult {
  27106. private _hasHit;
  27107. private _hitDistance;
  27108. private _hitNormalWorld;
  27109. private _hitPointWorld;
  27110. private _rayFromWorld;
  27111. private _rayToWorld;
  27112. /**
  27113. * Gets if there was a hit
  27114. */
  27115. get hasHit(): boolean;
  27116. /**
  27117. * Gets the distance from the hit
  27118. */
  27119. get hitDistance(): number;
  27120. /**
  27121. * Gets the hit normal/direction in the world
  27122. */
  27123. get hitNormalWorld(): Vector3;
  27124. /**
  27125. * Gets the hit point in the world
  27126. */
  27127. get hitPointWorld(): Vector3;
  27128. /**
  27129. * Gets the ray "start point" of the ray in the world
  27130. */
  27131. get rayFromWorld(): Vector3;
  27132. /**
  27133. * Gets the ray "end point" of the ray in the world
  27134. */
  27135. get rayToWorld(): Vector3;
  27136. /**
  27137. * Sets the hit data (normal & point in world space)
  27138. * @param hitNormalWorld defines the normal in world space
  27139. * @param hitPointWorld defines the point in world space
  27140. */
  27141. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27142. /**
  27143. * Sets the distance from the start point to the hit point
  27144. * @param distance
  27145. */
  27146. setHitDistance(distance: number): void;
  27147. /**
  27148. * Calculates the distance manually
  27149. */
  27150. calculateHitDistance(): void;
  27151. /**
  27152. * Resets all the values to default
  27153. * @param from The from point on world space
  27154. * @param to The to point on world space
  27155. */
  27156. reset(from?: Vector3, to?: Vector3): void;
  27157. }
  27158. /**
  27159. * Interface for the size containing width and height
  27160. */
  27161. interface IXYZ {
  27162. /**
  27163. * X
  27164. */
  27165. x: number;
  27166. /**
  27167. * Y
  27168. */
  27169. y: number;
  27170. /**
  27171. * Z
  27172. */
  27173. z: number;
  27174. }
  27175. }
  27176. declare module BABYLON {
  27177. /**
  27178. * Interface used to describe a physics joint
  27179. */
  27180. export interface PhysicsImpostorJoint {
  27181. /** Defines the main impostor to which the joint is linked */
  27182. mainImpostor: PhysicsImpostor;
  27183. /** Defines the impostor that is connected to the main impostor using this joint */
  27184. connectedImpostor: PhysicsImpostor;
  27185. /** Defines the joint itself */
  27186. joint: PhysicsJoint;
  27187. }
  27188. /** @hidden */
  27189. export interface IPhysicsEnginePlugin {
  27190. world: any;
  27191. name: string;
  27192. setGravity(gravity: Vector3): void;
  27193. setTimeStep(timeStep: number): void;
  27194. getTimeStep(): number;
  27195. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27196. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27197. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27198. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27199. removePhysicsBody(impostor: PhysicsImpostor): void;
  27200. generateJoint(joint: PhysicsImpostorJoint): void;
  27201. removeJoint(joint: PhysicsImpostorJoint): void;
  27202. isSupported(): boolean;
  27203. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27204. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27205. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27206. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27207. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27208. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27209. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27210. getBodyMass(impostor: PhysicsImpostor): number;
  27211. getBodyFriction(impostor: PhysicsImpostor): number;
  27212. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27213. getBodyRestitution(impostor: PhysicsImpostor): number;
  27214. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27215. getBodyPressure?(impostor: PhysicsImpostor): number;
  27216. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27217. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27218. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27219. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27220. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27221. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27222. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27223. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27224. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27225. sleepBody(impostor: PhysicsImpostor): void;
  27226. wakeUpBody(impostor: PhysicsImpostor): void;
  27227. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27228. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27229. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27230. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27231. getRadius(impostor: PhysicsImpostor): number;
  27232. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27233. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27234. dispose(): void;
  27235. }
  27236. /**
  27237. * Interface used to define a physics engine
  27238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27239. */
  27240. export interface IPhysicsEngine {
  27241. /**
  27242. * Gets the gravity vector used by the simulation
  27243. */
  27244. gravity: Vector3;
  27245. /**
  27246. * Sets the gravity vector used by the simulation
  27247. * @param gravity defines the gravity vector to use
  27248. */
  27249. setGravity(gravity: Vector3): void;
  27250. /**
  27251. * Set the time step of the physics engine.
  27252. * Default is 1/60.
  27253. * To slow it down, enter 1/600 for example.
  27254. * To speed it up, 1/30
  27255. * @param newTimeStep the new timestep to apply to this world.
  27256. */
  27257. setTimeStep(newTimeStep: number): void;
  27258. /**
  27259. * Get the time step of the physics engine.
  27260. * @returns the current time step
  27261. */
  27262. getTimeStep(): number;
  27263. /**
  27264. * Set the sub time step of the physics engine.
  27265. * Default is 0 meaning there is no sub steps
  27266. * To increase physics resolution precision, set a small value (like 1 ms)
  27267. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27268. */
  27269. setSubTimeStep(subTimeStep: number): void;
  27270. /**
  27271. * Get the sub time step of the physics engine.
  27272. * @returns the current sub time step
  27273. */
  27274. getSubTimeStep(): number;
  27275. /**
  27276. * Release all resources
  27277. */
  27278. dispose(): void;
  27279. /**
  27280. * Gets the name of the current physics plugin
  27281. * @returns the name of the plugin
  27282. */
  27283. getPhysicsPluginName(): string;
  27284. /**
  27285. * Adding a new impostor for the impostor tracking.
  27286. * This will be done by the impostor itself.
  27287. * @param impostor the impostor to add
  27288. */
  27289. addImpostor(impostor: PhysicsImpostor): void;
  27290. /**
  27291. * Remove an impostor from the engine.
  27292. * This impostor and its mesh will not longer be updated by the physics engine.
  27293. * @param impostor the impostor to remove
  27294. */
  27295. removeImpostor(impostor: PhysicsImpostor): void;
  27296. /**
  27297. * Add a joint to the physics engine
  27298. * @param mainImpostor defines the main impostor to which the joint is added.
  27299. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27300. * @param joint defines the joint that will connect both impostors.
  27301. */
  27302. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27303. /**
  27304. * Removes a joint from the simulation
  27305. * @param mainImpostor defines the impostor used with the joint
  27306. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27307. * @param joint defines the joint to remove
  27308. */
  27309. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27310. /**
  27311. * Gets the current plugin used to run the simulation
  27312. * @returns current plugin
  27313. */
  27314. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27315. /**
  27316. * Gets the list of physic impostors
  27317. * @returns an array of PhysicsImpostor
  27318. */
  27319. getImpostors(): Array<PhysicsImpostor>;
  27320. /**
  27321. * Gets the impostor for a physics enabled object
  27322. * @param object defines the object impersonated by the impostor
  27323. * @returns the PhysicsImpostor or null if not found
  27324. */
  27325. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27326. /**
  27327. * Gets the impostor for a physics body object
  27328. * @param body defines physics body used by the impostor
  27329. * @returns the PhysicsImpostor or null if not found
  27330. */
  27331. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27332. /**
  27333. * Does a raycast in the physics world
  27334. * @param from when should the ray start?
  27335. * @param to when should the ray end?
  27336. * @returns PhysicsRaycastResult
  27337. */
  27338. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27339. /**
  27340. * Called by the scene. No need to call it.
  27341. * @param delta defines the timespam between frames
  27342. */
  27343. _step(delta: number): void;
  27344. }
  27345. }
  27346. declare module BABYLON {
  27347. /**
  27348. * The interface for the physics imposter parameters
  27349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27350. */
  27351. export interface PhysicsImpostorParameters {
  27352. /**
  27353. * The mass of the physics imposter
  27354. */
  27355. mass: number;
  27356. /**
  27357. * The friction of the physics imposter
  27358. */
  27359. friction?: number;
  27360. /**
  27361. * The coefficient of restitution of the physics imposter
  27362. */
  27363. restitution?: number;
  27364. /**
  27365. * The native options of the physics imposter
  27366. */
  27367. nativeOptions?: any;
  27368. /**
  27369. * Specifies if the parent should be ignored
  27370. */
  27371. ignoreParent?: boolean;
  27372. /**
  27373. * Specifies if bi-directional transformations should be disabled
  27374. */
  27375. disableBidirectionalTransformation?: boolean;
  27376. /**
  27377. * The pressure inside the physics imposter, soft object only
  27378. */
  27379. pressure?: number;
  27380. /**
  27381. * The stiffness the physics imposter, soft object only
  27382. */
  27383. stiffness?: number;
  27384. /**
  27385. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27386. */
  27387. velocityIterations?: number;
  27388. /**
  27389. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27390. */
  27391. positionIterations?: number;
  27392. /**
  27393. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27394. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27395. * Add to fix multiple points
  27396. */
  27397. fixedPoints?: number;
  27398. /**
  27399. * The collision margin around a soft object
  27400. */
  27401. margin?: number;
  27402. /**
  27403. * The collision margin around a soft object
  27404. */
  27405. damping?: number;
  27406. /**
  27407. * The path for a rope based on an extrusion
  27408. */
  27409. path?: any;
  27410. /**
  27411. * The shape of an extrusion used for a rope based on an extrusion
  27412. */
  27413. shape?: any;
  27414. }
  27415. /**
  27416. * Interface for a physics-enabled object
  27417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27418. */
  27419. export interface IPhysicsEnabledObject {
  27420. /**
  27421. * The position of the physics-enabled object
  27422. */
  27423. position: Vector3;
  27424. /**
  27425. * The rotation of the physics-enabled object
  27426. */
  27427. rotationQuaternion: Nullable<Quaternion>;
  27428. /**
  27429. * The scale of the physics-enabled object
  27430. */
  27431. scaling: Vector3;
  27432. /**
  27433. * The rotation of the physics-enabled object
  27434. */
  27435. rotation?: Vector3;
  27436. /**
  27437. * The parent of the physics-enabled object
  27438. */
  27439. parent?: any;
  27440. /**
  27441. * The bounding info of the physics-enabled object
  27442. * @returns The bounding info of the physics-enabled object
  27443. */
  27444. getBoundingInfo(): BoundingInfo;
  27445. /**
  27446. * Computes the world matrix
  27447. * @param force Specifies if the world matrix should be computed by force
  27448. * @returns A world matrix
  27449. */
  27450. computeWorldMatrix(force: boolean): Matrix;
  27451. /**
  27452. * Gets the world matrix
  27453. * @returns A world matrix
  27454. */
  27455. getWorldMatrix?(): Matrix;
  27456. /**
  27457. * Gets the child meshes
  27458. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27459. * @returns An array of abstract meshes
  27460. */
  27461. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27462. /**
  27463. * Gets the vertex data
  27464. * @param kind The type of vertex data
  27465. * @returns A nullable array of numbers, or a float32 array
  27466. */
  27467. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27468. /**
  27469. * Gets the indices from the mesh
  27470. * @returns A nullable array of index arrays
  27471. */
  27472. getIndices?(): Nullable<IndicesArray>;
  27473. /**
  27474. * Gets the scene from the mesh
  27475. * @returns the indices array or null
  27476. */
  27477. getScene?(): Scene;
  27478. /**
  27479. * Gets the absolute position from the mesh
  27480. * @returns the absolute position
  27481. */
  27482. getAbsolutePosition(): Vector3;
  27483. /**
  27484. * Gets the absolute pivot point from the mesh
  27485. * @returns the absolute pivot point
  27486. */
  27487. getAbsolutePivotPoint(): Vector3;
  27488. /**
  27489. * Rotates the mesh
  27490. * @param axis The axis of rotation
  27491. * @param amount The amount of rotation
  27492. * @param space The space of the rotation
  27493. * @returns The rotation transform node
  27494. */
  27495. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27496. /**
  27497. * Translates the mesh
  27498. * @param axis The axis of translation
  27499. * @param distance The distance of translation
  27500. * @param space The space of the translation
  27501. * @returns The transform node
  27502. */
  27503. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27504. /**
  27505. * Sets the absolute position of the mesh
  27506. * @param absolutePosition The absolute position of the mesh
  27507. * @returns The transform node
  27508. */
  27509. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27510. /**
  27511. * Gets the class name of the mesh
  27512. * @returns The class name
  27513. */
  27514. getClassName(): string;
  27515. }
  27516. /**
  27517. * Represents a physics imposter
  27518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27519. */
  27520. export class PhysicsImpostor {
  27521. /**
  27522. * The physics-enabled object used as the physics imposter
  27523. */
  27524. object: IPhysicsEnabledObject;
  27525. /**
  27526. * The type of the physics imposter
  27527. */
  27528. type: number;
  27529. private _options;
  27530. private _scene?;
  27531. /**
  27532. * The default object size of the imposter
  27533. */
  27534. static DEFAULT_OBJECT_SIZE: Vector3;
  27535. /**
  27536. * The identity quaternion of the imposter
  27537. */
  27538. static IDENTITY_QUATERNION: Quaternion;
  27539. /** @hidden */
  27540. _pluginData: any;
  27541. private _physicsEngine;
  27542. private _physicsBody;
  27543. private _bodyUpdateRequired;
  27544. private _onBeforePhysicsStepCallbacks;
  27545. private _onAfterPhysicsStepCallbacks;
  27546. /** @hidden */
  27547. _onPhysicsCollideCallbacks: Array<{
  27548. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27549. otherImpostors: Array<PhysicsImpostor>;
  27550. }>;
  27551. private _deltaPosition;
  27552. private _deltaRotation;
  27553. private _deltaRotationConjugated;
  27554. /** @hidden */
  27555. _isFromLine: boolean;
  27556. private _parent;
  27557. private _isDisposed;
  27558. private static _tmpVecs;
  27559. private static _tmpQuat;
  27560. /**
  27561. * Specifies if the physics imposter is disposed
  27562. */
  27563. get isDisposed(): boolean;
  27564. /**
  27565. * Gets the mass of the physics imposter
  27566. */
  27567. get mass(): number;
  27568. set mass(value: number);
  27569. /**
  27570. * Gets the coefficient of friction
  27571. */
  27572. get friction(): number;
  27573. /**
  27574. * Sets the coefficient of friction
  27575. */
  27576. set friction(value: number);
  27577. /**
  27578. * Gets the coefficient of restitution
  27579. */
  27580. get restitution(): number;
  27581. /**
  27582. * Sets the coefficient of restitution
  27583. */
  27584. set restitution(value: number);
  27585. /**
  27586. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27587. */
  27588. get pressure(): number;
  27589. /**
  27590. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27591. */
  27592. set pressure(value: number);
  27593. /**
  27594. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27595. */
  27596. get stiffness(): number;
  27597. /**
  27598. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27599. */
  27600. set stiffness(value: number);
  27601. /**
  27602. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27603. */
  27604. get velocityIterations(): number;
  27605. /**
  27606. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27607. */
  27608. set velocityIterations(value: number);
  27609. /**
  27610. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27611. */
  27612. get positionIterations(): number;
  27613. /**
  27614. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27615. */
  27616. set positionIterations(value: number);
  27617. /**
  27618. * The unique id of the physics imposter
  27619. * set by the physics engine when adding this impostor to the array
  27620. */
  27621. uniqueId: number;
  27622. /**
  27623. * @hidden
  27624. */
  27625. soft: boolean;
  27626. /**
  27627. * @hidden
  27628. */
  27629. segments: number;
  27630. private _joints;
  27631. /**
  27632. * Initializes the physics imposter
  27633. * @param object The physics-enabled object used as the physics imposter
  27634. * @param type The type of the physics imposter
  27635. * @param _options The options for the physics imposter
  27636. * @param _scene The Babylon scene
  27637. */
  27638. constructor(
  27639. /**
  27640. * The physics-enabled object used as the physics imposter
  27641. */
  27642. object: IPhysicsEnabledObject,
  27643. /**
  27644. * The type of the physics imposter
  27645. */
  27646. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27647. /**
  27648. * This function will completly initialize this impostor.
  27649. * It will create a new body - but only if this mesh has no parent.
  27650. * If it has, this impostor will not be used other than to define the impostor
  27651. * of the child mesh.
  27652. * @hidden
  27653. */
  27654. _init(): void;
  27655. private _getPhysicsParent;
  27656. /**
  27657. * Should a new body be generated.
  27658. * @returns boolean specifying if body initialization is required
  27659. */
  27660. isBodyInitRequired(): boolean;
  27661. /**
  27662. * Sets the updated scaling
  27663. * @param updated Specifies if the scaling is updated
  27664. */
  27665. setScalingUpdated(): void;
  27666. /**
  27667. * Force a regeneration of this or the parent's impostor's body.
  27668. * Use under cautious - This will remove all joints already implemented.
  27669. */
  27670. forceUpdate(): void;
  27671. /**
  27672. * Gets the body that holds this impostor. Either its own, or its parent.
  27673. */
  27674. get physicsBody(): any;
  27675. /**
  27676. * Get the parent of the physics imposter
  27677. * @returns Physics imposter or null
  27678. */
  27679. get parent(): Nullable<PhysicsImpostor>;
  27680. /**
  27681. * Sets the parent of the physics imposter
  27682. */
  27683. set parent(value: Nullable<PhysicsImpostor>);
  27684. /**
  27685. * Set the physics body. Used mainly by the physics engine/plugin
  27686. */
  27687. set physicsBody(physicsBody: any);
  27688. /**
  27689. * Resets the update flags
  27690. */
  27691. resetUpdateFlags(): void;
  27692. /**
  27693. * Gets the object extend size
  27694. * @returns the object extend size
  27695. */
  27696. getObjectExtendSize(): Vector3;
  27697. /**
  27698. * Gets the object center
  27699. * @returns The object center
  27700. */
  27701. getObjectCenter(): Vector3;
  27702. /**
  27703. * Get a specific parameter from the options parameters
  27704. * @param paramName The object parameter name
  27705. * @returns The object parameter
  27706. */
  27707. getParam(paramName: string): any;
  27708. /**
  27709. * Sets a specific parameter in the options given to the physics plugin
  27710. * @param paramName The parameter name
  27711. * @param value The value of the parameter
  27712. */
  27713. setParam(paramName: string, value: number): void;
  27714. /**
  27715. * Specifically change the body's mass option. Won't recreate the physics body object
  27716. * @param mass The mass of the physics imposter
  27717. */
  27718. setMass(mass: number): void;
  27719. /**
  27720. * Gets the linear velocity
  27721. * @returns linear velocity or null
  27722. */
  27723. getLinearVelocity(): Nullable<Vector3>;
  27724. /**
  27725. * Sets the linear velocity
  27726. * @param velocity linear velocity or null
  27727. */
  27728. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27729. /**
  27730. * Gets the angular velocity
  27731. * @returns angular velocity or null
  27732. */
  27733. getAngularVelocity(): Nullable<Vector3>;
  27734. /**
  27735. * Sets the angular velocity
  27736. * @param velocity The velocity or null
  27737. */
  27738. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27739. /**
  27740. * Execute a function with the physics plugin native code
  27741. * Provide a function the will have two variables - the world object and the physics body object
  27742. * @param func The function to execute with the physics plugin native code
  27743. */
  27744. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27745. /**
  27746. * Register a function that will be executed before the physics world is stepping forward
  27747. * @param func The function to execute before the physics world is stepped forward
  27748. */
  27749. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27750. /**
  27751. * Unregister a function that will be executed before the physics world is stepping forward
  27752. * @param func The function to execute before the physics world is stepped forward
  27753. */
  27754. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27755. /**
  27756. * Register a function that will be executed after the physics step
  27757. * @param func The function to execute after physics step
  27758. */
  27759. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27760. /**
  27761. * Unregisters a function that will be executed after the physics step
  27762. * @param func The function to execute after physics step
  27763. */
  27764. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27765. /**
  27766. * register a function that will be executed when this impostor collides against a different body
  27767. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27768. * @param func Callback that is executed on collision
  27769. */
  27770. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27771. /**
  27772. * Unregisters the physics imposter on contact
  27773. * @param collideAgainst The physics object to collide against
  27774. * @param func Callback to execute on collision
  27775. */
  27776. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27777. private _tmpQuat;
  27778. private _tmpQuat2;
  27779. /**
  27780. * Get the parent rotation
  27781. * @returns The parent rotation
  27782. */
  27783. getParentsRotation(): Quaternion;
  27784. /**
  27785. * this function is executed by the physics engine.
  27786. */
  27787. beforeStep: () => void;
  27788. /**
  27789. * this function is executed by the physics engine
  27790. */
  27791. afterStep: () => void;
  27792. /**
  27793. * Legacy collision detection event support
  27794. */
  27795. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27796. /**
  27797. * event and body object due to cannon's event-based architecture.
  27798. */
  27799. onCollide: (e: {
  27800. body: any;
  27801. }) => void;
  27802. /**
  27803. * Apply a force
  27804. * @param force The force to apply
  27805. * @param contactPoint The contact point for the force
  27806. * @returns The physics imposter
  27807. */
  27808. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27809. /**
  27810. * Apply an impulse
  27811. * @param force The impulse force
  27812. * @param contactPoint The contact point for the impulse force
  27813. * @returns The physics imposter
  27814. */
  27815. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27816. /**
  27817. * A help function to create a joint
  27818. * @param otherImpostor A physics imposter used to create a joint
  27819. * @param jointType The type of joint
  27820. * @param jointData The data for the joint
  27821. * @returns The physics imposter
  27822. */
  27823. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27824. /**
  27825. * Add a joint to this impostor with a different impostor
  27826. * @param otherImpostor A physics imposter used to add a joint
  27827. * @param joint The joint to add
  27828. * @returns The physics imposter
  27829. */
  27830. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27831. /**
  27832. * Add an anchor to a cloth impostor
  27833. * @param otherImpostor rigid impostor to anchor to
  27834. * @param width ratio across width from 0 to 1
  27835. * @param height ratio up height from 0 to 1
  27836. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27837. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27838. * @returns impostor the soft imposter
  27839. */
  27840. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27841. /**
  27842. * Add a hook to a rope impostor
  27843. * @param otherImpostor rigid impostor to anchor to
  27844. * @param length ratio across rope from 0 to 1
  27845. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27846. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27847. * @returns impostor the rope imposter
  27848. */
  27849. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27850. /**
  27851. * Will keep this body still, in a sleep mode.
  27852. * @returns the physics imposter
  27853. */
  27854. sleep(): PhysicsImpostor;
  27855. /**
  27856. * Wake the body up.
  27857. * @returns The physics imposter
  27858. */
  27859. wakeUp(): PhysicsImpostor;
  27860. /**
  27861. * Clones the physics imposter
  27862. * @param newObject The physics imposter clones to this physics-enabled object
  27863. * @returns A nullable physics imposter
  27864. */
  27865. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27866. /**
  27867. * Disposes the physics imposter
  27868. */
  27869. dispose(): void;
  27870. /**
  27871. * Sets the delta position
  27872. * @param position The delta position amount
  27873. */
  27874. setDeltaPosition(position: Vector3): void;
  27875. /**
  27876. * Sets the delta rotation
  27877. * @param rotation The delta rotation amount
  27878. */
  27879. setDeltaRotation(rotation: Quaternion): void;
  27880. /**
  27881. * Gets the box size of the physics imposter and stores the result in the input parameter
  27882. * @param result Stores the box size
  27883. * @returns The physics imposter
  27884. */
  27885. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27886. /**
  27887. * Gets the radius of the physics imposter
  27888. * @returns Radius of the physics imposter
  27889. */
  27890. getRadius(): number;
  27891. /**
  27892. * Sync a bone with this impostor
  27893. * @param bone The bone to sync to the impostor.
  27894. * @param boneMesh The mesh that the bone is influencing.
  27895. * @param jointPivot The pivot of the joint / bone in local space.
  27896. * @param distToJoint Optional distance from the impostor to the joint.
  27897. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27898. */
  27899. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27900. /**
  27901. * Sync impostor to a bone
  27902. * @param bone The bone that the impostor will be synced to.
  27903. * @param boneMesh The mesh that the bone is influencing.
  27904. * @param jointPivot The pivot of the joint / bone in local space.
  27905. * @param distToJoint Optional distance from the impostor to the joint.
  27906. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27907. * @param boneAxis Optional vector3 axis the bone is aligned with
  27908. */
  27909. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27910. /**
  27911. * No-Imposter type
  27912. */
  27913. static NoImpostor: number;
  27914. /**
  27915. * Sphere-Imposter type
  27916. */
  27917. static SphereImpostor: number;
  27918. /**
  27919. * Box-Imposter type
  27920. */
  27921. static BoxImpostor: number;
  27922. /**
  27923. * Plane-Imposter type
  27924. */
  27925. static PlaneImpostor: number;
  27926. /**
  27927. * Mesh-imposter type
  27928. */
  27929. static MeshImpostor: number;
  27930. /**
  27931. * Capsule-Impostor type (Ammo.js plugin only)
  27932. */
  27933. static CapsuleImpostor: number;
  27934. /**
  27935. * Cylinder-Imposter type
  27936. */
  27937. static CylinderImpostor: number;
  27938. /**
  27939. * Particle-Imposter type
  27940. */
  27941. static ParticleImpostor: number;
  27942. /**
  27943. * Heightmap-Imposter type
  27944. */
  27945. static HeightmapImpostor: number;
  27946. /**
  27947. * ConvexHull-Impostor type (Ammo.js plugin only)
  27948. */
  27949. static ConvexHullImpostor: number;
  27950. /**
  27951. * Custom-Imposter type (Ammo.js plugin only)
  27952. */
  27953. static CustomImpostor: number;
  27954. /**
  27955. * Rope-Imposter type
  27956. */
  27957. static RopeImpostor: number;
  27958. /**
  27959. * Cloth-Imposter type
  27960. */
  27961. static ClothImpostor: number;
  27962. /**
  27963. * Softbody-Imposter type
  27964. */
  27965. static SoftbodyImpostor: number;
  27966. }
  27967. }
  27968. declare module BABYLON {
  27969. /**
  27970. * @hidden
  27971. **/
  27972. export class _CreationDataStorage {
  27973. closePath?: boolean;
  27974. closeArray?: boolean;
  27975. idx: number[];
  27976. dashSize: number;
  27977. gapSize: number;
  27978. path3D: Path3D;
  27979. pathArray: Vector3[][];
  27980. arc: number;
  27981. radius: number;
  27982. cap: number;
  27983. tessellation: number;
  27984. }
  27985. /**
  27986. * @hidden
  27987. **/
  27988. class _InstanceDataStorage {
  27989. visibleInstances: any;
  27990. batchCache: _InstancesBatch;
  27991. instancesBufferSize: number;
  27992. instancesBuffer: Nullable<Buffer>;
  27993. instancesData: Float32Array;
  27994. overridenInstanceCount: number;
  27995. isFrozen: boolean;
  27996. previousBatch: Nullable<_InstancesBatch>;
  27997. hardwareInstancedRendering: boolean;
  27998. sideOrientation: number;
  27999. manualUpdate: boolean;
  28000. }
  28001. /**
  28002. * @hidden
  28003. **/
  28004. export class _InstancesBatch {
  28005. mustReturn: boolean;
  28006. visibleInstances: Nullable<InstancedMesh[]>[];
  28007. renderSelf: boolean[];
  28008. hardwareInstancedRendering: boolean[];
  28009. }
  28010. /**
  28011. * @hidden
  28012. **/
  28013. class _ThinInstanceDataStorage {
  28014. instancesCount: number;
  28015. matrixBuffer: Nullable<Buffer>;
  28016. matrixBufferSize: number;
  28017. matrixData: Nullable<Float32Array>;
  28018. boundingVectors: Array<Vector3>;
  28019. worldMatrices: Nullable<Matrix[]>;
  28020. }
  28021. /**
  28022. * Class used to represent renderable models
  28023. */
  28024. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28025. /**
  28026. * Mesh side orientation : usually the external or front surface
  28027. */
  28028. static readonly FRONTSIDE: number;
  28029. /**
  28030. * Mesh side orientation : usually the internal or back surface
  28031. */
  28032. static readonly BACKSIDE: number;
  28033. /**
  28034. * Mesh side orientation : both internal and external or front and back surfaces
  28035. */
  28036. static readonly DOUBLESIDE: number;
  28037. /**
  28038. * Mesh side orientation : by default, `FRONTSIDE`
  28039. */
  28040. static readonly DEFAULTSIDE: number;
  28041. /**
  28042. * Mesh cap setting : no cap
  28043. */
  28044. static readonly NO_CAP: number;
  28045. /**
  28046. * Mesh cap setting : one cap at the beginning of the mesh
  28047. */
  28048. static readonly CAP_START: number;
  28049. /**
  28050. * Mesh cap setting : one cap at the end of the mesh
  28051. */
  28052. static readonly CAP_END: number;
  28053. /**
  28054. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28055. */
  28056. static readonly CAP_ALL: number;
  28057. /**
  28058. * Mesh pattern setting : no flip or rotate
  28059. */
  28060. static readonly NO_FLIP: number;
  28061. /**
  28062. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28063. */
  28064. static readonly FLIP_TILE: number;
  28065. /**
  28066. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28067. */
  28068. static readonly ROTATE_TILE: number;
  28069. /**
  28070. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28071. */
  28072. static readonly FLIP_ROW: number;
  28073. /**
  28074. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28075. */
  28076. static readonly ROTATE_ROW: number;
  28077. /**
  28078. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28079. */
  28080. static readonly FLIP_N_ROTATE_TILE: number;
  28081. /**
  28082. * Mesh pattern setting : rotate pattern and rotate
  28083. */
  28084. static readonly FLIP_N_ROTATE_ROW: number;
  28085. /**
  28086. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28087. */
  28088. static readonly CENTER: number;
  28089. /**
  28090. * Mesh tile positioning : part tiles on left
  28091. */
  28092. static readonly LEFT: number;
  28093. /**
  28094. * Mesh tile positioning : part tiles on right
  28095. */
  28096. static readonly RIGHT: number;
  28097. /**
  28098. * Mesh tile positioning : part tiles on top
  28099. */
  28100. static readonly TOP: number;
  28101. /**
  28102. * Mesh tile positioning : part tiles on bottom
  28103. */
  28104. static readonly BOTTOM: number;
  28105. /**
  28106. * Gets the default side orientation.
  28107. * @param orientation the orientation to value to attempt to get
  28108. * @returns the default orientation
  28109. * @hidden
  28110. */
  28111. static _GetDefaultSideOrientation(orientation?: number): number;
  28112. private _internalMeshDataInfo;
  28113. get computeBonesUsingShaders(): boolean;
  28114. set computeBonesUsingShaders(value: boolean);
  28115. /**
  28116. * An event triggered before rendering the mesh
  28117. */
  28118. get onBeforeRenderObservable(): Observable<Mesh>;
  28119. /**
  28120. * An event triggered before binding the mesh
  28121. */
  28122. get onBeforeBindObservable(): Observable<Mesh>;
  28123. /**
  28124. * An event triggered after rendering the mesh
  28125. */
  28126. get onAfterRenderObservable(): Observable<Mesh>;
  28127. /**
  28128. * An event triggered before drawing the mesh
  28129. */
  28130. get onBeforeDrawObservable(): Observable<Mesh>;
  28131. private _onBeforeDrawObserver;
  28132. /**
  28133. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28134. */
  28135. set onBeforeDraw(callback: () => void);
  28136. get hasInstances(): boolean;
  28137. get hasThinInstances(): boolean;
  28138. /**
  28139. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28140. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28141. */
  28142. delayLoadState: number;
  28143. /**
  28144. * Gets the list of instances created from this mesh
  28145. * it is not supposed to be modified manually.
  28146. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28147. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28148. */
  28149. instances: InstancedMesh[];
  28150. /**
  28151. * Gets the file containing delay loading data for this mesh
  28152. */
  28153. delayLoadingFile: string;
  28154. /** @hidden */
  28155. _binaryInfo: any;
  28156. /**
  28157. * User defined function used to change how LOD level selection is done
  28158. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28159. */
  28160. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28161. /**
  28162. * Gets or sets the morph target manager
  28163. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28164. */
  28165. get morphTargetManager(): Nullable<MorphTargetManager>;
  28166. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28167. /** @hidden */
  28168. _creationDataStorage: Nullable<_CreationDataStorage>;
  28169. /** @hidden */
  28170. _geometry: Nullable<Geometry>;
  28171. /** @hidden */
  28172. _delayInfo: Array<string>;
  28173. /** @hidden */
  28174. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28175. /** @hidden */
  28176. _instanceDataStorage: _InstanceDataStorage;
  28177. /** @hidden */
  28178. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28179. private _effectiveMaterial;
  28180. /** @hidden */
  28181. _shouldGenerateFlatShading: boolean;
  28182. /** @hidden */
  28183. _originalBuilderSideOrientation: number;
  28184. /**
  28185. * Use this property to change the original side orientation defined at construction time
  28186. */
  28187. overrideMaterialSideOrientation: Nullable<number>;
  28188. /**
  28189. * Gets the source mesh (the one used to clone this one from)
  28190. */
  28191. get source(): Nullable<Mesh>;
  28192. /**
  28193. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28194. */
  28195. get isUnIndexed(): boolean;
  28196. set isUnIndexed(value: boolean);
  28197. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28198. get worldMatrixInstancedBuffer(): Float32Array;
  28199. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28200. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28201. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28202. /**
  28203. * @constructor
  28204. * @param name The value used by scene.getMeshByName() to do a lookup.
  28205. * @param scene The scene to add this mesh to.
  28206. * @param parent The parent of this mesh, if it has one
  28207. * @param source An optional Mesh from which geometry is shared, cloned.
  28208. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28209. * When false, achieved by calling a clone(), also passing False.
  28210. * This will make creation of children, recursive.
  28211. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28212. */
  28213. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28214. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28215. doNotInstantiate: boolean;
  28216. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28217. /**
  28218. * Gets the class name
  28219. * @returns the string "Mesh".
  28220. */
  28221. getClassName(): string;
  28222. /** @hidden */
  28223. get _isMesh(): boolean;
  28224. /**
  28225. * Returns a description of this mesh
  28226. * @param fullDetails define if full details about this mesh must be used
  28227. * @returns a descriptive string representing this mesh
  28228. */
  28229. toString(fullDetails?: boolean): string;
  28230. /** @hidden */
  28231. _unBindEffect(): void;
  28232. /**
  28233. * Gets a boolean indicating if this mesh has LOD
  28234. */
  28235. get hasLODLevels(): boolean;
  28236. /**
  28237. * Gets the list of MeshLODLevel associated with the current mesh
  28238. * @returns an array of MeshLODLevel
  28239. */
  28240. getLODLevels(): MeshLODLevel[];
  28241. private _sortLODLevels;
  28242. /**
  28243. * Add a mesh as LOD level triggered at the given distance.
  28244. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28245. * @param distance The distance from the center of the object to show this level
  28246. * @param mesh The mesh to be added as LOD level (can be null)
  28247. * @return This mesh (for chaining)
  28248. */
  28249. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28250. /**
  28251. * Returns the LOD level mesh at the passed distance or null if not found.
  28252. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28253. * @param distance The distance from the center of the object to show this level
  28254. * @returns a Mesh or `null`
  28255. */
  28256. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28257. /**
  28258. * Remove a mesh from the LOD array
  28259. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28260. * @param mesh defines the mesh to be removed
  28261. * @return This mesh (for chaining)
  28262. */
  28263. removeLODLevel(mesh: Mesh): Mesh;
  28264. /**
  28265. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28266. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28267. * @param camera defines the camera to use to compute distance
  28268. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28269. * @return This mesh (for chaining)
  28270. */
  28271. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28272. /**
  28273. * Gets the mesh internal Geometry object
  28274. */
  28275. get geometry(): Nullable<Geometry>;
  28276. /**
  28277. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28278. * @returns the total number of vertices
  28279. */
  28280. getTotalVertices(): number;
  28281. /**
  28282. * Returns the content of an associated vertex buffer
  28283. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28284. * - VertexBuffer.PositionKind
  28285. * - VertexBuffer.UVKind
  28286. * - VertexBuffer.UV2Kind
  28287. * - VertexBuffer.UV3Kind
  28288. * - VertexBuffer.UV4Kind
  28289. * - VertexBuffer.UV5Kind
  28290. * - VertexBuffer.UV6Kind
  28291. * - VertexBuffer.ColorKind
  28292. * - VertexBuffer.MatricesIndicesKind
  28293. * - VertexBuffer.MatricesIndicesExtraKind
  28294. * - VertexBuffer.MatricesWeightsKind
  28295. * - VertexBuffer.MatricesWeightsExtraKind
  28296. * @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
  28297. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28298. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28299. */
  28300. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28301. /**
  28302. * Returns the mesh VertexBuffer object from the requested `kind`
  28303. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28304. * - VertexBuffer.PositionKind
  28305. * - VertexBuffer.NormalKind
  28306. * - VertexBuffer.UVKind
  28307. * - VertexBuffer.UV2Kind
  28308. * - VertexBuffer.UV3Kind
  28309. * - VertexBuffer.UV4Kind
  28310. * - VertexBuffer.UV5Kind
  28311. * - VertexBuffer.UV6Kind
  28312. * - VertexBuffer.ColorKind
  28313. * - VertexBuffer.MatricesIndicesKind
  28314. * - VertexBuffer.MatricesIndicesExtraKind
  28315. * - VertexBuffer.MatricesWeightsKind
  28316. * - VertexBuffer.MatricesWeightsExtraKind
  28317. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28318. */
  28319. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28320. /**
  28321. * Tests if a specific vertex buffer is associated with this mesh
  28322. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28323. * - VertexBuffer.PositionKind
  28324. * - VertexBuffer.NormalKind
  28325. * - VertexBuffer.UVKind
  28326. * - VertexBuffer.UV2Kind
  28327. * - VertexBuffer.UV3Kind
  28328. * - VertexBuffer.UV4Kind
  28329. * - VertexBuffer.UV5Kind
  28330. * - VertexBuffer.UV6Kind
  28331. * - VertexBuffer.ColorKind
  28332. * - VertexBuffer.MatricesIndicesKind
  28333. * - VertexBuffer.MatricesIndicesExtraKind
  28334. * - VertexBuffer.MatricesWeightsKind
  28335. * - VertexBuffer.MatricesWeightsExtraKind
  28336. * @returns a boolean
  28337. */
  28338. isVerticesDataPresent(kind: string): boolean;
  28339. /**
  28340. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28341. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28342. * - VertexBuffer.PositionKind
  28343. * - VertexBuffer.UVKind
  28344. * - VertexBuffer.UV2Kind
  28345. * - VertexBuffer.UV3Kind
  28346. * - VertexBuffer.UV4Kind
  28347. * - VertexBuffer.UV5Kind
  28348. * - VertexBuffer.UV6Kind
  28349. * - VertexBuffer.ColorKind
  28350. * - VertexBuffer.MatricesIndicesKind
  28351. * - VertexBuffer.MatricesIndicesExtraKind
  28352. * - VertexBuffer.MatricesWeightsKind
  28353. * - VertexBuffer.MatricesWeightsExtraKind
  28354. * @returns a boolean
  28355. */
  28356. isVertexBufferUpdatable(kind: string): boolean;
  28357. /**
  28358. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28359. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28360. * - VertexBuffer.PositionKind
  28361. * - VertexBuffer.NormalKind
  28362. * - VertexBuffer.UVKind
  28363. * - VertexBuffer.UV2Kind
  28364. * - VertexBuffer.UV3Kind
  28365. * - VertexBuffer.UV4Kind
  28366. * - VertexBuffer.UV5Kind
  28367. * - VertexBuffer.UV6Kind
  28368. * - VertexBuffer.ColorKind
  28369. * - VertexBuffer.MatricesIndicesKind
  28370. * - VertexBuffer.MatricesIndicesExtraKind
  28371. * - VertexBuffer.MatricesWeightsKind
  28372. * - VertexBuffer.MatricesWeightsExtraKind
  28373. * @returns an array of strings
  28374. */
  28375. getVerticesDataKinds(): string[];
  28376. /**
  28377. * Returns a positive integer : the total number of indices in this mesh geometry.
  28378. * @returns the numner of indices or zero if the mesh has no geometry.
  28379. */
  28380. getTotalIndices(): number;
  28381. /**
  28382. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28383. * @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.
  28384. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28385. * @returns the indices array or an empty array if the mesh has no geometry
  28386. */
  28387. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28388. get isBlocked(): boolean;
  28389. /**
  28390. * Determine if the current mesh is ready to be rendered
  28391. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28392. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28393. * @returns true if all associated assets are ready (material, textures, shaders)
  28394. */
  28395. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28396. /**
  28397. * 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.
  28398. */
  28399. get areNormalsFrozen(): boolean;
  28400. /**
  28401. * 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.
  28402. * @returns the current mesh
  28403. */
  28404. freezeNormals(): Mesh;
  28405. /**
  28406. * 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
  28407. * @returns the current mesh
  28408. */
  28409. unfreezeNormals(): Mesh;
  28410. /**
  28411. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28412. */
  28413. set overridenInstanceCount(count: number);
  28414. /** @hidden */
  28415. _preActivate(): Mesh;
  28416. /** @hidden */
  28417. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28418. /** @hidden */
  28419. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28420. protected _afterComputeWorldMatrix(): void;
  28421. /** @hidden */
  28422. _postActivate(): void;
  28423. /**
  28424. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28425. * This means the mesh underlying bounding box and sphere are recomputed.
  28426. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28427. * @returns the current mesh
  28428. */
  28429. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28430. /** @hidden */
  28431. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28432. /**
  28433. * This function will subdivide the mesh into multiple submeshes
  28434. * @param count defines the expected number of submeshes
  28435. */
  28436. subdivide(count: number): void;
  28437. /**
  28438. * Copy a FloatArray into a specific associated vertex buffer
  28439. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28440. * - VertexBuffer.PositionKind
  28441. * - VertexBuffer.UVKind
  28442. * - VertexBuffer.UV2Kind
  28443. * - VertexBuffer.UV3Kind
  28444. * - VertexBuffer.UV4Kind
  28445. * - VertexBuffer.UV5Kind
  28446. * - VertexBuffer.UV6Kind
  28447. * - VertexBuffer.ColorKind
  28448. * - VertexBuffer.MatricesIndicesKind
  28449. * - VertexBuffer.MatricesIndicesExtraKind
  28450. * - VertexBuffer.MatricesWeightsKind
  28451. * - VertexBuffer.MatricesWeightsExtraKind
  28452. * @param data defines the data source
  28453. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28454. * @param stride defines the data stride size (can be null)
  28455. * @returns the current mesh
  28456. */
  28457. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28458. /**
  28459. * Delete a vertex buffer associated with this mesh
  28460. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28461. * - VertexBuffer.PositionKind
  28462. * - VertexBuffer.UVKind
  28463. * - VertexBuffer.UV2Kind
  28464. * - VertexBuffer.UV3Kind
  28465. * - VertexBuffer.UV4Kind
  28466. * - VertexBuffer.UV5Kind
  28467. * - VertexBuffer.UV6Kind
  28468. * - VertexBuffer.ColorKind
  28469. * - VertexBuffer.MatricesIndicesKind
  28470. * - VertexBuffer.MatricesIndicesExtraKind
  28471. * - VertexBuffer.MatricesWeightsKind
  28472. * - VertexBuffer.MatricesWeightsExtraKind
  28473. */
  28474. removeVerticesData(kind: string): void;
  28475. /**
  28476. * Flags an associated vertex buffer as updatable
  28477. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28478. * - VertexBuffer.PositionKind
  28479. * - VertexBuffer.UVKind
  28480. * - VertexBuffer.UV2Kind
  28481. * - VertexBuffer.UV3Kind
  28482. * - VertexBuffer.UV4Kind
  28483. * - VertexBuffer.UV5Kind
  28484. * - VertexBuffer.UV6Kind
  28485. * - VertexBuffer.ColorKind
  28486. * - VertexBuffer.MatricesIndicesKind
  28487. * - VertexBuffer.MatricesIndicesExtraKind
  28488. * - VertexBuffer.MatricesWeightsKind
  28489. * - VertexBuffer.MatricesWeightsExtraKind
  28490. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28491. */
  28492. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28493. /**
  28494. * Sets the mesh global Vertex Buffer
  28495. * @param buffer defines the buffer to use
  28496. * @returns the current mesh
  28497. */
  28498. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28499. /**
  28500. * Update a specific associated vertex buffer
  28501. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28502. * - VertexBuffer.PositionKind
  28503. * - VertexBuffer.UVKind
  28504. * - VertexBuffer.UV2Kind
  28505. * - VertexBuffer.UV3Kind
  28506. * - VertexBuffer.UV4Kind
  28507. * - VertexBuffer.UV5Kind
  28508. * - VertexBuffer.UV6Kind
  28509. * - VertexBuffer.ColorKind
  28510. * - VertexBuffer.MatricesIndicesKind
  28511. * - VertexBuffer.MatricesIndicesExtraKind
  28512. * - VertexBuffer.MatricesWeightsKind
  28513. * - VertexBuffer.MatricesWeightsExtraKind
  28514. * @param data defines the data source
  28515. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28516. * @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)
  28517. * @returns the current mesh
  28518. */
  28519. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28520. /**
  28521. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28522. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28523. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28524. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28525. * @returns the current mesh
  28526. */
  28527. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28528. /**
  28529. * Creates a un-shared specific occurence of the geometry for the mesh.
  28530. * @returns the current mesh
  28531. */
  28532. makeGeometryUnique(): Mesh;
  28533. /**
  28534. * Set the index buffer of this mesh
  28535. * @param indices defines the source data
  28536. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28537. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28538. * @returns the current mesh
  28539. */
  28540. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28541. /**
  28542. * Update the current index buffer
  28543. * @param indices defines the source data
  28544. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28545. * @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)
  28546. * @returns the current mesh
  28547. */
  28548. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28549. /**
  28550. * Invert the geometry to move from a right handed system to a left handed one.
  28551. * @returns the current mesh
  28552. */
  28553. toLeftHanded(): Mesh;
  28554. /** @hidden */
  28555. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28556. /** @hidden */
  28557. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28558. /**
  28559. * Registers for this mesh a javascript function called just before the rendering process
  28560. * @param func defines the function to call before rendering this mesh
  28561. * @returns the current mesh
  28562. */
  28563. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28564. /**
  28565. * Disposes a previously registered javascript function called before the rendering
  28566. * @param func defines the function to remove
  28567. * @returns the current mesh
  28568. */
  28569. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28570. /**
  28571. * Registers for this mesh a javascript function called just after the rendering is complete
  28572. * @param func defines the function to call after rendering this mesh
  28573. * @returns the current mesh
  28574. */
  28575. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28576. /**
  28577. * Disposes a previously registered javascript function called after the rendering.
  28578. * @param func defines the function to remove
  28579. * @returns the current mesh
  28580. */
  28581. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28582. /** @hidden */
  28583. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28584. /** @hidden */
  28585. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28586. /** @hidden */
  28587. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28588. /** @hidden */
  28589. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28590. /** @hidden */
  28591. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28592. /** @hidden */
  28593. _rebuild(): void;
  28594. /** @hidden */
  28595. _freeze(): void;
  28596. /** @hidden */
  28597. _unFreeze(): void;
  28598. /**
  28599. * 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
  28600. * @param subMesh defines the subMesh to render
  28601. * @param enableAlphaMode defines if alpha mode can be changed
  28602. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28603. * @returns the current mesh
  28604. */
  28605. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28606. private _onBeforeDraw;
  28607. /**
  28608. * Renormalize the mesh and patch it up if there are no weights
  28609. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28610. * However in the case of zero weights then we set just a single influence to 1.
  28611. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28612. */
  28613. cleanMatrixWeights(): void;
  28614. private normalizeSkinFourWeights;
  28615. private normalizeSkinWeightsAndExtra;
  28616. /**
  28617. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28618. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28619. * the user know there was an issue with importing the mesh
  28620. * @returns a validation object with skinned, valid and report string
  28621. */
  28622. validateSkinning(): {
  28623. skinned: boolean;
  28624. valid: boolean;
  28625. report: string;
  28626. };
  28627. /** @hidden */
  28628. _checkDelayState(): Mesh;
  28629. private _queueLoad;
  28630. /**
  28631. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28632. * A mesh is in the frustum if its bounding box intersects the frustum
  28633. * @param frustumPlanes defines the frustum to test
  28634. * @returns true if the mesh is in the frustum planes
  28635. */
  28636. isInFrustum(frustumPlanes: Plane[]): boolean;
  28637. /**
  28638. * Sets the mesh material by the material or multiMaterial `id` property
  28639. * @param id is a string identifying the material or the multiMaterial
  28640. * @returns the current mesh
  28641. */
  28642. setMaterialByID(id: string): Mesh;
  28643. /**
  28644. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28645. * @returns an array of IAnimatable
  28646. */
  28647. getAnimatables(): IAnimatable[];
  28648. /**
  28649. * Modifies the mesh geometry according to the passed transformation matrix.
  28650. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28651. * The mesh normals are modified using the same transformation.
  28652. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28653. * @param transform defines the transform matrix to use
  28654. * @see https://doc.babylonjs.com/resources/baking_transformations
  28655. * @returns the current mesh
  28656. */
  28657. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28658. /**
  28659. * Modifies the mesh geometry according to its own current World Matrix.
  28660. * The mesh World Matrix is then reset.
  28661. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28662. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28663. * @see https://doc.babylonjs.com/resources/baking_transformations
  28664. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28665. * @returns the current mesh
  28666. */
  28667. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28668. /** @hidden */
  28669. get _positions(): Nullable<Vector3[]>;
  28670. /** @hidden */
  28671. _resetPointsArrayCache(): Mesh;
  28672. /** @hidden */
  28673. _generatePointsArray(): boolean;
  28674. /**
  28675. * Returns a new Mesh object generated from the current mesh properties.
  28676. * This method must not get confused with createInstance()
  28677. * @param name is a string, the name given to the new mesh
  28678. * @param newParent can be any Node object (default `null`)
  28679. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28680. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28681. * @returns a new mesh
  28682. */
  28683. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28684. /**
  28685. * Releases resources associated with this mesh.
  28686. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28687. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28688. */
  28689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28690. /** @hidden */
  28691. _disposeInstanceSpecificData(): void;
  28692. /** @hidden */
  28693. _disposeThinInstanceSpecificData(): void;
  28694. /**
  28695. * Modifies the mesh geometry according to a displacement map.
  28696. * 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.
  28697. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28698. * @param url is a string, the URL from the image file is to be downloaded.
  28699. * @param minHeight is the lower limit of the displacement.
  28700. * @param maxHeight is the upper limit of the displacement.
  28701. * @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.
  28702. * @param uvOffset is an optional vector2 used to offset UV.
  28703. * @param uvScale is an optional vector2 used to scale UV.
  28704. * @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.
  28705. * @returns the Mesh.
  28706. */
  28707. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28708. /**
  28709. * Modifies the mesh geometry according to a displacementMap buffer.
  28710. * 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.
  28711. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28712. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28713. * @param heightMapWidth is the width of the buffer image.
  28714. * @param heightMapHeight is the height of the buffer image.
  28715. * @param minHeight is the lower limit of the displacement.
  28716. * @param maxHeight is the upper limit of the displacement.
  28717. * @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.
  28718. * @param uvOffset is an optional vector2 used to offset UV.
  28719. * @param uvScale is an optional vector2 used to scale UV.
  28720. * @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.
  28721. * @returns the Mesh.
  28722. */
  28723. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28724. /**
  28725. * Modify the mesh to get a flat shading rendering.
  28726. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28727. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28728. * @returns current mesh
  28729. */
  28730. convertToFlatShadedMesh(): Mesh;
  28731. /**
  28732. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28733. * In other words, more vertices, no more indices and a single bigger VBO.
  28734. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28735. * @returns current mesh
  28736. */
  28737. convertToUnIndexedMesh(): Mesh;
  28738. /**
  28739. * Inverses facet orientations.
  28740. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28741. * @param flipNormals will also inverts the normals
  28742. * @returns current mesh
  28743. */
  28744. flipFaces(flipNormals?: boolean): Mesh;
  28745. /**
  28746. * Increase the number of facets and hence vertices in a mesh
  28747. * Vertex normals are interpolated from existing vertex normals
  28748. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28749. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28750. */
  28751. increaseVertices(numberPerEdge: number): void;
  28752. /**
  28753. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28754. * This will undo any application of covertToFlatShadedMesh
  28755. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28756. */
  28757. forceSharedVertices(): void;
  28758. /** @hidden */
  28759. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28760. /** @hidden */
  28761. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28762. /**
  28763. * Creates a new InstancedMesh object from the mesh model.
  28764. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28765. * @param name defines the name of the new instance
  28766. * @returns a new InstancedMesh
  28767. */
  28768. createInstance(name: string): InstancedMesh;
  28769. /**
  28770. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28771. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28772. * @returns the current mesh
  28773. */
  28774. synchronizeInstances(): Mesh;
  28775. /**
  28776. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28777. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28778. * This should be used together with the simplification to avoid disappearing triangles.
  28779. * @param successCallback an optional success callback to be called after the optimization finished.
  28780. * @returns the current mesh
  28781. */
  28782. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28783. /**
  28784. * Serialize current mesh
  28785. * @param serializationObject defines the object which will receive the serialization data
  28786. */
  28787. serialize(serializationObject: any): void;
  28788. /** @hidden */
  28789. _syncGeometryWithMorphTargetManager(): void;
  28790. /** @hidden */
  28791. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28792. /**
  28793. * Returns a new Mesh object parsed from the source provided.
  28794. * @param parsedMesh is the source
  28795. * @param scene defines the hosting scene
  28796. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28797. * @returns a new Mesh
  28798. */
  28799. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28800. /**
  28801. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28802. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28803. * @param name defines the name of the mesh to create
  28804. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28805. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28806. * @param closePath creates a seam between the first and the last points of each path of the path array
  28807. * @param offset is taken in account only if the `pathArray` is containing a single path
  28808. * @param scene defines the hosting scene
  28809. * @param updatable defines if the mesh must be flagged as updatable
  28810. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28811. * @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)
  28812. * @returns a new Mesh
  28813. */
  28814. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28815. /**
  28816. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28817. * @param name defines the name of the mesh to create
  28818. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28819. * @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
  28820. * @param scene defines the hosting scene
  28821. * @param updatable defines if the mesh must be flagged as updatable
  28822. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28823. * @returns a new Mesh
  28824. */
  28825. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28826. /**
  28827. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28828. * @param name defines the name of the mesh to create
  28829. * @param size sets the size (float) of each box side (default 1)
  28830. * @param scene defines the hosting scene
  28831. * @param updatable defines if the mesh must be flagged as updatable
  28832. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28833. * @returns a new Mesh
  28834. */
  28835. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28836. /**
  28837. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28838. * @param name defines the name of the mesh to create
  28839. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28840. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28841. * @param scene defines the hosting scene
  28842. * @param updatable defines if the mesh must be flagged as updatable
  28843. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28844. * @returns a new Mesh
  28845. */
  28846. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28847. /**
  28848. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28849. * @param name defines the name of the mesh to create
  28850. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28851. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28852. * @param scene defines the hosting scene
  28853. * @returns a new Mesh
  28854. */
  28855. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28856. /**
  28857. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28858. * @param name defines the name of the mesh to create
  28859. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28860. * @param diameterTop set the top cap diameter (floats, default 1)
  28861. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28862. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28863. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28864. * @param scene defines the hosting scene
  28865. * @param updatable defines if the mesh must be flagged as updatable
  28866. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28867. * @returns a new Mesh
  28868. */
  28869. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28870. /**
  28871. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28872. * @param name defines the name of the mesh to create
  28873. * @param diameter sets the diameter size (float) of the torus (default 1)
  28874. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28875. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28876. * @param scene defines the hosting scene
  28877. * @param updatable defines if the mesh must be flagged as updatable
  28878. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28879. * @returns a new Mesh
  28880. */
  28881. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28882. /**
  28883. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28884. * @param name defines the name of the mesh to create
  28885. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28886. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28887. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28888. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28889. * @param p the number of windings on X axis (positive integers, default 2)
  28890. * @param q the number of windings on Y axis (positive integers, default 3)
  28891. * @param scene defines the hosting scene
  28892. * @param updatable defines if the mesh must be flagged as updatable
  28893. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28894. * @returns a new Mesh
  28895. */
  28896. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28897. /**
  28898. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28899. * @param name defines the name of the mesh to create
  28900. * @param points is an array successive Vector3
  28901. * @param scene defines the hosting scene
  28902. * @param updatable defines if the mesh must be flagged as updatable
  28903. * @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).
  28904. * @returns a new Mesh
  28905. */
  28906. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28907. /**
  28908. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28909. * @param name defines the name of the mesh to create
  28910. * @param points is an array successive Vector3
  28911. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28912. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28913. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28914. * @param scene defines the hosting scene
  28915. * @param updatable defines if the mesh must be flagged as updatable
  28916. * @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)
  28917. * @returns a new Mesh
  28918. */
  28919. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28920. /**
  28921. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28922. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28923. * 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.
  28924. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28925. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28926. * Remember you can only change the shape positions, not their number when updating a polygon.
  28927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28928. * @param name defines the name of the mesh to create
  28929. * @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
  28930. * @param scene defines the hosting scene
  28931. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28932. * @param updatable defines if the mesh must be flagged as updatable
  28933. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28934. * @param earcutInjection can be used to inject your own earcut reference
  28935. * @returns a new Mesh
  28936. */
  28937. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28938. /**
  28939. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28941. * @param name defines the name of the mesh to create
  28942. * @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
  28943. * @param depth defines the height of extrusion
  28944. * @param scene defines the hosting scene
  28945. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28946. * @param updatable defines if the mesh must be flagged as updatable
  28947. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28948. * @param earcutInjection can be used to inject your own earcut reference
  28949. * @returns a new Mesh
  28950. */
  28951. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28952. /**
  28953. * Creates an extruded shape mesh.
  28954. * 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
  28955. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28957. * @param name defines the name of the mesh to create
  28958. * @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
  28959. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28960. * @param scale is the value to scale the shape
  28961. * @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
  28962. * @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
  28963. * @param scene defines the hosting scene
  28964. * @param updatable defines if the mesh must be flagged as updatable
  28965. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28966. * @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)
  28967. * @returns a new Mesh
  28968. */
  28969. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28970. /**
  28971. * Creates an custom extruded shape mesh.
  28972. * The custom extrusion is a parametric shape.
  28973. * It has no predefined shape. Its final shape will depend on the input parameters.
  28974. * Please consider using the same method from the MeshBuilder class instead
  28975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28976. * @param name defines the name of the mesh to create
  28977. * @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
  28978. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28979. * @param scaleFunction is a custom Javascript function called on each path point
  28980. * @param rotationFunction is a custom Javascript function called on each path point
  28981. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28982. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28983. * @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
  28984. * @param scene defines the hosting scene
  28985. * @param updatable defines if the mesh must be flagged as updatable
  28986. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28987. * @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)
  28988. * @returns a new Mesh
  28989. */
  28990. 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;
  28991. /**
  28992. * Creates lathe mesh.
  28993. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28994. * Please consider using the same method from the MeshBuilder class instead
  28995. * @param name defines the name of the mesh to create
  28996. * @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
  28997. * @param radius is the radius value of the lathe
  28998. * @param tessellation is the side number of the lathe.
  28999. * @param scene defines the hosting scene
  29000. * @param updatable defines if the mesh must be flagged as updatable
  29001. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29002. * @returns a new Mesh
  29003. */
  29004. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29005. /**
  29006. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29007. * @param name defines the name of the mesh to create
  29008. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29009. * @param scene defines the hosting scene
  29010. * @param updatable defines if the mesh must be flagged as updatable
  29011. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29012. * @returns a new Mesh
  29013. */
  29014. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29015. /**
  29016. * Creates a ground mesh.
  29017. * Please consider using the same method from the MeshBuilder class instead
  29018. * @param name defines the name of the mesh to create
  29019. * @param width set the width of the ground
  29020. * @param height set the height of the ground
  29021. * @param subdivisions sets the number of subdivisions per side
  29022. * @param scene defines the hosting scene
  29023. * @param updatable defines if the mesh must be flagged as updatable
  29024. * @returns a new Mesh
  29025. */
  29026. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29027. /**
  29028. * Creates a tiled ground mesh.
  29029. * Please consider using the same method from the MeshBuilder class instead
  29030. * @param name defines the name of the mesh to create
  29031. * @param xmin set the ground minimum X coordinate
  29032. * @param zmin set the ground minimum Y coordinate
  29033. * @param xmax set the ground maximum X coordinate
  29034. * @param zmax set the ground maximum Z coordinate
  29035. * @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
  29036. * @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
  29037. * @param scene defines the hosting scene
  29038. * @param updatable defines if the mesh must be flagged as updatable
  29039. * @returns a new Mesh
  29040. */
  29041. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29042. w: number;
  29043. h: number;
  29044. }, precision: {
  29045. w: number;
  29046. h: number;
  29047. }, scene: Scene, updatable?: boolean): Mesh;
  29048. /**
  29049. * Creates a ground mesh from a height map.
  29050. * Please consider using the same method from the MeshBuilder class instead
  29051. * @see https://doc.babylonjs.com/babylon101/height_map
  29052. * @param name defines the name of the mesh to create
  29053. * @param url sets the URL of the height map image resource
  29054. * @param width set the ground width size
  29055. * @param height set the ground height size
  29056. * @param subdivisions sets the number of subdivision per side
  29057. * @param minHeight is the minimum altitude on the ground
  29058. * @param maxHeight is the maximum altitude on the ground
  29059. * @param scene defines the hosting scene
  29060. * @param updatable defines if the mesh must be flagged as updatable
  29061. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29062. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29063. * @returns a new Mesh
  29064. */
  29065. 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;
  29066. /**
  29067. * Creates a tube mesh.
  29068. * The tube is a parametric shape.
  29069. * It has no predefined shape. Its final shape will depend on the input parameters.
  29070. * Please consider using the same method from the MeshBuilder class instead
  29071. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29072. * @param name defines the name of the mesh to create
  29073. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29074. * @param radius sets the tube radius size
  29075. * @param tessellation is the number of sides on the tubular surface
  29076. * @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
  29077. * @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
  29078. * @param scene defines the hosting scene
  29079. * @param updatable defines if the mesh must be flagged as updatable
  29080. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29081. * @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)
  29082. * @returns a new Mesh
  29083. */
  29084. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29085. (i: number, distance: number): number;
  29086. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29087. /**
  29088. * Creates a polyhedron mesh.
  29089. * Please consider using the same method from the MeshBuilder class instead.
  29090. * * 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
  29091. * * The parameter `size` (positive float, default 1) sets the polygon size
  29092. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29093. * * 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`
  29094. * * 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
  29095. * * 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)`)
  29096. * * 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
  29097. * * 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
  29098. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29099. * * 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
  29100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29101. * @param name defines the name of the mesh to create
  29102. * @param options defines the options used to create the mesh
  29103. * @param scene defines the hosting scene
  29104. * @returns a new Mesh
  29105. */
  29106. static CreatePolyhedron(name: string, options: {
  29107. type?: number;
  29108. size?: number;
  29109. sizeX?: number;
  29110. sizeY?: number;
  29111. sizeZ?: number;
  29112. custom?: any;
  29113. faceUV?: Vector4[];
  29114. faceColors?: Color4[];
  29115. updatable?: boolean;
  29116. sideOrientation?: number;
  29117. }, scene: Scene): Mesh;
  29118. /**
  29119. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29120. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29121. * * 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`)
  29122. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29123. * * 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
  29124. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29125. * * 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
  29126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29127. * @param name defines the name of the mesh
  29128. * @param options defines the options used to create the mesh
  29129. * @param scene defines the hosting scene
  29130. * @returns a new Mesh
  29131. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29132. */
  29133. static CreateIcoSphere(name: string, options: {
  29134. radius?: number;
  29135. flat?: boolean;
  29136. subdivisions?: number;
  29137. sideOrientation?: number;
  29138. updatable?: boolean;
  29139. }, scene: Scene): Mesh;
  29140. /**
  29141. * Creates a decal mesh.
  29142. * Please consider using the same method from the MeshBuilder class instead.
  29143. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29144. * @param name defines the name of the mesh
  29145. * @param sourceMesh defines the mesh receiving the decal
  29146. * @param position sets the position of the decal in world coordinates
  29147. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29148. * @param size sets the decal scaling
  29149. * @param angle sets the angle to rotate the decal
  29150. * @returns a new Mesh
  29151. */
  29152. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29153. /**
  29154. * Prepare internal position array for software CPU skinning
  29155. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29156. */
  29157. setPositionsForCPUSkinning(): Float32Array;
  29158. /**
  29159. * Prepare internal normal array for software CPU skinning
  29160. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29161. */
  29162. setNormalsForCPUSkinning(): Float32Array;
  29163. /**
  29164. * Updates the vertex buffer by applying transformation from the bones
  29165. * @param skeleton defines the skeleton to apply to current mesh
  29166. * @returns the current mesh
  29167. */
  29168. applySkeleton(skeleton: Skeleton): Mesh;
  29169. /**
  29170. * 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
  29171. * @param meshes defines the list of meshes to scan
  29172. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29173. */
  29174. static MinMax(meshes: AbstractMesh[]): {
  29175. min: Vector3;
  29176. max: Vector3;
  29177. };
  29178. /**
  29179. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29180. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29181. * @returns a vector3
  29182. */
  29183. static Center(meshesOrMinMaxVector: {
  29184. min: Vector3;
  29185. max: Vector3;
  29186. } | AbstractMesh[]): Vector3;
  29187. /**
  29188. * Merge the array of meshes into a single mesh for performance reasons.
  29189. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29190. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29191. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29192. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29193. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29194. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29195. * @returns a new mesh
  29196. */
  29197. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29198. /** @hidden */
  29199. addInstance(instance: InstancedMesh): void;
  29200. /** @hidden */
  29201. removeInstance(instance: InstancedMesh): void;
  29202. }
  29203. }
  29204. declare module BABYLON {
  29205. /**
  29206. * This is the base class of all the camera used in the application.
  29207. * @see https://doc.babylonjs.com/features/cameras
  29208. */
  29209. export class Camera extends Node {
  29210. /** @hidden */
  29211. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29212. /**
  29213. * This is the default projection mode used by the cameras.
  29214. * It helps recreating a feeling of perspective and better appreciate depth.
  29215. * This is the best way to simulate real life cameras.
  29216. */
  29217. static readonly PERSPECTIVE_CAMERA: number;
  29218. /**
  29219. * This helps creating camera with an orthographic mode.
  29220. * 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.
  29221. */
  29222. static readonly ORTHOGRAPHIC_CAMERA: number;
  29223. /**
  29224. * This is the default FOV mode for perspective cameras.
  29225. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29226. */
  29227. static readonly FOVMODE_VERTICAL_FIXED: number;
  29228. /**
  29229. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29230. */
  29231. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29232. /**
  29233. * This specifies ther is no need for a camera rig.
  29234. * Basically only one eye is rendered corresponding to the camera.
  29235. */
  29236. static readonly RIG_MODE_NONE: number;
  29237. /**
  29238. * Simulates a camera Rig with one blue eye and one red eye.
  29239. * This can be use with 3d blue and red glasses.
  29240. */
  29241. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29242. /**
  29243. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29244. */
  29245. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29246. /**
  29247. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29248. */
  29249. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29250. /**
  29251. * Defines that both eyes of the camera will be rendered over under each other.
  29252. */
  29253. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29254. /**
  29255. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29256. */
  29257. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29258. /**
  29259. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29260. */
  29261. static readonly RIG_MODE_VR: number;
  29262. /**
  29263. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29264. */
  29265. static readonly RIG_MODE_WEBVR: number;
  29266. /**
  29267. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29268. */
  29269. static readonly RIG_MODE_CUSTOM: number;
  29270. /**
  29271. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29272. */
  29273. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29274. /**
  29275. * Define the input manager associated with the camera.
  29276. */
  29277. inputs: CameraInputsManager<Camera>;
  29278. /** @hidden */
  29279. _position: Vector3;
  29280. /**
  29281. * Define the current local position of the camera in the scene
  29282. */
  29283. get position(): Vector3;
  29284. set position(newPosition: Vector3);
  29285. /**
  29286. * The vector the camera should consider as up.
  29287. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29288. */
  29289. upVector: Vector3;
  29290. /**
  29291. * Define the current limit on the left side for an orthographic camera
  29292. * In scene unit
  29293. */
  29294. orthoLeft: Nullable<number>;
  29295. /**
  29296. * Define the current limit on the right side for an orthographic camera
  29297. * In scene unit
  29298. */
  29299. orthoRight: Nullable<number>;
  29300. /**
  29301. * Define the current limit on the bottom side for an orthographic camera
  29302. * In scene unit
  29303. */
  29304. orthoBottom: Nullable<number>;
  29305. /**
  29306. * Define the current limit on the top side for an orthographic camera
  29307. * In scene unit
  29308. */
  29309. orthoTop: Nullable<number>;
  29310. /**
  29311. * Field Of View is set in Radians. (default is 0.8)
  29312. */
  29313. fov: number;
  29314. /**
  29315. * Define the minimum distance the camera can see from.
  29316. * This is important to note that the depth buffer are not infinite and the closer it starts
  29317. * the more your scene might encounter depth fighting issue.
  29318. */
  29319. minZ: number;
  29320. /**
  29321. * Define the maximum distance the camera can see to.
  29322. * This is important to note that the depth buffer are not infinite and the further it end
  29323. * the more your scene might encounter depth fighting issue.
  29324. */
  29325. maxZ: number;
  29326. /**
  29327. * Define the default inertia of the camera.
  29328. * This helps giving a smooth feeling to the camera movement.
  29329. */
  29330. inertia: number;
  29331. /**
  29332. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29333. */
  29334. mode: number;
  29335. /**
  29336. * Define whether the camera is intermediate.
  29337. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29338. */
  29339. isIntermediate: boolean;
  29340. /**
  29341. * Define the viewport of the camera.
  29342. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29343. */
  29344. viewport: Viewport;
  29345. /**
  29346. * Restricts the camera to viewing objects with the same layerMask.
  29347. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29348. */
  29349. layerMask: number;
  29350. /**
  29351. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29352. */
  29353. fovMode: number;
  29354. /**
  29355. * Rig mode of the camera.
  29356. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29357. * This is normally controlled byt the camera themselves as internal use.
  29358. */
  29359. cameraRigMode: number;
  29360. /**
  29361. * Defines the distance between both "eyes" in case of a RIG
  29362. */
  29363. interaxialDistance: number;
  29364. /**
  29365. * Defines if stereoscopic rendering is done side by side or over under.
  29366. */
  29367. isStereoscopicSideBySide: boolean;
  29368. /**
  29369. * 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
  29370. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29371. * else in the scene. (Eg. security camera)
  29372. *
  29373. * 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)
  29374. */
  29375. customRenderTargets: RenderTargetTexture[];
  29376. /**
  29377. * When set, the camera will render to this render target instead of the default canvas
  29378. *
  29379. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29380. */
  29381. outputRenderTarget: Nullable<RenderTargetTexture>;
  29382. /**
  29383. * Observable triggered when the camera view matrix has changed.
  29384. */
  29385. onViewMatrixChangedObservable: Observable<Camera>;
  29386. /**
  29387. * Observable triggered when the camera Projection matrix has changed.
  29388. */
  29389. onProjectionMatrixChangedObservable: Observable<Camera>;
  29390. /**
  29391. * Observable triggered when the inputs have been processed.
  29392. */
  29393. onAfterCheckInputsObservable: Observable<Camera>;
  29394. /**
  29395. * Observable triggered when reset has been called and applied to the camera.
  29396. */
  29397. onRestoreStateObservable: Observable<Camera>;
  29398. /**
  29399. * Is this camera a part of a rig system?
  29400. */
  29401. isRigCamera: boolean;
  29402. /**
  29403. * If isRigCamera set to true this will be set with the parent camera.
  29404. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29405. */
  29406. rigParent?: Camera;
  29407. /** @hidden */
  29408. _cameraRigParams: any;
  29409. /** @hidden */
  29410. _rigCameras: Camera[];
  29411. /** @hidden */
  29412. _rigPostProcess: Nullable<PostProcess>;
  29413. protected _webvrViewMatrix: Matrix;
  29414. /** @hidden */
  29415. _skipRendering: boolean;
  29416. /** @hidden */
  29417. _projectionMatrix: Matrix;
  29418. /** @hidden */
  29419. _postProcesses: Nullable<PostProcess>[];
  29420. /** @hidden */
  29421. _activeMeshes: SmartArray<AbstractMesh>;
  29422. protected _globalPosition: Vector3;
  29423. /** @hidden */
  29424. _computedViewMatrix: Matrix;
  29425. private _doNotComputeProjectionMatrix;
  29426. private _transformMatrix;
  29427. private _frustumPlanes;
  29428. private _refreshFrustumPlanes;
  29429. private _storedFov;
  29430. private _stateStored;
  29431. /**
  29432. * Instantiates a new camera object.
  29433. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29434. * @see https://doc.babylonjs.com/features/cameras
  29435. * @param name Defines the name of the camera in the scene
  29436. * @param position Defines the position of the camera
  29437. * @param scene Defines the scene the camera belongs too
  29438. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29439. */
  29440. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29441. /**
  29442. * Store current camera state (fov, position, etc..)
  29443. * @returns the camera
  29444. */
  29445. storeState(): Camera;
  29446. /**
  29447. * Restores the camera state values if it has been stored. You must call storeState() first
  29448. */
  29449. protected _restoreStateValues(): boolean;
  29450. /**
  29451. * Restored camera state. You must call storeState() first.
  29452. * @returns true if restored and false otherwise
  29453. */
  29454. restoreState(): boolean;
  29455. /**
  29456. * Gets the class name of the camera.
  29457. * @returns the class name
  29458. */
  29459. getClassName(): string;
  29460. /** @hidden */
  29461. readonly _isCamera: boolean;
  29462. /**
  29463. * Gets a string representation of the camera useful for debug purpose.
  29464. * @param fullDetails Defines that a more verboe level of logging is required
  29465. * @returns the string representation
  29466. */
  29467. toString(fullDetails?: boolean): string;
  29468. /**
  29469. * Gets the current world space position of the camera.
  29470. */
  29471. get globalPosition(): Vector3;
  29472. /**
  29473. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29474. * @returns the active meshe list
  29475. */
  29476. getActiveMeshes(): SmartArray<AbstractMesh>;
  29477. /**
  29478. * Check whether a mesh is part of the current active mesh list of the camera
  29479. * @param mesh Defines the mesh to check
  29480. * @returns true if active, false otherwise
  29481. */
  29482. isActiveMesh(mesh: Mesh): boolean;
  29483. /**
  29484. * Is this camera ready to be used/rendered
  29485. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29486. * @return true if the camera is ready
  29487. */
  29488. isReady(completeCheck?: boolean): boolean;
  29489. /** @hidden */
  29490. _initCache(): void;
  29491. /** @hidden */
  29492. _updateCache(ignoreParentClass?: boolean): void;
  29493. /** @hidden */
  29494. _isSynchronized(): boolean;
  29495. /** @hidden */
  29496. _isSynchronizedViewMatrix(): boolean;
  29497. /** @hidden */
  29498. _isSynchronizedProjectionMatrix(): boolean;
  29499. /**
  29500. * Attach the input controls to a specific dom element to get the input from.
  29501. * @param element Defines the element the controls should be listened from
  29502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29503. */
  29504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29505. /**
  29506. * Detach the current controls from the specified dom element.
  29507. * @param element Defines the element to stop listening the inputs from
  29508. */
  29509. detachControl(element: HTMLElement): void;
  29510. /**
  29511. * Update the camera state according to the different inputs gathered during the frame.
  29512. */
  29513. update(): void;
  29514. /** @hidden */
  29515. _checkInputs(): void;
  29516. /** @hidden */
  29517. get rigCameras(): Camera[];
  29518. /**
  29519. * Gets the post process used by the rig cameras
  29520. */
  29521. get rigPostProcess(): Nullable<PostProcess>;
  29522. /**
  29523. * Internal, gets the first post proces.
  29524. * @returns the first post process to be run on this camera.
  29525. */
  29526. _getFirstPostProcess(): Nullable<PostProcess>;
  29527. private _cascadePostProcessesToRigCams;
  29528. /**
  29529. * Attach a post process to the camera.
  29530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29531. * @param postProcess The post process to attach to the camera
  29532. * @param insertAt The position of the post process in case several of them are in use in the scene
  29533. * @returns the position the post process has been inserted at
  29534. */
  29535. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29536. /**
  29537. * Detach a post process to the camera.
  29538. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29539. * @param postProcess The post process to detach from the camera
  29540. */
  29541. detachPostProcess(postProcess: PostProcess): void;
  29542. /**
  29543. * Gets the current world matrix of the camera
  29544. */
  29545. getWorldMatrix(): Matrix;
  29546. /** @hidden */
  29547. _getViewMatrix(): Matrix;
  29548. /**
  29549. * Gets the current view matrix of the camera.
  29550. * @param force forces the camera to recompute the matrix without looking at the cached state
  29551. * @returns the view matrix
  29552. */
  29553. getViewMatrix(force?: boolean): Matrix;
  29554. /**
  29555. * Freeze the projection matrix.
  29556. * It will prevent the cache check of the camera projection compute and can speed up perf
  29557. * if no parameter of the camera are meant to change
  29558. * @param projection Defines manually a projection if necessary
  29559. */
  29560. freezeProjectionMatrix(projection?: Matrix): void;
  29561. /**
  29562. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29563. */
  29564. unfreezeProjectionMatrix(): void;
  29565. /**
  29566. * Gets the current projection matrix of the camera.
  29567. * @param force forces the camera to recompute the matrix without looking at the cached state
  29568. * @returns the projection matrix
  29569. */
  29570. getProjectionMatrix(force?: boolean): Matrix;
  29571. /**
  29572. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29573. * @returns a Matrix
  29574. */
  29575. getTransformationMatrix(): Matrix;
  29576. private _updateFrustumPlanes;
  29577. /**
  29578. * Checks if a cullable object (mesh...) is in the camera frustum
  29579. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29580. * @param target The object to check
  29581. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29582. * @returns true if the object is in frustum otherwise false
  29583. */
  29584. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29585. /**
  29586. * Checks if a cullable object (mesh...) is in the camera frustum
  29587. * Unlike isInFrustum this cheks the full bounding box
  29588. * @param target The object to check
  29589. * @returns true if the object is in frustum otherwise false
  29590. */
  29591. isCompletelyInFrustum(target: ICullable): boolean;
  29592. /**
  29593. * Gets a ray in the forward direction from the camera.
  29594. * @param length Defines the length of the ray to create
  29595. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29596. * @param origin Defines the start point of the ray which defaults to the camera position
  29597. * @returns the forward ray
  29598. */
  29599. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29600. /**
  29601. * Gets a ray in the forward direction from the camera.
  29602. * @param refRay the ray to (re)use when setting the values
  29603. * @param length Defines the length of the ray to create
  29604. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29605. * @param origin Defines the start point of the ray which defaults to the camera position
  29606. * @returns the forward ray
  29607. */
  29608. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29609. /**
  29610. * Releases resources associated with this node.
  29611. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29612. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29613. */
  29614. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29615. /** @hidden */
  29616. _isLeftCamera: boolean;
  29617. /**
  29618. * Gets the left camera of a rig setup in case of Rigged Camera
  29619. */
  29620. get isLeftCamera(): boolean;
  29621. /** @hidden */
  29622. _isRightCamera: boolean;
  29623. /**
  29624. * Gets the right camera of a rig setup in case of Rigged Camera
  29625. */
  29626. get isRightCamera(): boolean;
  29627. /**
  29628. * Gets the left camera of a rig setup in case of Rigged Camera
  29629. */
  29630. get leftCamera(): Nullable<FreeCamera>;
  29631. /**
  29632. * Gets the right camera of a rig setup in case of Rigged Camera
  29633. */
  29634. get rightCamera(): Nullable<FreeCamera>;
  29635. /**
  29636. * Gets the left camera target of a rig setup in case of Rigged Camera
  29637. * @returns the target position
  29638. */
  29639. getLeftTarget(): Nullable<Vector3>;
  29640. /**
  29641. * Gets the right camera target of a rig setup in case of Rigged Camera
  29642. * @returns the target position
  29643. */
  29644. getRightTarget(): Nullable<Vector3>;
  29645. /**
  29646. * @hidden
  29647. */
  29648. setCameraRigMode(mode: number, rigParams: any): void;
  29649. /** @hidden */
  29650. static _setStereoscopicRigMode(camera: Camera): void;
  29651. /** @hidden */
  29652. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29653. /** @hidden */
  29654. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29655. /** @hidden */
  29656. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29657. /** @hidden */
  29658. _getVRProjectionMatrix(): Matrix;
  29659. protected _updateCameraRotationMatrix(): void;
  29660. protected _updateWebVRCameraRotationMatrix(): void;
  29661. /**
  29662. * This function MUST be overwritten by the different WebVR cameras available.
  29663. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29664. * @hidden
  29665. */
  29666. _getWebVRProjectionMatrix(): Matrix;
  29667. /**
  29668. * This function MUST be overwritten by the different WebVR cameras available.
  29669. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29670. * @hidden
  29671. */
  29672. _getWebVRViewMatrix(): Matrix;
  29673. /** @hidden */
  29674. setCameraRigParameter(name: string, value: any): void;
  29675. /**
  29676. * needs to be overridden by children so sub has required properties to be copied
  29677. * @hidden
  29678. */
  29679. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29680. /**
  29681. * May need to be overridden by children
  29682. * @hidden
  29683. */
  29684. _updateRigCameras(): void;
  29685. /** @hidden */
  29686. _setupInputs(): void;
  29687. /**
  29688. * Serialiaze the camera setup to a json represention
  29689. * @returns the JSON representation
  29690. */
  29691. serialize(): any;
  29692. /**
  29693. * Clones the current camera.
  29694. * @param name The cloned camera name
  29695. * @returns the cloned camera
  29696. */
  29697. clone(name: string): Camera;
  29698. /**
  29699. * Gets the direction of the camera relative to a given local axis.
  29700. * @param localAxis Defines the reference axis to provide a relative direction.
  29701. * @return the direction
  29702. */
  29703. getDirection(localAxis: Vector3): Vector3;
  29704. /**
  29705. * Returns the current camera absolute rotation
  29706. */
  29707. get absoluteRotation(): Quaternion;
  29708. /**
  29709. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29710. * @param localAxis Defines the reference axis to provide a relative direction.
  29711. * @param result Defines the vector to store the result in
  29712. */
  29713. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29714. /**
  29715. * Gets a camera constructor for a given camera type
  29716. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29717. * @param name The name of the camera the result will be able to instantiate
  29718. * @param scene The scene the result will construct the camera in
  29719. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29720. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29721. * @returns a factory method to construc the camera
  29722. */
  29723. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29724. /**
  29725. * Compute the world matrix of the camera.
  29726. * @returns the camera world matrix
  29727. */
  29728. computeWorldMatrix(): Matrix;
  29729. /**
  29730. * Parse a JSON and creates the camera from the parsed information
  29731. * @param parsedCamera The JSON to parse
  29732. * @param scene The scene to instantiate the camera in
  29733. * @returns the newly constructed camera
  29734. */
  29735. static Parse(parsedCamera: any, scene: Scene): Camera;
  29736. }
  29737. }
  29738. declare module BABYLON {
  29739. /**
  29740. * Class containing static functions to help procedurally build meshes
  29741. */
  29742. export class DiscBuilder {
  29743. /**
  29744. * Creates a plane polygonal mesh. By default, this is a disc
  29745. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29746. * * 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
  29747. * * 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
  29748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29749. * * 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
  29750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29751. * @param name defines the name of the mesh
  29752. * @param options defines the options used to create the mesh
  29753. * @param scene defines the hosting scene
  29754. * @returns the plane polygonal mesh
  29755. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29756. */
  29757. static CreateDisc(name: string, options: {
  29758. radius?: number;
  29759. tessellation?: number;
  29760. arc?: number;
  29761. updatable?: boolean;
  29762. sideOrientation?: number;
  29763. frontUVs?: Vector4;
  29764. backUVs?: Vector4;
  29765. }, scene?: Nullable<Scene>): Mesh;
  29766. }
  29767. }
  29768. declare module BABYLON {
  29769. /**
  29770. * Options to be used when creating a FresnelParameters.
  29771. */
  29772. export type IFresnelParametersCreationOptions = {
  29773. /**
  29774. * Define the color used on edges (grazing angle)
  29775. */
  29776. leftColor?: Color3;
  29777. /**
  29778. * Define the color used on center
  29779. */
  29780. rightColor?: Color3;
  29781. /**
  29782. * Define bias applied to computed fresnel term
  29783. */
  29784. bias?: number;
  29785. /**
  29786. * Defined the power exponent applied to fresnel term
  29787. */
  29788. power?: number;
  29789. /**
  29790. * Define if the fresnel effect is enable or not.
  29791. */
  29792. isEnabled?: boolean;
  29793. };
  29794. /**
  29795. * Serialized format for FresnelParameters.
  29796. */
  29797. export type IFresnelParametersSerialized = {
  29798. /**
  29799. * Define the color used on edges (grazing angle) [as an array]
  29800. */
  29801. leftColor: number[];
  29802. /**
  29803. * Define the color used on center [as an array]
  29804. */
  29805. rightColor: number[];
  29806. /**
  29807. * Define bias applied to computed fresnel term
  29808. */
  29809. bias: number;
  29810. /**
  29811. * Defined the power exponent applied to fresnel term
  29812. */
  29813. power?: number;
  29814. /**
  29815. * Define if the fresnel effect is enable or not.
  29816. */
  29817. isEnabled: boolean;
  29818. };
  29819. /**
  29820. * This represents all the required information to add a fresnel effect on a material:
  29821. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29822. */
  29823. export class FresnelParameters {
  29824. private _isEnabled;
  29825. /**
  29826. * Define if the fresnel effect is enable or not.
  29827. */
  29828. get isEnabled(): boolean;
  29829. set isEnabled(value: boolean);
  29830. /**
  29831. * Define the color used on edges (grazing angle)
  29832. */
  29833. leftColor: Color3;
  29834. /**
  29835. * Define the color used on center
  29836. */
  29837. rightColor: Color3;
  29838. /**
  29839. * Define bias applied to computed fresnel term
  29840. */
  29841. bias: number;
  29842. /**
  29843. * Defined the power exponent applied to fresnel term
  29844. */
  29845. power: number;
  29846. /**
  29847. * Creates a new FresnelParameters object.
  29848. *
  29849. * @param options provide your own settings to optionally to override defaults
  29850. */
  29851. constructor(options?: IFresnelParametersCreationOptions);
  29852. /**
  29853. * Clones the current fresnel and its valuues
  29854. * @returns a clone fresnel configuration
  29855. */
  29856. clone(): FresnelParameters;
  29857. /**
  29858. * Determines equality between FresnelParameters objects
  29859. * @param otherFresnelParameters defines the second operand
  29860. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29861. */
  29862. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29863. /**
  29864. * Serializes the current fresnel parameters to a JSON representation.
  29865. * @return the JSON serialization
  29866. */
  29867. serialize(): IFresnelParametersSerialized;
  29868. /**
  29869. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29870. * @param parsedFresnelParameters Define the JSON representation
  29871. * @returns the parsed parameters
  29872. */
  29873. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29874. }
  29875. }
  29876. declare module BABYLON {
  29877. /**
  29878. * This groups all the flags used to control the materials channel.
  29879. */
  29880. export class MaterialFlags {
  29881. private static _DiffuseTextureEnabled;
  29882. /**
  29883. * Are diffuse textures enabled in the application.
  29884. */
  29885. static get DiffuseTextureEnabled(): boolean;
  29886. static set DiffuseTextureEnabled(value: boolean);
  29887. private static _DetailTextureEnabled;
  29888. /**
  29889. * Are detail textures enabled in the application.
  29890. */
  29891. static get DetailTextureEnabled(): boolean;
  29892. static set DetailTextureEnabled(value: boolean);
  29893. private static _AmbientTextureEnabled;
  29894. /**
  29895. * Are ambient textures enabled in the application.
  29896. */
  29897. static get AmbientTextureEnabled(): boolean;
  29898. static set AmbientTextureEnabled(value: boolean);
  29899. private static _OpacityTextureEnabled;
  29900. /**
  29901. * Are opacity textures enabled in the application.
  29902. */
  29903. static get OpacityTextureEnabled(): boolean;
  29904. static set OpacityTextureEnabled(value: boolean);
  29905. private static _ReflectionTextureEnabled;
  29906. /**
  29907. * Are reflection textures enabled in the application.
  29908. */
  29909. static get ReflectionTextureEnabled(): boolean;
  29910. static set ReflectionTextureEnabled(value: boolean);
  29911. private static _EmissiveTextureEnabled;
  29912. /**
  29913. * Are emissive textures enabled in the application.
  29914. */
  29915. static get EmissiveTextureEnabled(): boolean;
  29916. static set EmissiveTextureEnabled(value: boolean);
  29917. private static _SpecularTextureEnabled;
  29918. /**
  29919. * Are specular textures enabled in the application.
  29920. */
  29921. static get SpecularTextureEnabled(): boolean;
  29922. static set SpecularTextureEnabled(value: boolean);
  29923. private static _BumpTextureEnabled;
  29924. /**
  29925. * Are bump textures enabled in the application.
  29926. */
  29927. static get BumpTextureEnabled(): boolean;
  29928. static set BumpTextureEnabled(value: boolean);
  29929. private static _LightmapTextureEnabled;
  29930. /**
  29931. * Are lightmap textures enabled in the application.
  29932. */
  29933. static get LightmapTextureEnabled(): boolean;
  29934. static set LightmapTextureEnabled(value: boolean);
  29935. private static _RefractionTextureEnabled;
  29936. /**
  29937. * Are refraction textures enabled in the application.
  29938. */
  29939. static get RefractionTextureEnabled(): boolean;
  29940. static set RefractionTextureEnabled(value: boolean);
  29941. private static _ColorGradingTextureEnabled;
  29942. /**
  29943. * Are color grading textures enabled in the application.
  29944. */
  29945. static get ColorGradingTextureEnabled(): boolean;
  29946. static set ColorGradingTextureEnabled(value: boolean);
  29947. private static _FresnelEnabled;
  29948. /**
  29949. * Are fresnels enabled in the application.
  29950. */
  29951. static get FresnelEnabled(): boolean;
  29952. static set FresnelEnabled(value: boolean);
  29953. private static _ClearCoatTextureEnabled;
  29954. /**
  29955. * Are clear coat textures enabled in the application.
  29956. */
  29957. static get ClearCoatTextureEnabled(): boolean;
  29958. static set ClearCoatTextureEnabled(value: boolean);
  29959. private static _ClearCoatBumpTextureEnabled;
  29960. /**
  29961. * Are clear coat bump textures enabled in the application.
  29962. */
  29963. static get ClearCoatBumpTextureEnabled(): boolean;
  29964. static set ClearCoatBumpTextureEnabled(value: boolean);
  29965. private static _ClearCoatTintTextureEnabled;
  29966. /**
  29967. * Are clear coat tint textures enabled in the application.
  29968. */
  29969. static get ClearCoatTintTextureEnabled(): boolean;
  29970. static set ClearCoatTintTextureEnabled(value: boolean);
  29971. private static _SheenTextureEnabled;
  29972. /**
  29973. * Are sheen textures enabled in the application.
  29974. */
  29975. static get SheenTextureEnabled(): boolean;
  29976. static set SheenTextureEnabled(value: boolean);
  29977. private static _AnisotropicTextureEnabled;
  29978. /**
  29979. * Are anisotropic textures enabled in the application.
  29980. */
  29981. static get AnisotropicTextureEnabled(): boolean;
  29982. static set AnisotropicTextureEnabled(value: boolean);
  29983. private static _ThicknessTextureEnabled;
  29984. /**
  29985. * Are thickness textures enabled in the application.
  29986. */
  29987. static get ThicknessTextureEnabled(): boolean;
  29988. static set ThicknessTextureEnabled(value: boolean);
  29989. }
  29990. }
  29991. declare module BABYLON {
  29992. /** @hidden */
  29993. export var defaultFragmentDeclaration: {
  29994. name: string;
  29995. shader: string;
  29996. };
  29997. }
  29998. declare module BABYLON {
  29999. /** @hidden */
  30000. export var defaultUboDeclaration: {
  30001. name: string;
  30002. shader: string;
  30003. };
  30004. }
  30005. declare module BABYLON {
  30006. /** @hidden */
  30007. export var prePassDeclaration: {
  30008. name: string;
  30009. shader: string;
  30010. };
  30011. }
  30012. declare module BABYLON {
  30013. /** @hidden */
  30014. export var lightFragmentDeclaration: {
  30015. name: string;
  30016. shader: string;
  30017. };
  30018. }
  30019. declare module BABYLON {
  30020. /** @hidden */
  30021. export var lightUboDeclaration: {
  30022. name: string;
  30023. shader: string;
  30024. };
  30025. }
  30026. declare module BABYLON {
  30027. /** @hidden */
  30028. export var lightsFragmentFunctions: {
  30029. name: string;
  30030. shader: string;
  30031. };
  30032. }
  30033. declare module BABYLON {
  30034. /** @hidden */
  30035. export var shadowsFragmentFunctions: {
  30036. name: string;
  30037. shader: string;
  30038. };
  30039. }
  30040. declare module BABYLON {
  30041. /** @hidden */
  30042. export var fresnelFunction: {
  30043. name: string;
  30044. shader: string;
  30045. };
  30046. }
  30047. declare module BABYLON {
  30048. /** @hidden */
  30049. export var bumpFragmentMainFunctions: {
  30050. name: string;
  30051. shader: string;
  30052. };
  30053. }
  30054. declare module BABYLON {
  30055. /** @hidden */
  30056. export var bumpFragmentFunctions: {
  30057. name: string;
  30058. shader: string;
  30059. };
  30060. }
  30061. declare module BABYLON {
  30062. /** @hidden */
  30063. export var logDepthDeclaration: {
  30064. name: string;
  30065. shader: string;
  30066. };
  30067. }
  30068. declare module BABYLON {
  30069. /** @hidden */
  30070. export var bumpFragment: {
  30071. name: string;
  30072. shader: string;
  30073. };
  30074. }
  30075. declare module BABYLON {
  30076. /** @hidden */
  30077. export var depthPrePass: {
  30078. name: string;
  30079. shader: string;
  30080. };
  30081. }
  30082. declare module BABYLON {
  30083. /** @hidden */
  30084. export var lightFragment: {
  30085. name: string;
  30086. shader: string;
  30087. };
  30088. }
  30089. declare module BABYLON {
  30090. /** @hidden */
  30091. export var logDepthFragment: {
  30092. name: string;
  30093. shader: string;
  30094. };
  30095. }
  30096. declare module BABYLON {
  30097. /** @hidden */
  30098. export var defaultPixelShader: {
  30099. name: string;
  30100. shader: string;
  30101. };
  30102. }
  30103. declare module BABYLON {
  30104. /** @hidden */
  30105. export var defaultVertexDeclaration: {
  30106. name: string;
  30107. shader: string;
  30108. };
  30109. }
  30110. declare module BABYLON {
  30111. /** @hidden */
  30112. export var bumpVertexDeclaration: {
  30113. name: string;
  30114. shader: string;
  30115. };
  30116. }
  30117. declare module BABYLON {
  30118. /** @hidden */
  30119. export var bumpVertex: {
  30120. name: string;
  30121. shader: string;
  30122. };
  30123. }
  30124. declare module BABYLON {
  30125. /** @hidden */
  30126. export var fogVertex: {
  30127. name: string;
  30128. shader: string;
  30129. };
  30130. }
  30131. declare module BABYLON {
  30132. /** @hidden */
  30133. export var shadowsVertex: {
  30134. name: string;
  30135. shader: string;
  30136. };
  30137. }
  30138. declare module BABYLON {
  30139. /** @hidden */
  30140. export var pointCloudVertex: {
  30141. name: string;
  30142. shader: string;
  30143. };
  30144. }
  30145. declare module BABYLON {
  30146. /** @hidden */
  30147. export var logDepthVertex: {
  30148. name: string;
  30149. shader: string;
  30150. };
  30151. }
  30152. declare module BABYLON {
  30153. /** @hidden */
  30154. export var defaultVertexShader: {
  30155. name: string;
  30156. shader: string;
  30157. };
  30158. }
  30159. declare module BABYLON {
  30160. /**
  30161. * @hidden
  30162. */
  30163. export interface IMaterialDetailMapDefines {
  30164. DETAIL: boolean;
  30165. DETAILDIRECTUV: number;
  30166. DETAIL_NORMALBLENDMETHOD: number;
  30167. /** @hidden */
  30168. _areTexturesDirty: boolean;
  30169. }
  30170. /**
  30171. * Define the code related to the detail map parameters of a material
  30172. *
  30173. * Inspired from:
  30174. * 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
  30175. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30176. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30177. */
  30178. export class DetailMapConfiguration {
  30179. private _texture;
  30180. /**
  30181. * The detail texture of the material.
  30182. */
  30183. texture: Nullable<BaseTexture>;
  30184. /**
  30185. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30186. * Bigger values mean stronger blending
  30187. */
  30188. diffuseBlendLevel: number;
  30189. /**
  30190. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30191. * Bigger values mean stronger blending. Only used with PBR materials
  30192. */
  30193. roughnessBlendLevel: number;
  30194. /**
  30195. * Defines how strong the bump effect from the detail map is
  30196. * Bigger values mean stronger effect
  30197. */
  30198. bumpLevel: number;
  30199. private _normalBlendMethod;
  30200. /**
  30201. * The method used to blend the bump and detail normals together
  30202. */
  30203. normalBlendMethod: number;
  30204. private _isEnabled;
  30205. /**
  30206. * Enable or disable the detail map on this material
  30207. */
  30208. isEnabled: boolean;
  30209. /** @hidden */
  30210. private _internalMarkAllSubMeshesAsTexturesDirty;
  30211. /** @hidden */
  30212. _markAllSubMeshesAsTexturesDirty(): void;
  30213. /**
  30214. * Instantiate a new detail map
  30215. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30216. */
  30217. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30218. /**
  30219. * Gets whether the submesh is ready to be used or not.
  30220. * @param defines the list of "defines" to update.
  30221. * @param scene defines the scene the material belongs to.
  30222. * @returns - boolean indicating that the submesh is ready or not.
  30223. */
  30224. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30225. /**
  30226. * Update the defines for detail map usage
  30227. * @param defines the list of "defines" to update.
  30228. * @param scene defines the scene the material belongs to.
  30229. */
  30230. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30231. /**
  30232. * Binds the material data.
  30233. * @param uniformBuffer defines the Uniform buffer to fill in.
  30234. * @param scene defines the scene the material belongs to.
  30235. * @param isFrozen defines whether the material is frozen or not.
  30236. */
  30237. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30238. /**
  30239. * Checks to see if a texture is used in the material.
  30240. * @param texture - Base texture to use.
  30241. * @returns - Boolean specifying if a texture is used in the material.
  30242. */
  30243. hasTexture(texture: BaseTexture): boolean;
  30244. /**
  30245. * Returns an array of the actively used textures.
  30246. * @param activeTextures Array of BaseTextures
  30247. */
  30248. getActiveTextures(activeTextures: BaseTexture[]): void;
  30249. /**
  30250. * Returns the animatable textures.
  30251. * @param animatables Array of animatable textures.
  30252. */
  30253. getAnimatables(animatables: IAnimatable[]): void;
  30254. /**
  30255. * Disposes the resources of the material.
  30256. * @param forceDisposeTextures - Forces the disposal of all textures.
  30257. */
  30258. dispose(forceDisposeTextures?: boolean): void;
  30259. /**
  30260. * Get the current class name useful for serialization or dynamic coding.
  30261. * @returns "DetailMap"
  30262. */
  30263. getClassName(): string;
  30264. /**
  30265. * Add the required uniforms to the current list.
  30266. * @param uniforms defines the current uniform list.
  30267. */
  30268. static AddUniforms(uniforms: string[]): void;
  30269. /**
  30270. * Add the required samplers to the current list.
  30271. * @param samplers defines the current sampler list.
  30272. */
  30273. static AddSamplers(samplers: string[]): void;
  30274. /**
  30275. * Add the required uniforms to the current buffer.
  30276. * @param uniformBuffer defines the current uniform buffer.
  30277. */
  30278. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30279. /**
  30280. * Makes a duplicate of the current instance into another one.
  30281. * @param detailMap define the instance where to copy the info
  30282. */
  30283. copyTo(detailMap: DetailMapConfiguration): void;
  30284. /**
  30285. * Serializes this detail map instance
  30286. * @returns - An object with the serialized instance.
  30287. */
  30288. serialize(): any;
  30289. /**
  30290. * Parses a detail map setting from a serialized object.
  30291. * @param source - Serialized object.
  30292. * @param scene Defines the scene we are parsing for
  30293. * @param rootUrl Defines the rootUrl to load from
  30294. */
  30295. parse(source: any, scene: Scene, rootUrl: string): void;
  30296. }
  30297. }
  30298. declare module BABYLON {
  30299. /** @hidden */
  30300. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30301. MAINUV1: boolean;
  30302. MAINUV2: boolean;
  30303. DIFFUSE: boolean;
  30304. DIFFUSEDIRECTUV: number;
  30305. DETAIL: boolean;
  30306. DETAILDIRECTUV: number;
  30307. DETAIL_NORMALBLENDMETHOD: number;
  30308. AMBIENT: boolean;
  30309. AMBIENTDIRECTUV: number;
  30310. OPACITY: boolean;
  30311. OPACITYDIRECTUV: number;
  30312. OPACITYRGB: boolean;
  30313. REFLECTION: boolean;
  30314. EMISSIVE: boolean;
  30315. EMISSIVEDIRECTUV: number;
  30316. SPECULAR: boolean;
  30317. SPECULARDIRECTUV: number;
  30318. BUMP: boolean;
  30319. BUMPDIRECTUV: number;
  30320. PARALLAX: boolean;
  30321. PARALLAXOCCLUSION: boolean;
  30322. SPECULAROVERALPHA: boolean;
  30323. CLIPPLANE: boolean;
  30324. CLIPPLANE2: boolean;
  30325. CLIPPLANE3: boolean;
  30326. CLIPPLANE4: boolean;
  30327. CLIPPLANE5: boolean;
  30328. CLIPPLANE6: boolean;
  30329. ALPHATEST: boolean;
  30330. DEPTHPREPASS: boolean;
  30331. ALPHAFROMDIFFUSE: boolean;
  30332. POINTSIZE: boolean;
  30333. FOG: boolean;
  30334. SPECULARTERM: boolean;
  30335. DIFFUSEFRESNEL: boolean;
  30336. OPACITYFRESNEL: boolean;
  30337. REFLECTIONFRESNEL: boolean;
  30338. REFRACTIONFRESNEL: boolean;
  30339. EMISSIVEFRESNEL: boolean;
  30340. FRESNEL: boolean;
  30341. NORMAL: boolean;
  30342. UV1: boolean;
  30343. UV2: boolean;
  30344. VERTEXCOLOR: boolean;
  30345. VERTEXALPHA: boolean;
  30346. NUM_BONE_INFLUENCERS: number;
  30347. BonesPerMesh: number;
  30348. BONETEXTURE: boolean;
  30349. INSTANCES: boolean;
  30350. THIN_INSTANCES: boolean;
  30351. GLOSSINESS: boolean;
  30352. ROUGHNESS: boolean;
  30353. EMISSIVEASILLUMINATION: boolean;
  30354. LINKEMISSIVEWITHDIFFUSE: boolean;
  30355. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30356. LIGHTMAP: boolean;
  30357. LIGHTMAPDIRECTUV: number;
  30358. OBJECTSPACE_NORMALMAP: boolean;
  30359. USELIGHTMAPASSHADOWMAP: boolean;
  30360. REFLECTIONMAP_3D: boolean;
  30361. REFLECTIONMAP_SPHERICAL: boolean;
  30362. REFLECTIONMAP_PLANAR: boolean;
  30363. REFLECTIONMAP_CUBIC: boolean;
  30364. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30365. REFLECTIONMAP_PROJECTION: boolean;
  30366. REFLECTIONMAP_SKYBOX: boolean;
  30367. REFLECTIONMAP_EXPLICIT: boolean;
  30368. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30369. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30370. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30371. INVERTCUBICMAP: boolean;
  30372. LOGARITHMICDEPTH: boolean;
  30373. REFRACTION: boolean;
  30374. REFRACTIONMAP_3D: boolean;
  30375. REFLECTIONOVERALPHA: boolean;
  30376. TWOSIDEDLIGHTING: boolean;
  30377. SHADOWFLOAT: boolean;
  30378. MORPHTARGETS: boolean;
  30379. MORPHTARGETS_NORMAL: boolean;
  30380. MORPHTARGETS_TANGENT: boolean;
  30381. MORPHTARGETS_UV: boolean;
  30382. NUM_MORPH_INFLUENCERS: number;
  30383. NONUNIFORMSCALING: boolean;
  30384. PREMULTIPLYALPHA: boolean;
  30385. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30386. ALPHABLEND: boolean;
  30387. PREPASS: boolean;
  30388. SCENE_MRT_COUNT: number;
  30389. RGBDLIGHTMAP: boolean;
  30390. RGBDREFLECTION: boolean;
  30391. RGBDREFRACTION: boolean;
  30392. IMAGEPROCESSING: boolean;
  30393. VIGNETTE: boolean;
  30394. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30395. VIGNETTEBLENDMODEOPAQUE: boolean;
  30396. TONEMAPPING: boolean;
  30397. TONEMAPPING_ACES: boolean;
  30398. CONTRAST: boolean;
  30399. COLORCURVES: boolean;
  30400. COLORGRADING: boolean;
  30401. COLORGRADING3D: boolean;
  30402. SAMPLER3DGREENDEPTH: boolean;
  30403. SAMPLER3DBGRMAP: boolean;
  30404. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30405. MULTIVIEW: boolean;
  30406. /**
  30407. * If the reflection texture on this material is in linear color space
  30408. * @hidden
  30409. */
  30410. IS_REFLECTION_LINEAR: boolean;
  30411. /**
  30412. * If the refraction texture on this material is in linear color space
  30413. * @hidden
  30414. */
  30415. IS_REFRACTION_LINEAR: boolean;
  30416. EXPOSURE: boolean;
  30417. constructor();
  30418. setReflectionMode(modeToEnable: string): void;
  30419. }
  30420. /**
  30421. * This is the default material used in Babylon. It is the best trade off between quality
  30422. * and performances.
  30423. * @see https://doc.babylonjs.com/babylon101/materials
  30424. */
  30425. export class StandardMaterial extends PushMaterial {
  30426. private _diffuseTexture;
  30427. /**
  30428. * The basic texture of the material as viewed under a light.
  30429. */
  30430. diffuseTexture: Nullable<BaseTexture>;
  30431. private _ambientTexture;
  30432. /**
  30433. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30434. */
  30435. ambientTexture: Nullable<BaseTexture>;
  30436. private _opacityTexture;
  30437. /**
  30438. * Define the transparency of the material from a texture.
  30439. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30440. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30441. */
  30442. opacityTexture: Nullable<BaseTexture>;
  30443. private _reflectionTexture;
  30444. /**
  30445. * Define the texture used to display the reflection.
  30446. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30447. */
  30448. reflectionTexture: Nullable<BaseTexture>;
  30449. private _emissiveTexture;
  30450. /**
  30451. * Define texture of the material as if self lit.
  30452. * This will be mixed in the final result even in the absence of light.
  30453. */
  30454. emissiveTexture: Nullable<BaseTexture>;
  30455. private _specularTexture;
  30456. /**
  30457. * Define how the color and intensity of the highlight given by the light in the material.
  30458. */
  30459. specularTexture: Nullable<BaseTexture>;
  30460. private _bumpTexture;
  30461. /**
  30462. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30463. * 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.
  30464. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30465. */
  30466. bumpTexture: Nullable<BaseTexture>;
  30467. private _lightmapTexture;
  30468. /**
  30469. * Complex lighting can be computationally expensive to compute at runtime.
  30470. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30471. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30472. */
  30473. lightmapTexture: Nullable<BaseTexture>;
  30474. private _refractionTexture;
  30475. /**
  30476. * Define the texture used to display the refraction.
  30477. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30478. */
  30479. refractionTexture: Nullable<BaseTexture>;
  30480. /**
  30481. * The color of the material lit by the environmental background lighting.
  30482. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30483. */
  30484. ambientColor: Color3;
  30485. /**
  30486. * The basic color of the material as viewed under a light.
  30487. */
  30488. diffuseColor: Color3;
  30489. /**
  30490. * Define how the color and intensity of the highlight given by the light in the material.
  30491. */
  30492. specularColor: Color3;
  30493. /**
  30494. * Define the color of the material as if self lit.
  30495. * This will be mixed in the final result even in the absence of light.
  30496. */
  30497. emissiveColor: Color3;
  30498. /**
  30499. * Defines how sharp are the highlights in the material.
  30500. * The bigger the value the sharper giving a more glossy feeling to the result.
  30501. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30502. */
  30503. specularPower: number;
  30504. private _useAlphaFromDiffuseTexture;
  30505. /**
  30506. * Does the transparency come from the diffuse texture alpha channel.
  30507. */
  30508. useAlphaFromDiffuseTexture: boolean;
  30509. private _useEmissiveAsIllumination;
  30510. /**
  30511. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30512. */
  30513. useEmissiveAsIllumination: boolean;
  30514. private _linkEmissiveWithDiffuse;
  30515. /**
  30516. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30517. * the emissive level when the final color is close to one.
  30518. */
  30519. linkEmissiveWithDiffuse: boolean;
  30520. private _useSpecularOverAlpha;
  30521. /**
  30522. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30523. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30524. */
  30525. useSpecularOverAlpha: boolean;
  30526. private _useReflectionOverAlpha;
  30527. /**
  30528. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30529. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30530. */
  30531. useReflectionOverAlpha: boolean;
  30532. private _disableLighting;
  30533. /**
  30534. * Does lights from the scene impacts this material.
  30535. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30536. */
  30537. disableLighting: boolean;
  30538. private _useObjectSpaceNormalMap;
  30539. /**
  30540. * Allows using an object space normal map (instead of tangent space).
  30541. */
  30542. useObjectSpaceNormalMap: boolean;
  30543. private _useParallax;
  30544. /**
  30545. * Is parallax enabled or not.
  30546. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30547. */
  30548. useParallax: boolean;
  30549. private _useParallaxOcclusion;
  30550. /**
  30551. * Is parallax occlusion enabled or not.
  30552. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30553. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30554. */
  30555. useParallaxOcclusion: boolean;
  30556. /**
  30557. * 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.
  30558. */
  30559. parallaxScaleBias: number;
  30560. private _roughness;
  30561. /**
  30562. * Helps to define how blurry the reflections should appears in the material.
  30563. */
  30564. roughness: number;
  30565. /**
  30566. * In case of refraction, define the value of the index of refraction.
  30567. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30568. */
  30569. indexOfRefraction: number;
  30570. /**
  30571. * Invert the refraction texture alongside the y axis.
  30572. * It can be useful with procedural textures or probe for instance.
  30573. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30574. */
  30575. invertRefractionY: boolean;
  30576. /**
  30577. * Defines the alpha limits in alpha test mode.
  30578. */
  30579. alphaCutOff: number;
  30580. private _useLightmapAsShadowmap;
  30581. /**
  30582. * In case of light mapping, define whether the map contains light or shadow informations.
  30583. */
  30584. useLightmapAsShadowmap: boolean;
  30585. private _diffuseFresnelParameters;
  30586. /**
  30587. * Define the diffuse fresnel parameters of the material.
  30588. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30589. */
  30590. diffuseFresnelParameters: FresnelParameters;
  30591. private _opacityFresnelParameters;
  30592. /**
  30593. * Define the opacity fresnel parameters of the material.
  30594. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30595. */
  30596. opacityFresnelParameters: FresnelParameters;
  30597. private _reflectionFresnelParameters;
  30598. /**
  30599. * Define the reflection fresnel parameters of the material.
  30600. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30601. */
  30602. reflectionFresnelParameters: FresnelParameters;
  30603. private _refractionFresnelParameters;
  30604. /**
  30605. * Define the refraction fresnel parameters of the material.
  30606. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30607. */
  30608. refractionFresnelParameters: FresnelParameters;
  30609. private _emissiveFresnelParameters;
  30610. /**
  30611. * Define the emissive fresnel parameters of the material.
  30612. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30613. */
  30614. emissiveFresnelParameters: FresnelParameters;
  30615. private _useReflectionFresnelFromSpecular;
  30616. /**
  30617. * If true automatically deducts the fresnels values from the material specularity.
  30618. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30619. */
  30620. useReflectionFresnelFromSpecular: boolean;
  30621. private _useGlossinessFromSpecularMapAlpha;
  30622. /**
  30623. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30624. */
  30625. useGlossinessFromSpecularMapAlpha: boolean;
  30626. private _maxSimultaneousLights;
  30627. /**
  30628. * Defines the maximum number of lights that can be used in the material
  30629. */
  30630. maxSimultaneousLights: number;
  30631. private _invertNormalMapX;
  30632. /**
  30633. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30634. */
  30635. invertNormalMapX: boolean;
  30636. private _invertNormalMapY;
  30637. /**
  30638. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30639. */
  30640. invertNormalMapY: boolean;
  30641. private _twoSidedLighting;
  30642. /**
  30643. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30644. */
  30645. twoSidedLighting: boolean;
  30646. /**
  30647. * Default configuration related to image processing available in the standard Material.
  30648. */
  30649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30650. /**
  30651. * Gets the image processing configuration used either in this material.
  30652. */
  30653. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30654. /**
  30655. * Sets the Default image processing configuration used either in the this material.
  30656. *
  30657. * If sets to null, the scene one is in use.
  30658. */
  30659. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30660. /**
  30661. * Keep track of the image processing observer to allow dispose and replace.
  30662. */
  30663. private _imageProcessingObserver;
  30664. /**
  30665. * Attaches a new image processing configuration to the Standard Material.
  30666. * @param configuration
  30667. */
  30668. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30669. /**
  30670. * Gets wether the color curves effect is enabled.
  30671. */
  30672. get cameraColorCurvesEnabled(): boolean;
  30673. /**
  30674. * Sets wether the color curves effect is enabled.
  30675. */
  30676. set cameraColorCurvesEnabled(value: boolean);
  30677. /**
  30678. * Gets wether the color grading effect is enabled.
  30679. */
  30680. get cameraColorGradingEnabled(): boolean;
  30681. /**
  30682. * Gets wether the color grading effect is enabled.
  30683. */
  30684. set cameraColorGradingEnabled(value: boolean);
  30685. /**
  30686. * Gets wether tonemapping is enabled or not.
  30687. */
  30688. get cameraToneMappingEnabled(): boolean;
  30689. /**
  30690. * Sets wether tonemapping is enabled or not
  30691. */
  30692. set cameraToneMappingEnabled(value: boolean);
  30693. /**
  30694. * The camera exposure used on this material.
  30695. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30696. * This corresponds to a photographic exposure.
  30697. */
  30698. get cameraExposure(): number;
  30699. /**
  30700. * The camera exposure used on this material.
  30701. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30702. * This corresponds to a photographic exposure.
  30703. */
  30704. set cameraExposure(value: number);
  30705. /**
  30706. * Gets The camera contrast used on this material.
  30707. */
  30708. get cameraContrast(): number;
  30709. /**
  30710. * Sets The camera contrast used on this material.
  30711. */
  30712. set cameraContrast(value: number);
  30713. /**
  30714. * Gets the Color Grading 2D Lookup Texture.
  30715. */
  30716. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30717. /**
  30718. * Sets the Color Grading 2D Lookup Texture.
  30719. */
  30720. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30721. /**
  30722. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30723. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30724. * 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;
  30725. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30726. */
  30727. get cameraColorCurves(): Nullable<ColorCurves>;
  30728. /**
  30729. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30730. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30731. * 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;
  30732. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30733. */
  30734. set cameraColorCurves(value: Nullable<ColorCurves>);
  30735. /**
  30736. * Can this material render to several textures at once
  30737. */
  30738. get canRenderToMRT(): boolean;
  30739. /**
  30740. * Defines the detail map parameters for the material.
  30741. */
  30742. readonly detailMap: DetailMapConfiguration;
  30743. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30744. protected _worldViewProjectionMatrix: Matrix;
  30745. protected _globalAmbientColor: Color3;
  30746. protected _useLogarithmicDepth: boolean;
  30747. protected _rebuildInParallel: boolean;
  30748. /**
  30749. * Instantiates a new standard material.
  30750. * This is the default material used in Babylon. It is the best trade off between quality
  30751. * and performances.
  30752. * @see https://doc.babylonjs.com/babylon101/materials
  30753. * @param name Define the name of the material in the scene
  30754. * @param scene Define the scene the material belong to
  30755. */
  30756. constructor(name: string, scene: Scene);
  30757. /**
  30758. * Gets a boolean indicating that current material needs to register RTT
  30759. */
  30760. get hasRenderTargetTextures(): boolean;
  30761. /**
  30762. * Gets the current class name of the material e.g. "StandardMaterial"
  30763. * Mainly use in serialization.
  30764. * @returns the class name
  30765. */
  30766. getClassName(): string;
  30767. /**
  30768. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30769. * You can try switching to logarithmic depth.
  30770. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30771. */
  30772. get useLogarithmicDepth(): boolean;
  30773. set useLogarithmicDepth(value: boolean);
  30774. /**
  30775. * Specifies if the material will require alpha blending
  30776. * @returns a boolean specifying if alpha blending is needed
  30777. */
  30778. needAlphaBlending(): boolean;
  30779. /**
  30780. * Specifies if this material should be rendered in alpha test mode
  30781. * @returns a boolean specifying if an alpha test is needed.
  30782. */
  30783. needAlphaTesting(): boolean;
  30784. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30785. /**
  30786. * Get the texture used for alpha test purpose.
  30787. * @returns the diffuse texture in case of the standard material.
  30788. */
  30789. getAlphaTestTexture(): Nullable<BaseTexture>;
  30790. /**
  30791. * Get if the submesh is ready to be used and all its information available.
  30792. * Child classes can use it to update shaders
  30793. * @param mesh defines the mesh to check
  30794. * @param subMesh defines which submesh to check
  30795. * @param useInstances specifies that instances should be used
  30796. * @returns a boolean indicating that the submesh is ready or not
  30797. */
  30798. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30799. /**
  30800. * Builds the material UBO layouts.
  30801. * Used internally during the effect preparation.
  30802. */
  30803. buildUniformLayout(): void;
  30804. /**
  30805. * Unbinds the material from the mesh
  30806. */
  30807. unbind(): void;
  30808. /**
  30809. * Binds the submesh to this material by preparing the effect and shader to draw
  30810. * @param world defines the world transformation matrix
  30811. * @param mesh defines the mesh containing the submesh
  30812. * @param subMesh defines the submesh to bind the material to
  30813. */
  30814. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30815. /**
  30816. * Get the list of animatables in the material.
  30817. * @returns the list of animatables object used in the material
  30818. */
  30819. getAnimatables(): IAnimatable[];
  30820. /**
  30821. * Gets the active textures from the material
  30822. * @returns an array of textures
  30823. */
  30824. getActiveTextures(): BaseTexture[];
  30825. /**
  30826. * Specifies if the material uses a texture
  30827. * @param texture defines the texture to check against the material
  30828. * @returns a boolean specifying if the material uses the texture
  30829. */
  30830. hasTexture(texture: BaseTexture): boolean;
  30831. /**
  30832. * Disposes the material
  30833. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30834. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30835. */
  30836. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30837. /**
  30838. * Makes a duplicate of the material, and gives it a new name
  30839. * @param name defines the new name for the duplicated material
  30840. * @returns the cloned material
  30841. */
  30842. clone(name: string): StandardMaterial;
  30843. /**
  30844. * Serializes this material in a JSON representation
  30845. * @returns the serialized material object
  30846. */
  30847. serialize(): any;
  30848. /**
  30849. * Creates a standard material from parsed material data
  30850. * @param source defines the JSON representation of the material
  30851. * @param scene defines the hosting scene
  30852. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30853. * @returns a new standard material
  30854. */
  30855. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30856. /**
  30857. * Are diffuse textures enabled in the application.
  30858. */
  30859. static get DiffuseTextureEnabled(): boolean;
  30860. static set DiffuseTextureEnabled(value: boolean);
  30861. /**
  30862. * Are detail textures enabled in the application.
  30863. */
  30864. static get DetailTextureEnabled(): boolean;
  30865. static set DetailTextureEnabled(value: boolean);
  30866. /**
  30867. * Are ambient textures enabled in the application.
  30868. */
  30869. static get AmbientTextureEnabled(): boolean;
  30870. static set AmbientTextureEnabled(value: boolean);
  30871. /**
  30872. * Are opacity textures enabled in the application.
  30873. */
  30874. static get OpacityTextureEnabled(): boolean;
  30875. static set OpacityTextureEnabled(value: boolean);
  30876. /**
  30877. * Are reflection textures enabled in the application.
  30878. */
  30879. static get ReflectionTextureEnabled(): boolean;
  30880. static set ReflectionTextureEnabled(value: boolean);
  30881. /**
  30882. * Are emissive textures enabled in the application.
  30883. */
  30884. static get EmissiveTextureEnabled(): boolean;
  30885. static set EmissiveTextureEnabled(value: boolean);
  30886. /**
  30887. * Are specular textures enabled in the application.
  30888. */
  30889. static get SpecularTextureEnabled(): boolean;
  30890. static set SpecularTextureEnabled(value: boolean);
  30891. /**
  30892. * Are bump textures enabled in the application.
  30893. */
  30894. static get BumpTextureEnabled(): boolean;
  30895. static set BumpTextureEnabled(value: boolean);
  30896. /**
  30897. * Are lightmap textures enabled in the application.
  30898. */
  30899. static get LightmapTextureEnabled(): boolean;
  30900. static set LightmapTextureEnabled(value: boolean);
  30901. /**
  30902. * Are refraction textures enabled in the application.
  30903. */
  30904. static get RefractionTextureEnabled(): boolean;
  30905. static set RefractionTextureEnabled(value: boolean);
  30906. /**
  30907. * Are color grading textures enabled in the application.
  30908. */
  30909. static get ColorGradingTextureEnabled(): boolean;
  30910. static set ColorGradingTextureEnabled(value: boolean);
  30911. /**
  30912. * Are fresnels enabled in the application.
  30913. */
  30914. static get FresnelEnabled(): boolean;
  30915. static set FresnelEnabled(value: boolean);
  30916. }
  30917. }
  30918. declare module BABYLON {
  30919. /**
  30920. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30921. *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.
  30922. * The SPS is also a particle system. It provides some methods to manage the particles.
  30923. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30924. *
  30925. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30926. */
  30927. export class SolidParticleSystem implements IDisposable {
  30928. /**
  30929. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30930. * Example : var p = SPS.particles[i];
  30931. */
  30932. particles: SolidParticle[];
  30933. /**
  30934. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30935. */
  30936. nbParticles: number;
  30937. /**
  30938. * If the particles must ever face the camera (default false). Useful for planar particles.
  30939. */
  30940. billboard: boolean;
  30941. /**
  30942. * Recompute normals when adding a shape
  30943. */
  30944. recomputeNormals: boolean;
  30945. /**
  30946. * This a counter ofr your own usage. It's not set by any SPS functions.
  30947. */
  30948. counter: number;
  30949. /**
  30950. * The SPS name. This name is also given to the underlying mesh.
  30951. */
  30952. name: string;
  30953. /**
  30954. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30955. */
  30956. mesh: Mesh;
  30957. /**
  30958. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30959. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30960. */
  30961. vars: any;
  30962. /**
  30963. * This array is populated when the SPS is set as 'pickable'.
  30964. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30965. * Each element of this array is an object `{idx: int, faceId: int}`.
  30966. * `idx` is the picked particle index in the `SPS.particles` array
  30967. * `faceId` is the picked face index counted within this particle.
  30968. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30969. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30970. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30971. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30972. */
  30973. pickedParticles: {
  30974. idx: number;
  30975. faceId: number;
  30976. }[];
  30977. /**
  30978. * This array is populated when the SPS is set as 'pickable'
  30979. * Each key of this array is a submesh index.
  30980. * Each element of this array is a second array defined like this :
  30981. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30982. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30983. * `idx` is the picked particle index in the `SPS.particles` array
  30984. * `faceId` is the picked face index counted within this particle.
  30985. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30986. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30987. */
  30988. pickedBySubMesh: {
  30989. idx: number;
  30990. faceId: number;
  30991. }[][];
  30992. /**
  30993. * This array is populated when `enableDepthSort` is set to true.
  30994. * Each element of this array is an instance of the class DepthSortedParticle.
  30995. */
  30996. depthSortedParticles: DepthSortedParticle[];
  30997. /**
  30998. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30999. * @hidden
  31000. */
  31001. _bSphereOnly: boolean;
  31002. /**
  31003. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31004. * @hidden
  31005. */
  31006. _bSphereRadiusFactor: number;
  31007. private _scene;
  31008. private _positions;
  31009. private _indices;
  31010. private _normals;
  31011. private _colors;
  31012. private _uvs;
  31013. private _indices32;
  31014. private _positions32;
  31015. private _normals32;
  31016. private _fixedNormal32;
  31017. private _colors32;
  31018. private _uvs32;
  31019. private _index;
  31020. private _updatable;
  31021. private _pickable;
  31022. private _isVisibilityBoxLocked;
  31023. private _alwaysVisible;
  31024. private _depthSort;
  31025. private _expandable;
  31026. private _shapeCounter;
  31027. private _copy;
  31028. private _color;
  31029. private _computeParticleColor;
  31030. private _computeParticleTexture;
  31031. private _computeParticleRotation;
  31032. private _computeParticleVertex;
  31033. private _computeBoundingBox;
  31034. private _depthSortParticles;
  31035. private _camera;
  31036. private _mustUnrotateFixedNormals;
  31037. private _particlesIntersect;
  31038. private _needs32Bits;
  31039. private _isNotBuilt;
  31040. private _lastParticleId;
  31041. private _idxOfId;
  31042. private _multimaterialEnabled;
  31043. private _useModelMaterial;
  31044. private _indicesByMaterial;
  31045. private _materialIndexes;
  31046. private _depthSortFunction;
  31047. private _materialSortFunction;
  31048. private _materials;
  31049. private _multimaterial;
  31050. private _materialIndexesById;
  31051. private _defaultMaterial;
  31052. private _autoUpdateSubMeshes;
  31053. private _tmpVertex;
  31054. /**
  31055. * Creates a SPS (Solid Particle System) object.
  31056. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31057. * @param scene (Scene) is the scene in which the SPS is added.
  31058. * @param options defines the options of the sps e.g.
  31059. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31060. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31061. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31062. * * 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.
  31063. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31064. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31065. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31066. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31067. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31068. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31069. */
  31070. constructor(name: string, scene: Scene, options?: {
  31071. updatable?: boolean;
  31072. isPickable?: boolean;
  31073. enableDepthSort?: boolean;
  31074. particleIntersection?: boolean;
  31075. boundingSphereOnly?: boolean;
  31076. bSphereRadiusFactor?: number;
  31077. expandable?: boolean;
  31078. useModelMaterial?: boolean;
  31079. enableMultiMaterial?: boolean;
  31080. });
  31081. /**
  31082. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31083. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31084. * @returns the created mesh
  31085. */
  31086. buildMesh(): Mesh;
  31087. /**
  31088. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31089. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31090. * Thus the particles generated from `digest()` have their property `position` set yet.
  31091. * @param mesh ( Mesh ) is the mesh to be digested
  31092. * @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
  31093. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31094. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31095. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31096. * @returns the current SPS
  31097. */
  31098. digest(mesh: Mesh, options?: {
  31099. facetNb?: number;
  31100. number?: number;
  31101. delta?: number;
  31102. storage?: [];
  31103. }): SolidParticleSystem;
  31104. /**
  31105. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31106. * @hidden
  31107. */
  31108. private _unrotateFixedNormals;
  31109. /**
  31110. * Resets the temporary working copy particle
  31111. * @hidden
  31112. */
  31113. private _resetCopy;
  31114. /**
  31115. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31116. * @param p the current index in the positions array to be updated
  31117. * @param ind the current index in the indices array
  31118. * @param shape a Vector3 array, the shape geometry
  31119. * @param positions the positions array to be updated
  31120. * @param meshInd the shape indices array
  31121. * @param indices the indices array to be updated
  31122. * @param meshUV the shape uv array
  31123. * @param uvs the uv array to be updated
  31124. * @param meshCol the shape color array
  31125. * @param colors the color array to be updated
  31126. * @param meshNor the shape normals array
  31127. * @param normals the normals array to be updated
  31128. * @param idx the particle index
  31129. * @param idxInShape the particle index in its shape
  31130. * @param options the addShape() method passed options
  31131. * @model the particle model
  31132. * @hidden
  31133. */
  31134. private _meshBuilder;
  31135. /**
  31136. * Returns a shape Vector3 array from positions float array
  31137. * @param positions float array
  31138. * @returns a vector3 array
  31139. * @hidden
  31140. */
  31141. private _posToShape;
  31142. /**
  31143. * Returns a shapeUV array from a float uvs (array deep copy)
  31144. * @param uvs as a float array
  31145. * @returns a shapeUV array
  31146. * @hidden
  31147. */
  31148. private _uvsToShapeUV;
  31149. /**
  31150. * Adds a new particle object in the particles array
  31151. * @param idx particle index in particles array
  31152. * @param id particle id
  31153. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31154. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31155. * @param model particle ModelShape object
  31156. * @param shapeId model shape identifier
  31157. * @param idxInShape index of the particle in the current model
  31158. * @param bInfo model bounding info object
  31159. * @param storage target storage array, if any
  31160. * @hidden
  31161. */
  31162. private _addParticle;
  31163. /**
  31164. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31165. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31166. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31167. * @param nb (positive integer) the number of particles to be created from this model
  31168. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31169. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31170. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31171. * @returns the number of shapes in the system
  31172. */
  31173. addShape(mesh: Mesh, nb: number, options?: {
  31174. positionFunction?: any;
  31175. vertexFunction?: any;
  31176. storage?: [];
  31177. }): number;
  31178. /**
  31179. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31180. * @hidden
  31181. */
  31182. private _rebuildParticle;
  31183. /**
  31184. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31185. * @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.
  31186. * @returns the SPS.
  31187. */
  31188. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31189. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31190. * Returns an array with the removed particles.
  31191. * 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.
  31192. * The SPS can't be empty so at least one particle needs to remain in place.
  31193. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31194. * @param start index of the first particle to remove
  31195. * @param end index of the last particle to remove (included)
  31196. * @returns an array populated with the removed particles
  31197. */
  31198. removeParticles(start: number, end: number): SolidParticle[];
  31199. /**
  31200. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31201. * @param solidParticleArray an array populated with Solid Particles objects
  31202. * @returns the SPS
  31203. */
  31204. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31205. /**
  31206. * Creates a new particle and modifies the SPS mesh geometry :
  31207. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31208. * - calls _addParticle() to populate the particle array
  31209. * factorized code from addShape() and insertParticlesFromArray()
  31210. * @param idx particle index in the particles array
  31211. * @param i particle index in its shape
  31212. * @param modelShape particle ModelShape object
  31213. * @param shape shape vertex array
  31214. * @param meshInd shape indices array
  31215. * @param meshUV shape uv array
  31216. * @param meshCol shape color array
  31217. * @param meshNor shape normals array
  31218. * @param bbInfo shape bounding info
  31219. * @param storage target particle storage
  31220. * @options addShape() passed options
  31221. * @hidden
  31222. */
  31223. private _insertNewParticle;
  31224. /**
  31225. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31226. * This method calls `updateParticle()` for each particle of the SPS.
  31227. * For an animated SPS, it is usually called within the render loop.
  31228. * 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.
  31229. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31230. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31231. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31232. * @returns the SPS.
  31233. */
  31234. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31235. /**
  31236. * Disposes the SPS.
  31237. */
  31238. dispose(): void;
  31239. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31240. * idx is the particle index in the SPS
  31241. * faceId is the picked face index counted within this particle.
  31242. * Returns null if the pickInfo can't identify a picked particle.
  31243. * @param pickingInfo (PickingInfo object)
  31244. * @returns {idx: number, faceId: number} or null
  31245. */
  31246. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31247. idx: number;
  31248. faceId: number;
  31249. }>;
  31250. /**
  31251. * Returns a SolidParticle object from its identifier : particle.id
  31252. * @param id (integer) the particle Id
  31253. * @returns the searched particle or null if not found in the SPS.
  31254. */
  31255. getParticleById(id: number): Nullable<SolidParticle>;
  31256. /**
  31257. * Returns a new array populated with the particles having the passed shapeId.
  31258. * @param shapeId (integer) the shape identifier
  31259. * @returns a new solid particle array
  31260. */
  31261. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31262. /**
  31263. * Populates the passed array "ref" with the particles having the passed shapeId.
  31264. * @param shapeId the shape identifier
  31265. * @returns the SPS
  31266. * @param ref
  31267. */
  31268. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31269. /**
  31270. * Computes the required SubMeshes according the materials assigned to the particles.
  31271. * @returns the solid particle system.
  31272. * Does nothing if called before the SPS mesh is built.
  31273. */
  31274. computeSubMeshes(): SolidParticleSystem;
  31275. /**
  31276. * Sorts the solid particles by material when MultiMaterial is enabled.
  31277. * Updates the indices32 array.
  31278. * Updates the indicesByMaterial array.
  31279. * Updates the mesh indices array.
  31280. * @returns the SPS
  31281. * @hidden
  31282. */
  31283. private _sortParticlesByMaterial;
  31284. /**
  31285. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31286. * @hidden
  31287. */
  31288. private _setMaterialIndexesById;
  31289. /**
  31290. * Returns an array with unique values of Materials from the passed array
  31291. * @param array the material array to be checked and filtered
  31292. * @hidden
  31293. */
  31294. private _filterUniqueMaterialId;
  31295. /**
  31296. * Sets a new Standard Material as _defaultMaterial if not already set.
  31297. * @hidden
  31298. */
  31299. private _setDefaultMaterial;
  31300. /**
  31301. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31302. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31303. * @returns the SPS.
  31304. */
  31305. refreshVisibleSize(): SolidParticleSystem;
  31306. /**
  31307. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31308. * @param size the size (float) of the visibility box
  31309. * note : this doesn't lock the SPS mesh bounding box.
  31310. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31311. */
  31312. setVisibilityBox(size: number): void;
  31313. /**
  31314. * Gets whether the SPS as always visible or not
  31315. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31316. */
  31317. get isAlwaysVisible(): boolean;
  31318. /**
  31319. * Sets the SPS as always visible or not
  31320. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31321. */
  31322. set isAlwaysVisible(val: boolean);
  31323. /**
  31324. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31325. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31326. */
  31327. set isVisibilityBoxLocked(val: boolean);
  31328. /**
  31329. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31330. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31331. */
  31332. get isVisibilityBoxLocked(): boolean;
  31333. /**
  31334. * Tells to `setParticles()` to compute the particle rotations or not.
  31335. * Default value : true. The SPS is faster when it's set to false.
  31336. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31337. */
  31338. set computeParticleRotation(val: boolean);
  31339. /**
  31340. * Tells to `setParticles()` to compute the particle colors or not.
  31341. * Default value : true. The SPS is faster when it's set to false.
  31342. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31343. */
  31344. set computeParticleColor(val: boolean);
  31345. set computeParticleTexture(val: boolean);
  31346. /**
  31347. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31348. * Default value : false. The SPS is faster when it's set to false.
  31349. * Note : the particle custom vertex positions aren't stored values.
  31350. */
  31351. set computeParticleVertex(val: boolean);
  31352. /**
  31353. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31354. */
  31355. set computeBoundingBox(val: boolean);
  31356. /**
  31357. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31358. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31359. * Default : `true`
  31360. */
  31361. set depthSortParticles(val: boolean);
  31362. /**
  31363. * Gets if `setParticles()` computes the particle rotations or not.
  31364. * Default value : true. The SPS is faster when it's set to false.
  31365. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31366. */
  31367. get computeParticleRotation(): boolean;
  31368. /**
  31369. * Gets if `setParticles()` computes the particle colors or not.
  31370. * Default value : true. The SPS is faster when it's set to false.
  31371. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31372. */
  31373. get computeParticleColor(): boolean;
  31374. /**
  31375. * Gets if `setParticles()` computes the particle textures or not.
  31376. * Default value : true. The SPS is faster when it's set to false.
  31377. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31378. */
  31379. get computeParticleTexture(): boolean;
  31380. /**
  31381. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31382. * Default value : false. The SPS is faster when it's set to false.
  31383. * Note : the particle custom vertex positions aren't stored values.
  31384. */
  31385. get computeParticleVertex(): boolean;
  31386. /**
  31387. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31388. */
  31389. get computeBoundingBox(): boolean;
  31390. /**
  31391. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31392. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31393. * Default : `true`
  31394. */
  31395. get depthSortParticles(): boolean;
  31396. /**
  31397. * Gets if the SPS is created as expandable at construction time.
  31398. * Default : `false`
  31399. */
  31400. get expandable(): boolean;
  31401. /**
  31402. * Gets if the SPS supports the Multi Materials
  31403. */
  31404. get multimaterialEnabled(): boolean;
  31405. /**
  31406. * Gets if the SPS uses the model materials for its own multimaterial.
  31407. */
  31408. get useModelMaterial(): boolean;
  31409. /**
  31410. * The SPS used material array.
  31411. */
  31412. get materials(): Material[];
  31413. /**
  31414. * Sets the SPS MultiMaterial from the passed materials.
  31415. * Note : the passed array is internally copied and not used then by reference.
  31416. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31417. */
  31418. setMultiMaterial(materials: Material[]): void;
  31419. /**
  31420. * The SPS computed multimaterial object
  31421. */
  31422. get multimaterial(): MultiMaterial;
  31423. set multimaterial(mm: MultiMaterial);
  31424. /**
  31425. * If the subMeshes must be updated on the next call to setParticles()
  31426. */
  31427. get autoUpdateSubMeshes(): boolean;
  31428. set autoUpdateSubMeshes(val: boolean);
  31429. /**
  31430. * This function does nothing. It may be overwritten to set all the particle first values.
  31431. * The SPS doesn't call this function, you may have to call it by your own.
  31432. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31433. */
  31434. initParticles(): void;
  31435. /**
  31436. * This function does nothing. It may be overwritten to recycle a particle.
  31437. * The SPS doesn't call this function, you may have to call it by your own.
  31438. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31439. * @param particle The particle to recycle
  31440. * @returns the recycled particle
  31441. */
  31442. recycleParticle(particle: SolidParticle): SolidParticle;
  31443. /**
  31444. * Updates a particle : this function should be overwritten by the user.
  31445. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31446. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31447. * @example : just set a particle position or velocity and recycle conditions
  31448. * @param particle The particle to update
  31449. * @returns the updated particle
  31450. */
  31451. updateParticle(particle: SolidParticle): SolidParticle;
  31452. /**
  31453. * Updates a vertex of a particle : it can be overwritten by the user.
  31454. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31455. * @param particle the current particle
  31456. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31457. * @param pt the index of the current vertex in the particle shape
  31458. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31459. * @example : just set a vertex particle position or color
  31460. * @returns the sps
  31461. */
  31462. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31463. /**
  31464. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31465. * This does nothing and may be overwritten by the user.
  31466. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31467. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31468. * @param update the boolean update value actually passed to setParticles()
  31469. */
  31470. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31471. /**
  31472. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31473. * This will be passed three parameters.
  31474. * This does nothing and may be overwritten by the user.
  31475. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31476. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31477. * @param update the boolean update value actually passed to setParticles()
  31478. */
  31479. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31480. }
  31481. }
  31482. declare module BABYLON {
  31483. /**
  31484. * Represents one particle of a solid particle system.
  31485. */
  31486. export class SolidParticle {
  31487. /**
  31488. * particle global index
  31489. */
  31490. idx: number;
  31491. /**
  31492. * particle identifier
  31493. */
  31494. id: number;
  31495. /**
  31496. * The color of the particle
  31497. */
  31498. color: Nullable<Color4>;
  31499. /**
  31500. * The world space position of the particle.
  31501. */
  31502. position: Vector3;
  31503. /**
  31504. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31505. */
  31506. rotation: Vector3;
  31507. /**
  31508. * The world space rotation quaternion of the particle.
  31509. */
  31510. rotationQuaternion: Nullable<Quaternion>;
  31511. /**
  31512. * The scaling of the particle.
  31513. */
  31514. scaling: Vector3;
  31515. /**
  31516. * The uvs of the particle.
  31517. */
  31518. uvs: Vector4;
  31519. /**
  31520. * The current speed of the particle.
  31521. */
  31522. velocity: Vector3;
  31523. /**
  31524. * The pivot point in the particle local space.
  31525. */
  31526. pivot: Vector3;
  31527. /**
  31528. * Must the particle be translated from its pivot point in its local space ?
  31529. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31530. * Default : false
  31531. */
  31532. translateFromPivot: boolean;
  31533. /**
  31534. * Is the particle active or not ?
  31535. */
  31536. alive: boolean;
  31537. /**
  31538. * Is the particle visible or not ?
  31539. */
  31540. isVisible: boolean;
  31541. /**
  31542. * Index of this particle in the global "positions" array (Internal use)
  31543. * @hidden
  31544. */
  31545. _pos: number;
  31546. /**
  31547. * @hidden Index of this particle in the global "indices" array (Internal use)
  31548. */
  31549. _ind: number;
  31550. /**
  31551. * @hidden ModelShape of this particle (Internal use)
  31552. */
  31553. _model: ModelShape;
  31554. /**
  31555. * ModelShape id of this particle
  31556. */
  31557. shapeId: number;
  31558. /**
  31559. * Index of the particle in its shape id
  31560. */
  31561. idxInShape: number;
  31562. /**
  31563. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31564. */
  31565. _modelBoundingInfo: BoundingInfo;
  31566. /**
  31567. * @hidden Particle BoundingInfo object (Internal use)
  31568. */
  31569. _boundingInfo: BoundingInfo;
  31570. /**
  31571. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31572. */
  31573. _sps: SolidParticleSystem;
  31574. /**
  31575. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31576. */
  31577. _stillInvisible: boolean;
  31578. /**
  31579. * @hidden Last computed particle rotation matrix
  31580. */
  31581. _rotationMatrix: number[];
  31582. /**
  31583. * Parent particle Id, if any.
  31584. * Default null.
  31585. */
  31586. parentId: Nullable<number>;
  31587. /**
  31588. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31589. */
  31590. materialIndex: Nullable<number>;
  31591. /**
  31592. * Custom object or properties.
  31593. */
  31594. props: Nullable<any>;
  31595. /**
  31596. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31597. * The possible values are :
  31598. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31599. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31600. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31601. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31602. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31603. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31604. * */
  31605. cullingStrategy: number;
  31606. /**
  31607. * @hidden Internal global position in the SPS.
  31608. */
  31609. _globalPosition: Vector3;
  31610. /**
  31611. * Creates a Solid Particle object.
  31612. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31613. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31614. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31615. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31616. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31617. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31618. * @param shapeId (integer) is the model shape identifier in the SPS.
  31619. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31620. * @param sps defines the sps it is associated to
  31621. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31622. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31623. */
  31624. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31625. /**
  31626. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31627. * @param target the particle target
  31628. * @returns the current particle
  31629. */
  31630. copyToRef(target: SolidParticle): SolidParticle;
  31631. /**
  31632. * Legacy support, changed scale to scaling
  31633. */
  31634. get scale(): Vector3;
  31635. /**
  31636. * Legacy support, changed scale to scaling
  31637. */
  31638. set scale(scale: Vector3);
  31639. /**
  31640. * Legacy support, changed quaternion to rotationQuaternion
  31641. */
  31642. get quaternion(): Nullable<Quaternion>;
  31643. /**
  31644. * Legacy support, changed quaternion to rotationQuaternion
  31645. */
  31646. set quaternion(q: Nullable<Quaternion>);
  31647. /**
  31648. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31649. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31650. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31651. * @returns true if it intersects
  31652. */
  31653. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31654. /**
  31655. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31656. * A particle is in the frustum if its bounding box intersects the frustum
  31657. * @param frustumPlanes defines the frustum to test
  31658. * @returns true if the particle is in the frustum planes
  31659. */
  31660. isInFrustum(frustumPlanes: Plane[]): boolean;
  31661. /**
  31662. * get the rotation matrix of the particle
  31663. * @hidden
  31664. */
  31665. getRotationMatrix(m: Matrix): void;
  31666. }
  31667. /**
  31668. * Represents the shape of the model used by one particle of a solid particle system.
  31669. * SPS internal tool, don't use it manually.
  31670. */
  31671. export class ModelShape {
  31672. /**
  31673. * The shape id
  31674. * @hidden
  31675. */
  31676. shapeID: number;
  31677. /**
  31678. * flat array of model positions (internal use)
  31679. * @hidden
  31680. */
  31681. _shape: Vector3[];
  31682. /**
  31683. * flat array of model UVs (internal use)
  31684. * @hidden
  31685. */
  31686. _shapeUV: number[];
  31687. /**
  31688. * color array of the model
  31689. * @hidden
  31690. */
  31691. _shapeColors: number[];
  31692. /**
  31693. * indices array of the model
  31694. * @hidden
  31695. */
  31696. _indices: number[];
  31697. /**
  31698. * normals array of the model
  31699. * @hidden
  31700. */
  31701. _normals: number[];
  31702. /**
  31703. * length of the shape in the model indices array (internal use)
  31704. * @hidden
  31705. */
  31706. _indicesLength: number;
  31707. /**
  31708. * Custom position function (internal use)
  31709. * @hidden
  31710. */
  31711. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31712. /**
  31713. * Custom vertex function (internal use)
  31714. * @hidden
  31715. */
  31716. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31717. /**
  31718. * Model material (internal use)
  31719. * @hidden
  31720. */
  31721. _material: Nullable<Material>;
  31722. /**
  31723. * 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.
  31724. * SPS internal tool, don't use it manually.
  31725. * @hidden
  31726. */
  31727. 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>);
  31728. }
  31729. /**
  31730. * Represents a Depth Sorted Particle in the solid particle system.
  31731. * @hidden
  31732. */
  31733. export class DepthSortedParticle {
  31734. /**
  31735. * Particle index
  31736. */
  31737. idx: number;
  31738. /**
  31739. * Index of the particle in the "indices" array
  31740. */
  31741. ind: number;
  31742. /**
  31743. * Length of the particle shape in the "indices" array
  31744. */
  31745. indicesLength: number;
  31746. /**
  31747. * Squared distance from the particle to the camera
  31748. */
  31749. sqDistance: number;
  31750. /**
  31751. * Material index when used with MultiMaterials
  31752. */
  31753. materialIndex: number;
  31754. /**
  31755. * Creates a new sorted particle
  31756. * @param materialIndex
  31757. */
  31758. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31759. }
  31760. /**
  31761. * Represents a solid particle vertex
  31762. */
  31763. export class SolidParticleVertex {
  31764. /**
  31765. * Vertex position
  31766. */
  31767. position: Vector3;
  31768. /**
  31769. * Vertex color
  31770. */
  31771. color: Color4;
  31772. /**
  31773. * Vertex UV
  31774. */
  31775. uv: Vector2;
  31776. /**
  31777. * Creates a new solid particle vertex
  31778. */
  31779. constructor();
  31780. /** Vertex x coordinate */
  31781. get x(): number;
  31782. set x(val: number);
  31783. /** Vertex y coordinate */
  31784. get y(): number;
  31785. set y(val: number);
  31786. /** Vertex z coordinate */
  31787. get z(): number;
  31788. set z(val: number);
  31789. }
  31790. }
  31791. declare module BABYLON {
  31792. /**
  31793. * @hidden
  31794. */
  31795. export class _MeshCollisionData {
  31796. _checkCollisions: boolean;
  31797. _collisionMask: number;
  31798. _collisionGroup: number;
  31799. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31800. _collider: Nullable<Collider>;
  31801. _oldPositionForCollisions: Vector3;
  31802. _diffPositionForCollisions: Vector3;
  31803. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31804. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31805. }
  31806. }
  31807. declare module BABYLON {
  31808. /** @hidden */
  31809. class _FacetDataStorage {
  31810. facetPositions: Vector3[];
  31811. facetNormals: Vector3[];
  31812. facetPartitioning: number[][];
  31813. facetNb: number;
  31814. partitioningSubdivisions: number;
  31815. partitioningBBoxRatio: number;
  31816. facetDataEnabled: boolean;
  31817. facetParameters: any;
  31818. bbSize: Vector3;
  31819. subDiv: {
  31820. max: number;
  31821. X: number;
  31822. Y: number;
  31823. Z: number;
  31824. };
  31825. facetDepthSort: boolean;
  31826. facetDepthSortEnabled: boolean;
  31827. depthSortedIndices: IndicesArray;
  31828. depthSortedFacets: {
  31829. ind: number;
  31830. sqDistance: number;
  31831. }[];
  31832. facetDepthSortFunction: (f1: {
  31833. ind: number;
  31834. sqDistance: number;
  31835. }, f2: {
  31836. ind: number;
  31837. sqDistance: number;
  31838. }) => number;
  31839. facetDepthSortFrom: Vector3;
  31840. facetDepthSortOrigin: Vector3;
  31841. invertedMatrix: Matrix;
  31842. }
  31843. /**
  31844. * @hidden
  31845. **/
  31846. class _InternalAbstractMeshDataInfo {
  31847. _hasVertexAlpha: boolean;
  31848. _useVertexColors: boolean;
  31849. _numBoneInfluencers: number;
  31850. _applyFog: boolean;
  31851. _receiveShadows: boolean;
  31852. _facetData: _FacetDataStorage;
  31853. _visibility: number;
  31854. _skeleton: Nullable<Skeleton>;
  31855. _layerMask: number;
  31856. _computeBonesUsingShaders: boolean;
  31857. _isActive: boolean;
  31858. _onlyForInstances: boolean;
  31859. _isActiveIntermediate: boolean;
  31860. _onlyForInstancesIntermediate: boolean;
  31861. _actAsRegularMesh: boolean;
  31862. }
  31863. /**
  31864. * Class used to store all common mesh properties
  31865. */
  31866. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31867. /** No occlusion */
  31868. static OCCLUSION_TYPE_NONE: number;
  31869. /** Occlusion set to optimisitic */
  31870. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31871. /** Occlusion set to strict */
  31872. static OCCLUSION_TYPE_STRICT: number;
  31873. /** Use an accurante occlusion algorithm */
  31874. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31875. /** Use a conservative occlusion algorithm */
  31876. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31877. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31878. * Test order :
  31879. * Is the bounding sphere outside the frustum ?
  31880. * If not, are the bounding box vertices outside the frustum ?
  31881. * It not, then the cullable object is in the frustum.
  31882. */
  31883. static readonly CULLINGSTRATEGY_STANDARD: number;
  31884. /** Culling strategy : Bounding Sphere Only.
  31885. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31886. * It's also less accurate than the standard because some not visible objects can still be selected.
  31887. * Test : is the bounding sphere outside the frustum ?
  31888. * If not, then the cullable object is in the frustum.
  31889. */
  31890. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31891. /** Culling strategy : Optimistic Inclusion.
  31892. * This in an inclusion test first, then the standard exclusion test.
  31893. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31894. * 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.
  31895. * Anyway, it's as accurate as the standard strategy.
  31896. * Test :
  31897. * Is the cullable object bounding sphere center in the frustum ?
  31898. * If not, apply the default culling strategy.
  31899. */
  31900. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31901. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31902. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31903. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31904. * 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.
  31905. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31906. * Test :
  31907. * Is the cullable object bounding sphere center in the frustum ?
  31908. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31909. */
  31910. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31911. /**
  31912. * No billboard
  31913. */
  31914. static get BILLBOARDMODE_NONE(): number;
  31915. /** Billboard on X axis */
  31916. static get BILLBOARDMODE_X(): number;
  31917. /** Billboard on Y axis */
  31918. static get BILLBOARDMODE_Y(): number;
  31919. /** Billboard on Z axis */
  31920. static get BILLBOARDMODE_Z(): number;
  31921. /** Billboard on all axes */
  31922. static get BILLBOARDMODE_ALL(): number;
  31923. /** Billboard on using position instead of orientation */
  31924. static get BILLBOARDMODE_USE_POSITION(): number;
  31925. /** @hidden */
  31926. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31927. /**
  31928. * The culling strategy to use to check whether the mesh must be rendered or not.
  31929. * This value can be changed at any time and will be used on the next render mesh selection.
  31930. * The possible values are :
  31931. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31932. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31933. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31934. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31935. * Please read each static variable documentation to get details about the culling process.
  31936. * */
  31937. cullingStrategy: number;
  31938. /**
  31939. * Gets the number of facets in the mesh
  31940. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31941. */
  31942. get facetNb(): number;
  31943. /**
  31944. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31945. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31946. */
  31947. get partitioningSubdivisions(): number;
  31948. set partitioningSubdivisions(nb: number);
  31949. /**
  31950. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31951. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31952. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31953. */
  31954. get partitioningBBoxRatio(): number;
  31955. set partitioningBBoxRatio(ratio: number);
  31956. /**
  31957. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31958. * Works only for updatable meshes.
  31959. * Doesn't work with multi-materials
  31960. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31961. */
  31962. get mustDepthSortFacets(): boolean;
  31963. set mustDepthSortFacets(sort: boolean);
  31964. /**
  31965. * The location (Vector3) where the facet depth sort must be computed from.
  31966. * By default, the active camera position.
  31967. * Used only when facet depth sort is enabled
  31968. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31969. */
  31970. get facetDepthSortFrom(): Vector3;
  31971. set facetDepthSortFrom(location: Vector3);
  31972. /**
  31973. * gets a boolean indicating if facetData is enabled
  31974. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31975. */
  31976. get isFacetDataEnabled(): boolean;
  31977. /** @hidden */
  31978. _updateNonUniformScalingState(value: boolean): boolean;
  31979. /**
  31980. * An event triggered when this mesh collides with another one
  31981. */
  31982. onCollideObservable: Observable<AbstractMesh>;
  31983. /** Set a function to call when this mesh collides with another one */
  31984. set onCollide(callback: () => void);
  31985. /**
  31986. * An event triggered when the collision's position changes
  31987. */
  31988. onCollisionPositionChangeObservable: Observable<Vector3>;
  31989. /** Set a function to call when the collision's position changes */
  31990. set onCollisionPositionChange(callback: () => void);
  31991. /**
  31992. * An event triggered when material is changed
  31993. */
  31994. onMaterialChangedObservable: Observable<AbstractMesh>;
  31995. /**
  31996. * Gets or sets the orientation for POV movement & rotation
  31997. */
  31998. definedFacingForward: boolean;
  31999. /** @hidden */
  32000. _occlusionQuery: Nullable<WebGLQuery>;
  32001. /** @hidden */
  32002. _renderingGroup: Nullable<RenderingGroup>;
  32003. /**
  32004. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32005. */
  32006. get visibility(): number;
  32007. /**
  32008. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32009. */
  32010. set visibility(value: number);
  32011. /** Gets or sets the alpha index used to sort transparent meshes
  32012. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32013. */
  32014. alphaIndex: number;
  32015. /**
  32016. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32017. */
  32018. isVisible: boolean;
  32019. /**
  32020. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32021. */
  32022. isPickable: boolean;
  32023. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32024. showSubMeshesBoundingBox: boolean;
  32025. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32026. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32027. */
  32028. isBlocker: boolean;
  32029. /**
  32030. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32031. */
  32032. enablePointerMoveEvents: boolean;
  32033. /**
  32034. * Specifies the rendering group id for this mesh (0 by default)
  32035. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32036. */
  32037. renderingGroupId: number;
  32038. private _material;
  32039. /** Gets or sets current material */
  32040. get material(): Nullable<Material>;
  32041. set material(value: Nullable<Material>);
  32042. /**
  32043. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32044. * @see https://doc.babylonjs.com/babylon101/shadows
  32045. */
  32046. get receiveShadows(): boolean;
  32047. set receiveShadows(value: boolean);
  32048. /** Defines color to use when rendering outline */
  32049. outlineColor: Color3;
  32050. /** Define width to use when rendering outline */
  32051. outlineWidth: number;
  32052. /** Defines color to use when rendering overlay */
  32053. overlayColor: Color3;
  32054. /** Defines alpha to use when rendering overlay */
  32055. overlayAlpha: number;
  32056. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32057. get hasVertexAlpha(): boolean;
  32058. set hasVertexAlpha(value: boolean);
  32059. /** 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) */
  32060. get useVertexColors(): boolean;
  32061. set useVertexColors(value: boolean);
  32062. /**
  32063. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32064. */
  32065. get computeBonesUsingShaders(): boolean;
  32066. set computeBonesUsingShaders(value: boolean);
  32067. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32068. get numBoneInfluencers(): number;
  32069. set numBoneInfluencers(value: number);
  32070. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32071. get applyFog(): boolean;
  32072. set applyFog(value: boolean);
  32073. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32074. useOctreeForRenderingSelection: boolean;
  32075. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32076. useOctreeForPicking: boolean;
  32077. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32078. useOctreeForCollisions: boolean;
  32079. /**
  32080. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32081. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32082. */
  32083. get layerMask(): number;
  32084. set layerMask(value: number);
  32085. /**
  32086. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32087. */
  32088. alwaysSelectAsActiveMesh: boolean;
  32089. /**
  32090. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32091. */
  32092. doNotSyncBoundingInfo: boolean;
  32093. /**
  32094. * Gets or sets the current action manager
  32095. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32096. */
  32097. actionManager: Nullable<AbstractActionManager>;
  32098. private _meshCollisionData;
  32099. /**
  32100. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32101. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32102. */
  32103. ellipsoid: Vector3;
  32104. /**
  32105. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32106. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32107. */
  32108. ellipsoidOffset: Vector3;
  32109. /**
  32110. * Gets or sets a collision mask used to mask collisions (default is -1).
  32111. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32112. */
  32113. get collisionMask(): number;
  32114. set collisionMask(mask: number);
  32115. /**
  32116. * Gets or sets the current collision group mask (-1 by default).
  32117. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32118. */
  32119. get collisionGroup(): number;
  32120. set collisionGroup(mask: number);
  32121. /**
  32122. * Gets or sets current surrounding meshes (null by default).
  32123. *
  32124. * By default collision detection is tested against every mesh in the scene.
  32125. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32126. * meshes will be tested for the collision.
  32127. *
  32128. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32129. */
  32130. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32131. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32132. /**
  32133. * Defines edge width used when edgesRenderer is enabled
  32134. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32135. */
  32136. edgesWidth: number;
  32137. /**
  32138. * Defines edge color used when edgesRenderer is enabled
  32139. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32140. */
  32141. edgesColor: Color4;
  32142. /** @hidden */
  32143. _edgesRenderer: Nullable<IEdgesRenderer>;
  32144. /** @hidden */
  32145. _masterMesh: Nullable<AbstractMesh>;
  32146. /** @hidden */
  32147. _boundingInfo: Nullable<BoundingInfo>;
  32148. /** @hidden */
  32149. _renderId: number;
  32150. /**
  32151. * Gets or sets the list of subMeshes
  32152. * @see https://doc.babylonjs.com/how_to/multi_materials
  32153. */
  32154. subMeshes: SubMesh[];
  32155. /** @hidden */
  32156. _intersectionsInProgress: AbstractMesh[];
  32157. /** @hidden */
  32158. _unIndexed: boolean;
  32159. /** @hidden */
  32160. _lightSources: Light[];
  32161. /** Gets the list of lights affecting that mesh */
  32162. get lightSources(): Light[];
  32163. /** @hidden */
  32164. get _positions(): Nullable<Vector3[]>;
  32165. /** @hidden */
  32166. _waitingData: {
  32167. lods: Nullable<any>;
  32168. actions: Nullable<any>;
  32169. freezeWorldMatrix: Nullable<boolean>;
  32170. };
  32171. /** @hidden */
  32172. _bonesTransformMatrices: Nullable<Float32Array>;
  32173. /** @hidden */
  32174. _transformMatrixTexture: Nullable<RawTexture>;
  32175. /**
  32176. * Gets or sets a skeleton to apply skining transformations
  32177. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32178. */
  32179. set skeleton(value: Nullable<Skeleton>);
  32180. get skeleton(): Nullable<Skeleton>;
  32181. /**
  32182. * An event triggered when the mesh is rebuilt.
  32183. */
  32184. onRebuildObservable: Observable<AbstractMesh>;
  32185. /**
  32186. * Creates a new AbstractMesh
  32187. * @param name defines the name of the mesh
  32188. * @param scene defines the hosting scene
  32189. */
  32190. constructor(name: string, scene?: Nullable<Scene>);
  32191. /**
  32192. * Returns the string "AbstractMesh"
  32193. * @returns "AbstractMesh"
  32194. */
  32195. getClassName(): string;
  32196. /**
  32197. * Gets a string representation of the current mesh
  32198. * @param fullDetails defines a boolean indicating if full details must be included
  32199. * @returns a string representation of the current mesh
  32200. */
  32201. toString(fullDetails?: boolean): string;
  32202. /**
  32203. * @hidden
  32204. */
  32205. protected _getEffectiveParent(): Nullable<Node>;
  32206. /** @hidden */
  32207. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32208. /** @hidden */
  32209. _rebuild(): void;
  32210. /** @hidden */
  32211. _resyncLightSources(): void;
  32212. /** @hidden */
  32213. _resyncLightSource(light: Light): void;
  32214. /** @hidden */
  32215. _unBindEffect(): void;
  32216. /** @hidden */
  32217. _removeLightSource(light: Light, dispose: boolean): void;
  32218. private _markSubMeshesAsDirty;
  32219. /** @hidden */
  32220. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32221. /** @hidden */
  32222. _markSubMeshesAsAttributesDirty(): void;
  32223. /** @hidden */
  32224. _markSubMeshesAsMiscDirty(): void;
  32225. /**
  32226. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32227. */
  32228. get scaling(): Vector3;
  32229. set scaling(newScaling: Vector3);
  32230. /**
  32231. * Returns true if the mesh is blocked. Implemented by child classes
  32232. */
  32233. get isBlocked(): boolean;
  32234. /**
  32235. * Returns the mesh itself by default. Implemented by child classes
  32236. * @param camera defines the camera to use to pick the right LOD level
  32237. * @returns the currentAbstractMesh
  32238. */
  32239. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32240. /**
  32241. * Returns 0 by default. Implemented by child classes
  32242. * @returns an integer
  32243. */
  32244. getTotalVertices(): number;
  32245. /**
  32246. * Returns a positive integer : the total number of indices in this mesh geometry.
  32247. * @returns the numner of indices or zero if the mesh has no geometry.
  32248. */
  32249. getTotalIndices(): number;
  32250. /**
  32251. * Returns null by default. Implemented by child classes
  32252. * @returns null
  32253. */
  32254. getIndices(): Nullable<IndicesArray>;
  32255. /**
  32256. * Returns the array of the requested vertex data kind. Implemented by child classes
  32257. * @param kind defines the vertex data kind to use
  32258. * @returns null
  32259. */
  32260. getVerticesData(kind: string): Nullable<FloatArray>;
  32261. /**
  32262. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32263. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32264. * Note that a new underlying VertexBuffer object is created each call.
  32265. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32266. * @param kind defines vertex data kind:
  32267. * * VertexBuffer.PositionKind
  32268. * * VertexBuffer.UVKind
  32269. * * VertexBuffer.UV2Kind
  32270. * * VertexBuffer.UV3Kind
  32271. * * VertexBuffer.UV4Kind
  32272. * * VertexBuffer.UV5Kind
  32273. * * VertexBuffer.UV6Kind
  32274. * * VertexBuffer.ColorKind
  32275. * * VertexBuffer.MatricesIndicesKind
  32276. * * VertexBuffer.MatricesIndicesExtraKind
  32277. * * VertexBuffer.MatricesWeightsKind
  32278. * * VertexBuffer.MatricesWeightsExtraKind
  32279. * @param data defines the data source
  32280. * @param updatable defines if the data must be flagged as updatable (or static)
  32281. * @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
  32282. * @returns the current mesh
  32283. */
  32284. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32285. /**
  32286. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32287. * If the mesh has no geometry, it is simply returned as it is.
  32288. * @param kind defines vertex data kind:
  32289. * * VertexBuffer.PositionKind
  32290. * * VertexBuffer.UVKind
  32291. * * VertexBuffer.UV2Kind
  32292. * * VertexBuffer.UV3Kind
  32293. * * VertexBuffer.UV4Kind
  32294. * * VertexBuffer.UV5Kind
  32295. * * VertexBuffer.UV6Kind
  32296. * * VertexBuffer.ColorKind
  32297. * * VertexBuffer.MatricesIndicesKind
  32298. * * VertexBuffer.MatricesIndicesExtraKind
  32299. * * VertexBuffer.MatricesWeightsKind
  32300. * * VertexBuffer.MatricesWeightsExtraKind
  32301. * @param data defines the data source
  32302. * @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
  32303. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32304. * @returns the current mesh
  32305. */
  32306. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32307. /**
  32308. * Sets the mesh indices,
  32309. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32310. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32311. * @param totalVertices Defines the total number of vertices
  32312. * @returns the current mesh
  32313. */
  32314. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32315. /**
  32316. * Gets a boolean indicating if specific vertex data is present
  32317. * @param kind defines the vertex data kind to use
  32318. * @returns true is data kind is present
  32319. */
  32320. isVerticesDataPresent(kind: string): boolean;
  32321. /**
  32322. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32323. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32324. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32325. * @returns a BoundingInfo
  32326. */
  32327. getBoundingInfo(): BoundingInfo;
  32328. /**
  32329. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32330. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32331. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32332. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32333. * @returns the current mesh
  32334. */
  32335. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32336. /**
  32337. * Overwrite the current bounding info
  32338. * @param boundingInfo defines the new bounding info
  32339. * @returns the current mesh
  32340. */
  32341. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32342. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32343. get useBones(): boolean;
  32344. /** @hidden */
  32345. _preActivate(): void;
  32346. /** @hidden */
  32347. _preActivateForIntermediateRendering(renderId: number): void;
  32348. /** @hidden */
  32349. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32350. /** @hidden */
  32351. _postActivate(): void;
  32352. /** @hidden */
  32353. _freeze(): void;
  32354. /** @hidden */
  32355. _unFreeze(): void;
  32356. /**
  32357. * Gets the current world matrix
  32358. * @returns a Matrix
  32359. */
  32360. getWorldMatrix(): Matrix;
  32361. /** @hidden */
  32362. _getWorldMatrixDeterminant(): number;
  32363. /**
  32364. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32365. */
  32366. get isAnInstance(): boolean;
  32367. /**
  32368. * Gets a boolean indicating if this mesh has instances
  32369. */
  32370. get hasInstances(): boolean;
  32371. /**
  32372. * Gets a boolean indicating if this mesh has thin instances
  32373. */
  32374. get hasThinInstances(): boolean;
  32375. /**
  32376. * Perform relative position change from the point of view of behind the front of the mesh.
  32377. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32378. * Supports definition of mesh facing forward or backward
  32379. * @param amountRight defines the distance on the right axis
  32380. * @param amountUp defines the distance on the up axis
  32381. * @param amountForward defines the distance on the forward axis
  32382. * @returns the current mesh
  32383. */
  32384. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32385. /**
  32386. * Calculate relative position change from the point of view of behind the front of the mesh.
  32387. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32388. * Supports definition of mesh facing forward or backward
  32389. * @param amountRight defines the distance on the right axis
  32390. * @param amountUp defines the distance on the up axis
  32391. * @param amountForward defines the distance on the forward axis
  32392. * @returns the new displacement vector
  32393. */
  32394. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32395. /**
  32396. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32397. * Supports definition of mesh facing forward or backward
  32398. * @param flipBack defines the flip
  32399. * @param twirlClockwise defines the twirl
  32400. * @param tiltRight defines the tilt
  32401. * @returns the current mesh
  32402. */
  32403. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32404. /**
  32405. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32406. * Supports definition of mesh facing forward or backward.
  32407. * @param flipBack defines the flip
  32408. * @param twirlClockwise defines the twirl
  32409. * @param tiltRight defines the tilt
  32410. * @returns the new rotation vector
  32411. */
  32412. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32413. /**
  32414. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32415. * This means the mesh underlying bounding box and sphere are recomputed.
  32416. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32417. * @returns the current mesh
  32418. */
  32419. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32420. /** @hidden */
  32421. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32422. /** @hidden */
  32423. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32424. /** @hidden */
  32425. _updateBoundingInfo(): AbstractMesh;
  32426. /** @hidden */
  32427. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32428. /** @hidden */
  32429. protected _afterComputeWorldMatrix(): void;
  32430. /** @hidden */
  32431. get _effectiveMesh(): AbstractMesh;
  32432. /**
  32433. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32434. * A mesh is in the frustum if its bounding box intersects the frustum
  32435. * @param frustumPlanes defines the frustum to test
  32436. * @returns true if the mesh is in the frustum planes
  32437. */
  32438. isInFrustum(frustumPlanes: Plane[]): boolean;
  32439. /**
  32440. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32441. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32442. * @param frustumPlanes defines the frustum to test
  32443. * @returns true if the mesh is completely in the frustum planes
  32444. */
  32445. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32446. /**
  32447. * True if the mesh intersects another mesh or a SolidParticle object
  32448. * @param mesh defines a target mesh or SolidParticle to test
  32449. * @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)
  32450. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32451. * @returns true if there is an intersection
  32452. */
  32453. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32454. /**
  32455. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32456. * @param point defines the point to test
  32457. * @returns true if there is an intersection
  32458. */
  32459. intersectsPoint(point: Vector3): boolean;
  32460. /**
  32461. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32462. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32463. */
  32464. get checkCollisions(): boolean;
  32465. set checkCollisions(collisionEnabled: boolean);
  32466. /**
  32467. * Gets Collider object used to compute collisions (not physics)
  32468. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32469. */
  32470. get collider(): Nullable<Collider>;
  32471. /**
  32472. * Move the mesh using collision engine
  32473. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32474. * @param displacement defines the requested displacement vector
  32475. * @returns the current mesh
  32476. */
  32477. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32478. private _onCollisionPositionChange;
  32479. /** @hidden */
  32480. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32481. /** @hidden */
  32482. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32483. /** @hidden */
  32484. _checkCollision(collider: Collider): AbstractMesh;
  32485. /** @hidden */
  32486. _generatePointsArray(): boolean;
  32487. /**
  32488. * Checks if the passed Ray intersects with the mesh
  32489. * @param ray defines the ray to use
  32490. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32491. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32492. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32493. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32494. * @returns the picking info
  32495. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32496. */
  32497. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32498. /**
  32499. * Clones the current mesh
  32500. * @param name defines the mesh name
  32501. * @param newParent defines the new mesh parent
  32502. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32503. * @returns the new mesh
  32504. */
  32505. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32506. /**
  32507. * Disposes all the submeshes of the current meshnp
  32508. * @returns the current mesh
  32509. */
  32510. releaseSubMeshes(): AbstractMesh;
  32511. /**
  32512. * Releases resources associated with this abstract mesh.
  32513. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32514. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32515. */
  32516. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32517. /**
  32518. * Adds the passed mesh as a child to the current mesh
  32519. * @param mesh defines the child mesh
  32520. * @returns the current mesh
  32521. */
  32522. addChild(mesh: AbstractMesh): AbstractMesh;
  32523. /**
  32524. * Removes the passed mesh from the current mesh children list
  32525. * @param mesh defines the child mesh
  32526. * @returns the current mesh
  32527. */
  32528. removeChild(mesh: AbstractMesh): AbstractMesh;
  32529. /** @hidden */
  32530. private _initFacetData;
  32531. /**
  32532. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32533. * This method can be called within the render loop.
  32534. * 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
  32535. * @returns the current mesh
  32536. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32537. */
  32538. updateFacetData(): AbstractMesh;
  32539. /**
  32540. * Returns the facetLocalNormals array.
  32541. * The normals are expressed in the mesh local spac
  32542. * @returns an array of Vector3
  32543. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32544. */
  32545. getFacetLocalNormals(): Vector3[];
  32546. /**
  32547. * Returns the facetLocalPositions array.
  32548. * The facet positions are expressed in the mesh local space
  32549. * @returns an array of Vector3
  32550. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32551. */
  32552. getFacetLocalPositions(): Vector3[];
  32553. /**
  32554. * Returns the facetLocalPartioning array
  32555. * @returns an array of array of numbers
  32556. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32557. */
  32558. getFacetLocalPartitioning(): number[][];
  32559. /**
  32560. * Returns the i-th facet position in the world system.
  32561. * This method allocates a new Vector3 per call
  32562. * @param i defines the facet index
  32563. * @returns a new Vector3
  32564. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32565. */
  32566. getFacetPosition(i: number): Vector3;
  32567. /**
  32568. * Sets the reference Vector3 with the i-th facet position in the world system
  32569. * @param i defines the facet index
  32570. * @param ref defines the target vector
  32571. * @returns the current mesh
  32572. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32573. */
  32574. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32575. /**
  32576. * Returns the i-th facet normal in the world system.
  32577. * This method allocates a new Vector3 per call
  32578. * @param i defines the facet index
  32579. * @returns a new Vector3
  32580. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32581. */
  32582. getFacetNormal(i: number): Vector3;
  32583. /**
  32584. * Sets the reference Vector3 with the i-th facet normal in the world system
  32585. * @param i defines the facet index
  32586. * @param ref defines the target vector
  32587. * @returns the current mesh
  32588. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32589. */
  32590. getFacetNormalToRef(i: number, ref: Vector3): this;
  32591. /**
  32592. * 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)
  32593. * @param x defines x coordinate
  32594. * @param y defines y coordinate
  32595. * @param z defines z coordinate
  32596. * @returns the array of facet indexes
  32597. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32598. */
  32599. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32600. /**
  32601. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32602. * @param projected sets as the (x,y,z) world projection on the facet
  32603. * @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
  32604. * @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
  32605. * @param x defines x coordinate
  32606. * @param y defines y coordinate
  32607. * @param z defines z coordinate
  32608. * @returns the face index if found (or null instead)
  32609. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32610. */
  32611. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32612. /**
  32613. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32614. * @param projected sets as the (x,y,z) local projection on the facet
  32615. * @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
  32616. * @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
  32617. * @param x defines x coordinate
  32618. * @param y defines y coordinate
  32619. * @param z defines z coordinate
  32620. * @returns the face index if found (or null instead)
  32621. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32622. */
  32623. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32624. /**
  32625. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32626. * @returns the parameters
  32627. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32628. */
  32629. getFacetDataParameters(): any;
  32630. /**
  32631. * Disables the feature FacetData and frees the related memory
  32632. * @returns the current mesh
  32633. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32634. */
  32635. disableFacetData(): AbstractMesh;
  32636. /**
  32637. * Updates the AbstractMesh indices array
  32638. * @param indices defines the data source
  32639. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32640. * @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)
  32641. * @returns the current mesh
  32642. */
  32643. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32644. /**
  32645. * Creates new normals data for the mesh
  32646. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32647. * @returns the current mesh
  32648. */
  32649. createNormals(updatable: boolean): AbstractMesh;
  32650. /**
  32651. * Align the mesh with a normal
  32652. * @param normal defines the normal to use
  32653. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32654. * @returns the current mesh
  32655. */
  32656. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32657. /** @hidden */
  32658. _checkOcclusionQuery(): boolean;
  32659. /**
  32660. * Disables the mesh edge rendering mode
  32661. * @returns the currentAbstractMesh
  32662. */
  32663. disableEdgesRendering(): AbstractMesh;
  32664. /**
  32665. * Enables the edge rendering mode on the mesh.
  32666. * This mode makes the mesh edges visible
  32667. * @param epsilon defines the maximal distance between two angles to detect a face
  32668. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32669. * @returns the currentAbstractMesh
  32670. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32671. */
  32672. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32673. /**
  32674. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32675. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32676. */
  32677. getConnectedParticleSystems(): IParticleSystem[];
  32678. }
  32679. }
  32680. declare module BABYLON {
  32681. /**
  32682. * Interface used to define ActionEvent
  32683. */
  32684. export interface IActionEvent {
  32685. /** The mesh or sprite that triggered the action */
  32686. source: any;
  32687. /** The X mouse cursor position at the time of the event */
  32688. pointerX: number;
  32689. /** The Y mouse cursor position at the time of the event */
  32690. pointerY: number;
  32691. /** The mesh that is currently pointed at (can be null) */
  32692. meshUnderPointer: Nullable<AbstractMesh>;
  32693. /** the original (browser) event that triggered the ActionEvent */
  32694. sourceEvent?: any;
  32695. /** additional data for the event */
  32696. additionalData?: any;
  32697. }
  32698. /**
  32699. * ActionEvent is the event being sent when an action is triggered.
  32700. */
  32701. export class ActionEvent implements IActionEvent {
  32702. /** The mesh or sprite that triggered the action */
  32703. source: any;
  32704. /** The X mouse cursor position at the time of the event */
  32705. pointerX: number;
  32706. /** The Y mouse cursor position at the time of the event */
  32707. pointerY: number;
  32708. /** The mesh that is currently pointed at (can be null) */
  32709. meshUnderPointer: Nullable<AbstractMesh>;
  32710. /** the original (browser) event that triggered the ActionEvent */
  32711. sourceEvent?: any;
  32712. /** additional data for the event */
  32713. additionalData?: any;
  32714. /**
  32715. * Creates a new ActionEvent
  32716. * @param source The mesh or sprite that triggered the action
  32717. * @param pointerX The X mouse cursor position at the time of the event
  32718. * @param pointerY The Y mouse cursor position at the time of the event
  32719. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32720. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32721. * @param additionalData additional data for the event
  32722. */
  32723. constructor(
  32724. /** The mesh or sprite that triggered the action */
  32725. source: any,
  32726. /** The X mouse cursor position at the time of the event */
  32727. pointerX: number,
  32728. /** The Y mouse cursor position at the time of the event */
  32729. pointerY: number,
  32730. /** The mesh that is currently pointed at (can be null) */
  32731. meshUnderPointer: Nullable<AbstractMesh>,
  32732. /** the original (browser) event that triggered the ActionEvent */
  32733. sourceEvent?: any,
  32734. /** additional data for the event */
  32735. additionalData?: any);
  32736. /**
  32737. * Helper function to auto-create an ActionEvent from a source mesh.
  32738. * @param source The source mesh that triggered the event
  32739. * @param evt The original (browser) event
  32740. * @param additionalData additional data for the event
  32741. * @returns the new ActionEvent
  32742. */
  32743. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32744. /**
  32745. * Helper function to auto-create an ActionEvent from a source sprite
  32746. * @param source The source sprite that triggered the event
  32747. * @param scene Scene associated with the sprite
  32748. * @param evt The original (browser) event
  32749. * @param additionalData additional data for the event
  32750. * @returns the new ActionEvent
  32751. */
  32752. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32753. /**
  32754. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32755. * @param scene the scene where the event occurred
  32756. * @param evt The original (browser) event
  32757. * @returns the new ActionEvent
  32758. */
  32759. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32760. /**
  32761. * Helper function to auto-create an ActionEvent from a primitive
  32762. * @param prim defines the target primitive
  32763. * @param pointerPos defines the pointer position
  32764. * @param evt The original (browser) event
  32765. * @param additionalData additional data for the event
  32766. * @returns the new ActionEvent
  32767. */
  32768. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32769. }
  32770. }
  32771. declare module BABYLON {
  32772. /**
  32773. * Abstract class used to decouple action Manager from scene and meshes.
  32774. * Do not instantiate.
  32775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32776. */
  32777. export abstract class AbstractActionManager implements IDisposable {
  32778. /** Gets the list of active triggers */
  32779. static Triggers: {
  32780. [key: string]: number;
  32781. };
  32782. /** Gets the cursor to use when hovering items */
  32783. hoverCursor: string;
  32784. /** Gets the list of actions */
  32785. actions: IAction[];
  32786. /**
  32787. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32788. */
  32789. isRecursive: boolean;
  32790. /**
  32791. * Releases all associated resources
  32792. */
  32793. abstract dispose(): void;
  32794. /**
  32795. * Does this action manager has pointer triggers
  32796. */
  32797. abstract get hasPointerTriggers(): boolean;
  32798. /**
  32799. * Does this action manager has pick triggers
  32800. */
  32801. abstract get hasPickTriggers(): boolean;
  32802. /**
  32803. * Process a specific trigger
  32804. * @param trigger defines the trigger to process
  32805. * @param evt defines the event details to be processed
  32806. */
  32807. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32808. /**
  32809. * Does this action manager handles actions of any of the given triggers
  32810. * @param triggers defines the triggers to be tested
  32811. * @return a boolean indicating whether one (or more) of the triggers is handled
  32812. */
  32813. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32814. /**
  32815. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32816. * speed.
  32817. * @param triggerA defines the trigger to be tested
  32818. * @param triggerB defines the trigger to be tested
  32819. * @return a boolean indicating whether one (or more) of the triggers is handled
  32820. */
  32821. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32822. /**
  32823. * Does this action manager handles actions of a given trigger
  32824. * @param trigger defines the trigger to be tested
  32825. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32826. * @return whether the trigger is handled
  32827. */
  32828. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32829. /**
  32830. * Serialize this manager to a JSON object
  32831. * @param name defines the property name to store this manager
  32832. * @returns a JSON representation of this manager
  32833. */
  32834. abstract serialize(name: string): any;
  32835. /**
  32836. * Registers an action to this action manager
  32837. * @param action defines the action to be registered
  32838. * @return the action amended (prepared) after registration
  32839. */
  32840. abstract registerAction(action: IAction): Nullable<IAction>;
  32841. /**
  32842. * Unregisters an action to this action manager
  32843. * @param action defines the action to be unregistered
  32844. * @return a boolean indicating whether the action has been unregistered
  32845. */
  32846. abstract unregisterAction(action: IAction): Boolean;
  32847. /**
  32848. * Does exist one action manager with at least one trigger
  32849. **/
  32850. static get HasTriggers(): boolean;
  32851. /**
  32852. * Does exist one action manager with at least one pick trigger
  32853. **/
  32854. static get HasPickTriggers(): boolean;
  32855. /**
  32856. * Does exist one action manager that handles actions of a given trigger
  32857. * @param trigger defines the trigger to be tested
  32858. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32859. **/
  32860. static HasSpecificTrigger(trigger: number): boolean;
  32861. }
  32862. }
  32863. declare module BABYLON {
  32864. /**
  32865. * Defines how a node can be built from a string name.
  32866. */
  32867. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32868. /**
  32869. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32870. */
  32871. export class Node implements IBehaviorAware<Node> {
  32872. /** @hidden */
  32873. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32874. private static _NodeConstructors;
  32875. /**
  32876. * Add a new node constructor
  32877. * @param type defines the type name of the node to construct
  32878. * @param constructorFunc defines the constructor function
  32879. */
  32880. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32881. /**
  32882. * Returns a node constructor based on type name
  32883. * @param type defines the type name
  32884. * @param name defines the new node name
  32885. * @param scene defines the hosting scene
  32886. * @param options defines optional options to transmit to constructors
  32887. * @returns the new constructor or null
  32888. */
  32889. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32890. /**
  32891. * Gets or sets the name of the node
  32892. */
  32893. name: string;
  32894. /**
  32895. * Gets or sets the id of the node
  32896. */
  32897. id: string;
  32898. /**
  32899. * Gets or sets the unique id of the node
  32900. */
  32901. uniqueId: number;
  32902. /**
  32903. * Gets or sets a string used to store user defined state for the node
  32904. */
  32905. state: string;
  32906. /**
  32907. * Gets or sets an object used to store user defined information for the node
  32908. */
  32909. metadata: any;
  32910. /**
  32911. * For internal use only. Please do not use.
  32912. */
  32913. reservedDataStore: any;
  32914. /**
  32915. * List of inspectable custom properties (used by the Inspector)
  32916. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32917. */
  32918. inspectableCustomProperties: IInspectable[];
  32919. private _doNotSerialize;
  32920. /**
  32921. * Gets or sets a boolean used to define if the node must be serialized
  32922. */
  32923. get doNotSerialize(): boolean;
  32924. set doNotSerialize(value: boolean);
  32925. /** @hidden */
  32926. _isDisposed: boolean;
  32927. /**
  32928. * Gets a list of Animations associated with the node
  32929. */
  32930. animations: Animation[];
  32931. protected _ranges: {
  32932. [name: string]: Nullable<AnimationRange>;
  32933. };
  32934. /**
  32935. * Callback raised when the node is ready to be used
  32936. */
  32937. onReady: Nullable<(node: Node) => void>;
  32938. private _isEnabled;
  32939. private _isParentEnabled;
  32940. private _isReady;
  32941. /** @hidden */
  32942. _currentRenderId: number;
  32943. private _parentUpdateId;
  32944. /** @hidden */
  32945. _childUpdateId: number;
  32946. /** @hidden */
  32947. _waitingParentId: Nullable<string>;
  32948. /** @hidden */
  32949. _scene: Scene;
  32950. /** @hidden */
  32951. _cache: any;
  32952. private _parentNode;
  32953. private _children;
  32954. /** @hidden */
  32955. _worldMatrix: Matrix;
  32956. /** @hidden */
  32957. _worldMatrixDeterminant: number;
  32958. /** @hidden */
  32959. _worldMatrixDeterminantIsDirty: boolean;
  32960. /** @hidden */
  32961. private _sceneRootNodesIndex;
  32962. /**
  32963. * Gets a boolean indicating if the node has been disposed
  32964. * @returns true if the node was disposed
  32965. */
  32966. isDisposed(): boolean;
  32967. /**
  32968. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32969. * @see https://doc.babylonjs.com/how_to/parenting
  32970. */
  32971. set parent(parent: Nullable<Node>);
  32972. get parent(): Nullable<Node>;
  32973. /** @hidden */
  32974. _addToSceneRootNodes(): void;
  32975. /** @hidden */
  32976. _removeFromSceneRootNodes(): void;
  32977. private _animationPropertiesOverride;
  32978. /**
  32979. * Gets or sets the animation properties override
  32980. */
  32981. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32982. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32983. /**
  32984. * Gets a string idenfifying the name of the class
  32985. * @returns "Node" string
  32986. */
  32987. getClassName(): string;
  32988. /** @hidden */
  32989. readonly _isNode: boolean;
  32990. /**
  32991. * An event triggered when the mesh is disposed
  32992. */
  32993. onDisposeObservable: Observable<Node>;
  32994. private _onDisposeObserver;
  32995. /**
  32996. * Sets a callback that will be raised when the node will be disposed
  32997. */
  32998. set onDispose(callback: () => void);
  32999. /**
  33000. * Creates a new Node
  33001. * @param name the name and id to be given to this node
  33002. * @param scene the scene this node will be added to
  33003. */
  33004. constructor(name: string, scene?: Nullable<Scene>);
  33005. /**
  33006. * Gets the scene of the node
  33007. * @returns a scene
  33008. */
  33009. getScene(): Scene;
  33010. /**
  33011. * Gets the engine of the node
  33012. * @returns a Engine
  33013. */
  33014. getEngine(): Engine;
  33015. private _behaviors;
  33016. /**
  33017. * Attach a behavior to the node
  33018. * @see https://doc.babylonjs.com/features/behaviour
  33019. * @param behavior defines the behavior to attach
  33020. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33021. * @returns the current Node
  33022. */
  33023. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33024. /**
  33025. * Remove an attached behavior
  33026. * @see https://doc.babylonjs.com/features/behaviour
  33027. * @param behavior defines the behavior to attach
  33028. * @returns the current Node
  33029. */
  33030. removeBehavior(behavior: Behavior<Node>): Node;
  33031. /**
  33032. * Gets the list of attached behaviors
  33033. * @see https://doc.babylonjs.com/features/behaviour
  33034. */
  33035. get behaviors(): Behavior<Node>[];
  33036. /**
  33037. * Gets an attached behavior by name
  33038. * @param name defines the name of the behavior to look for
  33039. * @see https://doc.babylonjs.com/features/behaviour
  33040. * @returns null if behavior was not found else the requested behavior
  33041. */
  33042. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33043. /**
  33044. * Returns the latest update of the World matrix
  33045. * @returns a Matrix
  33046. */
  33047. getWorldMatrix(): Matrix;
  33048. /** @hidden */
  33049. _getWorldMatrixDeterminant(): number;
  33050. /**
  33051. * Returns directly the latest state of the mesh World matrix.
  33052. * A Matrix is returned.
  33053. */
  33054. get worldMatrixFromCache(): Matrix;
  33055. /** @hidden */
  33056. _initCache(): void;
  33057. /** @hidden */
  33058. updateCache(force?: boolean): void;
  33059. /** @hidden */
  33060. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33061. /** @hidden */
  33062. _updateCache(ignoreParentClass?: boolean): void;
  33063. /** @hidden */
  33064. _isSynchronized(): boolean;
  33065. /** @hidden */
  33066. _markSyncedWithParent(): void;
  33067. /** @hidden */
  33068. isSynchronizedWithParent(): boolean;
  33069. /** @hidden */
  33070. isSynchronized(): boolean;
  33071. /**
  33072. * Is this node ready to be used/rendered
  33073. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33074. * @return true if the node is ready
  33075. */
  33076. isReady(completeCheck?: boolean): boolean;
  33077. /**
  33078. * Is this node enabled?
  33079. * 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
  33080. * @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
  33081. * @return whether this node (and its parent) is enabled
  33082. */
  33083. isEnabled(checkAncestors?: boolean): boolean;
  33084. /** @hidden */
  33085. protected _syncParentEnabledState(): void;
  33086. /**
  33087. * Set the enabled state of this node
  33088. * @param value defines the new enabled state
  33089. */
  33090. setEnabled(value: boolean): void;
  33091. /**
  33092. * Is this node a descendant of the given node?
  33093. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33094. * @param ancestor defines the parent node to inspect
  33095. * @returns a boolean indicating if this node is a descendant of the given node
  33096. */
  33097. isDescendantOf(ancestor: Node): boolean;
  33098. /** @hidden */
  33099. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33100. /**
  33101. * Will return all nodes that have this node as ascendant
  33102. * @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
  33103. * @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
  33104. * @return all children nodes of all types
  33105. */
  33106. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33107. /**
  33108. * Get all child-meshes of this node
  33109. * @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)
  33110. * @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
  33111. * @returns an array of AbstractMesh
  33112. */
  33113. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33114. /**
  33115. * Get all direct children of this node
  33116. * @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
  33117. * @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)
  33118. * @returns an array of Node
  33119. */
  33120. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33121. /** @hidden */
  33122. _setReady(state: boolean): void;
  33123. /**
  33124. * Get an animation by name
  33125. * @param name defines the name of the animation to look for
  33126. * @returns null if not found else the requested animation
  33127. */
  33128. getAnimationByName(name: string): Nullable<Animation>;
  33129. /**
  33130. * Creates an animation range for this node
  33131. * @param name defines the name of the range
  33132. * @param from defines the starting key
  33133. * @param to defines the end key
  33134. */
  33135. createAnimationRange(name: string, from: number, to: number): void;
  33136. /**
  33137. * Delete a specific animation range
  33138. * @param name defines the name of the range to delete
  33139. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33140. */
  33141. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33142. /**
  33143. * Get an animation range by name
  33144. * @param name defines the name of the animation range to look for
  33145. * @returns null if not found else the requested animation range
  33146. */
  33147. getAnimationRange(name: string): Nullable<AnimationRange>;
  33148. /**
  33149. * Gets the list of all animation ranges defined on this node
  33150. * @returns an array
  33151. */
  33152. getAnimationRanges(): Nullable<AnimationRange>[];
  33153. /**
  33154. * Will start the animation sequence
  33155. * @param name defines the range frames for animation sequence
  33156. * @param loop defines if the animation should loop (false by default)
  33157. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33158. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33159. * @returns the object created for this animation. If range does not exist, it will return null
  33160. */
  33161. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33162. /**
  33163. * Serialize animation ranges into a JSON compatible object
  33164. * @returns serialization object
  33165. */
  33166. serializeAnimationRanges(): any;
  33167. /**
  33168. * Computes the world matrix of the node
  33169. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33170. * @returns the world matrix
  33171. */
  33172. computeWorldMatrix(force?: boolean): Matrix;
  33173. /**
  33174. * Releases resources associated with this node.
  33175. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33176. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33177. */
  33178. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33179. /**
  33180. * Parse animation range data from a serialization object and store them into a given node
  33181. * @param node defines where to store the animation ranges
  33182. * @param parsedNode defines the serialization object to read data from
  33183. * @param scene defines the hosting scene
  33184. */
  33185. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33186. /**
  33187. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33188. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33189. * @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
  33190. * @returns the new bounding vectors
  33191. */
  33192. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33193. min: Vector3;
  33194. max: Vector3;
  33195. };
  33196. }
  33197. }
  33198. declare module BABYLON {
  33199. /**
  33200. * @hidden
  33201. */
  33202. export class _IAnimationState {
  33203. key: number;
  33204. repeatCount: number;
  33205. workValue?: any;
  33206. loopMode?: number;
  33207. offsetValue?: any;
  33208. highLimitValue?: any;
  33209. }
  33210. /**
  33211. * Class used to store any kind of animation
  33212. */
  33213. export class Animation {
  33214. /**Name of the animation */
  33215. name: string;
  33216. /**Property to animate */
  33217. targetProperty: string;
  33218. /**The frames per second of the animation */
  33219. framePerSecond: number;
  33220. /**The data type of the animation */
  33221. dataType: number;
  33222. /**The loop mode of the animation */
  33223. loopMode?: number | undefined;
  33224. /**Specifies if blending should be enabled */
  33225. enableBlending?: boolean | undefined;
  33226. /**
  33227. * Use matrix interpolation instead of using direct key value when animating matrices
  33228. */
  33229. static AllowMatricesInterpolation: boolean;
  33230. /**
  33231. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33232. */
  33233. static AllowMatrixDecomposeForInterpolation: boolean;
  33234. /** Define the Url to load snippets */
  33235. static SnippetUrl: string;
  33236. /** Snippet ID if the animation was created from the snippet server */
  33237. snippetId: string;
  33238. /**
  33239. * Stores the key frames of the animation
  33240. */
  33241. private _keys;
  33242. /**
  33243. * Stores the easing function of the animation
  33244. */
  33245. private _easingFunction;
  33246. /**
  33247. * @hidden Internal use only
  33248. */
  33249. _runtimeAnimations: RuntimeAnimation[];
  33250. /**
  33251. * The set of event that will be linked to this animation
  33252. */
  33253. private _events;
  33254. /**
  33255. * Stores an array of target property paths
  33256. */
  33257. targetPropertyPath: string[];
  33258. /**
  33259. * Stores the blending speed of the animation
  33260. */
  33261. blendingSpeed: number;
  33262. /**
  33263. * Stores the animation ranges for the animation
  33264. */
  33265. private _ranges;
  33266. /**
  33267. * @hidden Internal use
  33268. */
  33269. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33270. /**
  33271. * Sets up an animation
  33272. * @param property The property to animate
  33273. * @param animationType The animation type to apply
  33274. * @param framePerSecond The frames per second of the animation
  33275. * @param easingFunction The easing function used in the animation
  33276. * @returns The created animation
  33277. */
  33278. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33279. /**
  33280. * Create and start an animation on a node
  33281. * @param name defines the name of the global animation that will be run on all nodes
  33282. * @param node defines the root node where the animation will take place
  33283. * @param targetProperty defines property to animate
  33284. * @param framePerSecond defines the number of frame per second yo use
  33285. * @param totalFrame defines the number of frames in total
  33286. * @param from defines the initial value
  33287. * @param to defines the final value
  33288. * @param loopMode defines which loop mode you want to use (off by default)
  33289. * @param easingFunction defines the easing function to use (linear by default)
  33290. * @param onAnimationEnd defines the callback to call when animation end
  33291. * @returns the animatable created for this animation
  33292. */
  33293. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33294. /**
  33295. * Create and start an animation on a node and its descendants
  33296. * @param name defines the name of the global animation that will be run on all nodes
  33297. * @param node defines the root node where the animation will take place
  33298. * @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
  33299. * @param targetProperty defines property to animate
  33300. * @param framePerSecond defines the number of frame per second to use
  33301. * @param totalFrame defines the number of frames in total
  33302. * @param from defines the initial value
  33303. * @param to defines the final value
  33304. * @param loopMode defines which loop mode you want to use (off by default)
  33305. * @param easingFunction defines the easing function to use (linear by default)
  33306. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33307. * @returns the list of animatables created for all nodes
  33308. * @example https://www.babylonjs-playground.com/#MH0VLI
  33309. */
  33310. 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[]>;
  33311. /**
  33312. * Creates a new animation, merges it with the existing animations and starts it
  33313. * @param name Name of the animation
  33314. * @param node Node which contains the scene that begins the animations
  33315. * @param targetProperty Specifies which property to animate
  33316. * @param framePerSecond The frames per second of the animation
  33317. * @param totalFrame The total number of frames
  33318. * @param from The frame at the beginning of the animation
  33319. * @param to The frame at the end of the animation
  33320. * @param loopMode Specifies the loop mode of the animation
  33321. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33322. * @param onAnimationEnd Callback to run once the animation is complete
  33323. * @returns Nullable animation
  33324. */
  33325. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33326. /**
  33327. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33328. * @param sourceAnimation defines the Animation containing keyframes to convert
  33329. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33330. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33331. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33332. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33333. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33334. */
  33335. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33336. /**
  33337. * Transition property of an host to the target Value
  33338. * @param property The property to transition
  33339. * @param targetValue The target Value of the property
  33340. * @param host The object where the property to animate belongs
  33341. * @param scene Scene used to run the animation
  33342. * @param frameRate Framerate (in frame/s) to use
  33343. * @param transition The transition type we want to use
  33344. * @param duration The duration of the animation, in milliseconds
  33345. * @param onAnimationEnd Callback trigger at the end of the animation
  33346. * @returns Nullable animation
  33347. */
  33348. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33349. /**
  33350. * Return the array of runtime animations currently using this animation
  33351. */
  33352. get runtimeAnimations(): RuntimeAnimation[];
  33353. /**
  33354. * Specifies if any of the runtime animations are currently running
  33355. */
  33356. get hasRunningRuntimeAnimations(): boolean;
  33357. /**
  33358. * Initializes the animation
  33359. * @param name Name of the animation
  33360. * @param targetProperty Property to animate
  33361. * @param framePerSecond The frames per second of the animation
  33362. * @param dataType The data type of the animation
  33363. * @param loopMode The loop mode of the animation
  33364. * @param enableBlending Specifies if blending should be enabled
  33365. */
  33366. constructor(
  33367. /**Name of the animation */
  33368. name: string,
  33369. /**Property to animate */
  33370. targetProperty: string,
  33371. /**The frames per second of the animation */
  33372. framePerSecond: number,
  33373. /**The data type of the animation */
  33374. dataType: number,
  33375. /**The loop mode of the animation */
  33376. loopMode?: number | undefined,
  33377. /**Specifies if blending should be enabled */
  33378. enableBlending?: boolean | undefined);
  33379. /**
  33380. * Converts the animation to a string
  33381. * @param fullDetails support for multiple levels of logging within scene loading
  33382. * @returns String form of the animation
  33383. */
  33384. toString(fullDetails?: boolean): string;
  33385. /**
  33386. * Add an event to this animation
  33387. * @param event Event to add
  33388. */
  33389. addEvent(event: AnimationEvent): void;
  33390. /**
  33391. * Remove all events found at the given frame
  33392. * @param frame The frame to remove events from
  33393. */
  33394. removeEvents(frame: number): void;
  33395. /**
  33396. * Retrieves all the events from the animation
  33397. * @returns Events from the animation
  33398. */
  33399. getEvents(): AnimationEvent[];
  33400. /**
  33401. * Creates an animation range
  33402. * @param name Name of the animation range
  33403. * @param from Starting frame of the animation range
  33404. * @param to Ending frame of the animation
  33405. */
  33406. createRange(name: string, from: number, to: number): void;
  33407. /**
  33408. * Deletes an animation range by name
  33409. * @param name Name of the animation range to delete
  33410. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33411. */
  33412. deleteRange(name: string, deleteFrames?: boolean): void;
  33413. /**
  33414. * Gets the animation range by name, or null if not defined
  33415. * @param name Name of the animation range
  33416. * @returns Nullable animation range
  33417. */
  33418. getRange(name: string): Nullable<AnimationRange>;
  33419. /**
  33420. * Gets the key frames from the animation
  33421. * @returns The key frames of the animation
  33422. */
  33423. getKeys(): Array<IAnimationKey>;
  33424. /**
  33425. * Gets the highest frame rate of the animation
  33426. * @returns Highest frame rate of the animation
  33427. */
  33428. getHighestFrame(): number;
  33429. /**
  33430. * Gets the easing function of the animation
  33431. * @returns Easing function of the animation
  33432. */
  33433. getEasingFunction(): IEasingFunction;
  33434. /**
  33435. * Sets the easing function of the animation
  33436. * @param easingFunction A custom mathematical formula for animation
  33437. */
  33438. setEasingFunction(easingFunction: EasingFunction): void;
  33439. /**
  33440. * Interpolates a scalar linearly
  33441. * @param startValue Start value of the animation curve
  33442. * @param endValue End value of the animation curve
  33443. * @param gradient Scalar amount to interpolate
  33444. * @returns Interpolated scalar value
  33445. */
  33446. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33447. /**
  33448. * Interpolates a scalar cubically
  33449. * @param startValue Start value of the animation curve
  33450. * @param outTangent End tangent of the animation
  33451. * @param endValue End value of the animation curve
  33452. * @param inTangent Start tangent of the animation curve
  33453. * @param gradient Scalar amount to interpolate
  33454. * @returns Interpolated scalar value
  33455. */
  33456. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33457. /**
  33458. * Interpolates a quaternion using a spherical linear interpolation
  33459. * @param startValue Start value of the animation curve
  33460. * @param endValue End value of the animation curve
  33461. * @param gradient Scalar amount to interpolate
  33462. * @returns Interpolated quaternion value
  33463. */
  33464. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33465. /**
  33466. * Interpolates a quaternion cubically
  33467. * @param startValue Start value of the animation curve
  33468. * @param outTangent End tangent of the animation curve
  33469. * @param endValue End value of the animation curve
  33470. * @param inTangent Start tangent of the animation curve
  33471. * @param gradient Scalar amount to interpolate
  33472. * @returns Interpolated quaternion value
  33473. */
  33474. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33475. /**
  33476. * Interpolates a Vector3 linearl
  33477. * @param startValue Start value of the animation curve
  33478. * @param endValue End value of the animation curve
  33479. * @param gradient Scalar amount to interpolate
  33480. * @returns Interpolated scalar value
  33481. */
  33482. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33483. /**
  33484. * Interpolates a Vector3 cubically
  33485. * @param startValue Start value of the animation curve
  33486. * @param outTangent End tangent of the animation
  33487. * @param endValue End value of the animation curve
  33488. * @param inTangent Start tangent of the animation curve
  33489. * @param gradient Scalar amount to interpolate
  33490. * @returns InterpolatedVector3 value
  33491. */
  33492. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33493. /**
  33494. * Interpolates a Vector2 linearly
  33495. * @param startValue Start value of the animation curve
  33496. * @param endValue End value of the animation curve
  33497. * @param gradient Scalar amount to interpolate
  33498. * @returns Interpolated Vector2 value
  33499. */
  33500. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33501. /**
  33502. * Interpolates a Vector2 cubically
  33503. * @param startValue Start value of the animation curve
  33504. * @param outTangent End tangent of the animation
  33505. * @param endValue End value of the animation curve
  33506. * @param inTangent Start tangent of the animation curve
  33507. * @param gradient Scalar amount to interpolate
  33508. * @returns Interpolated Vector2 value
  33509. */
  33510. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33511. /**
  33512. * Interpolates a size linearly
  33513. * @param startValue Start value of the animation curve
  33514. * @param endValue End value of the animation curve
  33515. * @param gradient Scalar amount to interpolate
  33516. * @returns Interpolated Size value
  33517. */
  33518. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33519. /**
  33520. * Interpolates a Color3 linearly
  33521. * @param startValue Start value of the animation curve
  33522. * @param endValue End value of the animation curve
  33523. * @param gradient Scalar amount to interpolate
  33524. * @returns Interpolated Color3 value
  33525. */
  33526. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33527. /**
  33528. * Interpolates a Color4 linearly
  33529. * @param startValue Start value of the animation curve
  33530. * @param endValue End value of the animation curve
  33531. * @param gradient Scalar amount to interpolate
  33532. * @returns Interpolated Color3 value
  33533. */
  33534. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33535. /**
  33536. * @hidden Internal use only
  33537. */
  33538. _getKeyValue(value: any): any;
  33539. /**
  33540. * @hidden Internal use only
  33541. */
  33542. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33543. /**
  33544. * Defines the function to use to interpolate matrices
  33545. * @param startValue defines the start matrix
  33546. * @param endValue defines the end matrix
  33547. * @param gradient defines the gradient between both matrices
  33548. * @param result defines an optional target matrix where to store the interpolation
  33549. * @returns the interpolated matrix
  33550. */
  33551. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33552. /**
  33553. * Makes a copy of the animation
  33554. * @returns Cloned animation
  33555. */
  33556. clone(): Animation;
  33557. /**
  33558. * Sets the key frames of the animation
  33559. * @param values The animation key frames to set
  33560. */
  33561. setKeys(values: Array<IAnimationKey>): void;
  33562. /**
  33563. * Serializes the animation to an object
  33564. * @returns Serialized object
  33565. */
  33566. serialize(): any;
  33567. /**
  33568. * Float animation type
  33569. */
  33570. static readonly ANIMATIONTYPE_FLOAT: number;
  33571. /**
  33572. * Vector3 animation type
  33573. */
  33574. static readonly ANIMATIONTYPE_VECTOR3: number;
  33575. /**
  33576. * Quaternion animation type
  33577. */
  33578. static readonly ANIMATIONTYPE_QUATERNION: number;
  33579. /**
  33580. * Matrix animation type
  33581. */
  33582. static readonly ANIMATIONTYPE_MATRIX: number;
  33583. /**
  33584. * Color3 animation type
  33585. */
  33586. static readonly ANIMATIONTYPE_COLOR3: number;
  33587. /**
  33588. * Color3 animation type
  33589. */
  33590. static readonly ANIMATIONTYPE_COLOR4: number;
  33591. /**
  33592. * Vector2 animation type
  33593. */
  33594. static readonly ANIMATIONTYPE_VECTOR2: number;
  33595. /**
  33596. * Size animation type
  33597. */
  33598. static readonly ANIMATIONTYPE_SIZE: number;
  33599. /**
  33600. * Relative Loop Mode
  33601. */
  33602. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33603. /**
  33604. * Cycle Loop Mode
  33605. */
  33606. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33607. /**
  33608. * Constant Loop Mode
  33609. */
  33610. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33611. /** @hidden */
  33612. static _UniversalLerp(left: any, right: any, amount: number): any;
  33613. /**
  33614. * Parses an animation object and creates an animation
  33615. * @param parsedAnimation Parsed animation object
  33616. * @returns Animation object
  33617. */
  33618. static Parse(parsedAnimation: any): Animation;
  33619. /**
  33620. * Appends the serialized animations from the source animations
  33621. * @param source Source containing the animations
  33622. * @param destination Target to store the animations
  33623. */
  33624. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33625. /**
  33626. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33627. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33628. * @param url defines the url to load from
  33629. * @returns a promise that will resolve to the new animation or an array of animations
  33630. */
  33631. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33632. /**
  33633. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33634. * @param snippetId defines the snippet to load
  33635. * @returns a promise that will resolve to the new animation or a new array of animations
  33636. */
  33637. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33638. }
  33639. }
  33640. declare module BABYLON {
  33641. /**
  33642. * Interface containing an array of animations
  33643. */
  33644. export interface IAnimatable {
  33645. /**
  33646. * Array of animations
  33647. */
  33648. animations: Nullable<Array<Animation>>;
  33649. }
  33650. }
  33651. declare module BABYLON {
  33652. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33653. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33654. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33655. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33656. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33657. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33658. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33659. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33660. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33661. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33662. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33663. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33664. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33665. /**
  33666. * Decorator used to define property that can be serialized as reference to a camera
  33667. * @param sourceName defines the name of the property to decorate
  33668. */
  33669. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33670. /**
  33671. * Class used to help serialization objects
  33672. */
  33673. export class SerializationHelper {
  33674. /** @hidden */
  33675. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33676. /** @hidden */
  33677. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33678. /** @hidden */
  33679. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33680. /** @hidden */
  33681. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33682. /**
  33683. * Appends the serialized animations from the source animations
  33684. * @param source Source containing the animations
  33685. * @param destination Target to store the animations
  33686. */
  33687. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33688. /**
  33689. * Static function used to serialized a specific entity
  33690. * @param entity defines the entity to serialize
  33691. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33692. * @returns a JSON compatible object representing the serialization of the entity
  33693. */
  33694. static Serialize<T>(entity: T, serializationObject?: any): any;
  33695. /**
  33696. * Creates a new entity from a serialization data object
  33697. * @param creationFunction defines a function used to instanciated the new entity
  33698. * @param source defines the source serialization data
  33699. * @param scene defines the hosting scene
  33700. * @param rootUrl defines the root url for resources
  33701. * @returns a new entity
  33702. */
  33703. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33704. /**
  33705. * Clones an object
  33706. * @param creationFunction defines the function used to instanciate the new object
  33707. * @param source defines the source object
  33708. * @returns the cloned object
  33709. */
  33710. static Clone<T>(creationFunction: () => T, source: T): T;
  33711. /**
  33712. * Instanciates a new object based on a source one (some data will be shared between both object)
  33713. * @param creationFunction defines the function used to instanciate the new object
  33714. * @param source defines the source object
  33715. * @returns the new object
  33716. */
  33717. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33718. }
  33719. }
  33720. declare module BABYLON {
  33721. /**
  33722. * Base class of all the textures in babylon.
  33723. * It groups all the common properties the materials, post process, lights... might need
  33724. * in order to make a correct use of the texture.
  33725. */
  33726. export class BaseTexture implements IAnimatable {
  33727. /**
  33728. * Default anisotropic filtering level for the application.
  33729. * It is set to 4 as a good tradeoff between perf and quality.
  33730. */
  33731. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33732. /**
  33733. * Gets or sets the unique id of the texture
  33734. */
  33735. uniqueId: number;
  33736. /**
  33737. * Define the name of the texture.
  33738. */
  33739. name: string;
  33740. /**
  33741. * Gets or sets an object used to store user defined information.
  33742. */
  33743. metadata: any;
  33744. /**
  33745. * For internal use only. Please do not use.
  33746. */
  33747. reservedDataStore: any;
  33748. private _hasAlpha;
  33749. /**
  33750. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33751. */
  33752. set hasAlpha(value: boolean);
  33753. get hasAlpha(): boolean;
  33754. /**
  33755. * Defines if the alpha value should be determined via the rgb values.
  33756. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33757. */
  33758. getAlphaFromRGB: boolean;
  33759. /**
  33760. * Intensity or strength of the texture.
  33761. * It is commonly used by materials to fine tune the intensity of the texture
  33762. */
  33763. level: number;
  33764. /**
  33765. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33766. * This is part of the texture as textures usually maps to one uv set.
  33767. */
  33768. coordinatesIndex: number;
  33769. private _coordinatesMode;
  33770. /**
  33771. * How a texture is mapped.
  33772. *
  33773. * | Value | Type | Description |
  33774. * | ----- | ----------------------------------- | ----------- |
  33775. * | 0 | EXPLICIT_MODE | |
  33776. * | 1 | SPHERICAL_MODE | |
  33777. * | 2 | PLANAR_MODE | |
  33778. * | 3 | CUBIC_MODE | |
  33779. * | 4 | PROJECTION_MODE | |
  33780. * | 5 | SKYBOX_MODE | |
  33781. * | 6 | INVCUBIC_MODE | |
  33782. * | 7 | EQUIRECTANGULAR_MODE | |
  33783. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33784. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33785. */
  33786. set coordinatesMode(value: number);
  33787. get coordinatesMode(): number;
  33788. /**
  33789. * | Value | Type | Description |
  33790. * | ----- | ------------------ | ----------- |
  33791. * | 0 | CLAMP_ADDRESSMODE | |
  33792. * | 1 | WRAP_ADDRESSMODE | |
  33793. * | 2 | MIRROR_ADDRESSMODE | |
  33794. */
  33795. wrapU: number;
  33796. /**
  33797. * | Value | Type | Description |
  33798. * | ----- | ------------------ | ----------- |
  33799. * | 0 | CLAMP_ADDRESSMODE | |
  33800. * | 1 | WRAP_ADDRESSMODE | |
  33801. * | 2 | MIRROR_ADDRESSMODE | |
  33802. */
  33803. wrapV: number;
  33804. /**
  33805. * | Value | Type | Description |
  33806. * | ----- | ------------------ | ----------- |
  33807. * | 0 | CLAMP_ADDRESSMODE | |
  33808. * | 1 | WRAP_ADDRESSMODE | |
  33809. * | 2 | MIRROR_ADDRESSMODE | |
  33810. */
  33811. wrapR: number;
  33812. /**
  33813. * With compliant hardware and browser (supporting anisotropic filtering)
  33814. * this defines the level of anisotropic filtering in the texture.
  33815. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33816. */
  33817. anisotropicFilteringLevel: number;
  33818. /**
  33819. * Define if the texture is a cube texture or if false a 2d texture.
  33820. */
  33821. get isCube(): boolean;
  33822. set isCube(value: boolean);
  33823. /**
  33824. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33825. */
  33826. get is3D(): boolean;
  33827. set is3D(value: boolean);
  33828. /**
  33829. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33830. */
  33831. get is2DArray(): boolean;
  33832. set is2DArray(value: boolean);
  33833. /**
  33834. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33835. * HDR texture are usually stored in linear space.
  33836. * This only impacts the PBR and Background materials
  33837. */
  33838. gammaSpace: boolean;
  33839. /**
  33840. * Gets or sets whether or not the texture contains RGBD data.
  33841. */
  33842. get isRGBD(): boolean;
  33843. set isRGBD(value: boolean);
  33844. /**
  33845. * Is Z inverted in the texture (useful in a cube texture).
  33846. */
  33847. invertZ: boolean;
  33848. /**
  33849. * Are mip maps generated for this texture or not.
  33850. */
  33851. get noMipmap(): boolean;
  33852. /**
  33853. * @hidden
  33854. */
  33855. lodLevelInAlpha: boolean;
  33856. /**
  33857. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33858. */
  33859. get lodGenerationOffset(): number;
  33860. set lodGenerationOffset(value: number);
  33861. /**
  33862. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33863. */
  33864. get lodGenerationScale(): number;
  33865. set lodGenerationScale(value: number);
  33866. /**
  33867. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33868. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33869. * average roughness values.
  33870. */
  33871. get linearSpecularLOD(): boolean;
  33872. set linearSpecularLOD(value: boolean);
  33873. /**
  33874. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33875. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33876. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33877. */
  33878. get irradianceTexture(): Nullable<BaseTexture>;
  33879. set irradianceTexture(value: Nullable<BaseTexture>);
  33880. /**
  33881. * Define if the texture is a render target.
  33882. */
  33883. isRenderTarget: boolean;
  33884. /**
  33885. * Define the unique id of the texture in the scene.
  33886. */
  33887. get uid(): string;
  33888. /** @hidden */
  33889. _prefiltered: boolean;
  33890. /**
  33891. * Return a string representation of the texture.
  33892. * @returns the texture as a string
  33893. */
  33894. toString(): string;
  33895. /**
  33896. * Get the class name of the texture.
  33897. * @returns "BaseTexture"
  33898. */
  33899. getClassName(): string;
  33900. /**
  33901. * Define the list of animation attached to the texture.
  33902. */
  33903. animations: Animation[];
  33904. /**
  33905. * An event triggered when the texture is disposed.
  33906. */
  33907. onDisposeObservable: Observable<BaseTexture>;
  33908. private _onDisposeObserver;
  33909. /**
  33910. * Callback triggered when the texture has been disposed.
  33911. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33912. */
  33913. set onDispose(callback: () => void);
  33914. /**
  33915. * Define the current state of the loading sequence when in delayed load mode.
  33916. */
  33917. delayLoadState: number;
  33918. protected _scene: Nullable<Scene>;
  33919. protected _engine: Nullable<ThinEngine>;
  33920. /** @hidden */
  33921. _texture: Nullable<InternalTexture>;
  33922. private _uid;
  33923. /**
  33924. * Define if the texture is preventinga material to render or not.
  33925. * If not and the texture is not ready, the engine will use a default black texture instead.
  33926. */
  33927. get isBlocking(): boolean;
  33928. /**
  33929. * Instantiates a new BaseTexture.
  33930. * Base class of all the textures in babylon.
  33931. * It groups all the common properties the materials, post process, lights... might need
  33932. * in order to make a correct use of the texture.
  33933. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33934. */
  33935. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33936. /**
  33937. * Get the scene the texture belongs to.
  33938. * @returns the scene or null if undefined
  33939. */
  33940. getScene(): Nullable<Scene>;
  33941. /** @hidden */
  33942. protected _getEngine(): Nullable<ThinEngine>;
  33943. /**
  33944. * Get the texture transform matrix used to offset tile the texture for istance.
  33945. * @returns the transformation matrix
  33946. */
  33947. getTextureMatrix(): Matrix;
  33948. /**
  33949. * Get the texture reflection matrix used to rotate/transform the reflection.
  33950. * @returns the reflection matrix
  33951. */
  33952. getReflectionTextureMatrix(): Matrix;
  33953. /**
  33954. * Get the underlying lower level texture from Babylon.
  33955. * @returns the insternal texture
  33956. */
  33957. getInternalTexture(): Nullable<InternalTexture>;
  33958. /**
  33959. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33960. * @returns true if ready or not blocking
  33961. */
  33962. isReadyOrNotBlocking(): boolean;
  33963. /**
  33964. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33965. * @returns true if fully ready
  33966. */
  33967. isReady(): boolean;
  33968. private _cachedSize;
  33969. /**
  33970. * Get the size of the texture.
  33971. * @returns the texture size.
  33972. */
  33973. getSize(): ISize;
  33974. /**
  33975. * Get the base size of the texture.
  33976. * It can be different from the size if the texture has been resized for POT for instance
  33977. * @returns the base size
  33978. */
  33979. getBaseSize(): ISize;
  33980. /**
  33981. * Update the sampling mode of the texture.
  33982. * Default is Trilinear mode.
  33983. *
  33984. * | Value | Type | Description |
  33985. * | ----- | ------------------ | ----------- |
  33986. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33987. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33988. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33989. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33990. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33991. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33992. * | 7 | NEAREST_LINEAR | |
  33993. * | 8 | NEAREST_NEAREST | |
  33994. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33995. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33996. * | 11 | LINEAR_LINEAR | |
  33997. * | 12 | LINEAR_NEAREST | |
  33998. *
  33999. * > _mag_: magnification filter (close to the viewer)
  34000. * > _min_: minification filter (far from the viewer)
  34001. * > _mip_: filter used between mip map levels
  34002. *@param samplingMode Define the new sampling mode of the texture
  34003. */
  34004. updateSamplingMode(samplingMode: number): void;
  34005. /**
  34006. * Scales the texture if is `canRescale()`
  34007. * @param ratio the resize factor we want to use to rescale
  34008. */
  34009. scale(ratio: number): void;
  34010. /**
  34011. * Get if the texture can rescale.
  34012. */
  34013. get canRescale(): boolean;
  34014. /** @hidden */
  34015. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34016. /** @hidden */
  34017. _rebuild(): void;
  34018. /**
  34019. * Triggers the load sequence in delayed load mode.
  34020. */
  34021. delayLoad(): void;
  34022. /**
  34023. * Clones the texture.
  34024. * @returns the cloned texture
  34025. */
  34026. clone(): Nullable<BaseTexture>;
  34027. /**
  34028. * Get the texture underlying type (INT, FLOAT...)
  34029. */
  34030. get textureType(): number;
  34031. /**
  34032. * Get the texture underlying format (RGB, RGBA...)
  34033. */
  34034. get textureFormat(): number;
  34035. /**
  34036. * Indicates that textures need to be re-calculated for all materials
  34037. */
  34038. protected _markAllSubMeshesAsTexturesDirty(): void;
  34039. /**
  34040. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34041. * This will returns an RGBA array buffer containing either in values (0-255) or
  34042. * float values (0-1) depending of the underlying buffer type.
  34043. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34044. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34045. * @param buffer defines a user defined buffer to fill with data (can be null)
  34046. * @returns The Array buffer containing the pixels data.
  34047. */
  34048. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34049. /**
  34050. * Release and destroy the underlying lower level texture aka internalTexture.
  34051. */
  34052. releaseInternalTexture(): void;
  34053. /** @hidden */
  34054. get _lodTextureHigh(): Nullable<BaseTexture>;
  34055. /** @hidden */
  34056. get _lodTextureMid(): Nullable<BaseTexture>;
  34057. /** @hidden */
  34058. get _lodTextureLow(): Nullable<BaseTexture>;
  34059. /**
  34060. * Dispose the texture and release its associated resources.
  34061. */
  34062. dispose(): void;
  34063. /**
  34064. * Serialize the texture into a JSON representation that can be parsed later on.
  34065. * @returns the JSON representation of the texture
  34066. */
  34067. serialize(): any;
  34068. /**
  34069. * Helper function to be called back once a list of texture contains only ready textures.
  34070. * @param textures Define the list of textures to wait for
  34071. * @param callback Define the callback triggered once the entire list will be ready
  34072. */
  34073. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34074. private static _isScene;
  34075. }
  34076. }
  34077. declare module BABYLON {
  34078. /**
  34079. * Options to be used when creating an effect.
  34080. */
  34081. export interface IEffectCreationOptions {
  34082. /**
  34083. * Atrributes that will be used in the shader.
  34084. */
  34085. attributes: string[];
  34086. /**
  34087. * Uniform varible names that will be set in the shader.
  34088. */
  34089. uniformsNames: string[];
  34090. /**
  34091. * Uniform buffer variable names that will be set in the shader.
  34092. */
  34093. uniformBuffersNames: string[];
  34094. /**
  34095. * Sampler texture variable names that will be set in the shader.
  34096. */
  34097. samplers: string[];
  34098. /**
  34099. * Define statements that will be set in the shader.
  34100. */
  34101. defines: any;
  34102. /**
  34103. * Possible fallbacks for this effect to improve performance when needed.
  34104. */
  34105. fallbacks: Nullable<IEffectFallbacks>;
  34106. /**
  34107. * Callback that will be called when the shader is compiled.
  34108. */
  34109. onCompiled: Nullable<(effect: Effect) => void>;
  34110. /**
  34111. * Callback that will be called if an error occurs during shader compilation.
  34112. */
  34113. onError: Nullable<(effect: Effect, errors: string) => void>;
  34114. /**
  34115. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34116. */
  34117. indexParameters?: any;
  34118. /**
  34119. * Max number of lights that can be used in the shader.
  34120. */
  34121. maxSimultaneousLights?: number;
  34122. /**
  34123. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34124. */
  34125. transformFeedbackVaryings?: Nullable<string[]>;
  34126. /**
  34127. * 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
  34128. */
  34129. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34130. /**
  34131. * Is this effect rendering to several color attachments ?
  34132. */
  34133. multiTarget?: boolean;
  34134. }
  34135. /**
  34136. * Effect containing vertex and fragment shader that can be executed on an object.
  34137. */
  34138. export class Effect implements IDisposable {
  34139. /**
  34140. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34141. */
  34142. static ShadersRepository: string;
  34143. /**
  34144. * Enable logging of the shader code when a compilation error occurs
  34145. */
  34146. static LogShaderCodeOnCompilationError: boolean;
  34147. /**
  34148. * Name of the effect.
  34149. */
  34150. name: any;
  34151. /**
  34152. * String container all the define statements that should be set on the shader.
  34153. */
  34154. defines: string;
  34155. /**
  34156. * Callback that will be called when the shader is compiled.
  34157. */
  34158. onCompiled: Nullable<(effect: Effect) => void>;
  34159. /**
  34160. * Callback that will be called if an error occurs during shader compilation.
  34161. */
  34162. onError: Nullable<(effect: Effect, errors: string) => void>;
  34163. /**
  34164. * Callback that will be called when effect is bound.
  34165. */
  34166. onBind: Nullable<(effect: Effect) => void>;
  34167. /**
  34168. * Unique ID of the effect.
  34169. */
  34170. uniqueId: number;
  34171. /**
  34172. * Observable that will be called when the shader is compiled.
  34173. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34174. */
  34175. onCompileObservable: Observable<Effect>;
  34176. /**
  34177. * Observable that will be called if an error occurs during shader compilation.
  34178. */
  34179. onErrorObservable: Observable<Effect>;
  34180. /** @hidden */
  34181. _onBindObservable: Nullable<Observable<Effect>>;
  34182. /**
  34183. * @hidden
  34184. * Specifies if the effect was previously ready
  34185. */
  34186. _wasPreviouslyReady: boolean;
  34187. /**
  34188. * Observable that will be called when effect is bound.
  34189. */
  34190. get onBindObservable(): Observable<Effect>;
  34191. /** @hidden */
  34192. _bonesComputationForcedToCPU: boolean;
  34193. /** @hidden */
  34194. _multiTarget: boolean;
  34195. private static _uniqueIdSeed;
  34196. private _engine;
  34197. private _uniformBuffersNames;
  34198. private _uniformBuffersNamesList;
  34199. private _uniformsNames;
  34200. private _samplerList;
  34201. private _samplers;
  34202. private _isReady;
  34203. private _compilationError;
  34204. private _allFallbacksProcessed;
  34205. private _attributesNames;
  34206. private _attributes;
  34207. private _attributeLocationByName;
  34208. private _uniforms;
  34209. /**
  34210. * Key for the effect.
  34211. * @hidden
  34212. */
  34213. _key: string;
  34214. private _indexParameters;
  34215. private _fallbacks;
  34216. private _vertexSourceCode;
  34217. private _fragmentSourceCode;
  34218. private _vertexSourceCodeOverride;
  34219. private _fragmentSourceCodeOverride;
  34220. private _transformFeedbackVaryings;
  34221. /**
  34222. * Compiled shader to webGL program.
  34223. * @hidden
  34224. */
  34225. _pipelineContext: Nullable<IPipelineContext>;
  34226. private _valueCache;
  34227. private static _baseCache;
  34228. /**
  34229. * Instantiates an effect.
  34230. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34231. * @param baseName Name of the effect.
  34232. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34233. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34234. * @param samplers List of sampler variables that will be passed to the shader.
  34235. * @param engine Engine to be used to render the effect
  34236. * @param defines Define statements to be added to the shader.
  34237. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34238. * @param onCompiled Callback that will be called when the shader is compiled.
  34239. * @param onError Callback that will be called if an error occurs during shader compilation.
  34240. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34241. */
  34242. 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);
  34243. private _useFinalCode;
  34244. /**
  34245. * Unique key for this effect
  34246. */
  34247. get key(): string;
  34248. /**
  34249. * If the effect has been compiled and prepared.
  34250. * @returns if the effect is compiled and prepared.
  34251. */
  34252. isReady(): boolean;
  34253. private _isReadyInternal;
  34254. /**
  34255. * The engine the effect was initialized with.
  34256. * @returns the engine.
  34257. */
  34258. getEngine(): Engine;
  34259. /**
  34260. * The pipeline context for this effect
  34261. * @returns the associated pipeline context
  34262. */
  34263. getPipelineContext(): Nullable<IPipelineContext>;
  34264. /**
  34265. * The set of names of attribute variables for the shader.
  34266. * @returns An array of attribute names.
  34267. */
  34268. getAttributesNames(): string[];
  34269. /**
  34270. * Returns the attribute at the given index.
  34271. * @param index The index of the attribute.
  34272. * @returns The location of the attribute.
  34273. */
  34274. getAttributeLocation(index: number): number;
  34275. /**
  34276. * Returns the attribute based on the name of the variable.
  34277. * @param name of the attribute to look up.
  34278. * @returns the attribute location.
  34279. */
  34280. getAttributeLocationByName(name: string): number;
  34281. /**
  34282. * The number of attributes.
  34283. * @returns the numnber of attributes.
  34284. */
  34285. getAttributesCount(): number;
  34286. /**
  34287. * Gets the index of a uniform variable.
  34288. * @param uniformName of the uniform to look up.
  34289. * @returns the index.
  34290. */
  34291. getUniformIndex(uniformName: string): number;
  34292. /**
  34293. * Returns the attribute based on the name of the variable.
  34294. * @param uniformName of the uniform to look up.
  34295. * @returns the location of the uniform.
  34296. */
  34297. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34298. /**
  34299. * Returns an array of sampler variable names
  34300. * @returns The array of sampler variable names.
  34301. */
  34302. getSamplers(): string[];
  34303. /**
  34304. * Returns an array of uniform variable names
  34305. * @returns The array of uniform variable names.
  34306. */
  34307. getUniformNames(): string[];
  34308. /**
  34309. * Returns an array of uniform buffer variable names
  34310. * @returns The array of uniform buffer variable names.
  34311. */
  34312. getUniformBuffersNames(): string[];
  34313. /**
  34314. * Returns the index parameters used to create the effect
  34315. * @returns The index parameters object
  34316. */
  34317. getIndexParameters(): any;
  34318. /**
  34319. * The error from the last compilation.
  34320. * @returns the error string.
  34321. */
  34322. getCompilationError(): string;
  34323. /**
  34324. * Gets a boolean indicating that all fallbacks were used during compilation
  34325. * @returns true if all fallbacks were used
  34326. */
  34327. allFallbacksProcessed(): boolean;
  34328. /**
  34329. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34330. * @param func The callback to be used.
  34331. */
  34332. executeWhenCompiled(func: (effect: Effect) => void): void;
  34333. private _checkIsReady;
  34334. private _loadShader;
  34335. /**
  34336. * Gets the vertex shader source code of this effect
  34337. */
  34338. get vertexSourceCode(): string;
  34339. /**
  34340. * Gets the fragment shader source code of this effect
  34341. */
  34342. get fragmentSourceCode(): string;
  34343. /**
  34344. * Recompiles the webGL program
  34345. * @param vertexSourceCode The source code for the vertex shader.
  34346. * @param fragmentSourceCode The source code for the fragment shader.
  34347. * @param onCompiled Callback called when completed.
  34348. * @param onError Callback called on error.
  34349. * @hidden
  34350. */
  34351. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34352. /**
  34353. * Prepares the effect
  34354. * @hidden
  34355. */
  34356. _prepareEffect(): void;
  34357. private _getShaderCodeAndErrorLine;
  34358. private _processCompilationErrors;
  34359. /**
  34360. * Checks if the effect is supported. (Must be called after compilation)
  34361. */
  34362. get isSupported(): boolean;
  34363. /**
  34364. * Binds a texture to the engine to be used as output of the shader.
  34365. * @param channel Name of the output variable.
  34366. * @param texture Texture to bind.
  34367. * @hidden
  34368. */
  34369. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34370. /**
  34371. * Sets a texture on the engine to be used in the shader.
  34372. * @param channel Name of the sampler variable.
  34373. * @param texture Texture to set.
  34374. */
  34375. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34376. /**
  34377. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34378. * @param channel Name of the sampler variable.
  34379. * @param texture Texture to set.
  34380. */
  34381. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34382. /**
  34383. * Sets an array of textures on the engine to be used in the shader.
  34384. * @param channel Name of the variable.
  34385. * @param textures Textures to set.
  34386. */
  34387. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34388. /**
  34389. * 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)
  34390. * @param channel Name of the sampler variable.
  34391. * @param postProcess Post process to get the input texture from.
  34392. */
  34393. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34394. /**
  34395. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34396. * 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)
  34397. * @param channel Name of the sampler variable.
  34398. * @param postProcess Post process to get the output texture from.
  34399. */
  34400. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34401. /** @hidden */
  34402. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34403. /** @hidden */
  34404. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34405. /** @hidden */
  34406. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34407. /** @hidden */
  34408. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34409. /**
  34410. * Binds a buffer to a uniform.
  34411. * @param buffer Buffer to bind.
  34412. * @param name Name of the uniform variable to bind to.
  34413. */
  34414. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34415. /**
  34416. * Binds block to a uniform.
  34417. * @param blockName Name of the block to bind.
  34418. * @param index Index to bind.
  34419. */
  34420. bindUniformBlock(blockName: string, index: number): void;
  34421. /**
  34422. * Sets an interger value on a uniform variable.
  34423. * @param uniformName Name of the variable.
  34424. * @param value Value to be set.
  34425. * @returns this effect.
  34426. */
  34427. setInt(uniformName: string, value: number): Effect;
  34428. /**
  34429. * Sets an int array on a uniform variable.
  34430. * @param uniformName Name of the variable.
  34431. * @param array array to be set.
  34432. * @returns this effect.
  34433. */
  34434. setIntArray(uniformName: string, array: Int32Array): Effect;
  34435. /**
  34436. * 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)
  34437. * @param uniformName Name of the variable.
  34438. * @param array array to be set.
  34439. * @returns this effect.
  34440. */
  34441. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34442. /**
  34443. * 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)
  34444. * @param uniformName Name of the variable.
  34445. * @param array array to be set.
  34446. * @returns this effect.
  34447. */
  34448. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34449. /**
  34450. * 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)
  34451. * @param uniformName Name of the variable.
  34452. * @param array array to be set.
  34453. * @returns this effect.
  34454. */
  34455. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34456. /**
  34457. * Sets an float array on a uniform variable.
  34458. * @param uniformName Name of the variable.
  34459. * @param array array to be set.
  34460. * @returns this effect.
  34461. */
  34462. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34463. /**
  34464. * 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)
  34465. * @param uniformName Name of the variable.
  34466. * @param array array to be set.
  34467. * @returns this effect.
  34468. */
  34469. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34470. /**
  34471. * 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)
  34472. * @param uniformName Name of the variable.
  34473. * @param array array to be set.
  34474. * @returns this effect.
  34475. */
  34476. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34477. /**
  34478. * 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)
  34479. * @param uniformName Name of the variable.
  34480. * @param array array to be set.
  34481. * @returns this effect.
  34482. */
  34483. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34484. /**
  34485. * Sets an array on a uniform variable.
  34486. * @param uniformName Name of the variable.
  34487. * @param array array to be set.
  34488. * @returns this effect.
  34489. */
  34490. setArray(uniformName: string, array: number[]): Effect;
  34491. /**
  34492. * 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)
  34493. * @param uniformName Name of the variable.
  34494. * @param array array to be set.
  34495. * @returns this effect.
  34496. */
  34497. setArray2(uniformName: string, array: number[]): Effect;
  34498. /**
  34499. * 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)
  34500. * @param uniformName Name of the variable.
  34501. * @param array array to be set.
  34502. * @returns this effect.
  34503. */
  34504. setArray3(uniformName: string, array: number[]): Effect;
  34505. /**
  34506. * 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)
  34507. * @param uniformName Name of the variable.
  34508. * @param array array to be set.
  34509. * @returns this effect.
  34510. */
  34511. setArray4(uniformName: string, array: number[]): Effect;
  34512. /**
  34513. * Sets matrices on a uniform variable.
  34514. * @param uniformName Name of the variable.
  34515. * @param matrices matrices to be set.
  34516. * @returns this effect.
  34517. */
  34518. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34519. /**
  34520. * Sets matrix on a uniform variable.
  34521. * @param uniformName Name of the variable.
  34522. * @param matrix matrix to be set.
  34523. * @returns this effect.
  34524. */
  34525. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34526. /**
  34527. * 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)
  34528. * @param uniformName Name of the variable.
  34529. * @param matrix matrix to be set.
  34530. * @returns this effect.
  34531. */
  34532. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34533. /**
  34534. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34535. * @param uniformName Name of the variable.
  34536. * @param matrix matrix to be set.
  34537. * @returns this effect.
  34538. */
  34539. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34540. /**
  34541. * Sets a float on a uniform variable.
  34542. * @param uniformName Name of the variable.
  34543. * @param value value to be set.
  34544. * @returns this effect.
  34545. */
  34546. setFloat(uniformName: string, value: number): Effect;
  34547. /**
  34548. * Sets a boolean on a uniform variable.
  34549. * @param uniformName Name of the variable.
  34550. * @param bool value to be set.
  34551. * @returns this effect.
  34552. */
  34553. setBool(uniformName: string, bool: boolean): Effect;
  34554. /**
  34555. * Sets a Vector2 on a uniform variable.
  34556. * @param uniformName Name of the variable.
  34557. * @param vector2 vector2 to be set.
  34558. * @returns this effect.
  34559. */
  34560. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34561. /**
  34562. * Sets a float2 on a uniform variable.
  34563. * @param uniformName Name of the variable.
  34564. * @param x First float in float2.
  34565. * @param y Second float in float2.
  34566. * @returns this effect.
  34567. */
  34568. setFloat2(uniformName: string, x: number, y: number): Effect;
  34569. /**
  34570. * Sets a Vector3 on a uniform variable.
  34571. * @param uniformName Name of the variable.
  34572. * @param vector3 Value to be set.
  34573. * @returns this effect.
  34574. */
  34575. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34576. /**
  34577. * Sets a float3 on a uniform variable.
  34578. * @param uniformName Name of the variable.
  34579. * @param x First float in float3.
  34580. * @param y Second float in float3.
  34581. * @param z Third float in float3.
  34582. * @returns this effect.
  34583. */
  34584. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34585. /**
  34586. * Sets a Vector4 on a uniform variable.
  34587. * @param uniformName Name of the variable.
  34588. * @param vector4 Value to be set.
  34589. * @returns this effect.
  34590. */
  34591. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34592. /**
  34593. * Sets a float4 on a uniform variable.
  34594. * @param uniformName Name of the variable.
  34595. * @param x First float in float4.
  34596. * @param y Second float in float4.
  34597. * @param z Third float in float4.
  34598. * @param w Fourth float in float4.
  34599. * @returns this effect.
  34600. */
  34601. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34602. /**
  34603. * Sets a Color3 on a uniform variable.
  34604. * @param uniformName Name of the variable.
  34605. * @param color3 Value to be set.
  34606. * @returns this effect.
  34607. */
  34608. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34609. /**
  34610. * Sets a Color4 on a uniform variable.
  34611. * @param uniformName Name of the variable.
  34612. * @param color3 Value to be set.
  34613. * @param alpha Alpha value to be set.
  34614. * @returns this effect.
  34615. */
  34616. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34617. /**
  34618. * Sets a Color4 on a uniform variable
  34619. * @param uniformName defines the name of the variable
  34620. * @param color4 defines the value to be set
  34621. * @returns this effect.
  34622. */
  34623. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34624. /** Release all associated resources */
  34625. dispose(): void;
  34626. /**
  34627. * This function will add a new shader to the shader store
  34628. * @param name the name of the shader
  34629. * @param pixelShader optional pixel shader content
  34630. * @param vertexShader optional vertex shader content
  34631. */
  34632. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34633. /**
  34634. * Store of each shader (The can be looked up using effect.key)
  34635. */
  34636. static ShadersStore: {
  34637. [key: string]: string;
  34638. };
  34639. /**
  34640. * Store of each included file for a shader (The can be looked up using effect.key)
  34641. */
  34642. static IncludesShadersStore: {
  34643. [key: string]: string;
  34644. };
  34645. /**
  34646. * Resets the cache of effects.
  34647. */
  34648. static ResetCache(): void;
  34649. }
  34650. }
  34651. declare module BABYLON {
  34652. /**
  34653. * Interface used to describe the capabilities of the engine relatively to the current browser
  34654. */
  34655. export interface EngineCapabilities {
  34656. /** Maximum textures units per fragment shader */
  34657. maxTexturesImageUnits: number;
  34658. /** Maximum texture units per vertex shader */
  34659. maxVertexTextureImageUnits: number;
  34660. /** Maximum textures units in the entire pipeline */
  34661. maxCombinedTexturesImageUnits: number;
  34662. /** Maximum texture size */
  34663. maxTextureSize: number;
  34664. /** Maximum texture samples */
  34665. maxSamples?: number;
  34666. /** Maximum cube texture size */
  34667. maxCubemapTextureSize: number;
  34668. /** Maximum render texture size */
  34669. maxRenderTextureSize: number;
  34670. /** Maximum number of vertex attributes */
  34671. maxVertexAttribs: number;
  34672. /** Maximum number of varyings */
  34673. maxVaryingVectors: number;
  34674. /** Maximum number of uniforms per vertex shader */
  34675. maxVertexUniformVectors: number;
  34676. /** Maximum number of uniforms per fragment shader */
  34677. maxFragmentUniformVectors: number;
  34678. /** Defines if standard derivates (dx/dy) are supported */
  34679. standardDerivatives: boolean;
  34680. /** Defines if s3tc texture compression is supported */
  34681. s3tc?: WEBGL_compressed_texture_s3tc;
  34682. /** Defines if pvrtc texture compression is supported */
  34683. pvrtc: any;
  34684. /** Defines if etc1 texture compression is supported */
  34685. etc1: any;
  34686. /** Defines if etc2 texture compression is supported */
  34687. etc2: any;
  34688. /** Defines if astc texture compression is supported */
  34689. astc: any;
  34690. /** Defines if float textures are supported */
  34691. textureFloat: boolean;
  34692. /** Defines if vertex array objects are supported */
  34693. vertexArrayObject: boolean;
  34694. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34695. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34696. /** Gets the maximum level of anisotropy supported */
  34697. maxAnisotropy: number;
  34698. /** Defines if instancing is supported */
  34699. instancedArrays: boolean;
  34700. /** Defines if 32 bits indices are supported */
  34701. uintIndices: boolean;
  34702. /** Defines if high precision shaders are supported */
  34703. highPrecisionShaderSupported: boolean;
  34704. /** Defines if depth reading in the fragment shader is supported */
  34705. fragmentDepthSupported: boolean;
  34706. /** Defines if float texture linear filtering is supported*/
  34707. textureFloatLinearFiltering: boolean;
  34708. /** Defines if rendering to float textures is supported */
  34709. textureFloatRender: boolean;
  34710. /** Defines if half float textures are supported*/
  34711. textureHalfFloat: boolean;
  34712. /** Defines if half float texture linear filtering is supported*/
  34713. textureHalfFloatLinearFiltering: boolean;
  34714. /** Defines if rendering to half float textures is supported */
  34715. textureHalfFloatRender: boolean;
  34716. /** Defines if textureLOD shader command is supported */
  34717. textureLOD: boolean;
  34718. /** Defines if draw buffers extension is supported */
  34719. drawBuffersExtension: boolean;
  34720. /** Defines if depth textures are supported */
  34721. depthTextureExtension: boolean;
  34722. /** Defines if float color buffer are supported */
  34723. colorBufferFloat: boolean;
  34724. /** Gets disjoint timer query extension (null if not supported) */
  34725. timerQuery?: EXT_disjoint_timer_query;
  34726. /** Defines if timestamp can be used with timer query */
  34727. canUseTimestampForTimerQuery: boolean;
  34728. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34729. multiview?: any;
  34730. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34731. oculusMultiview?: any;
  34732. /** Function used to let the system compiles shaders in background */
  34733. parallelShaderCompile?: {
  34734. COMPLETION_STATUS_KHR: number;
  34735. };
  34736. /** Max number of texture samples for MSAA */
  34737. maxMSAASamples: number;
  34738. /** Defines if the blend min max extension is supported */
  34739. blendMinMax: boolean;
  34740. }
  34741. }
  34742. declare module BABYLON {
  34743. /**
  34744. * @hidden
  34745. **/
  34746. export class DepthCullingState {
  34747. private _isDepthTestDirty;
  34748. private _isDepthMaskDirty;
  34749. private _isDepthFuncDirty;
  34750. private _isCullFaceDirty;
  34751. private _isCullDirty;
  34752. private _isZOffsetDirty;
  34753. private _isFrontFaceDirty;
  34754. private _depthTest;
  34755. private _depthMask;
  34756. private _depthFunc;
  34757. private _cull;
  34758. private _cullFace;
  34759. private _zOffset;
  34760. private _frontFace;
  34761. /**
  34762. * Initializes the state.
  34763. */
  34764. constructor();
  34765. get isDirty(): boolean;
  34766. get zOffset(): number;
  34767. set zOffset(value: number);
  34768. get cullFace(): Nullable<number>;
  34769. set cullFace(value: Nullable<number>);
  34770. get cull(): Nullable<boolean>;
  34771. set cull(value: Nullable<boolean>);
  34772. get depthFunc(): Nullable<number>;
  34773. set depthFunc(value: Nullable<number>);
  34774. get depthMask(): boolean;
  34775. set depthMask(value: boolean);
  34776. get depthTest(): boolean;
  34777. set depthTest(value: boolean);
  34778. get frontFace(): Nullable<number>;
  34779. set frontFace(value: Nullable<number>);
  34780. reset(): void;
  34781. apply(gl: WebGLRenderingContext): void;
  34782. }
  34783. }
  34784. declare module BABYLON {
  34785. /**
  34786. * @hidden
  34787. **/
  34788. export class StencilState {
  34789. /** 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 */
  34790. static readonly ALWAYS: number;
  34791. /** Passed to stencilOperation to specify that stencil value must be kept */
  34792. static readonly KEEP: number;
  34793. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34794. static readonly REPLACE: number;
  34795. private _isStencilTestDirty;
  34796. private _isStencilMaskDirty;
  34797. private _isStencilFuncDirty;
  34798. private _isStencilOpDirty;
  34799. private _stencilTest;
  34800. private _stencilMask;
  34801. private _stencilFunc;
  34802. private _stencilFuncRef;
  34803. private _stencilFuncMask;
  34804. private _stencilOpStencilFail;
  34805. private _stencilOpDepthFail;
  34806. private _stencilOpStencilDepthPass;
  34807. get isDirty(): boolean;
  34808. get stencilFunc(): number;
  34809. set stencilFunc(value: number);
  34810. get stencilFuncRef(): number;
  34811. set stencilFuncRef(value: number);
  34812. get stencilFuncMask(): number;
  34813. set stencilFuncMask(value: number);
  34814. get stencilOpStencilFail(): number;
  34815. set stencilOpStencilFail(value: number);
  34816. get stencilOpDepthFail(): number;
  34817. set stencilOpDepthFail(value: number);
  34818. get stencilOpStencilDepthPass(): number;
  34819. set stencilOpStencilDepthPass(value: number);
  34820. get stencilMask(): number;
  34821. set stencilMask(value: number);
  34822. get stencilTest(): boolean;
  34823. set stencilTest(value: boolean);
  34824. constructor();
  34825. reset(): void;
  34826. apply(gl: WebGLRenderingContext): void;
  34827. }
  34828. }
  34829. declare module BABYLON {
  34830. /**
  34831. * @hidden
  34832. **/
  34833. export class AlphaState {
  34834. private _isAlphaBlendDirty;
  34835. private _isBlendFunctionParametersDirty;
  34836. private _isBlendEquationParametersDirty;
  34837. private _isBlendConstantsDirty;
  34838. private _alphaBlend;
  34839. private _blendFunctionParameters;
  34840. private _blendEquationParameters;
  34841. private _blendConstants;
  34842. /**
  34843. * Initializes the state.
  34844. */
  34845. constructor();
  34846. get isDirty(): boolean;
  34847. get alphaBlend(): boolean;
  34848. set alphaBlend(value: boolean);
  34849. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34850. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34851. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34852. reset(): void;
  34853. apply(gl: WebGLRenderingContext): void;
  34854. }
  34855. }
  34856. declare module BABYLON {
  34857. /** @hidden */
  34858. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34859. attributeProcessor(attribute: string): string;
  34860. varyingProcessor(varying: string, isFragment: boolean): string;
  34861. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34862. }
  34863. }
  34864. declare module BABYLON {
  34865. /**
  34866. * Interface for attribute information associated with buffer instanciation
  34867. */
  34868. export interface InstancingAttributeInfo {
  34869. /**
  34870. * Name of the GLSL attribute
  34871. * if attribute index is not specified, this is used to retrieve the index from the effect
  34872. */
  34873. attributeName: string;
  34874. /**
  34875. * Index/offset of the attribute in the vertex shader
  34876. * if not specified, this will be computes from the name.
  34877. */
  34878. index?: number;
  34879. /**
  34880. * size of the attribute, 1, 2, 3 or 4
  34881. */
  34882. attributeSize: number;
  34883. /**
  34884. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34885. */
  34886. offset: number;
  34887. /**
  34888. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34889. * default to 1
  34890. */
  34891. divisor?: number;
  34892. /**
  34893. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34894. * default is FLOAT
  34895. */
  34896. attributeType?: number;
  34897. /**
  34898. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34899. */
  34900. normalized?: boolean;
  34901. }
  34902. }
  34903. declare module BABYLON {
  34904. interface ThinEngine {
  34905. /**
  34906. * Update a video texture
  34907. * @param texture defines the texture to update
  34908. * @param video defines the video element to use
  34909. * @param invertY defines if data must be stored with Y axis inverted
  34910. */
  34911. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34912. }
  34913. }
  34914. declare module BABYLON {
  34915. interface ThinEngine {
  34916. /**
  34917. * Creates a dynamic texture
  34918. * @param width defines the width of the texture
  34919. * @param height defines the height of the texture
  34920. * @param generateMipMaps defines if the engine should generate the mip levels
  34921. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34922. * @returns the dynamic texture inside an InternalTexture
  34923. */
  34924. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34925. /**
  34926. * Update the content of a dynamic texture
  34927. * @param texture defines the texture to update
  34928. * @param canvas defines the canvas containing the source
  34929. * @param invertY defines if data must be stored with Y axis inverted
  34930. * @param premulAlpha defines if alpha is stored as premultiplied
  34931. * @param format defines the format of the data
  34932. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34933. */
  34934. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34935. }
  34936. }
  34937. declare module BABYLON {
  34938. /**
  34939. * Settings for finer control over video usage
  34940. */
  34941. export interface VideoTextureSettings {
  34942. /**
  34943. * Applies `autoplay` to video, if specified
  34944. */
  34945. autoPlay?: boolean;
  34946. /**
  34947. * Applies `loop` to video, if specified
  34948. */
  34949. loop?: boolean;
  34950. /**
  34951. * Automatically updates internal texture from video at every frame in the render loop
  34952. */
  34953. autoUpdateTexture: boolean;
  34954. /**
  34955. * Image src displayed during the video loading or until the user interacts with the video.
  34956. */
  34957. poster?: string;
  34958. }
  34959. /**
  34960. * If you want to display a video in your scene, this is the special texture for that.
  34961. * This special texture works similar to other textures, with the exception of a few parameters.
  34962. * @see https://doc.babylonjs.com/how_to/video_texture
  34963. */
  34964. export class VideoTexture extends Texture {
  34965. /**
  34966. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34967. */
  34968. readonly autoUpdateTexture: boolean;
  34969. /**
  34970. * The video instance used by the texture internally
  34971. */
  34972. readonly video: HTMLVideoElement;
  34973. private _onUserActionRequestedObservable;
  34974. /**
  34975. * Event triggerd when a dom action is required by the user to play the video.
  34976. * This happens due to recent changes in browser policies preventing video to auto start.
  34977. */
  34978. get onUserActionRequestedObservable(): Observable<Texture>;
  34979. private _generateMipMaps;
  34980. private _stillImageCaptured;
  34981. private _displayingPosterTexture;
  34982. private _settings;
  34983. private _createInternalTextureOnEvent;
  34984. private _frameId;
  34985. private _currentSrc;
  34986. /**
  34987. * Creates a video texture.
  34988. * If you want to display a video in your scene, this is the special texture for that.
  34989. * This special texture works similar to other textures, with the exception of a few parameters.
  34990. * @see https://doc.babylonjs.com/how_to/video_texture
  34991. * @param name optional name, will detect from video source, if not defined
  34992. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34993. * @param scene is obviously the current scene.
  34994. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34995. * @param invertY is false by default but can be used to invert video on Y axis
  34996. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34997. * @param settings allows finer control over video usage
  34998. */
  34999. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35000. private _getName;
  35001. private _getVideo;
  35002. private _createInternalTexture;
  35003. private reset;
  35004. /**
  35005. * @hidden Internal method to initiate `update`.
  35006. */
  35007. _rebuild(): void;
  35008. /**
  35009. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35010. */
  35011. update(): void;
  35012. /**
  35013. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35014. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35015. */
  35016. updateTexture(isVisible: boolean): void;
  35017. protected _updateInternalTexture: () => void;
  35018. /**
  35019. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35020. * @param url New url.
  35021. */
  35022. updateURL(url: string): void;
  35023. /**
  35024. * Clones the texture.
  35025. * @returns the cloned texture
  35026. */
  35027. clone(): VideoTexture;
  35028. /**
  35029. * Dispose the texture and release its associated resources.
  35030. */
  35031. dispose(): void;
  35032. /**
  35033. * Creates a video texture straight from a stream.
  35034. * @param scene Define the scene the texture should be created in
  35035. * @param stream Define the stream the texture should be created from
  35036. * @returns The created video texture as a promise
  35037. */
  35038. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35039. /**
  35040. * Creates a video texture straight from your WebCam video feed.
  35041. * @param scene Define the scene the texture should be created in
  35042. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35043. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35044. * @returns The created video texture as a promise
  35045. */
  35046. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35047. minWidth: number;
  35048. maxWidth: number;
  35049. minHeight: number;
  35050. maxHeight: number;
  35051. deviceId: string;
  35052. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35053. /**
  35054. * Creates a video texture straight from your WebCam video feed.
  35055. * @param scene Define the scene the texture should be created in
  35056. * @param onReady Define a callback to triggered once the texture will be ready
  35057. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35058. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35059. */
  35060. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35061. minWidth: number;
  35062. maxWidth: number;
  35063. minHeight: number;
  35064. maxHeight: number;
  35065. deviceId: string;
  35066. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35067. }
  35068. }
  35069. declare module BABYLON {
  35070. /**
  35071. * Defines the interface used by objects working like Scene
  35072. * @hidden
  35073. */
  35074. export interface ISceneLike {
  35075. _addPendingData(data: any): void;
  35076. _removePendingData(data: any): void;
  35077. offlineProvider: IOfflineProvider;
  35078. }
  35079. /** Interface defining initialization parameters for Engine class */
  35080. export interface EngineOptions extends WebGLContextAttributes {
  35081. /**
  35082. * Defines if the engine should no exceed a specified device ratio
  35083. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35084. */
  35085. limitDeviceRatio?: number;
  35086. /**
  35087. * Defines if webvr should be enabled automatically
  35088. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35089. */
  35090. autoEnableWebVR?: boolean;
  35091. /**
  35092. * Defines if webgl2 should be turned off even if supported
  35093. * @see https://doc.babylonjs.com/features/webgl2
  35094. */
  35095. disableWebGL2Support?: boolean;
  35096. /**
  35097. * Defines if webaudio should be initialized as well
  35098. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35099. */
  35100. audioEngine?: boolean;
  35101. /**
  35102. * Defines if animations should run using a deterministic lock step
  35103. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35104. */
  35105. deterministicLockstep?: boolean;
  35106. /** Defines the maximum steps to use with deterministic lock step mode */
  35107. lockstepMaxSteps?: number;
  35108. /** Defines the seconds between each deterministic lock step */
  35109. timeStep?: number;
  35110. /**
  35111. * Defines that engine should ignore context lost events
  35112. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35113. */
  35114. doNotHandleContextLost?: boolean;
  35115. /**
  35116. * Defines that engine should ignore modifying touch action attribute and style
  35117. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35118. */
  35119. doNotHandleTouchAction?: boolean;
  35120. /**
  35121. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35122. */
  35123. useHighPrecisionFloats?: boolean;
  35124. /**
  35125. * Make the canvas XR Compatible for XR sessions
  35126. */
  35127. xrCompatible?: boolean;
  35128. /**
  35129. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35130. */
  35131. useHighPrecisionMatrix?: boolean;
  35132. }
  35133. /**
  35134. * The base engine class (root of all engines)
  35135. */
  35136. export class ThinEngine {
  35137. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35138. static ExceptionList: ({
  35139. key: string;
  35140. capture: string;
  35141. captureConstraint: number;
  35142. targets: string[];
  35143. } | {
  35144. key: string;
  35145. capture: null;
  35146. captureConstraint: null;
  35147. targets: string[];
  35148. })[];
  35149. /** @hidden */
  35150. static _TextureLoaders: IInternalTextureLoader[];
  35151. /**
  35152. * Returns the current npm package of the sdk
  35153. */
  35154. static get NpmPackage(): string;
  35155. /**
  35156. * Returns the current version of the framework
  35157. */
  35158. static get Version(): string;
  35159. /**
  35160. * Returns a string describing the current engine
  35161. */
  35162. get description(): string;
  35163. /**
  35164. * Gets or sets the epsilon value used by collision engine
  35165. */
  35166. static CollisionsEpsilon: number;
  35167. /**
  35168. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35169. */
  35170. static get ShadersRepository(): string;
  35171. static set ShadersRepository(value: string);
  35172. /** @hidden */
  35173. _shaderProcessor: IShaderProcessor;
  35174. /**
  35175. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35176. */
  35177. forcePOTTextures: boolean;
  35178. /**
  35179. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35180. */
  35181. isFullscreen: boolean;
  35182. /**
  35183. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35184. */
  35185. cullBackFaces: boolean;
  35186. /**
  35187. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35188. */
  35189. renderEvenInBackground: boolean;
  35190. /**
  35191. * Gets or sets a boolean indicating that cache can be kept between frames
  35192. */
  35193. preventCacheWipeBetweenFrames: boolean;
  35194. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35195. validateShaderPrograms: boolean;
  35196. /**
  35197. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35198. * This can provide greater z depth for distant objects.
  35199. */
  35200. useReverseDepthBuffer: boolean;
  35201. /**
  35202. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35203. */
  35204. disableUniformBuffers: boolean;
  35205. /** @hidden */
  35206. _uniformBuffers: UniformBuffer[];
  35207. /**
  35208. * Gets a boolean indicating that the engine supports uniform buffers
  35209. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35210. */
  35211. get supportsUniformBuffers(): boolean;
  35212. /** @hidden */
  35213. _gl: WebGLRenderingContext;
  35214. /** @hidden */
  35215. _webGLVersion: number;
  35216. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35217. protected _windowIsBackground: boolean;
  35218. protected _creationOptions: EngineOptions;
  35219. protected _highPrecisionShadersAllowed: boolean;
  35220. /** @hidden */
  35221. get _shouldUseHighPrecisionShader(): boolean;
  35222. /**
  35223. * Gets a boolean indicating that only power of 2 textures are supported
  35224. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35225. */
  35226. get needPOTTextures(): boolean;
  35227. /** @hidden */
  35228. _badOS: boolean;
  35229. /** @hidden */
  35230. _badDesktopOS: boolean;
  35231. private _hardwareScalingLevel;
  35232. /** @hidden */
  35233. _caps: EngineCapabilities;
  35234. private _isStencilEnable;
  35235. private _glVersion;
  35236. private _glRenderer;
  35237. private _glVendor;
  35238. /** @hidden */
  35239. _videoTextureSupported: boolean;
  35240. protected _renderingQueueLaunched: boolean;
  35241. protected _activeRenderLoops: (() => void)[];
  35242. /**
  35243. * Observable signaled when a context lost event is raised
  35244. */
  35245. onContextLostObservable: Observable<ThinEngine>;
  35246. /**
  35247. * Observable signaled when a context restored event is raised
  35248. */
  35249. onContextRestoredObservable: Observable<ThinEngine>;
  35250. private _onContextLost;
  35251. private _onContextRestored;
  35252. protected _contextWasLost: boolean;
  35253. /** @hidden */
  35254. _doNotHandleContextLost: boolean;
  35255. /**
  35256. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35257. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35258. */
  35259. get doNotHandleContextLost(): boolean;
  35260. set doNotHandleContextLost(value: boolean);
  35261. /**
  35262. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35263. */
  35264. disableVertexArrayObjects: boolean;
  35265. /** @hidden */
  35266. protected _colorWrite: boolean;
  35267. /** @hidden */
  35268. protected _colorWriteChanged: boolean;
  35269. /** @hidden */
  35270. protected _depthCullingState: DepthCullingState;
  35271. /** @hidden */
  35272. protected _stencilState: StencilState;
  35273. /** @hidden */
  35274. _alphaState: AlphaState;
  35275. /** @hidden */
  35276. _alphaMode: number;
  35277. /** @hidden */
  35278. _alphaEquation: number;
  35279. /** @hidden */
  35280. _internalTexturesCache: InternalTexture[];
  35281. /** @hidden */
  35282. protected _activeChannel: number;
  35283. private _currentTextureChannel;
  35284. /** @hidden */
  35285. protected _boundTexturesCache: {
  35286. [key: string]: Nullable<InternalTexture>;
  35287. };
  35288. /** @hidden */
  35289. protected _currentEffect: Nullable<Effect>;
  35290. /** @hidden */
  35291. protected _currentProgram: Nullable<WebGLProgram>;
  35292. private _compiledEffects;
  35293. private _vertexAttribArraysEnabled;
  35294. /** @hidden */
  35295. protected _cachedViewport: Nullable<IViewportLike>;
  35296. private _cachedVertexArrayObject;
  35297. /** @hidden */
  35298. protected _cachedVertexBuffers: any;
  35299. /** @hidden */
  35300. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35301. /** @hidden */
  35302. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35303. /** @hidden */
  35304. _currentRenderTarget: Nullable<InternalTexture>;
  35305. private _uintIndicesCurrentlySet;
  35306. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35307. /** @hidden */
  35308. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35309. /** @hidden */
  35310. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35311. private _currentBufferPointers;
  35312. private _currentInstanceLocations;
  35313. private _currentInstanceBuffers;
  35314. private _textureUnits;
  35315. /** @hidden */
  35316. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35317. /** @hidden */
  35318. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35319. /** @hidden */
  35320. _boundRenderFunction: any;
  35321. private _vaoRecordInProgress;
  35322. private _mustWipeVertexAttributes;
  35323. private _emptyTexture;
  35324. private _emptyCubeTexture;
  35325. private _emptyTexture3D;
  35326. private _emptyTexture2DArray;
  35327. /** @hidden */
  35328. _frameHandler: number;
  35329. private _nextFreeTextureSlots;
  35330. private _maxSimultaneousTextures;
  35331. private _activeRequests;
  35332. /** @hidden */
  35333. _transformTextureUrl: Nullable<(url: string) => string>;
  35334. protected get _supportsHardwareTextureRescaling(): boolean;
  35335. private _framebufferDimensionsObject;
  35336. /**
  35337. * sets the object from which width and height will be taken from when getting render width and height
  35338. * Will fallback to the gl object
  35339. * @param dimensions the framebuffer width and height that will be used.
  35340. */
  35341. set framebufferDimensionsObject(dimensions: Nullable<{
  35342. framebufferWidth: number;
  35343. framebufferHeight: number;
  35344. }>);
  35345. /**
  35346. * Gets the current viewport
  35347. */
  35348. get currentViewport(): Nullable<IViewportLike>;
  35349. /**
  35350. * Gets the default empty texture
  35351. */
  35352. get emptyTexture(): InternalTexture;
  35353. /**
  35354. * Gets the default empty 3D texture
  35355. */
  35356. get emptyTexture3D(): InternalTexture;
  35357. /**
  35358. * Gets the default empty 2D array texture
  35359. */
  35360. get emptyTexture2DArray(): InternalTexture;
  35361. /**
  35362. * Gets the default empty cube texture
  35363. */
  35364. get emptyCubeTexture(): InternalTexture;
  35365. /**
  35366. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35367. */
  35368. readonly premultipliedAlpha: boolean;
  35369. /**
  35370. * Observable event triggered before each texture is initialized
  35371. */
  35372. onBeforeTextureInitObservable: Observable<Texture>;
  35373. /**
  35374. * Creates a new engine
  35375. * @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
  35376. * @param antialias defines enable antialiasing (default: false)
  35377. * @param options defines further options to be sent to the getContext() function
  35378. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35379. */
  35380. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35381. private _rebuildInternalTextures;
  35382. private _rebuildEffects;
  35383. /**
  35384. * Gets a boolean indicating if all created effects are ready
  35385. * @returns true if all effects are ready
  35386. */
  35387. areAllEffectsReady(): boolean;
  35388. protected _rebuildBuffers(): void;
  35389. protected _initGLContext(): void;
  35390. /**
  35391. * Gets version of the current webGL context
  35392. */
  35393. get webGLVersion(): number;
  35394. /**
  35395. * Gets a string idenfifying the name of the class
  35396. * @returns "Engine" string
  35397. */
  35398. getClassName(): string;
  35399. /**
  35400. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35401. */
  35402. get isStencilEnable(): boolean;
  35403. /** @hidden */
  35404. _prepareWorkingCanvas(): void;
  35405. /**
  35406. * Reset the texture cache to empty state
  35407. */
  35408. resetTextureCache(): void;
  35409. /**
  35410. * Gets an object containing information about the current webGL context
  35411. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35412. */
  35413. getGlInfo(): {
  35414. vendor: string;
  35415. renderer: string;
  35416. version: string;
  35417. };
  35418. /**
  35419. * Defines the hardware scaling level.
  35420. * By default the hardware scaling level is computed from the window device ratio.
  35421. * 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.
  35422. * @param level defines the level to use
  35423. */
  35424. setHardwareScalingLevel(level: number): void;
  35425. /**
  35426. * Gets the current hardware scaling level.
  35427. * By default the hardware scaling level is computed from the window device ratio.
  35428. * 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.
  35429. * @returns a number indicating the current hardware scaling level
  35430. */
  35431. getHardwareScalingLevel(): number;
  35432. /**
  35433. * Gets the list of loaded textures
  35434. * @returns an array containing all loaded textures
  35435. */
  35436. getLoadedTexturesCache(): InternalTexture[];
  35437. /**
  35438. * Gets the object containing all engine capabilities
  35439. * @returns the EngineCapabilities object
  35440. */
  35441. getCaps(): EngineCapabilities;
  35442. /**
  35443. * stop executing a render loop function and remove it from the execution array
  35444. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35445. */
  35446. stopRenderLoop(renderFunction?: () => void): void;
  35447. /** @hidden */
  35448. _renderLoop(): void;
  35449. /**
  35450. * Gets the HTML canvas attached with the current webGL context
  35451. * @returns a HTML canvas
  35452. */
  35453. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35454. /**
  35455. * Gets host window
  35456. * @returns the host window object
  35457. */
  35458. getHostWindow(): Nullable<Window>;
  35459. /**
  35460. * Gets the current render width
  35461. * @param useScreen defines if screen size must be used (or the current render target if any)
  35462. * @returns a number defining the current render width
  35463. */
  35464. getRenderWidth(useScreen?: boolean): number;
  35465. /**
  35466. * Gets the current render height
  35467. * @param useScreen defines if screen size must be used (or the current render target if any)
  35468. * @returns a number defining the current render height
  35469. */
  35470. getRenderHeight(useScreen?: boolean): number;
  35471. /**
  35472. * Can be used to override the current requestAnimationFrame requester.
  35473. * @hidden
  35474. */
  35475. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35476. /**
  35477. * Register and execute a render loop. The engine can have more than one render function
  35478. * @param renderFunction defines the function to continuously execute
  35479. */
  35480. runRenderLoop(renderFunction: () => void): void;
  35481. /**
  35482. * Clear the current render buffer or the current render target (if any is set up)
  35483. * @param color defines the color to use
  35484. * @param backBuffer defines if the back buffer must be cleared
  35485. * @param depth defines if the depth buffer must be cleared
  35486. * @param stencil defines if the stencil buffer must be cleared
  35487. */
  35488. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35489. private _viewportCached;
  35490. /** @hidden */
  35491. _viewport(x: number, y: number, width: number, height: number): void;
  35492. /**
  35493. * Set the WebGL's viewport
  35494. * @param viewport defines the viewport element to be used
  35495. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35496. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35497. */
  35498. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35499. /**
  35500. * Begin a new frame
  35501. */
  35502. beginFrame(): void;
  35503. /**
  35504. * Enf the current frame
  35505. */
  35506. endFrame(): void;
  35507. /**
  35508. * Resize the view according to the canvas' size
  35509. */
  35510. resize(): void;
  35511. /**
  35512. * Force a specific size of the canvas
  35513. * @param width defines the new canvas' width
  35514. * @param height defines the new canvas' height
  35515. * @returns true if the size was changed
  35516. */
  35517. setSize(width: number, height: number): boolean;
  35518. /**
  35519. * Binds the frame buffer to the specified texture.
  35520. * @param texture The texture to render to or null for the default canvas
  35521. * @param faceIndex The face of the texture to render to in case of cube texture
  35522. * @param requiredWidth The width of the target to render to
  35523. * @param requiredHeight The height of the target to render to
  35524. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35525. * @param lodLevel defines the lod level to bind to the frame buffer
  35526. * @param layer defines the 2d array index to bind to frame buffer to
  35527. */
  35528. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35529. /** @hidden */
  35530. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35531. /**
  35532. * Unbind the current render target texture from the webGL context
  35533. * @param texture defines the render target texture to unbind
  35534. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35535. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35536. */
  35537. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35538. /**
  35539. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35540. */
  35541. flushFramebuffer(): void;
  35542. /**
  35543. * Unbind the current render target and bind the default framebuffer
  35544. */
  35545. restoreDefaultFramebuffer(): void;
  35546. /** @hidden */
  35547. protected _resetVertexBufferBinding(): void;
  35548. /**
  35549. * Creates a vertex buffer
  35550. * @param data the data for the vertex buffer
  35551. * @returns the new WebGL static buffer
  35552. */
  35553. createVertexBuffer(data: DataArray): DataBuffer;
  35554. private _createVertexBuffer;
  35555. /**
  35556. * Creates a dynamic vertex buffer
  35557. * @param data the data for the dynamic vertex buffer
  35558. * @returns the new WebGL dynamic buffer
  35559. */
  35560. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35561. protected _resetIndexBufferBinding(): void;
  35562. /**
  35563. * Creates a new index buffer
  35564. * @param indices defines the content of the index buffer
  35565. * @param updatable defines if the index buffer must be updatable
  35566. * @returns a new webGL buffer
  35567. */
  35568. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35569. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35570. /**
  35571. * Bind a webGL buffer to the webGL context
  35572. * @param buffer defines the buffer to bind
  35573. */
  35574. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35575. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35576. private bindBuffer;
  35577. /**
  35578. * update the bound buffer with the given data
  35579. * @param data defines the data to update
  35580. */
  35581. updateArrayBuffer(data: Float32Array): void;
  35582. private _vertexAttribPointer;
  35583. /** @hidden */
  35584. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35585. private _bindVertexBuffersAttributes;
  35586. /**
  35587. * Records a vertex array object
  35588. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35589. * @param vertexBuffers defines the list of vertex buffers to store
  35590. * @param indexBuffer defines the index buffer to store
  35591. * @param effect defines the effect to store
  35592. * @returns the new vertex array object
  35593. */
  35594. recordVertexArrayObject(vertexBuffers: {
  35595. [key: string]: VertexBuffer;
  35596. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35597. /**
  35598. * Bind a specific vertex array object
  35599. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35600. * @param vertexArrayObject defines the vertex array object to bind
  35601. * @param indexBuffer defines the index buffer to bind
  35602. */
  35603. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35604. /**
  35605. * Bind webGl buffers directly to the webGL context
  35606. * @param vertexBuffer defines the vertex buffer to bind
  35607. * @param indexBuffer defines the index buffer to bind
  35608. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35609. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35610. * @param effect defines the effect associated with the vertex buffer
  35611. */
  35612. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35613. private _unbindVertexArrayObject;
  35614. /**
  35615. * Bind a list of vertex buffers to the webGL context
  35616. * @param vertexBuffers defines the list of vertex buffers to bind
  35617. * @param indexBuffer defines the index buffer to bind
  35618. * @param effect defines the effect associated with the vertex buffers
  35619. */
  35620. bindBuffers(vertexBuffers: {
  35621. [key: string]: Nullable<VertexBuffer>;
  35622. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35623. /**
  35624. * Unbind all instance attributes
  35625. */
  35626. unbindInstanceAttributes(): void;
  35627. /**
  35628. * Release and free the memory of a vertex array object
  35629. * @param vao defines the vertex array object to delete
  35630. */
  35631. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35632. /** @hidden */
  35633. _releaseBuffer(buffer: DataBuffer): boolean;
  35634. protected _deleteBuffer(buffer: DataBuffer): void;
  35635. /**
  35636. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35637. * @param instancesBuffer defines the webGL buffer to update and bind
  35638. * @param data defines the data to store in the buffer
  35639. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35640. */
  35641. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35642. /**
  35643. * Bind the content of a webGL buffer used with instantiation
  35644. * @param instancesBuffer defines the webGL buffer to bind
  35645. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35646. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35647. */
  35648. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35649. /**
  35650. * Disable the instance attribute corresponding to the name in parameter
  35651. * @param name defines the name of the attribute to disable
  35652. */
  35653. disableInstanceAttributeByName(name: string): void;
  35654. /**
  35655. * Disable the instance attribute corresponding to the location in parameter
  35656. * @param attributeLocation defines the attribute location of the attribute to disable
  35657. */
  35658. disableInstanceAttribute(attributeLocation: number): void;
  35659. /**
  35660. * Disable the attribute corresponding to the location in parameter
  35661. * @param attributeLocation defines the attribute location of the attribute to disable
  35662. */
  35663. disableAttributeByIndex(attributeLocation: number): void;
  35664. /**
  35665. * Send a draw order
  35666. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35667. * @param indexStart defines the starting index
  35668. * @param indexCount defines the number of index to draw
  35669. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35670. */
  35671. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35672. /**
  35673. * Draw a list of points
  35674. * @param verticesStart defines the index of first vertex to draw
  35675. * @param verticesCount defines the count of vertices to draw
  35676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35677. */
  35678. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35679. /**
  35680. * Draw a list of unindexed primitives
  35681. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35682. * @param verticesStart defines the index of first vertex to draw
  35683. * @param verticesCount defines the count of vertices to draw
  35684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35685. */
  35686. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35687. /**
  35688. * Draw a list of indexed primitives
  35689. * @param fillMode defines the primitive to use
  35690. * @param indexStart defines the starting index
  35691. * @param indexCount defines the number of index to draw
  35692. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35693. */
  35694. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35695. /**
  35696. * Draw a list of unindexed primitives
  35697. * @param fillMode defines the primitive to use
  35698. * @param verticesStart defines the index of first vertex to draw
  35699. * @param verticesCount defines the count of vertices to draw
  35700. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35701. */
  35702. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35703. private _drawMode;
  35704. /** @hidden */
  35705. protected _reportDrawCall(): void;
  35706. /** @hidden */
  35707. _releaseEffect(effect: Effect): void;
  35708. /** @hidden */
  35709. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35710. /**
  35711. * Create a new effect (used to store vertex/fragment shaders)
  35712. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35713. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35714. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35715. * @param samplers defines an array of string used to represent textures
  35716. * @param defines defines the string containing the defines to use to compile the shaders
  35717. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35718. * @param onCompiled defines a function to call when the effect creation is successful
  35719. * @param onError defines a function to call when the effect creation has failed
  35720. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35721. * @returns the new Effect
  35722. */
  35723. 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;
  35724. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35725. private _compileShader;
  35726. private _compileRawShader;
  35727. /** @hidden */
  35728. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35729. /**
  35730. * Directly creates a webGL program
  35731. * @param pipelineContext defines the pipeline context to attach to
  35732. * @param vertexCode defines the vertex shader code to use
  35733. * @param fragmentCode defines the fragment shader code to use
  35734. * @param context defines the webGL context to use (if not set, the current one will be used)
  35735. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35736. * @returns the new webGL program
  35737. */
  35738. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35739. /**
  35740. * Creates a webGL program
  35741. * @param pipelineContext defines the pipeline context to attach to
  35742. * @param vertexCode defines the vertex shader code to use
  35743. * @param fragmentCode defines the fragment shader code to use
  35744. * @param defines defines the string containing the defines to use to compile the shaders
  35745. * @param context defines the webGL context to use (if not set, the current one will be used)
  35746. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35747. * @returns the new webGL program
  35748. */
  35749. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35750. /**
  35751. * Creates a new pipeline context
  35752. * @returns the new pipeline
  35753. */
  35754. createPipelineContext(): IPipelineContext;
  35755. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35756. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35757. /** @hidden */
  35758. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35759. /** @hidden */
  35760. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35761. /** @hidden */
  35762. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35763. /**
  35764. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35765. * @param pipelineContext defines the pipeline context to use
  35766. * @param uniformsNames defines the list of uniform names
  35767. * @returns an array of webGL uniform locations
  35768. */
  35769. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35770. /**
  35771. * Gets the lsit of active attributes for a given webGL program
  35772. * @param pipelineContext defines the pipeline context to use
  35773. * @param attributesNames defines the list of attribute names to get
  35774. * @returns an array of indices indicating the offset of each attribute
  35775. */
  35776. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35777. /**
  35778. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35779. * @param effect defines the effect to activate
  35780. */
  35781. enableEffect(effect: Nullable<Effect>): void;
  35782. /**
  35783. * Set the value of an uniform to a number (int)
  35784. * @param uniform defines the webGL uniform location where to store the value
  35785. * @param value defines the int number to store
  35786. */
  35787. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35788. /**
  35789. * Set the value of an uniform to an array of int32
  35790. * @param uniform defines the webGL uniform location where to store the value
  35791. * @param array defines the array of int32 to store
  35792. */
  35793. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35794. /**
  35795. * Set the value of an uniform to an array of int32 (stored as vec2)
  35796. * @param uniform defines the webGL uniform location where to store the value
  35797. * @param array defines the array of int32 to store
  35798. */
  35799. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35800. /**
  35801. * Set the value of an uniform to an array of int32 (stored as vec3)
  35802. * @param uniform defines the webGL uniform location where to store the value
  35803. * @param array defines the array of int32 to store
  35804. */
  35805. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35806. /**
  35807. * Set the value of an uniform to an array of int32 (stored as vec4)
  35808. * @param uniform defines the webGL uniform location where to store the value
  35809. * @param array defines the array of int32 to store
  35810. */
  35811. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35812. /**
  35813. * Set the value of an uniform to an array of number
  35814. * @param uniform defines the webGL uniform location where to store the value
  35815. * @param array defines the array of number to store
  35816. */
  35817. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35818. /**
  35819. * Set the value of an uniform to an array of number (stored as vec2)
  35820. * @param uniform defines the webGL uniform location where to store the value
  35821. * @param array defines the array of number to store
  35822. */
  35823. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35824. /**
  35825. * Set the value of an uniform to an array of number (stored as vec3)
  35826. * @param uniform defines the webGL uniform location where to store the value
  35827. * @param array defines the array of number to store
  35828. */
  35829. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35830. /**
  35831. * Set the value of an uniform to an array of number (stored as vec4)
  35832. * @param uniform defines the webGL uniform location where to store the value
  35833. * @param array defines the array of number to store
  35834. */
  35835. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35836. /**
  35837. * Set the value of an uniform to an array of float32 (stored as matrices)
  35838. * @param uniform defines the webGL uniform location where to store the value
  35839. * @param matrices defines the array of float32 to store
  35840. */
  35841. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35842. /**
  35843. * Set the value of an uniform to a matrix (3x3)
  35844. * @param uniform defines the webGL uniform location where to store the value
  35845. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35846. */
  35847. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35848. /**
  35849. * Set the value of an uniform to a matrix (2x2)
  35850. * @param uniform defines the webGL uniform location where to store the value
  35851. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35852. */
  35853. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35854. /**
  35855. * Set the value of an uniform to a number (float)
  35856. * @param uniform defines the webGL uniform location where to store the value
  35857. * @param value defines the float number to store
  35858. */
  35859. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35860. /**
  35861. * Set the value of an uniform to a vec2
  35862. * @param uniform defines the webGL uniform location where to store the value
  35863. * @param x defines the 1st component of the value
  35864. * @param y defines the 2nd component of the value
  35865. */
  35866. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35867. /**
  35868. * Set the value of an uniform to a vec3
  35869. * @param uniform defines the webGL uniform location where to store the value
  35870. * @param x defines the 1st component of the value
  35871. * @param y defines the 2nd component of the value
  35872. * @param z defines the 3rd component of the value
  35873. */
  35874. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35875. /**
  35876. * Set the value of an uniform to a vec4
  35877. * @param uniform defines the webGL uniform location where to store the value
  35878. * @param x defines the 1st component of the value
  35879. * @param y defines the 2nd component of the value
  35880. * @param z defines the 3rd component of the value
  35881. * @param w defines the 4th component of the value
  35882. */
  35883. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35884. /**
  35885. * Apply all cached states (depth, culling, stencil and alpha)
  35886. */
  35887. applyStates(): void;
  35888. /**
  35889. * Enable or disable color writing
  35890. * @param enable defines the state to set
  35891. */
  35892. setColorWrite(enable: boolean): void;
  35893. /**
  35894. * Gets a boolean indicating if color writing is enabled
  35895. * @returns the current color writing state
  35896. */
  35897. getColorWrite(): boolean;
  35898. /**
  35899. * Gets the depth culling state manager
  35900. */
  35901. get depthCullingState(): DepthCullingState;
  35902. /**
  35903. * Gets the alpha state manager
  35904. */
  35905. get alphaState(): AlphaState;
  35906. /**
  35907. * Gets the stencil state manager
  35908. */
  35909. get stencilState(): StencilState;
  35910. /**
  35911. * Clears the list of texture accessible through engine.
  35912. * This can help preventing texture load conflict due to name collision.
  35913. */
  35914. clearInternalTexturesCache(): void;
  35915. /**
  35916. * Force the entire cache to be cleared
  35917. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35918. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35919. */
  35920. wipeCaches(bruteForce?: boolean): void;
  35921. /** @hidden */
  35922. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35923. min: number;
  35924. mag: number;
  35925. };
  35926. /** @hidden */
  35927. _createTexture(): WebGLTexture;
  35928. /**
  35929. * Usually called from Texture.ts.
  35930. * Passed information to create a WebGLTexture
  35931. * @param url defines a value which contains one of the following:
  35932. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35933. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35934. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35935. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35936. * @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)
  35937. * @param scene needed for loading to the correct scene
  35938. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35939. * @param onLoad optional callback to be called upon successful completion
  35940. * @param onError optional callback to be called upon failure
  35941. * @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
  35942. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35943. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35944. * @param forcedExtension defines the extension to use to pick the right loader
  35945. * @param mimeType defines an optional mime type
  35946. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35947. */
  35948. 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;
  35949. /**
  35950. * Loads an image as an HTMLImageElement.
  35951. * @param input url string, ArrayBuffer, or Blob to load
  35952. * @param onLoad callback called when the image successfully loads
  35953. * @param onError callback called when the image fails to load
  35954. * @param offlineProvider offline provider for caching
  35955. * @param mimeType optional mime type
  35956. * @returns the HTMLImageElement of the loaded image
  35957. * @hidden
  35958. */
  35959. 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>;
  35960. /**
  35961. * @hidden
  35962. */
  35963. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35964. private _unpackFlipYCached;
  35965. /**
  35966. * In case you are sharing the context with other applications, it might
  35967. * be interested to not cache the unpack flip y state to ensure a consistent
  35968. * value would be set.
  35969. */
  35970. enableUnpackFlipYCached: boolean;
  35971. /** @hidden */
  35972. _unpackFlipY(value: boolean): void;
  35973. /** @hidden */
  35974. _getUnpackAlignement(): number;
  35975. private _getTextureTarget;
  35976. /**
  35977. * Update the sampling mode of a given texture
  35978. * @param samplingMode defines the required sampling mode
  35979. * @param texture defines the texture to update
  35980. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35981. */
  35982. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35983. /**
  35984. * Update the sampling mode of a given texture
  35985. * @param texture defines the texture to update
  35986. * @param wrapU defines the texture wrap mode of the u coordinates
  35987. * @param wrapV defines the texture wrap mode of the v coordinates
  35988. * @param wrapR defines the texture wrap mode of the r coordinates
  35989. */
  35990. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35991. /** @hidden */
  35992. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35993. width: number;
  35994. height: number;
  35995. layers?: number;
  35996. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35997. /** @hidden */
  35998. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35999. /** @hidden */
  36000. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36001. /**
  36002. * Update a portion of an internal texture
  36003. * @param texture defines the texture to update
  36004. * @param imageData defines the data to store into the texture
  36005. * @param xOffset defines the x coordinates of the update rectangle
  36006. * @param yOffset defines the y coordinates of the update rectangle
  36007. * @param width defines the width of the update rectangle
  36008. * @param height defines the height of the update rectangle
  36009. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36010. * @param lod defines the lod level to update (0 by default)
  36011. */
  36012. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36013. /** @hidden */
  36014. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36015. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36016. private _prepareWebGLTexture;
  36017. /** @hidden */
  36018. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36019. private _getDepthStencilBuffer;
  36020. /** @hidden */
  36021. _releaseFramebufferObjects(texture: InternalTexture): void;
  36022. /** @hidden */
  36023. _releaseTexture(texture: InternalTexture): void;
  36024. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36025. protected _setProgram(program: WebGLProgram): void;
  36026. protected _boundUniforms: {
  36027. [key: number]: WebGLUniformLocation;
  36028. };
  36029. /**
  36030. * Binds an effect to the webGL context
  36031. * @param effect defines the effect to bind
  36032. */
  36033. bindSamplers(effect: Effect): void;
  36034. private _activateCurrentTexture;
  36035. /** @hidden */
  36036. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36037. /** @hidden */
  36038. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36039. /**
  36040. * Unbind all textures from the webGL context
  36041. */
  36042. unbindAllTextures(): void;
  36043. /**
  36044. * Sets a texture to the according uniform.
  36045. * @param channel The texture channel
  36046. * @param uniform The uniform to set
  36047. * @param texture The texture to apply
  36048. */
  36049. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36050. private _bindSamplerUniformToChannel;
  36051. private _getTextureWrapMode;
  36052. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36053. /**
  36054. * Sets an array of texture to the webGL context
  36055. * @param channel defines the channel where the texture array must be set
  36056. * @param uniform defines the associated uniform location
  36057. * @param textures defines the array of textures to bind
  36058. */
  36059. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36060. /** @hidden */
  36061. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36062. private _setTextureParameterFloat;
  36063. private _setTextureParameterInteger;
  36064. /**
  36065. * Unbind all vertex attributes from the webGL context
  36066. */
  36067. unbindAllAttributes(): void;
  36068. /**
  36069. * 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
  36070. */
  36071. releaseEffects(): void;
  36072. /**
  36073. * Dispose and release all associated resources
  36074. */
  36075. dispose(): void;
  36076. /**
  36077. * Attach a new callback raised when context lost event is fired
  36078. * @param callback defines the callback to call
  36079. */
  36080. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36081. /**
  36082. * Attach a new callback raised when context restored event is fired
  36083. * @param callback defines the callback to call
  36084. */
  36085. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36086. /**
  36087. * Get the current error code of the webGL context
  36088. * @returns the error code
  36089. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36090. */
  36091. getError(): number;
  36092. private _canRenderToFloatFramebuffer;
  36093. private _canRenderToHalfFloatFramebuffer;
  36094. private _canRenderToFramebuffer;
  36095. /** @hidden */
  36096. _getWebGLTextureType(type: number): number;
  36097. /** @hidden */
  36098. _getInternalFormat(format: number): number;
  36099. /** @hidden */
  36100. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36101. /** @hidden */
  36102. _getRGBAMultiSampleBufferFormat(type: number): number;
  36103. /** @hidden */
  36104. _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;
  36105. /**
  36106. * Loads a file from a url
  36107. * @param url url to load
  36108. * @param onSuccess callback called when the file successfully loads
  36109. * @param onProgress callback called while file is loading (if the server supports this mode)
  36110. * @param offlineProvider defines the offline provider for caching
  36111. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36112. * @param onError callback called when the file fails to load
  36113. * @returns a file request object
  36114. * @hidden
  36115. */
  36116. 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;
  36117. /**
  36118. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36119. * @param x defines the x coordinate of the rectangle where pixels must be read
  36120. * @param y defines the y coordinate of the rectangle where pixels must be read
  36121. * @param width defines the width of the rectangle where pixels must be read
  36122. * @param height defines the height of the rectangle where pixels must be read
  36123. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36124. * @returns a Uint8Array containing RGBA colors
  36125. */
  36126. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36127. private static _isSupported;
  36128. /**
  36129. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36130. * @returns true if the engine can be created
  36131. * @ignorenaming
  36132. */
  36133. static isSupported(): boolean;
  36134. /**
  36135. * Find the next highest power of two.
  36136. * @param x Number to start search from.
  36137. * @return Next highest power of two.
  36138. */
  36139. static CeilingPOT(x: number): number;
  36140. /**
  36141. * Find the next lowest power of two.
  36142. * @param x Number to start search from.
  36143. * @return Next lowest power of two.
  36144. */
  36145. static FloorPOT(x: number): number;
  36146. /**
  36147. * Find the nearest power of two.
  36148. * @param x Number to start search from.
  36149. * @return Next nearest power of two.
  36150. */
  36151. static NearestPOT(x: number): number;
  36152. /**
  36153. * Get the closest exponent of two
  36154. * @param value defines the value to approximate
  36155. * @param max defines the maximum value to return
  36156. * @param mode defines how to define the closest value
  36157. * @returns closest exponent of two of the given value
  36158. */
  36159. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36160. /**
  36161. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36162. * @param func - the function to be called
  36163. * @param requester - the object that will request the next frame. Falls back to window.
  36164. * @returns frame number
  36165. */
  36166. static QueueNewFrame(func: () => void, requester?: any): number;
  36167. /**
  36168. * Gets host document
  36169. * @returns the host document object
  36170. */
  36171. getHostDocument(): Nullable<Document>;
  36172. }
  36173. }
  36174. declare module BABYLON {
  36175. /**
  36176. * Class representing spherical harmonics coefficients to the 3rd degree
  36177. */
  36178. export class SphericalHarmonics {
  36179. /**
  36180. * Defines whether or not the harmonics have been prescaled for rendering.
  36181. */
  36182. preScaled: boolean;
  36183. /**
  36184. * The l0,0 coefficients of the spherical harmonics
  36185. */
  36186. l00: Vector3;
  36187. /**
  36188. * The l1,-1 coefficients of the spherical harmonics
  36189. */
  36190. l1_1: Vector3;
  36191. /**
  36192. * The l1,0 coefficients of the spherical harmonics
  36193. */
  36194. l10: Vector3;
  36195. /**
  36196. * The l1,1 coefficients of the spherical harmonics
  36197. */
  36198. l11: Vector3;
  36199. /**
  36200. * The l2,-2 coefficients of the spherical harmonics
  36201. */
  36202. l2_2: Vector3;
  36203. /**
  36204. * The l2,-1 coefficients of the spherical harmonics
  36205. */
  36206. l2_1: Vector3;
  36207. /**
  36208. * The l2,0 coefficients of the spherical harmonics
  36209. */
  36210. l20: Vector3;
  36211. /**
  36212. * The l2,1 coefficients of the spherical harmonics
  36213. */
  36214. l21: Vector3;
  36215. /**
  36216. * The l2,2 coefficients of the spherical harmonics
  36217. */
  36218. l22: Vector3;
  36219. /**
  36220. * Adds a light to the spherical harmonics
  36221. * @param direction the direction of the light
  36222. * @param color the color of the light
  36223. * @param deltaSolidAngle the delta solid angle of the light
  36224. */
  36225. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36226. /**
  36227. * Scales the spherical harmonics by the given amount
  36228. * @param scale the amount to scale
  36229. */
  36230. scaleInPlace(scale: number): void;
  36231. /**
  36232. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36233. *
  36234. * ```
  36235. * E_lm = A_l * L_lm
  36236. * ```
  36237. *
  36238. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36239. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36240. * the scaling factors are given in equation 9.
  36241. */
  36242. convertIncidentRadianceToIrradiance(): void;
  36243. /**
  36244. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36245. *
  36246. * ```
  36247. * L = (1/pi) * E * rho
  36248. * ```
  36249. *
  36250. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36251. */
  36252. convertIrradianceToLambertianRadiance(): void;
  36253. /**
  36254. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36255. * required operations at run time.
  36256. *
  36257. * This is simply done by scaling back the SH with Ylm constants parameter.
  36258. * The trigonometric part being applied by the shader at run time.
  36259. */
  36260. preScaleForRendering(): void;
  36261. /**
  36262. * Constructs a spherical harmonics from an array.
  36263. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36264. * @returns the spherical harmonics
  36265. */
  36266. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36267. /**
  36268. * Gets the spherical harmonics from polynomial
  36269. * @param polynomial the spherical polynomial
  36270. * @returns the spherical harmonics
  36271. */
  36272. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36273. }
  36274. /**
  36275. * Class representing spherical polynomial coefficients to the 3rd degree
  36276. */
  36277. export class SphericalPolynomial {
  36278. private _harmonics;
  36279. /**
  36280. * The spherical harmonics used to create the polynomials.
  36281. */
  36282. get preScaledHarmonics(): SphericalHarmonics;
  36283. /**
  36284. * The x coefficients of the spherical polynomial
  36285. */
  36286. x: Vector3;
  36287. /**
  36288. * The y coefficients of the spherical polynomial
  36289. */
  36290. y: Vector3;
  36291. /**
  36292. * The z coefficients of the spherical polynomial
  36293. */
  36294. z: Vector3;
  36295. /**
  36296. * The xx coefficients of the spherical polynomial
  36297. */
  36298. xx: Vector3;
  36299. /**
  36300. * The yy coefficients of the spherical polynomial
  36301. */
  36302. yy: Vector3;
  36303. /**
  36304. * The zz coefficients of the spherical polynomial
  36305. */
  36306. zz: Vector3;
  36307. /**
  36308. * The xy coefficients of the spherical polynomial
  36309. */
  36310. xy: Vector3;
  36311. /**
  36312. * The yz coefficients of the spherical polynomial
  36313. */
  36314. yz: Vector3;
  36315. /**
  36316. * The zx coefficients of the spherical polynomial
  36317. */
  36318. zx: Vector3;
  36319. /**
  36320. * Adds an ambient color to the spherical polynomial
  36321. * @param color the color to add
  36322. */
  36323. addAmbient(color: Color3): void;
  36324. /**
  36325. * Scales the spherical polynomial by the given amount
  36326. * @param scale the amount to scale
  36327. */
  36328. scaleInPlace(scale: number): void;
  36329. /**
  36330. * Gets the spherical polynomial from harmonics
  36331. * @param harmonics the spherical harmonics
  36332. * @returns the spherical polynomial
  36333. */
  36334. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36335. /**
  36336. * Constructs a spherical polynomial from an array.
  36337. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36338. * @returns the spherical polynomial
  36339. */
  36340. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36341. }
  36342. }
  36343. declare module BABYLON {
  36344. /**
  36345. * Defines the source of the internal texture
  36346. */
  36347. export enum InternalTextureSource {
  36348. /**
  36349. * The source of the texture data is unknown
  36350. */
  36351. Unknown = 0,
  36352. /**
  36353. * Texture data comes from an URL
  36354. */
  36355. Url = 1,
  36356. /**
  36357. * Texture data is only used for temporary storage
  36358. */
  36359. Temp = 2,
  36360. /**
  36361. * Texture data comes from raw data (ArrayBuffer)
  36362. */
  36363. Raw = 3,
  36364. /**
  36365. * Texture content is dynamic (video or dynamic texture)
  36366. */
  36367. Dynamic = 4,
  36368. /**
  36369. * Texture content is generated by rendering to it
  36370. */
  36371. RenderTarget = 5,
  36372. /**
  36373. * Texture content is part of a multi render target process
  36374. */
  36375. MultiRenderTarget = 6,
  36376. /**
  36377. * Texture data comes from a cube data file
  36378. */
  36379. Cube = 7,
  36380. /**
  36381. * Texture data comes from a raw cube data
  36382. */
  36383. CubeRaw = 8,
  36384. /**
  36385. * Texture data come from a prefiltered cube data file
  36386. */
  36387. CubePrefiltered = 9,
  36388. /**
  36389. * Texture content is raw 3D data
  36390. */
  36391. Raw3D = 10,
  36392. /**
  36393. * Texture content is raw 2D array data
  36394. */
  36395. Raw2DArray = 11,
  36396. /**
  36397. * Texture content is a depth texture
  36398. */
  36399. Depth = 12,
  36400. /**
  36401. * Texture data comes from a raw cube data encoded with RGBD
  36402. */
  36403. CubeRawRGBD = 13
  36404. }
  36405. /**
  36406. * Class used to store data associated with WebGL texture data for the engine
  36407. * This class should not be used directly
  36408. */
  36409. export class InternalTexture {
  36410. /** @hidden */
  36411. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36412. /**
  36413. * Defines if the texture is ready
  36414. */
  36415. isReady: boolean;
  36416. /**
  36417. * Defines if the texture is a cube texture
  36418. */
  36419. isCube: boolean;
  36420. /**
  36421. * Defines if the texture contains 3D data
  36422. */
  36423. is3D: boolean;
  36424. /**
  36425. * Defines if the texture contains 2D array data
  36426. */
  36427. is2DArray: boolean;
  36428. /**
  36429. * Defines if the texture contains multiview data
  36430. */
  36431. isMultiview: boolean;
  36432. /**
  36433. * Gets the URL used to load this texture
  36434. */
  36435. url: string;
  36436. /**
  36437. * Gets the sampling mode of the texture
  36438. */
  36439. samplingMode: number;
  36440. /**
  36441. * Gets a boolean indicating if the texture needs mipmaps generation
  36442. */
  36443. generateMipMaps: boolean;
  36444. /**
  36445. * Gets the number of samples used by the texture (WebGL2+ only)
  36446. */
  36447. samples: number;
  36448. /**
  36449. * Gets the type of the texture (int, float...)
  36450. */
  36451. type: number;
  36452. /**
  36453. * Gets the format of the texture (RGB, RGBA...)
  36454. */
  36455. format: number;
  36456. /**
  36457. * Observable called when the texture is loaded
  36458. */
  36459. onLoadedObservable: Observable<InternalTexture>;
  36460. /**
  36461. * Gets the width of the texture
  36462. */
  36463. width: number;
  36464. /**
  36465. * Gets the height of the texture
  36466. */
  36467. height: number;
  36468. /**
  36469. * Gets the depth of the texture
  36470. */
  36471. depth: number;
  36472. /**
  36473. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36474. */
  36475. baseWidth: number;
  36476. /**
  36477. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36478. */
  36479. baseHeight: number;
  36480. /**
  36481. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36482. */
  36483. baseDepth: number;
  36484. /**
  36485. * Gets a boolean indicating if the texture is inverted on Y axis
  36486. */
  36487. invertY: boolean;
  36488. /** @hidden */
  36489. _invertVScale: boolean;
  36490. /** @hidden */
  36491. _associatedChannel: number;
  36492. /** @hidden */
  36493. _source: InternalTextureSource;
  36494. /** @hidden */
  36495. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36496. /** @hidden */
  36497. _bufferView: Nullable<ArrayBufferView>;
  36498. /** @hidden */
  36499. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36500. /** @hidden */
  36501. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36502. /** @hidden */
  36503. _size: number;
  36504. /** @hidden */
  36505. _extension: string;
  36506. /** @hidden */
  36507. _files: Nullable<string[]>;
  36508. /** @hidden */
  36509. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36510. /** @hidden */
  36511. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36512. /** @hidden */
  36513. _framebuffer: Nullable<WebGLFramebuffer>;
  36514. /** @hidden */
  36515. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36516. /** @hidden */
  36517. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36518. /** @hidden */
  36519. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36520. /** @hidden */
  36521. _attachments: Nullable<number[]>;
  36522. /** @hidden */
  36523. _textureArray: Nullable<InternalTexture[]>;
  36524. /** @hidden */
  36525. _cachedCoordinatesMode: Nullable<number>;
  36526. /** @hidden */
  36527. _cachedWrapU: Nullable<number>;
  36528. /** @hidden */
  36529. _cachedWrapV: Nullable<number>;
  36530. /** @hidden */
  36531. _cachedWrapR: Nullable<number>;
  36532. /** @hidden */
  36533. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36534. /** @hidden */
  36535. _isDisabled: boolean;
  36536. /** @hidden */
  36537. _compression: Nullable<string>;
  36538. /** @hidden */
  36539. _generateStencilBuffer: boolean;
  36540. /** @hidden */
  36541. _generateDepthBuffer: boolean;
  36542. /** @hidden */
  36543. _comparisonFunction: number;
  36544. /** @hidden */
  36545. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36546. /** @hidden */
  36547. _lodGenerationScale: number;
  36548. /** @hidden */
  36549. _lodGenerationOffset: number;
  36550. /** @hidden */
  36551. _depthStencilTexture: Nullable<InternalTexture>;
  36552. /** @hidden */
  36553. _colorTextureArray: Nullable<WebGLTexture>;
  36554. /** @hidden */
  36555. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36556. /** @hidden */
  36557. _lodTextureHigh: Nullable<BaseTexture>;
  36558. /** @hidden */
  36559. _lodTextureMid: Nullable<BaseTexture>;
  36560. /** @hidden */
  36561. _lodTextureLow: Nullable<BaseTexture>;
  36562. /** @hidden */
  36563. _isRGBD: boolean;
  36564. /** @hidden */
  36565. _linearSpecularLOD: boolean;
  36566. /** @hidden */
  36567. _irradianceTexture: Nullable<BaseTexture>;
  36568. /** @hidden */
  36569. _webGLTexture: Nullable<WebGLTexture>;
  36570. /** @hidden */
  36571. _references: number;
  36572. private _engine;
  36573. /**
  36574. * Gets the Engine the texture belongs to.
  36575. * @returns The babylon engine
  36576. */
  36577. getEngine(): ThinEngine;
  36578. /**
  36579. * Gets the data source type of the texture
  36580. */
  36581. get source(): InternalTextureSource;
  36582. /**
  36583. * Creates a new InternalTexture
  36584. * @param engine defines the engine to use
  36585. * @param source defines the type of data that will be used
  36586. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36587. */
  36588. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36589. /**
  36590. * Increments the number of references (ie. the number of Texture that point to it)
  36591. */
  36592. incrementReferences(): void;
  36593. /**
  36594. * Change the size of the texture (not the size of the content)
  36595. * @param width defines the new width
  36596. * @param height defines the new height
  36597. * @param depth defines the new depth (1 by default)
  36598. */
  36599. updateSize(width: int, height: int, depth?: int): void;
  36600. /** @hidden */
  36601. _rebuild(): void;
  36602. /** @hidden */
  36603. _swapAndDie(target: InternalTexture): void;
  36604. /**
  36605. * Dispose the current allocated resources
  36606. */
  36607. dispose(): void;
  36608. }
  36609. }
  36610. declare module BABYLON {
  36611. /**
  36612. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36613. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36614. */
  36615. export class Analyser {
  36616. /**
  36617. * Gets or sets the smoothing
  36618. * @ignorenaming
  36619. */
  36620. SMOOTHING: number;
  36621. /**
  36622. * Gets or sets the FFT table size
  36623. * @ignorenaming
  36624. */
  36625. FFT_SIZE: number;
  36626. /**
  36627. * Gets or sets the bar graph amplitude
  36628. * @ignorenaming
  36629. */
  36630. BARGRAPHAMPLITUDE: number;
  36631. /**
  36632. * Gets or sets the position of the debug canvas
  36633. * @ignorenaming
  36634. */
  36635. DEBUGCANVASPOS: {
  36636. x: number;
  36637. y: number;
  36638. };
  36639. /**
  36640. * Gets or sets the debug canvas size
  36641. * @ignorenaming
  36642. */
  36643. DEBUGCANVASSIZE: {
  36644. width: number;
  36645. height: number;
  36646. };
  36647. private _byteFreqs;
  36648. private _byteTime;
  36649. private _floatFreqs;
  36650. private _webAudioAnalyser;
  36651. private _debugCanvas;
  36652. private _debugCanvasContext;
  36653. private _scene;
  36654. private _registerFunc;
  36655. private _audioEngine;
  36656. /**
  36657. * Creates a new analyser
  36658. * @param scene defines hosting scene
  36659. */
  36660. constructor(scene: Scene);
  36661. /**
  36662. * Get the number of data values you will have to play with for the visualization
  36663. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36664. * @returns a number
  36665. */
  36666. getFrequencyBinCount(): number;
  36667. /**
  36668. * Gets the current frequency data as a byte array
  36669. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36670. * @returns a Uint8Array
  36671. */
  36672. getByteFrequencyData(): Uint8Array;
  36673. /**
  36674. * Gets the current waveform as a byte array
  36675. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36676. * @returns a Uint8Array
  36677. */
  36678. getByteTimeDomainData(): Uint8Array;
  36679. /**
  36680. * Gets the current frequency data as a float array
  36681. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36682. * @returns a Float32Array
  36683. */
  36684. getFloatFrequencyData(): Float32Array;
  36685. /**
  36686. * Renders the debug canvas
  36687. */
  36688. drawDebugCanvas(): void;
  36689. /**
  36690. * Stops rendering the debug canvas and removes it
  36691. */
  36692. stopDebugCanvas(): void;
  36693. /**
  36694. * Connects two audio nodes
  36695. * @param inputAudioNode defines first node to connect
  36696. * @param outputAudioNode defines second node to connect
  36697. */
  36698. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36699. /**
  36700. * Releases all associated resources
  36701. */
  36702. dispose(): void;
  36703. }
  36704. }
  36705. declare module BABYLON {
  36706. /**
  36707. * This represents an audio engine and it is responsible
  36708. * to play, synchronize and analyse sounds throughout the application.
  36709. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36710. */
  36711. export interface IAudioEngine extends IDisposable {
  36712. /**
  36713. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36714. */
  36715. readonly canUseWebAudio: boolean;
  36716. /**
  36717. * Gets the current AudioContext if available.
  36718. */
  36719. readonly audioContext: Nullable<AudioContext>;
  36720. /**
  36721. * The master gain node defines the global audio volume of your audio engine.
  36722. */
  36723. readonly masterGain: GainNode;
  36724. /**
  36725. * Gets whether or not mp3 are supported by your browser.
  36726. */
  36727. readonly isMP3supported: boolean;
  36728. /**
  36729. * Gets whether or not ogg are supported by your browser.
  36730. */
  36731. readonly isOGGsupported: boolean;
  36732. /**
  36733. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36734. * @ignoreNaming
  36735. */
  36736. WarnedWebAudioUnsupported: boolean;
  36737. /**
  36738. * Defines if the audio engine relies on a custom unlocked button.
  36739. * In this case, the embedded button will not be displayed.
  36740. */
  36741. useCustomUnlockedButton: boolean;
  36742. /**
  36743. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36744. */
  36745. readonly unlocked: boolean;
  36746. /**
  36747. * Event raised when audio has been unlocked on the browser.
  36748. */
  36749. onAudioUnlockedObservable: Observable<AudioEngine>;
  36750. /**
  36751. * Event raised when audio has been locked on the browser.
  36752. */
  36753. onAudioLockedObservable: Observable<AudioEngine>;
  36754. /**
  36755. * Flags the audio engine in Locked state.
  36756. * This happens due to new browser policies preventing audio to autoplay.
  36757. */
  36758. lock(): void;
  36759. /**
  36760. * Unlocks the audio engine once a user action has been done on the dom.
  36761. * This is helpful to resume play once browser policies have been satisfied.
  36762. */
  36763. unlock(): void;
  36764. /**
  36765. * Gets the global volume sets on the master gain.
  36766. * @returns the global volume if set or -1 otherwise
  36767. */
  36768. getGlobalVolume(): number;
  36769. /**
  36770. * Sets the global volume of your experience (sets on the master gain).
  36771. * @param newVolume Defines the new global volume of the application
  36772. */
  36773. setGlobalVolume(newVolume: number): void;
  36774. /**
  36775. * Connect the audio engine to an audio analyser allowing some amazing
  36776. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36777. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36778. * @param analyser The analyser to connect to the engine
  36779. */
  36780. connectToAnalyser(analyser: Analyser): void;
  36781. }
  36782. /**
  36783. * This represents the default audio engine used in babylon.
  36784. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36785. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36786. */
  36787. export class AudioEngine implements IAudioEngine {
  36788. private _audioContext;
  36789. private _audioContextInitialized;
  36790. private _muteButton;
  36791. private _hostElement;
  36792. /**
  36793. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36794. */
  36795. canUseWebAudio: boolean;
  36796. /**
  36797. * The master gain node defines the global audio volume of your audio engine.
  36798. */
  36799. masterGain: GainNode;
  36800. /**
  36801. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36802. * @ignoreNaming
  36803. */
  36804. WarnedWebAudioUnsupported: boolean;
  36805. /**
  36806. * Gets whether or not mp3 are supported by your browser.
  36807. */
  36808. isMP3supported: boolean;
  36809. /**
  36810. * Gets whether or not ogg are supported by your browser.
  36811. */
  36812. isOGGsupported: boolean;
  36813. /**
  36814. * Gets whether audio has been unlocked on the device.
  36815. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36816. * a user interaction has happened.
  36817. */
  36818. unlocked: boolean;
  36819. /**
  36820. * Defines if the audio engine relies on a custom unlocked button.
  36821. * In this case, the embedded button will not be displayed.
  36822. */
  36823. useCustomUnlockedButton: boolean;
  36824. /**
  36825. * Event raised when audio has been unlocked on the browser.
  36826. */
  36827. onAudioUnlockedObservable: Observable<AudioEngine>;
  36828. /**
  36829. * Event raised when audio has been locked on the browser.
  36830. */
  36831. onAudioLockedObservable: Observable<AudioEngine>;
  36832. /**
  36833. * Gets the current AudioContext if available.
  36834. */
  36835. get audioContext(): Nullable<AudioContext>;
  36836. private _connectedAnalyser;
  36837. /**
  36838. * Instantiates a new audio engine.
  36839. *
  36840. * There should be only one per page as some browsers restrict the number
  36841. * of audio contexts you can create.
  36842. * @param hostElement defines the host element where to display the mute icon if necessary
  36843. */
  36844. constructor(hostElement?: Nullable<HTMLElement>);
  36845. /**
  36846. * Flags the audio engine in Locked state.
  36847. * This happens due to new browser policies preventing audio to autoplay.
  36848. */
  36849. lock(): void;
  36850. /**
  36851. * Unlocks the audio engine once a user action has been done on the dom.
  36852. * This is helpful to resume play once browser policies have been satisfied.
  36853. */
  36854. unlock(): void;
  36855. private _resumeAudioContext;
  36856. private _initializeAudioContext;
  36857. private _tryToRun;
  36858. private _triggerRunningState;
  36859. private _triggerSuspendedState;
  36860. private _displayMuteButton;
  36861. private _moveButtonToTopLeft;
  36862. private _onResize;
  36863. private _hideMuteButton;
  36864. /**
  36865. * Destroy and release the resources associated with the audio ccontext.
  36866. */
  36867. dispose(): void;
  36868. /**
  36869. * Gets the global volume sets on the master gain.
  36870. * @returns the global volume if set or -1 otherwise
  36871. */
  36872. getGlobalVolume(): number;
  36873. /**
  36874. * Sets the global volume of your experience (sets on the master gain).
  36875. * @param newVolume Defines the new global volume of the application
  36876. */
  36877. setGlobalVolume(newVolume: number): void;
  36878. /**
  36879. * Connect the audio engine to an audio analyser allowing some amazing
  36880. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36881. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36882. * @param analyser The analyser to connect to the engine
  36883. */
  36884. connectToAnalyser(analyser: Analyser): void;
  36885. }
  36886. }
  36887. declare module BABYLON {
  36888. /**
  36889. * Interface used to present a loading screen while loading a scene
  36890. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36891. */
  36892. export interface ILoadingScreen {
  36893. /**
  36894. * Function called to display the loading screen
  36895. */
  36896. displayLoadingUI: () => void;
  36897. /**
  36898. * Function called to hide the loading screen
  36899. */
  36900. hideLoadingUI: () => void;
  36901. /**
  36902. * Gets or sets the color to use for the background
  36903. */
  36904. loadingUIBackgroundColor: string;
  36905. /**
  36906. * Gets or sets the text to display while loading
  36907. */
  36908. loadingUIText: string;
  36909. }
  36910. /**
  36911. * Class used for the default loading screen
  36912. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36913. */
  36914. export class DefaultLoadingScreen implements ILoadingScreen {
  36915. private _renderingCanvas;
  36916. private _loadingText;
  36917. private _loadingDivBackgroundColor;
  36918. private _loadingDiv;
  36919. private _loadingTextDiv;
  36920. /** Gets or sets the logo url to use for the default loading screen */
  36921. static DefaultLogoUrl: string;
  36922. /** Gets or sets the spinner url to use for the default loading screen */
  36923. static DefaultSpinnerUrl: string;
  36924. /**
  36925. * Creates a new default loading screen
  36926. * @param _renderingCanvas defines the canvas used to render the scene
  36927. * @param _loadingText defines the default text to display
  36928. * @param _loadingDivBackgroundColor defines the default background color
  36929. */
  36930. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36931. /**
  36932. * Function called to display the loading screen
  36933. */
  36934. displayLoadingUI(): void;
  36935. /**
  36936. * Function called to hide the loading screen
  36937. */
  36938. hideLoadingUI(): void;
  36939. /**
  36940. * Gets or sets the text to display while loading
  36941. */
  36942. set loadingUIText(text: string);
  36943. get loadingUIText(): string;
  36944. /**
  36945. * Gets or sets the color to use for the background
  36946. */
  36947. get loadingUIBackgroundColor(): string;
  36948. set loadingUIBackgroundColor(color: string);
  36949. private _resizeLoadingUI;
  36950. }
  36951. }
  36952. declare module BABYLON {
  36953. /**
  36954. * Interface for any object that can request an animation frame
  36955. */
  36956. export interface ICustomAnimationFrameRequester {
  36957. /**
  36958. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36959. */
  36960. renderFunction?: Function;
  36961. /**
  36962. * Called to request the next frame to render to
  36963. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36964. */
  36965. requestAnimationFrame: Function;
  36966. /**
  36967. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36968. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36969. */
  36970. requestID?: number;
  36971. }
  36972. }
  36973. declare module BABYLON {
  36974. /**
  36975. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36976. */
  36977. export class PerformanceMonitor {
  36978. private _enabled;
  36979. private _rollingFrameTime;
  36980. private _lastFrameTimeMs;
  36981. /**
  36982. * constructor
  36983. * @param frameSampleSize The number of samples required to saturate the sliding window
  36984. */
  36985. constructor(frameSampleSize?: number);
  36986. /**
  36987. * Samples current frame
  36988. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36989. */
  36990. sampleFrame(timeMs?: number): void;
  36991. /**
  36992. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36993. */
  36994. get averageFrameTime(): number;
  36995. /**
  36996. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36997. */
  36998. get averageFrameTimeVariance(): number;
  36999. /**
  37000. * Returns the frame time of the most recent frame
  37001. */
  37002. get instantaneousFrameTime(): number;
  37003. /**
  37004. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37005. */
  37006. get averageFPS(): number;
  37007. /**
  37008. * Returns the average framerate in frames per second using the most recent frame time
  37009. */
  37010. get instantaneousFPS(): number;
  37011. /**
  37012. * Returns true if enough samples have been taken to completely fill the sliding window
  37013. */
  37014. get isSaturated(): boolean;
  37015. /**
  37016. * Enables contributions to the sliding window sample set
  37017. */
  37018. enable(): void;
  37019. /**
  37020. * Disables contributions to the sliding window sample set
  37021. * Samples will not be interpolated over the disabled period
  37022. */
  37023. disable(): void;
  37024. /**
  37025. * Returns true if sampling is enabled
  37026. */
  37027. get isEnabled(): boolean;
  37028. /**
  37029. * Resets performance monitor
  37030. */
  37031. reset(): void;
  37032. }
  37033. /**
  37034. * RollingAverage
  37035. *
  37036. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37037. */
  37038. export class RollingAverage {
  37039. /**
  37040. * Current average
  37041. */
  37042. average: number;
  37043. /**
  37044. * Current variance
  37045. */
  37046. variance: number;
  37047. protected _samples: Array<number>;
  37048. protected _sampleCount: number;
  37049. protected _pos: number;
  37050. protected _m2: number;
  37051. /**
  37052. * constructor
  37053. * @param length The number of samples required to saturate the sliding window
  37054. */
  37055. constructor(length: number);
  37056. /**
  37057. * Adds a sample to the sample set
  37058. * @param v The sample value
  37059. */
  37060. add(v: number): void;
  37061. /**
  37062. * Returns previously added values or null if outside of history or outside the sliding window domain
  37063. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37064. * @return Value previously recorded with add() or null if outside of range
  37065. */
  37066. history(i: number): number;
  37067. /**
  37068. * Returns true if enough samples have been taken to completely fill the sliding window
  37069. * @return true if sample-set saturated
  37070. */
  37071. isSaturated(): boolean;
  37072. /**
  37073. * Resets the rolling average (equivalent to 0 samples taken so far)
  37074. */
  37075. reset(): void;
  37076. /**
  37077. * Wraps a value around the sample range boundaries
  37078. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37079. * @return Wrapped position in sample range
  37080. */
  37081. protected _wrapPosition(i: number): number;
  37082. }
  37083. }
  37084. declare module BABYLON {
  37085. /**
  37086. * This class is used to track a performance counter which is number based.
  37087. * The user has access to many properties which give statistics of different nature.
  37088. *
  37089. * The implementer can track two kinds of Performance Counter: time and count.
  37090. * 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.
  37091. * 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.
  37092. */
  37093. export class PerfCounter {
  37094. /**
  37095. * Gets or sets a global boolean to turn on and off all the counters
  37096. */
  37097. static Enabled: boolean;
  37098. /**
  37099. * Returns the smallest value ever
  37100. */
  37101. get min(): number;
  37102. /**
  37103. * Returns the biggest value ever
  37104. */
  37105. get max(): number;
  37106. /**
  37107. * Returns the average value since the performance counter is running
  37108. */
  37109. get average(): number;
  37110. /**
  37111. * Returns the average value of the last second the counter was monitored
  37112. */
  37113. get lastSecAverage(): number;
  37114. /**
  37115. * Returns the current value
  37116. */
  37117. get current(): number;
  37118. /**
  37119. * Gets the accumulated total
  37120. */
  37121. get total(): number;
  37122. /**
  37123. * Gets the total value count
  37124. */
  37125. get count(): number;
  37126. /**
  37127. * Creates a new counter
  37128. */
  37129. constructor();
  37130. /**
  37131. * Call this method to start monitoring a new frame.
  37132. * 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.
  37133. */
  37134. fetchNewFrame(): void;
  37135. /**
  37136. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37137. * @param newCount the count value to add to the monitored count
  37138. * @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.
  37139. */
  37140. addCount(newCount: number, fetchResult: boolean): void;
  37141. /**
  37142. * Start monitoring this performance counter
  37143. */
  37144. beginMonitoring(): void;
  37145. /**
  37146. * Compute the time lapsed since the previous beginMonitoring() call.
  37147. * @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
  37148. */
  37149. endMonitoring(newFrame?: boolean): void;
  37150. private _fetchResult;
  37151. private _startMonitoringTime;
  37152. private _min;
  37153. private _max;
  37154. private _average;
  37155. private _current;
  37156. private _totalValueCount;
  37157. private _totalAccumulated;
  37158. private _lastSecAverage;
  37159. private _lastSecAccumulated;
  37160. private _lastSecTime;
  37161. private _lastSecValueCount;
  37162. }
  37163. }
  37164. declare module BABYLON {
  37165. interface ThinEngine {
  37166. /**
  37167. * Sets alpha constants used by some alpha blending modes
  37168. * @param r defines the red component
  37169. * @param g defines the green component
  37170. * @param b defines the blue component
  37171. * @param a defines the alpha component
  37172. */
  37173. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37174. /**
  37175. * Sets the current alpha mode
  37176. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37177. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37178. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37179. */
  37180. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37181. /**
  37182. * Gets the current alpha mode
  37183. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37184. * @returns the current alpha mode
  37185. */
  37186. getAlphaMode(): number;
  37187. /**
  37188. * Sets the current alpha equation
  37189. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37190. */
  37191. setAlphaEquation(equation: number): void;
  37192. /**
  37193. * Gets the current alpha equation.
  37194. * @returns the current alpha equation
  37195. */
  37196. getAlphaEquation(): number;
  37197. }
  37198. }
  37199. declare module BABYLON {
  37200. interface ThinEngine {
  37201. /** @hidden */
  37202. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37203. }
  37204. }
  37205. declare module BABYLON {
  37206. /**
  37207. * Defines the interface used by display changed events
  37208. */
  37209. export interface IDisplayChangedEventArgs {
  37210. /** Gets the vrDisplay object (if any) */
  37211. vrDisplay: Nullable<any>;
  37212. /** Gets a boolean indicating if webVR is supported */
  37213. vrSupported: boolean;
  37214. }
  37215. /**
  37216. * Defines the interface used by objects containing a viewport (like a camera)
  37217. */
  37218. interface IViewportOwnerLike {
  37219. /**
  37220. * Gets or sets the viewport
  37221. */
  37222. viewport: IViewportLike;
  37223. }
  37224. /**
  37225. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37226. */
  37227. export class Engine extends ThinEngine {
  37228. /** Defines that alpha blending is disabled */
  37229. static readonly ALPHA_DISABLE: number;
  37230. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37231. static readonly ALPHA_ADD: number;
  37232. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37233. static readonly ALPHA_COMBINE: number;
  37234. /** Defines that alpha blending to DEST - SRC * DEST */
  37235. static readonly ALPHA_SUBTRACT: number;
  37236. /** Defines that alpha blending to SRC * DEST */
  37237. static readonly ALPHA_MULTIPLY: number;
  37238. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37239. static readonly ALPHA_MAXIMIZED: number;
  37240. /** Defines that alpha blending to SRC + DEST */
  37241. static readonly ALPHA_ONEONE: number;
  37242. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37243. static readonly ALPHA_PREMULTIPLIED: number;
  37244. /**
  37245. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37246. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37247. */
  37248. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37249. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37250. static readonly ALPHA_INTERPOLATE: number;
  37251. /**
  37252. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37253. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37254. */
  37255. static readonly ALPHA_SCREENMODE: number;
  37256. /** Defines that the ressource is not delayed*/
  37257. static readonly DELAYLOADSTATE_NONE: number;
  37258. /** Defines that the ressource was successfully delay loaded */
  37259. static readonly DELAYLOADSTATE_LOADED: number;
  37260. /** Defines that the ressource is currently delay loading */
  37261. static readonly DELAYLOADSTATE_LOADING: number;
  37262. /** Defines that the ressource is delayed and has not started loading */
  37263. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37264. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37265. static readonly NEVER: number;
  37266. /** 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 */
  37267. static readonly ALWAYS: number;
  37268. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37269. static readonly LESS: number;
  37270. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37271. static readonly EQUAL: number;
  37272. /** 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 */
  37273. static readonly LEQUAL: number;
  37274. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37275. static readonly GREATER: number;
  37276. /** 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 */
  37277. static readonly GEQUAL: number;
  37278. /** 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 */
  37279. static readonly NOTEQUAL: number;
  37280. /** Passed to stencilOperation to specify that stencil value must be kept */
  37281. static readonly KEEP: number;
  37282. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37283. static readonly REPLACE: number;
  37284. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37285. static readonly INCR: number;
  37286. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37287. static readonly DECR: number;
  37288. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37289. static readonly INVERT: number;
  37290. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37291. static readonly INCR_WRAP: number;
  37292. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37293. static readonly DECR_WRAP: number;
  37294. /** Texture is not repeating outside of 0..1 UVs */
  37295. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37296. /** Texture is repeating outside of 0..1 UVs */
  37297. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37298. /** Texture is repeating and mirrored */
  37299. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37300. /** ALPHA */
  37301. static readonly TEXTUREFORMAT_ALPHA: number;
  37302. /** LUMINANCE */
  37303. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37304. /** LUMINANCE_ALPHA */
  37305. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37306. /** RGB */
  37307. static readonly TEXTUREFORMAT_RGB: number;
  37308. /** RGBA */
  37309. static readonly TEXTUREFORMAT_RGBA: number;
  37310. /** RED */
  37311. static readonly TEXTUREFORMAT_RED: number;
  37312. /** RED (2nd reference) */
  37313. static readonly TEXTUREFORMAT_R: number;
  37314. /** RG */
  37315. static readonly TEXTUREFORMAT_RG: number;
  37316. /** RED_INTEGER */
  37317. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37318. /** RED_INTEGER (2nd reference) */
  37319. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37320. /** RG_INTEGER */
  37321. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37322. /** RGB_INTEGER */
  37323. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37324. /** RGBA_INTEGER */
  37325. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37326. /** UNSIGNED_BYTE */
  37327. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37328. /** UNSIGNED_BYTE (2nd reference) */
  37329. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37330. /** FLOAT */
  37331. static readonly TEXTURETYPE_FLOAT: number;
  37332. /** HALF_FLOAT */
  37333. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37334. /** BYTE */
  37335. static readonly TEXTURETYPE_BYTE: number;
  37336. /** SHORT */
  37337. static readonly TEXTURETYPE_SHORT: number;
  37338. /** UNSIGNED_SHORT */
  37339. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37340. /** INT */
  37341. static readonly TEXTURETYPE_INT: number;
  37342. /** UNSIGNED_INT */
  37343. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37344. /** UNSIGNED_SHORT_4_4_4_4 */
  37345. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37346. /** UNSIGNED_SHORT_5_5_5_1 */
  37347. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37348. /** UNSIGNED_SHORT_5_6_5 */
  37349. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37350. /** UNSIGNED_INT_2_10_10_10_REV */
  37351. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37352. /** UNSIGNED_INT_24_8 */
  37353. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37354. /** UNSIGNED_INT_10F_11F_11F_REV */
  37355. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37356. /** UNSIGNED_INT_5_9_9_9_REV */
  37357. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37358. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37359. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37360. /** nearest is mag = nearest and min = nearest and mip = linear */
  37361. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37362. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37363. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37364. /** Trilinear is mag = linear and min = linear and mip = linear */
  37365. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37366. /** nearest is mag = nearest and min = nearest and mip = linear */
  37367. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37368. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37369. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37370. /** Trilinear is mag = linear and min = linear and mip = linear */
  37371. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37372. /** mag = nearest and min = nearest and mip = nearest */
  37373. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37374. /** mag = nearest and min = linear and mip = nearest */
  37375. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37376. /** mag = nearest and min = linear and mip = linear */
  37377. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37378. /** mag = nearest and min = linear and mip = none */
  37379. static readonly TEXTURE_NEAREST_LINEAR: number;
  37380. /** mag = nearest and min = nearest and mip = none */
  37381. static readonly TEXTURE_NEAREST_NEAREST: number;
  37382. /** mag = linear and min = nearest and mip = nearest */
  37383. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37384. /** mag = linear and min = nearest and mip = linear */
  37385. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37386. /** mag = linear and min = linear and mip = none */
  37387. static readonly TEXTURE_LINEAR_LINEAR: number;
  37388. /** mag = linear and min = nearest and mip = none */
  37389. static readonly TEXTURE_LINEAR_NEAREST: number;
  37390. /** Explicit coordinates mode */
  37391. static readonly TEXTURE_EXPLICIT_MODE: number;
  37392. /** Spherical coordinates mode */
  37393. static readonly TEXTURE_SPHERICAL_MODE: number;
  37394. /** Planar coordinates mode */
  37395. static readonly TEXTURE_PLANAR_MODE: number;
  37396. /** Cubic coordinates mode */
  37397. static readonly TEXTURE_CUBIC_MODE: number;
  37398. /** Projection coordinates mode */
  37399. static readonly TEXTURE_PROJECTION_MODE: number;
  37400. /** Skybox coordinates mode */
  37401. static readonly TEXTURE_SKYBOX_MODE: number;
  37402. /** Inverse Cubic coordinates mode */
  37403. static readonly TEXTURE_INVCUBIC_MODE: number;
  37404. /** Equirectangular coordinates mode */
  37405. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37406. /** Equirectangular Fixed coordinates mode */
  37407. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37408. /** Equirectangular Fixed Mirrored coordinates mode */
  37409. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37410. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37411. static readonly SCALEMODE_FLOOR: number;
  37412. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37413. static readonly SCALEMODE_NEAREST: number;
  37414. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37415. static readonly SCALEMODE_CEILING: number;
  37416. /**
  37417. * Returns the current npm package of the sdk
  37418. */
  37419. static get NpmPackage(): string;
  37420. /**
  37421. * Returns the current version of the framework
  37422. */
  37423. static get Version(): string;
  37424. /** Gets the list of created engines */
  37425. static get Instances(): Engine[];
  37426. /**
  37427. * Gets the latest created engine
  37428. */
  37429. static get LastCreatedEngine(): Nullable<Engine>;
  37430. /**
  37431. * Gets the latest created scene
  37432. */
  37433. static get LastCreatedScene(): Nullable<Scene>;
  37434. /**
  37435. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37436. * @param flag defines which part of the materials must be marked as dirty
  37437. * @param predicate defines a predicate used to filter which materials should be affected
  37438. */
  37439. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37440. /**
  37441. * Method called to create the default loading screen.
  37442. * This can be overriden in your own app.
  37443. * @param canvas The rendering canvas element
  37444. * @returns The loading screen
  37445. */
  37446. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37447. /**
  37448. * Method called to create the default rescale post process on each engine.
  37449. */
  37450. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37451. /**
  37452. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37453. **/
  37454. enableOfflineSupport: boolean;
  37455. /**
  37456. * 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)
  37457. **/
  37458. disableManifestCheck: boolean;
  37459. /**
  37460. * Gets the list of created scenes
  37461. */
  37462. scenes: Scene[];
  37463. /**
  37464. * Event raised when a new scene is created
  37465. */
  37466. onNewSceneAddedObservable: Observable<Scene>;
  37467. /**
  37468. * Gets the list of created postprocesses
  37469. */
  37470. postProcesses: PostProcess[];
  37471. /**
  37472. * Gets a boolean indicating if the pointer is currently locked
  37473. */
  37474. isPointerLock: boolean;
  37475. /**
  37476. * Observable event triggered each time the rendering canvas is resized
  37477. */
  37478. onResizeObservable: Observable<Engine>;
  37479. /**
  37480. * Observable event triggered each time the canvas loses focus
  37481. */
  37482. onCanvasBlurObservable: Observable<Engine>;
  37483. /**
  37484. * Observable event triggered each time the canvas gains focus
  37485. */
  37486. onCanvasFocusObservable: Observable<Engine>;
  37487. /**
  37488. * Observable event triggered each time the canvas receives pointerout event
  37489. */
  37490. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37491. /**
  37492. * Observable raised when the engine begins a new frame
  37493. */
  37494. onBeginFrameObservable: Observable<Engine>;
  37495. /**
  37496. * If set, will be used to request the next animation frame for the render loop
  37497. */
  37498. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37499. /**
  37500. * Observable raised when the engine ends the current frame
  37501. */
  37502. onEndFrameObservable: Observable<Engine>;
  37503. /**
  37504. * Observable raised when the engine is about to compile a shader
  37505. */
  37506. onBeforeShaderCompilationObservable: Observable<Engine>;
  37507. /**
  37508. * Observable raised when the engine has jsut compiled a shader
  37509. */
  37510. onAfterShaderCompilationObservable: Observable<Engine>;
  37511. /**
  37512. * Gets the audio engine
  37513. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37514. * @ignorenaming
  37515. */
  37516. static audioEngine: IAudioEngine;
  37517. /**
  37518. * Default AudioEngine factory responsible of creating the Audio Engine.
  37519. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37520. */
  37521. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37522. /**
  37523. * Default offline support factory responsible of creating a tool used to store data locally.
  37524. * By default, this will create a Database object if the workload has been embedded.
  37525. */
  37526. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37527. private _loadingScreen;
  37528. private _pointerLockRequested;
  37529. private _rescalePostProcess;
  37530. private _deterministicLockstep;
  37531. private _lockstepMaxSteps;
  37532. private _timeStep;
  37533. protected get _supportsHardwareTextureRescaling(): boolean;
  37534. private _fps;
  37535. private _deltaTime;
  37536. /** @hidden */
  37537. _drawCalls: PerfCounter;
  37538. /** 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 */
  37539. canvasTabIndex: number;
  37540. /**
  37541. * Turn this value on if you want to pause FPS computation when in background
  37542. */
  37543. disablePerformanceMonitorInBackground: boolean;
  37544. private _performanceMonitor;
  37545. /**
  37546. * Gets the performance monitor attached to this engine
  37547. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37548. */
  37549. get performanceMonitor(): PerformanceMonitor;
  37550. private _onFocus;
  37551. private _onBlur;
  37552. private _onCanvasPointerOut;
  37553. private _onCanvasBlur;
  37554. private _onCanvasFocus;
  37555. private _onFullscreenChange;
  37556. private _onPointerLockChange;
  37557. /**
  37558. * Gets the HTML element used to attach event listeners
  37559. * @returns a HTML element
  37560. */
  37561. getInputElement(): Nullable<HTMLElement>;
  37562. /**
  37563. * Creates a new engine
  37564. * @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
  37565. * @param antialias defines enable antialiasing (default: false)
  37566. * @param options defines further options to be sent to the getContext() function
  37567. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37568. */
  37569. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37570. /**
  37571. * Gets current aspect ratio
  37572. * @param viewportOwner defines the camera to use to get the aspect ratio
  37573. * @param useScreen defines if screen size must be used (or the current render target if any)
  37574. * @returns a number defining the aspect ratio
  37575. */
  37576. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37577. /**
  37578. * Gets current screen aspect ratio
  37579. * @returns a number defining the aspect ratio
  37580. */
  37581. getScreenAspectRatio(): number;
  37582. /**
  37583. * Gets the client rect of the HTML canvas attached with the current webGL context
  37584. * @returns a client rectanglee
  37585. */
  37586. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37587. /**
  37588. * Gets the client rect of the HTML element used for events
  37589. * @returns a client rectanglee
  37590. */
  37591. getInputElementClientRect(): Nullable<ClientRect>;
  37592. /**
  37593. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37594. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37595. * @returns true if engine is in deterministic lock step mode
  37596. */
  37597. isDeterministicLockStep(): boolean;
  37598. /**
  37599. * Gets the max steps when engine is running in deterministic lock step
  37600. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37601. * @returns the max steps
  37602. */
  37603. getLockstepMaxSteps(): number;
  37604. /**
  37605. * Returns the time in ms between steps when using deterministic lock step.
  37606. * @returns time step in (ms)
  37607. */
  37608. getTimeStep(): number;
  37609. /**
  37610. * Force the mipmap generation for the given render target texture
  37611. * @param texture defines the render target texture to use
  37612. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37613. */
  37614. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37615. /** States */
  37616. /**
  37617. * Set various states to the webGL context
  37618. * @param culling defines backface culling state
  37619. * @param zOffset defines the value to apply to zOffset (0 by default)
  37620. * @param force defines if states must be applied even if cache is up to date
  37621. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37622. */
  37623. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37624. /**
  37625. * Set the z offset to apply to current rendering
  37626. * @param value defines the offset to apply
  37627. */
  37628. setZOffset(value: number): void;
  37629. /**
  37630. * Gets the current value of the zOffset
  37631. * @returns the current zOffset state
  37632. */
  37633. getZOffset(): number;
  37634. /**
  37635. * Enable or disable depth buffering
  37636. * @param enable defines the state to set
  37637. */
  37638. setDepthBuffer(enable: boolean): void;
  37639. /**
  37640. * Gets a boolean indicating if depth writing is enabled
  37641. * @returns the current depth writing state
  37642. */
  37643. getDepthWrite(): boolean;
  37644. /**
  37645. * Enable or disable depth writing
  37646. * @param enable defines the state to set
  37647. */
  37648. setDepthWrite(enable: boolean): void;
  37649. /**
  37650. * Gets a boolean indicating if stencil buffer is enabled
  37651. * @returns the current stencil buffer state
  37652. */
  37653. getStencilBuffer(): boolean;
  37654. /**
  37655. * Enable or disable the stencil buffer
  37656. * @param enable defines if the stencil buffer must be enabled or disabled
  37657. */
  37658. setStencilBuffer(enable: boolean): void;
  37659. /**
  37660. * Gets the current stencil mask
  37661. * @returns a number defining the new stencil mask to use
  37662. */
  37663. getStencilMask(): number;
  37664. /**
  37665. * Sets the current stencil mask
  37666. * @param mask defines the new stencil mask to use
  37667. */
  37668. setStencilMask(mask: number): void;
  37669. /**
  37670. * Gets the current stencil function
  37671. * @returns a number defining the stencil function to use
  37672. */
  37673. getStencilFunction(): number;
  37674. /**
  37675. * Gets the current stencil reference value
  37676. * @returns a number defining the stencil reference value to use
  37677. */
  37678. getStencilFunctionReference(): number;
  37679. /**
  37680. * Gets the current stencil mask
  37681. * @returns a number defining the stencil mask to use
  37682. */
  37683. getStencilFunctionMask(): number;
  37684. /**
  37685. * Sets the current stencil function
  37686. * @param stencilFunc defines the new stencil function to use
  37687. */
  37688. setStencilFunction(stencilFunc: number): void;
  37689. /**
  37690. * Sets the current stencil reference
  37691. * @param reference defines the new stencil reference to use
  37692. */
  37693. setStencilFunctionReference(reference: number): void;
  37694. /**
  37695. * Sets the current stencil mask
  37696. * @param mask defines the new stencil mask to use
  37697. */
  37698. setStencilFunctionMask(mask: number): void;
  37699. /**
  37700. * Gets the current stencil operation when stencil fails
  37701. * @returns a number defining stencil operation to use when stencil fails
  37702. */
  37703. getStencilOperationFail(): number;
  37704. /**
  37705. * Gets the current stencil operation when depth fails
  37706. * @returns a number defining stencil operation to use when depth fails
  37707. */
  37708. getStencilOperationDepthFail(): number;
  37709. /**
  37710. * Gets the current stencil operation when stencil passes
  37711. * @returns a number defining stencil operation to use when stencil passes
  37712. */
  37713. getStencilOperationPass(): number;
  37714. /**
  37715. * Sets the stencil operation to use when stencil fails
  37716. * @param operation defines the stencil operation to use when stencil fails
  37717. */
  37718. setStencilOperationFail(operation: number): void;
  37719. /**
  37720. * Sets the stencil operation to use when depth fails
  37721. * @param operation defines the stencil operation to use when depth fails
  37722. */
  37723. setStencilOperationDepthFail(operation: number): void;
  37724. /**
  37725. * Sets the stencil operation to use when stencil passes
  37726. * @param operation defines the stencil operation to use when stencil passes
  37727. */
  37728. setStencilOperationPass(operation: number): void;
  37729. /**
  37730. * Sets a boolean indicating if the dithering state is enabled or disabled
  37731. * @param value defines the dithering state
  37732. */
  37733. setDitheringState(value: boolean): void;
  37734. /**
  37735. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37736. * @param value defines the rasterizer state
  37737. */
  37738. setRasterizerState(value: boolean): void;
  37739. /**
  37740. * Gets the current depth function
  37741. * @returns a number defining the depth function
  37742. */
  37743. getDepthFunction(): Nullable<number>;
  37744. /**
  37745. * Sets the current depth function
  37746. * @param depthFunc defines the function to use
  37747. */
  37748. setDepthFunction(depthFunc: number): void;
  37749. /**
  37750. * Sets the current depth function to GREATER
  37751. */
  37752. setDepthFunctionToGreater(): void;
  37753. /**
  37754. * Sets the current depth function to GEQUAL
  37755. */
  37756. setDepthFunctionToGreaterOrEqual(): void;
  37757. /**
  37758. * Sets the current depth function to LESS
  37759. */
  37760. setDepthFunctionToLess(): void;
  37761. /**
  37762. * Sets the current depth function to LEQUAL
  37763. */
  37764. setDepthFunctionToLessOrEqual(): void;
  37765. private _cachedStencilBuffer;
  37766. private _cachedStencilFunction;
  37767. private _cachedStencilMask;
  37768. private _cachedStencilOperationPass;
  37769. private _cachedStencilOperationFail;
  37770. private _cachedStencilOperationDepthFail;
  37771. private _cachedStencilReference;
  37772. /**
  37773. * Caches the the state of the stencil buffer
  37774. */
  37775. cacheStencilState(): void;
  37776. /**
  37777. * Restores the state of the stencil buffer
  37778. */
  37779. restoreStencilState(): void;
  37780. /**
  37781. * Directly set the WebGL Viewport
  37782. * @param x defines the x coordinate of the viewport (in screen space)
  37783. * @param y defines the y coordinate of the viewport (in screen space)
  37784. * @param width defines the width of the viewport (in screen space)
  37785. * @param height defines the height of the viewport (in screen space)
  37786. * @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
  37787. */
  37788. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37789. /**
  37790. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37791. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37792. * @param y defines the y-coordinate of the corner of the clear rectangle
  37793. * @param width defines the width of the clear rectangle
  37794. * @param height defines the height of the clear rectangle
  37795. * @param clearColor defines the clear color
  37796. */
  37797. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37798. /**
  37799. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37800. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37801. * @param y defines the y-coordinate of the corner of the clear rectangle
  37802. * @param width defines the width of the clear rectangle
  37803. * @param height defines the height of the clear rectangle
  37804. */
  37805. enableScissor(x: number, y: number, width: number, height: number): void;
  37806. /**
  37807. * Disable previously set scissor test rectangle
  37808. */
  37809. disableScissor(): void;
  37810. protected _reportDrawCall(): void;
  37811. /**
  37812. * Initializes a webVR display and starts listening to display change events
  37813. * The onVRDisplayChangedObservable will be notified upon these changes
  37814. * @returns The onVRDisplayChangedObservable
  37815. */
  37816. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37817. /** @hidden */
  37818. _prepareVRComponent(): void;
  37819. /** @hidden */
  37820. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37821. /** @hidden */
  37822. _submitVRFrame(): void;
  37823. /**
  37824. * Call this function to leave webVR mode
  37825. * Will do nothing if webVR is not supported or if there is no webVR device
  37826. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37827. */
  37828. disableVR(): void;
  37829. /**
  37830. * Gets a boolean indicating that the system is in VR mode and is presenting
  37831. * @returns true if VR mode is engaged
  37832. */
  37833. isVRPresenting(): boolean;
  37834. /** @hidden */
  37835. _requestVRFrame(): void;
  37836. /** @hidden */
  37837. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37838. /**
  37839. * Gets the source code of the vertex shader associated with a specific webGL program
  37840. * @param program defines the program to use
  37841. * @returns a string containing the source code of the vertex shader associated with the program
  37842. */
  37843. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37844. /**
  37845. * Gets the source code of the fragment shader associated with a specific webGL program
  37846. * @param program defines the program to use
  37847. * @returns a string containing the source code of the fragment shader associated with the program
  37848. */
  37849. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37850. /**
  37851. * Sets a depth stencil texture from a render target to the according uniform.
  37852. * @param channel The texture channel
  37853. * @param uniform The uniform to set
  37854. * @param texture The render target texture containing the depth stencil texture to apply
  37855. */
  37856. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37857. /**
  37858. * Sets a texture to the webGL context from a postprocess
  37859. * @param channel defines the channel to use
  37860. * @param postProcess defines the source postprocess
  37861. */
  37862. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37863. /**
  37864. * Binds the output of the passed in post process to the texture channel specified
  37865. * @param channel The channel the texture should be bound to
  37866. * @param postProcess The post process which's output should be bound
  37867. */
  37868. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37869. protected _rebuildBuffers(): void;
  37870. /** @hidden */
  37871. _renderFrame(): void;
  37872. _renderLoop(): void;
  37873. /** @hidden */
  37874. _renderViews(): boolean;
  37875. /**
  37876. * Toggle full screen mode
  37877. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37878. */
  37879. switchFullscreen(requestPointerLock: boolean): void;
  37880. /**
  37881. * Enters full screen mode
  37882. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37883. */
  37884. enterFullscreen(requestPointerLock: boolean): void;
  37885. /**
  37886. * Exits full screen mode
  37887. */
  37888. exitFullscreen(): void;
  37889. /**
  37890. * Enters Pointerlock mode
  37891. */
  37892. enterPointerlock(): void;
  37893. /**
  37894. * Exits Pointerlock mode
  37895. */
  37896. exitPointerlock(): void;
  37897. /**
  37898. * Begin a new frame
  37899. */
  37900. beginFrame(): void;
  37901. /**
  37902. * Enf the current frame
  37903. */
  37904. endFrame(): void;
  37905. resize(): void;
  37906. /**
  37907. * Force a specific size of the canvas
  37908. * @param width defines the new canvas' width
  37909. * @param height defines the new canvas' height
  37910. * @returns true if the size was changed
  37911. */
  37912. setSize(width: number, height: number): boolean;
  37913. /**
  37914. * Updates a dynamic vertex buffer.
  37915. * @param vertexBuffer the vertex buffer to update
  37916. * @param data the data used to update the vertex buffer
  37917. * @param byteOffset the byte offset of the data
  37918. * @param byteLength the byte length of the data
  37919. */
  37920. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37921. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37922. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37923. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37924. _releaseTexture(texture: InternalTexture): void;
  37925. /**
  37926. * @hidden
  37927. * Rescales a texture
  37928. * @param source input texutre
  37929. * @param destination destination texture
  37930. * @param scene scene to use to render the resize
  37931. * @param internalFormat format to use when resizing
  37932. * @param onComplete callback to be called when resize has completed
  37933. */
  37934. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37935. /**
  37936. * Gets the current framerate
  37937. * @returns a number representing the framerate
  37938. */
  37939. getFps(): number;
  37940. /**
  37941. * Gets the time spent between current and previous frame
  37942. * @returns a number representing the delta time in ms
  37943. */
  37944. getDeltaTime(): number;
  37945. private _measureFps;
  37946. /** @hidden */
  37947. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37948. /**
  37949. * Update a dynamic index buffer
  37950. * @param indexBuffer defines the target index buffer
  37951. * @param indices defines the data to update
  37952. * @param offset defines the offset in the target index buffer where update should start
  37953. */
  37954. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37955. /**
  37956. * Updates the sample count of a render target texture
  37957. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37958. * @param texture defines the texture to update
  37959. * @param samples defines the sample count to set
  37960. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37961. */
  37962. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37963. /**
  37964. * Updates a depth texture Comparison Mode and Function.
  37965. * If the comparison Function is equal to 0, the mode will be set to none.
  37966. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37967. * @param texture The texture to set the comparison function for
  37968. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37969. */
  37970. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37971. /**
  37972. * Creates a webGL buffer to use with instanciation
  37973. * @param capacity defines the size of the buffer
  37974. * @returns the webGL buffer
  37975. */
  37976. createInstancesBuffer(capacity: number): DataBuffer;
  37977. /**
  37978. * Delete a webGL buffer used with instanciation
  37979. * @param buffer defines the webGL buffer to delete
  37980. */
  37981. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37982. private _clientWaitAsync;
  37983. /** @hidden */
  37984. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37985. dispose(): void;
  37986. private _disableTouchAction;
  37987. /**
  37988. * Display the loading screen
  37989. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37990. */
  37991. displayLoadingUI(): void;
  37992. /**
  37993. * Hide the loading screen
  37994. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37995. */
  37996. hideLoadingUI(): void;
  37997. /**
  37998. * Gets the current loading screen object
  37999. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38000. */
  38001. get loadingScreen(): ILoadingScreen;
  38002. /**
  38003. * Sets the current loading screen object
  38004. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38005. */
  38006. set loadingScreen(loadingScreen: ILoadingScreen);
  38007. /**
  38008. * Sets the current loading screen text
  38009. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38010. */
  38011. set loadingUIText(text: string);
  38012. /**
  38013. * Sets the current loading screen background color
  38014. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38015. */
  38016. set loadingUIBackgroundColor(color: string);
  38017. /** Pointerlock and fullscreen */
  38018. /**
  38019. * Ask the browser to promote the current element to pointerlock mode
  38020. * @param element defines the DOM element to promote
  38021. */
  38022. static _RequestPointerlock(element: HTMLElement): void;
  38023. /**
  38024. * Asks the browser to exit pointerlock mode
  38025. */
  38026. static _ExitPointerlock(): void;
  38027. /**
  38028. * Ask the browser to promote the current element to fullscreen rendering mode
  38029. * @param element defines the DOM element to promote
  38030. */
  38031. static _RequestFullscreen(element: HTMLElement): void;
  38032. /**
  38033. * Asks the browser to exit fullscreen mode
  38034. */
  38035. static _ExitFullscreen(): void;
  38036. }
  38037. }
  38038. declare module BABYLON {
  38039. /**
  38040. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38041. * during the life time of the application.
  38042. */
  38043. export class EngineStore {
  38044. /** Gets the list of created engines */
  38045. static Instances: Engine[];
  38046. /** @hidden */
  38047. static _LastCreatedScene: Nullable<Scene>;
  38048. /**
  38049. * Gets the latest created engine
  38050. */
  38051. static get LastCreatedEngine(): Nullable<Engine>;
  38052. /**
  38053. * Gets the latest created scene
  38054. */
  38055. static get LastCreatedScene(): Nullable<Scene>;
  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 UseFallbackTexture: boolean;
  38061. /**
  38062. * Texture content used if a texture cannot loaded
  38063. * @ignorenaming
  38064. */
  38065. static FallbackTexture: string;
  38066. }
  38067. }
  38068. declare module BABYLON {
  38069. /**
  38070. * Helper class that provides a small promise polyfill
  38071. */
  38072. export class PromisePolyfill {
  38073. /**
  38074. * Static function used to check if the polyfill is required
  38075. * If this is the case then the function will inject the polyfill to window.Promise
  38076. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38077. */
  38078. static Apply(force?: boolean): void;
  38079. }
  38080. }
  38081. declare module BABYLON {
  38082. /**
  38083. * Interface for screenshot methods with describe argument called `size` as object with options
  38084. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38085. */
  38086. export interface IScreenshotSize {
  38087. /**
  38088. * number in pixels for canvas height
  38089. */
  38090. height?: number;
  38091. /**
  38092. * multiplier allowing render at a higher or lower resolution
  38093. * If value is defined then height and width will be ignored and taken from camera
  38094. */
  38095. precision?: number;
  38096. /**
  38097. * number in pixels for canvas width
  38098. */
  38099. width?: number;
  38100. }
  38101. }
  38102. declare module BABYLON {
  38103. interface IColor4Like {
  38104. r: float;
  38105. g: float;
  38106. b: float;
  38107. a: float;
  38108. }
  38109. /**
  38110. * Class containing a set of static utilities functions
  38111. */
  38112. export class Tools {
  38113. /**
  38114. * Gets or sets the base URL to use to load assets
  38115. */
  38116. static get BaseUrl(): string;
  38117. static set BaseUrl(value: string);
  38118. /**
  38119. * Enable/Disable Custom HTTP Request Headers globally.
  38120. * default = false
  38121. * @see CustomRequestHeaders
  38122. */
  38123. static UseCustomRequestHeaders: boolean;
  38124. /**
  38125. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38126. * i.e. when loading files, where the server/service expects an Authorization header
  38127. */
  38128. static CustomRequestHeaders: {
  38129. [key: string]: string;
  38130. };
  38131. /**
  38132. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38133. */
  38134. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38135. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38136. /**
  38137. * Default behaviour for cors in the application.
  38138. * It can be a string if the expected behavior is identical in the entire app.
  38139. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38140. */
  38141. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38142. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38143. /**
  38144. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38145. * @ignorenaming
  38146. */
  38147. static get UseFallbackTexture(): boolean;
  38148. static set UseFallbackTexture(value: boolean);
  38149. /**
  38150. * Use this object to register external classes like custom textures or material
  38151. * to allow the laoders to instantiate them
  38152. */
  38153. static get RegisteredExternalClasses(): {
  38154. [key: string]: Object;
  38155. };
  38156. static set RegisteredExternalClasses(classes: {
  38157. [key: string]: Object;
  38158. });
  38159. /**
  38160. * Texture content used if a texture cannot loaded
  38161. * @ignorenaming
  38162. */
  38163. static get fallbackTexture(): string;
  38164. static set fallbackTexture(value: string);
  38165. /**
  38166. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38167. * @param u defines the coordinate on X axis
  38168. * @param v defines the coordinate on Y axis
  38169. * @param width defines the width of the source data
  38170. * @param height defines the height of the source data
  38171. * @param pixels defines the source byte array
  38172. * @param color defines the output color
  38173. */
  38174. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38175. /**
  38176. * Interpolates between a and b via alpha
  38177. * @param a The lower value (returned when alpha = 0)
  38178. * @param b The upper value (returned when alpha = 1)
  38179. * @param alpha The interpolation-factor
  38180. * @return The mixed value
  38181. */
  38182. static Mix(a: number, b: number, alpha: number): number;
  38183. /**
  38184. * Tries to instantiate a new object from a given class name
  38185. * @param className defines the class name to instantiate
  38186. * @returns the new object or null if the system was not able to do the instantiation
  38187. */
  38188. static Instantiate(className: string): any;
  38189. /**
  38190. * Provides a slice function that will work even on IE
  38191. * @param data defines the array to slice
  38192. * @param start defines the start of the data (optional)
  38193. * @param end defines the end of the data (optional)
  38194. * @returns the new sliced array
  38195. */
  38196. static Slice<T>(data: T, start?: number, end?: number): T;
  38197. /**
  38198. * Polyfill for setImmediate
  38199. * @param action defines the action to execute after the current execution block
  38200. */
  38201. static SetImmediate(action: () => void): void;
  38202. /**
  38203. * Function indicating if a number is an exponent of 2
  38204. * @param value defines the value to test
  38205. * @returns true if the value is an exponent of 2
  38206. */
  38207. static IsExponentOfTwo(value: number): boolean;
  38208. private static _tmpFloatArray;
  38209. /**
  38210. * Returns the nearest 32-bit single precision float representation of a Number
  38211. * @param value A Number. If the parameter is of a different type, it will get converted
  38212. * to a number or to NaN if it cannot be converted
  38213. * @returns number
  38214. */
  38215. static FloatRound(value: number): number;
  38216. /**
  38217. * Extracts the filename from a path
  38218. * @param path defines the path to use
  38219. * @returns the filename
  38220. */
  38221. static GetFilename(path: string): string;
  38222. /**
  38223. * Extracts the "folder" part of a path (everything before the filename).
  38224. * @param uri The URI to extract the info from
  38225. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38226. * @returns The "folder" part of the path
  38227. */
  38228. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38229. /**
  38230. * Extracts text content from a DOM element hierarchy
  38231. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38232. */
  38233. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38234. /**
  38235. * Convert an angle in radians to degrees
  38236. * @param angle defines the angle to convert
  38237. * @returns the angle in degrees
  38238. */
  38239. static ToDegrees(angle: number): number;
  38240. /**
  38241. * Convert an angle in degrees to radians
  38242. * @param angle defines the angle to convert
  38243. * @returns the angle in radians
  38244. */
  38245. static ToRadians(angle: number): number;
  38246. /**
  38247. * Returns an array if obj is not an array
  38248. * @param obj defines the object to evaluate as an array
  38249. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38250. * @returns either obj directly if obj is an array or a new array containing obj
  38251. */
  38252. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38253. /**
  38254. * Gets the pointer prefix to use
  38255. * @param engine defines the engine we are finding the prefix for
  38256. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38257. */
  38258. static GetPointerPrefix(engine: Engine): string;
  38259. /**
  38260. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38261. * @param url define the url we are trying
  38262. * @param element define the dom element where to configure the cors policy
  38263. */
  38264. static SetCorsBehavior(url: string | string[], element: {
  38265. crossOrigin: string | null;
  38266. }): void;
  38267. /**
  38268. * Removes unwanted characters from an url
  38269. * @param url defines the url to clean
  38270. * @returns the cleaned url
  38271. */
  38272. static CleanUrl(url: string): string;
  38273. /**
  38274. * Gets or sets a function used to pre-process url before using them to load assets
  38275. */
  38276. static get PreprocessUrl(): (url: string) => string;
  38277. static set PreprocessUrl(processor: (url: string) => string);
  38278. /**
  38279. * Loads an image as an HTMLImageElement.
  38280. * @param input url string, ArrayBuffer, or Blob to load
  38281. * @param onLoad callback called when the image successfully loads
  38282. * @param onError callback called when the image fails to load
  38283. * @param offlineProvider offline provider for caching
  38284. * @param mimeType optional mime type
  38285. * @returns the HTMLImageElement of the loaded image
  38286. */
  38287. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38288. /**
  38289. * Loads a file from a url
  38290. * @param url url string, ArrayBuffer, or Blob to load
  38291. * @param onSuccess callback called when the file successfully loads
  38292. * @param onProgress callback called while file is loading (if the server supports this mode)
  38293. * @param offlineProvider defines the offline provider for caching
  38294. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38295. * @param onError callback called when the file fails to load
  38296. * @returns a file request object
  38297. */
  38298. 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;
  38299. /**
  38300. * Loads a file from a url
  38301. * @param url the file url to load
  38302. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38303. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38304. */
  38305. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38306. /**
  38307. * Load a script (identified by an url). When the url returns, the
  38308. * content of this file is added into a new script element, attached to the DOM (body element)
  38309. * @param scriptUrl defines the url of the script to laod
  38310. * @param onSuccess defines the callback called when the script is loaded
  38311. * @param onError defines the callback to call if an error occurs
  38312. * @param scriptId defines the id of the script element
  38313. */
  38314. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38315. /**
  38316. * Load an asynchronous script (identified by an url). When the url returns, the
  38317. * content of this file is added into a new script element, attached to the DOM (body element)
  38318. * @param scriptUrl defines the url of the script to laod
  38319. * @param scriptId defines the id of the script element
  38320. * @returns a promise request object
  38321. */
  38322. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38323. /**
  38324. * Loads a file from a blob
  38325. * @param fileToLoad defines the blob to use
  38326. * @param callback defines the callback to call when data is loaded
  38327. * @param progressCallback defines the callback to call during loading process
  38328. * @returns a file request object
  38329. */
  38330. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38331. /**
  38332. * Reads a file from a File object
  38333. * @param file defines the file to load
  38334. * @param onSuccess defines the callback to call when data is loaded
  38335. * @param onProgress defines the callback to call during loading process
  38336. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38337. * @param onError defines the callback to call when an error occurs
  38338. * @returns a file request object
  38339. */
  38340. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38341. /**
  38342. * Creates a data url from a given string content
  38343. * @param content defines the content to convert
  38344. * @returns the new data url link
  38345. */
  38346. static FileAsURL(content: string): string;
  38347. /**
  38348. * Format the given number to a specific decimal format
  38349. * @param value defines the number to format
  38350. * @param decimals defines the number of decimals to use
  38351. * @returns the formatted string
  38352. */
  38353. static Format(value: number, decimals?: number): string;
  38354. /**
  38355. * Tries to copy an object by duplicating every property
  38356. * @param source defines the source object
  38357. * @param destination defines the target object
  38358. * @param doNotCopyList defines a list of properties to avoid
  38359. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38360. */
  38361. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38362. /**
  38363. * Gets a boolean indicating if the given object has no own property
  38364. * @param obj defines the object to test
  38365. * @returns true if object has no own property
  38366. */
  38367. static IsEmpty(obj: any): boolean;
  38368. /**
  38369. * Function used to register events at window level
  38370. * @param windowElement defines the Window object to use
  38371. * @param events defines the events to register
  38372. */
  38373. static RegisterTopRootEvents(windowElement: Window, events: {
  38374. name: string;
  38375. handler: Nullable<(e: FocusEvent) => any>;
  38376. }[]): void;
  38377. /**
  38378. * Function used to unregister events from window level
  38379. * @param windowElement defines the Window object to use
  38380. * @param events defines the events to unregister
  38381. */
  38382. static UnregisterTopRootEvents(windowElement: Window, events: {
  38383. name: string;
  38384. handler: Nullable<(e: FocusEvent) => any>;
  38385. }[]): void;
  38386. /**
  38387. * @ignore
  38388. */
  38389. static _ScreenshotCanvas: HTMLCanvasElement;
  38390. /**
  38391. * Dumps the current bound framebuffer
  38392. * @param width defines the rendering width
  38393. * @param height defines the rendering height
  38394. * @param engine defines the hosting engine
  38395. * @param successCallback defines the callback triggered once the data are available
  38396. * @param mimeType defines the mime type of the result
  38397. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38398. */
  38399. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38400. /**
  38401. * Converts the canvas data to blob.
  38402. * This acts as a polyfill for browsers not supporting the to blob function.
  38403. * @param canvas Defines the canvas to extract the data from
  38404. * @param successCallback Defines the callback triggered once the data are available
  38405. * @param mimeType Defines the mime type of the result
  38406. */
  38407. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38408. /**
  38409. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38410. * @param successCallback defines the callback triggered once the data are available
  38411. * @param mimeType defines the mime type of the result
  38412. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38413. */
  38414. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38415. /**
  38416. * Downloads a blob in the browser
  38417. * @param blob defines the blob to download
  38418. * @param fileName defines the name of the downloaded file
  38419. */
  38420. static Download(blob: Blob, fileName: string): void;
  38421. /**
  38422. * Captures a screenshot of the current rendering
  38423. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38424. * @param engine defines the rendering engine
  38425. * @param camera defines the source camera
  38426. * @param size This parameter can be set to a single number or to an object with the
  38427. * following (optional) properties: precision, width, height. If a single number is passed,
  38428. * it will be used for both width and height. If an object is passed, the screenshot size
  38429. * will be derived from the parameters. The precision property is a multiplier allowing
  38430. * rendering at a higher or lower resolution
  38431. * @param successCallback defines the callback receives a single parameter which contains the
  38432. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38433. * src parameter of an <img> to display it
  38434. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38435. * Check your browser for supported MIME types
  38436. */
  38437. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38438. /**
  38439. * Captures a screenshot of the current rendering
  38440. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38441. * @param engine defines the rendering engine
  38442. * @param camera defines the source camera
  38443. * @param size This parameter can be set to a single number or to an object with the
  38444. * following (optional) properties: precision, width, height. If a single number is passed,
  38445. * it will be used for both width and height. If an object is passed, the screenshot size
  38446. * will be derived from the parameters. The precision property is a multiplier allowing
  38447. * rendering at a higher or lower resolution
  38448. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38449. * Check your browser for supported MIME types
  38450. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38451. * to the src parameter of an <img> to display it
  38452. */
  38453. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38454. /**
  38455. * Generates an image screenshot from the specified camera.
  38456. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38457. * @param engine The engine to use for rendering
  38458. * @param camera The camera to use for rendering
  38459. * @param size This parameter can be set to a single number or to an object with the
  38460. * following (optional) properties: precision, width, height. If a single number is passed,
  38461. * it will be used for both width and height. If an object is passed, the screenshot size
  38462. * will be derived from the parameters. The precision property is a multiplier allowing
  38463. * rendering at a higher or lower resolution
  38464. * @param successCallback The callback receives a single parameter which contains the
  38465. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38466. * src parameter of an <img> to display it
  38467. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38468. * Check your browser for supported MIME types
  38469. * @param samples Texture samples (default: 1)
  38470. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38471. * @param fileName A name for for the downloaded file.
  38472. */
  38473. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38474. /**
  38475. * Generates an image screenshot from the specified camera.
  38476. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38477. * @param engine The engine to use for rendering
  38478. * @param camera The camera to use for rendering
  38479. * @param size This parameter can be set to a single number or to an object with the
  38480. * following (optional) properties: precision, width, height. If a single number is passed,
  38481. * it will be used for both width and height. If an object is passed, the screenshot size
  38482. * will be derived from the parameters. The precision property is a multiplier allowing
  38483. * rendering at a higher or lower resolution
  38484. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38485. * Check your browser for supported MIME types
  38486. * @param samples Texture samples (default: 1)
  38487. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38488. * @param fileName A name for for the downloaded file.
  38489. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38490. * to the src parameter of an <img> to display it
  38491. */
  38492. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38493. /**
  38494. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38495. * Be aware Math.random() could cause collisions, but:
  38496. * "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"
  38497. * @returns a pseudo random id
  38498. */
  38499. static RandomId(): string;
  38500. /**
  38501. * Test if the given uri is a base64 string
  38502. * @param uri The uri to test
  38503. * @return True if the uri is a base64 string or false otherwise
  38504. */
  38505. static IsBase64(uri: string): boolean;
  38506. /**
  38507. * Decode the given base64 uri.
  38508. * @param uri The uri to decode
  38509. * @return The decoded base64 data.
  38510. */
  38511. static DecodeBase64(uri: string): ArrayBuffer;
  38512. /**
  38513. * Gets the absolute url.
  38514. * @param url the input url
  38515. * @return the absolute url
  38516. */
  38517. static GetAbsoluteUrl(url: string): string;
  38518. /**
  38519. * No log
  38520. */
  38521. static readonly NoneLogLevel: number;
  38522. /**
  38523. * Only message logs
  38524. */
  38525. static readonly MessageLogLevel: number;
  38526. /**
  38527. * Only warning logs
  38528. */
  38529. static readonly WarningLogLevel: number;
  38530. /**
  38531. * Only error logs
  38532. */
  38533. static readonly ErrorLogLevel: number;
  38534. /**
  38535. * All logs
  38536. */
  38537. static readonly AllLogLevel: number;
  38538. /**
  38539. * Gets a value indicating the number of loading errors
  38540. * @ignorenaming
  38541. */
  38542. static get errorsCount(): number;
  38543. /**
  38544. * Callback called when a new log is added
  38545. */
  38546. static OnNewCacheEntry: (entry: string) => void;
  38547. /**
  38548. * Log a message to the console
  38549. * @param message defines the message to log
  38550. */
  38551. static Log(message: string): void;
  38552. /**
  38553. * Write a warning message to the console
  38554. * @param message defines the message to log
  38555. */
  38556. static Warn(message: string): void;
  38557. /**
  38558. * Write an error message to the console
  38559. * @param message defines the message to log
  38560. */
  38561. static Error(message: string): void;
  38562. /**
  38563. * Gets current log cache (list of logs)
  38564. */
  38565. static get LogCache(): string;
  38566. /**
  38567. * Clears the log cache
  38568. */
  38569. static ClearLogCache(): void;
  38570. /**
  38571. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38572. */
  38573. static set LogLevels(level: number);
  38574. /**
  38575. * Checks if the window object exists
  38576. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38577. */
  38578. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38579. /**
  38580. * No performance log
  38581. */
  38582. static readonly PerformanceNoneLogLevel: number;
  38583. /**
  38584. * Use user marks to log performance
  38585. */
  38586. static readonly PerformanceUserMarkLogLevel: number;
  38587. /**
  38588. * Log performance to the console
  38589. */
  38590. static readonly PerformanceConsoleLogLevel: number;
  38591. private static _performance;
  38592. /**
  38593. * Sets the current performance log level
  38594. */
  38595. static set PerformanceLogLevel(level: number);
  38596. private static _StartPerformanceCounterDisabled;
  38597. private static _EndPerformanceCounterDisabled;
  38598. private static _StartUserMark;
  38599. private static _EndUserMark;
  38600. private static _StartPerformanceConsole;
  38601. private static _EndPerformanceConsole;
  38602. /**
  38603. * Starts a performance counter
  38604. */
  38605. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38606. /**
  38607. * Ends a specific performance coutner
  38608. */
  38609. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38610. /**
  38611. * Gets either window.performance.now() if supported or Date.now() else
  38612. */
  38613. static get Now(): number;
  38614. /**
  38615. * This method will return the name of the class used to create the instance of the given object.
  38616. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38617. * @param object the object to get the class name from
  38618. * @param isType defines if the object is actually a type
  38619. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38620. */
  38621. static GetClassName(object: any, isType?: boolean): string;
  38622. /**
  38623. * Gets the first element of an array satisfying a given predicate
  38624. * @param array defines the array to browse
  38625. * @param predicate defines the predicate to use
  38626. * @returns null if not found or the element
  38627. */
  38628. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38629. /**
  38630. * This method will return the name of the full name of the class, including its owning module (if any).
  38631. * 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).
  38632. * @param object the object to get the class name from
  38633. * @param isType defines if the object is actually a type
  38634. * @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.
  38635. * @ignorenaming
  38636. */
  38637. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38638. /**
  38639. * Returns a promise that resolves after the given amount of time.
  38640. * @param delay Number of milliseconds to delay
  38641. * @returns Promise that resolves after the given amount of time
  38642. */
  38643. static DelayAsync(delay: number): Promise<void>;
  38644. /**
  38645. * Utility function to detect if the current user agent is Safari
  38646. * @returns whether or not the current user agent is safari
  38647. */
  38648. static IsSafari(): boolean;
  38649. }
  38650. /**
  38651. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38652. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38653. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38654. * @param name The name of the class, case should be preserved
  38655. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38656. */
  38657. export function className(name: string, module?: string): (target: Object) => void;
  38658. /**
  38659. * An implementation of a loop for asynchronous functions.
  38660. */
  38661. export class AsyncLoop {
  38662. /**
  38663. * Defines the number of iterations for the loop
  38664. */
  38665. iterations: number;
  38666. /**
  38667. * Defines the current index of the loop.
  38668. */
  38669. index: number;
  38670. private _done;
  38671. private _fn;
  38672. private _successCallback;
  38673. /**
  38674. * Constructor.
  38675. * @param iterations the number of iterations.
  38676. * @param func the function to run each iteration
  38677. * @param successCallback the callback that will be called upon succesful execution
  38678. * @param offset starting offset.
  38679. */
  38680. constructor(
  38681. /**
  38682. * Defines the number of iterations for the loop
  38683. */
  38684. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38685. /**
  38686. * Execute the next iteration. Must be called after the last iteration was finished.
  38687. */
  38688. executeNext(): void;
  38689. /**
  38690. * Break the loop and run the success callback.
  38691. */
  38692. breakLoop(): void;
  38693. /**
  38694. * Create and run an async loop.
  38695. * @param iterations the number of iterations.
  38696. * @param fn the function to run each iteration
  38697. * @param successCallback the callback that will be called upon succesful execution
  38698. * @param offset starting offset.
  38699. * @returns the created async loop object
  38700. */
  38701. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38702. /**
  38703. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38704. * @param iterations total number of iterations
  38705. * @param syncedIterations number of synchronous iterations in each async iteration.
  38706. * @param fn the function to call each iteration.
  38707. * @param callback a success call back that will be called when iterating stops.
  38708. * @param breakFunction a break condition (optional)
  38709. * @param timeout timeout settings for the setTimeout function. default - 0.
  38710. * @returns the created async loop object
  38711. */
  38712. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38713. }
  38714. }
  38715. declare module BABYLON {
  38716. /**
  38717. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38718. * The underlying implementation relies on an associative array to ensure the best performances.
  38719. * The value can be anything including 'null' but except 'undefined'
  38720. */
  38721. export class StringDictionary<T> {
  38722. /**
  38723. * This will clear this dictionary and copy the content from the 'source' one.
  38724. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38725. * @param source the dictionary to take the content from and copy to this dictionary
  38726. */
  38727. copyFrom(source: StringDictionary<T>): void;
  38728. /**
  38729. * Get a value based from its key
  38730. * @param key the given key to get the matching value from
  38731. * @return the value if found, otherwise undefined is returned
  38732. */
  38733. get(key: string): T | undefined;
  38734. /**
  38735. * Get a value from its key or add it if it doesn't exist.
  38736. * This method will ensure you that a given key/data will be present in the dictionary.
  38737. * @param key the given key to get the matching value from
  38738. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38739. * The factory will only be invoked if there's no data for the given key.
  38740. * @return the value corresponding to the key.
  38741. */
  38742. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38743. /**
  38744. * Get a value from its key if present in the dictionary otherwise add it
  38745. * @param key the key to get the value from
  38746. * @param val if there's no such key/value pair in the dictionary add it with this value
  38747. * @return the value corresponding to the key
  38748. */
  38749. getOrAdd(key: string, val: T): T;
  38750. /**
  38751. * Check if there's a given key in the dictionary
  38752. * @param key the key to check for
  38753. * @return true if the key is present, false otherwise
  38754. */
  38755. contains(key: string): boolean;
  38756. /**
  38757. * Add a new key and its corresponding value
  38758. * @param key the key to add
  38759. * @param value the value corresponding to the key
  38760. * @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
  38761. */
  38762. add(key: string, value: T): boolean;
  38763. /**
  38764. * Update a specific value associated to a key
  38765. * @param key defines the key to use
  38766. * @param value defines the value to store
  38767. * @returns true if the value was updated (or false if the key was not found)
  38768. */
  38769. set(key: string, value: T): boolean;
  38770. /**
  38771. * Get the element of the given key and remove it from the dictionary
  38772. * @param key defines the key to search
  38773. * @returns the value associated with the key or null if not found
  38774. */
  38775. getAndRemove(key: string): Nullable<T>;
  38776. /**
  38777. * Remove a key/value from the dictionary.
  38778. * @param key the key to remove
  38779. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38780. */
  38781. remove(key: string): boolean;
  38782. /**
  38783. * Clear the whole content of the dictionary
  38784. */
  38785. clear(): void;
  38786. /**
  38787. * Gets the current count
  38788. */
  38789. get count(): number;
  38790. /**
  38791. * Execute a callback on each key/val of the dictionary.
  38792. * Note that you can remove any element in this dictionary in the callback implementation
  38793. * @param callback the callback to execute on a given key/value pair
  38794. */
  38795. forEach(callback: (key: string, val: T) => void): void;
  38796. /**
  38797. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38798. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38799. * Note that you can remove any element in this dictionary in the callback implementation
  38800. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38801. * @returns the first item
  38802. */
  38803. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38804. private _count;
  38805. private _data;
  38806. }
  38807. }
  38808. declare module BABYLON {
  38809. /** @hidden */
  38810. export interface ICollisionCoordinator {
  38811. createCollider(): Collider;
  38812. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38813. init(scene: Scene): void;
  38814. }
  38815. /** @hidden */
  38816. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38817. private _scene;
  38818. private _scaledPosition;
  38819. private _scaledVelocity;
  38820. private _finalPosition;
  38821. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38822. createCollider(): Collider;
  38823. init(scene: Scene): void;
  38824. private _collideWithWorld;
  38825. }
  38826. }
  38827. declare module BABYLON {
  38828. /**
  38829. * Class used to manage all inputs for the scene.
  38830. */
  38831. export class InputManager {
  38832. /** The distance in pixel that you have to move to prevent some events */
  38833. static DragMovementThreshold: number;
  38834. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38835. static LongPressDelay: number;
  38836. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38837. static DoubleClickDelay: number;
  38838. /** If you need to check double click without raising a single click at first click, enable this flag */
  38839. static ExclusiveDoubleClickMode: boolean;
  38840. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  38841. private _alreadyAttached;
  38842. private _wheelEventName;
  38843. private _onPointerMove;
  38844. private _onPointerDown;
  38845. private _onPointerUp;
  38846. private _initClickEvent;
  38847. private _initActionManager;
  38848. private _delayedSimpleClick;
  38849. private _delayedSimpleClickTimeout;
  38850. private _previousDelayedSimpleClickTimeout;
  38851. private _meshPickProceed;
  38852. private _previousButtonPressed;
  38853. private _currentPickResult;
  38854. private _previousPickResult;
  38855. private _totalPointersPressed;
  38856. private _doubleClickOccured;
  38857. private _pointerOverMesh;
  38858. private _pickedDownMesh;
  38859. private _pickedUpMesh;
  38860. private _pointerX;
  38861. private _pointerY;
  38862. private _unTranslatedPointerX;
  38863. private _unTranslatedPointerY;
  38864. private _startingPointerPosition;
  38865. private _previousStartingPointerPosition;
  38866. private _startingPointerTime;
  38867. private _previousStartingPointerTime;
  38868. private _pointerCaptures;
  38869. private _onKeyDown;
  38870. private _onKeyUp;
  38871. private _onCanvasFocusObserver;
  38872. private _onCanvasBlurObserver;
  38873. private _scene;
  38874. /**
  38875. * Creates a new InputManager
  38876. * @param scene defines the hosting scene
  38877. */
  38878. constructor(scene: Scene);
  38879. /**
  38880. * Gets the mesh that is currently under the pointer
  38881. */
  38882. get meshUnderPointer(): Nullable<AbstractMesh>;
  38883. /**
  38884. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38885. */
  38886. get unTranslatedPointer(): Vector2;
  38887. /**
  38888. * Gets or sets the current on-screen X position of the pointer
  38889. */
  38890. get pointerX(): number;
  38891. set pointerX(value: number);
  38892. /**
  38893. * Gets or sets the current on-screen Y position of the pointer
  38894. */
  38895. get pointerY(): number;
  38896. set pointerY(value: number);
  38897. private _updatePointerPosition;
  38898. private _processPointerMove;
  38899. private _setRayOnPointerInfo;
  38900. private _checkPrePointerObservable;
  38901. /**
  38902. * Use this method to simulate a pointer move on a mesh
  38903. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38904. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38905. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38906. */
  38907. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38908. /**
  38909. * Use this method to simulate a pointer down on a mesh
  38910. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38911. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38912. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38913. */
  38914. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38915. private _processPointerDown;
  38916. /** @hidden */
  38917. _isPointerSwiping(): boolean;
  38918. /**
  38919. * Use this method to simulate a pointer up on a mesh
  38920. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38921. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38922. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38923. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38924. */
  38925. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38926. private _processPointerUp;
  38927. /**
  38928. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38929. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38930. * @returns true if the pointer was captured
  38931. */
  38932. isPointerCaptured(pointerId?: number): boolean;
  38933. /**
  38934. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38935. * @param attachUp defines if you want to attach events to pointerup
  38936. * @param attachDown defines if you want to attach events to pointerdown
  38937. * @param attachMove defines if you want to attach events to pointermove
  38938. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38939. */
  38940. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38941. /**
  38942. * Detaches all event handlers
  38943. */
  38944. detachControl(): void;
  38945. /**
  38946. * Force the value of meshUnderPointer
  38947. * @param mesh defines the mesh to use
  38948. */
  38949. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38950. /**
  38951. * Gets the mesh under the pointer
  38952. * @returns a Mesh or null if no mesh is under the pointer
  38953. */
  38954. getPointerOverMesh(): Nullable<AbstractMesh>;
  38955. }
  38956. }
  38957. declare module BABYLON {
  38958. /**
  38959. * This class defines the direct association between an animation and a target
  38960. */
  38961. export class TargetedAnimation {
  38962. /**
  38963. * Animation to perform
  38964. */
  38965. animation: Animation;
  38966. /**
  38967. * Target to animate
  38968. */
  38969. target: any;
  38970. /**
  38971. * Returns the string "TargetedAnimation"
  38972. * @returns "TargetedAnimation"
  38973. */
  38974. getClassName(): string;
  38975. /**
  38976. * Serialize the object
  38977. * @returns the JSON object representing the current entity
  38978. */
  38979. serialize(): any;
  38980. }
  38981. /**
  38982. * Use this class to create coordinated animations on multiple targets
  38983. */
  38984. export class AnimationGroup implements IDisposable {
  38985. /** The name of the animation group */
  38986. name: string;
  38987. private _scene;
  38988. private _targetedAnimations;
  38989. private _animatables;
  38990. private _from;
  38991. private _to;
  38992. private _isStarted;
  38993. private _isPaused;
  38994. private _speedRatio;
  38995. private _loopAnimation;
  38996. private _isAdditive;
  38997. /**
  38998. * Gets or sets the unique id of the node
  38999. */
  39000. uniqueId: number;
  39001. /**
  39002. * This observable will notify when one animation have ended
  39003. */
  39004. onAnimationEndObservable: Observable<TargetedAnimation>;
  39005. /**
  39006. * Observer raised when one animation loops
  39007. */
  39008. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39009. /**
  39010. * Observer raised when all animations have looped
  39011. */
  39012. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39013. /**
  39014. * This observable will notify when all animations have ended.
  39015. */
  39016. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39017. /**
  39018. * This observable will notify when all animations have paused.
  39019. */
  39020. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39021. /**
  39022. * This observable will notify when all animations are playing.
  39023. */
  39024. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39025. /**
  39026. * Gets the first frame
  39027. */
  39028. get from(): number;
  39029. /**
  39030. * Gets the last frame
  39031. */
  39032. get to(): number;
  39033. /**
  39034. * Define if the animations are started
  39035. */
  39036. get isStarted(): boolean;
  39037. /**
  39038. * Gets a value indicating that the current group is playing
  39039. */
  39040. get isPlaying(): boolean;
  39041. /**
  39042. * Gets or sets the speed ratio to use for all animations
  39043. */
  39044. get speedRatio(): number;
  39045. /**
  39046. * Gets or sets the speed ratio to use for all animations
  39047. */
  39048. set speedRatio(value: number);
  39049. /**
  39050. * Gets or sets if all animations should loop or not
  39051. */
  39052. get loopAnimation(): boolean;
  39053. set loopAnimation(value: boolean);
  39054. /**
  39055. * Gets or sets if all animations should be evaluated additively
  39056. */
  39057. get isAdditive(): boolean;
  39058. set isAdditive(value: boolean);
  39059. /**
  39060. * Gets the targeted animations for this animation group
  39061. */
  39062. get targetedAnimations(): Array<TargetedAnimation>;
  39063. /**
  39064. * returning the list of animatables controlled by this animation group.
  39065. */
  39066. get animatables(): Array<Animatable>;
  39067. /**
  39068. * Gets the list of target animations
  39069. */
  39070. get children(): TargetedAnimation[];
  39071. /**
  39072. * Instantiates a new Animation Group.
  39073. * This helps managing several animations at once.
  39074. * @see https://doc.babylonjs.com/how_to/group
  39075. * @param name Defines the name of the group
  39076. * @param scene Defines the scene the group belongs to
  39077. */
  39078. constructor(
  39079. /** The name of the animation group */
  39080. name: string, scene?: Nullable<Scene>);
  39081. /**
  39082. * Add an animation (with its target) in the group
  39083. * @param animation defines the animation we want to add
  39084. * @param target defines the target of the animation
  39085. * @returns the TargetedAnimation object
  39086. */
  39087. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39088. /**
  39089. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39090. * It can add constant keys at begin or end
  39091. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39092. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39093. * @returns the animation group
  39094. */
  39095. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39096. private _animationLoopCount;
  39097. private _animationLoopFlags;
  39098. private _processLoop;
  39099. /**
  39100. * Start all animations on given targets
  39101. * @param loop defines if animations must loop
  39102. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39103. * @param from defines the from key (optional)
  39104. * @param to defines the to key (optional)
  39105. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39106. * @returns the current animation group
  39107. */
  39108. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39109. /**
  39110. * Pause all animations
  39111. * @returns the animation group
  39112. */
  39113. pause(): AnimationGroup;
  39114. /**
  39115. * Play all animations to initial state
  39116. * This function will start() the animations if they were not started or will restart() them if they were paused
  39117. * @param loop defines if animations must loop
  39118. * @returns the animation group
  39119. */
  39120. play(loop?: boolean): AnimationGroup;
  39121. /**
  39122. * Reset all animations to initial state
  39123. * @returns the animation group
  39124. */
  39125. reset(): AnimationGroup;
  39126. /**
  39127. * Restart animations from key 0
  39128. * @returns the animation group
  39129. */
  39130. restart(): AnimationGroup;
  39131. /**
  39132. * Stop all animations
  39133. * @returns the animation group
  39134. */
  39135. stop(): AnimationGroup;
  39136. /**
  39137. * Set animation weight for all animatables
  39138. * @param weight defines the weight to use
  39139. * @return the animationGroup
  39140. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39141. */
  39142. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39143. /**
  39144. * Synchronize and normalize all animatables with a source animatable
  39145. * @param root defines the root animatable to synchronize with
  39146. * @return the animationGroup
  39147. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39148. */
  39149. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39150. /**
  39151. * Goes to a specific frame in this animation group
  39152. * @param frame the frame number to go to
  39153. * @return the animationGroup
  39154. */
  39155. goToFrame(frame: number): AnimationGroup;
  39156. /**
  39157. * Dispose all associated resources
  39158. */
  39159. dispose(): void;
  39160. private _checkAnimationGroupEnded;
  39161. /**
  39162. * Clone the current animation group and returns a copy
  39163. * @param newName defines the name of the new group
  39164. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39165. * @returns the new aniamtion group
  39166. */
  39167. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39168. /**
  39169. * Serializes the animationGroup to an object
  39170. * @returns Serialized object
  39171. */
  39172. serialize(): any;
  39173. /**
  39174. * Returns a new AnimationGroup object parsed from the source provided.
  39175. * @param parsedAnimationGroup defines the source
  39176. * @param scene defines the scene that will receive the animationGroup
  39177. * @returns a new AnimationGroup
  39178. */
  39179. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39180. /**
  39181. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39182. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39183. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39184. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39185. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39186. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39187. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39188. */
  39189. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39190. /**
  39191. * Returns the string "AnimationGroup"
  39192. * @returns "AnimationGroup"
  39193. */
  39194. getClassName(): string;
  39195. /**
  39196. * Creates a detailled string about the object
  39197. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39198. * @returns a string representing the object
  39199. */
  39200. toString(fullDetails?: boolean): string;
  39201. }
  39202. }
  39203. declare module BABYLON {
  39204. /**
  39205. * Define an interface for all classes that will hold resources
  39206. */
  39207. export interface IDisposable {
  39208. /**
  39209. * Releases all held resources
  39210. */
  39211. dispose(): void;
  39212. }
  39213. /** Interface defining initialization parameters for Scene class */
  39214. export interface SceneOptions {
  39215. /**
  39216. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39217. * It will improve performance when the number of geometries becomes important.
  39218. */
  39219. useGeometryUniqueIdsMap?: boolean;
  39220. /**
  39221. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39222. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39223. */
  39224. useMaterialMeshMap?: boolean;
  39225. /**
  39226. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39227. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39228. */
  39229. useClonedMeshMap?: boolean;
  39230. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39231. virtual?: boolean;
  39232. }
  39233. /**
  39234. * Represents a scene to be rendered by the engine.
  39235. * @see https://doc.babylonjs.com/features/scene
  39236. */
  39237. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39238. /** The fog is deactivated */
  39239. static readonly FOGMODE_NONE: number;
  39240. /** The fog density is following an exponential function */
  39241. static readonly FOGMODE_EXP: number;
  39242. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39243. static readonly FOGMODE_EXP2: number;
  39244. /** The fog density is following a linear function. */
  39245. static readonly FOGMODE_LINEAR: number;
  39246. /**
  39247. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39248. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39249. */
  39250. static MinDeltaTime: number;
  39251. /**
  39252. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39253. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39254. */
  39255. static MaxDeltaTime: number;
  39256. /**
  39257. * Factory used to create the default material.
  39258. * @param name The name of the material to create
  39259. * @param scene The scene to create the material for
  39260. * @returns The default material
  39261. */
  39262. static DefaultMaterialFactory(scene: Scene): Material;
  39263. /**
  39264. * Factory used to create the a collision coordinator.
  39265. * @returns The collision coordinator
  39266. */
  39267. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39268. /** @hidden */
  39269. _inputManager: InputManager;
  39270. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39271. cameraToUseForPointers: Nullable<Camera>;
  39272. /** @hidden */
  39273. readonly _isScene: boolean;
  39274. /** @hidden */
  39275. _blockEntityCollection: boolean;
  39276. /**
  39277. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39278. */
  39279. autoClear: boolean;
  39280. /**
  39281. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39282. */
  39283. autoClearDepthAndStencil: boolean;
  39284. /**
  39285. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39286. */
  39287. clearColor: Color4;
  39288. /**
  39289. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39290. */
  39291. ambientColor: Color3;
  39292. /**
  39293. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39294. * It should only be one of the following (if not the default embedded one):
  39295. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39296. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39297. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39298. * The material properties need to be setup according to the type of texture in use.
  39299. */
  39300. environmentBRDFTexture: BaseTexture;
  39301. /** @hidden */
  39302. protected _environmentTexture: Nullable<BaseTexture>;
  39303. /**
  39304. * Texture used in all pbr material as the reflection texture.
  39305. * As in the majority of the scene they are the same (exception for multi room and so on),
  39306. * this is easier to reference from here than from all the materials.
  39307. */
  39308. get environmentTexture(): Nullable<BaseTexture>;
  39309. /**
  39310. * Texture used in all pbr material as the reflection texture.
  39311. * As in the majority of the scene they are the same (exception for multi room and so on),
  39312. * this is easier to set here than in all the materials.
  39313. */
  39314. set environmentTexture(value: Nullable<BaseTexture>);
  39315. /** @hidden */
  39316. protected _environmentIntensity: number;
  39317. /**
  39318. * Intensity of the environment in all pbr material.
  39319. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39320. * As in the majority of the scene they are the same (exception for multi room and so on),
  39321. * this is easier to reference from here than from all the materials.
  39322. */
  39323. get environmentIntensity(): number;
  39324. /**
  39325. * Intensity of the environment in all pbr material.
  39326. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39327. * As in the majority of the scene they are the same (exception for multi room and so on),
  39328. * this is easier to set here than in all the materials.
  39329. */
  39330. set environmentIntensity(value: number);
  39331. /** @hidden */
  39332. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39333. /**
  39334. * Default image processing configuration used either in the rendering
  39335. * Forward main pass or through the imageProcessingPostProcess if present.
  39336. * As in the majority of the scene they are the same (exception for multi camera),
  39337. * this is easier to reference from here than from all the materials and post process.
  39338. *
  39339. * No setter as we it is a shared configuration, you can set the values instead.
  39340. */
  39341. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39342. private _forceWireframe;
  39343. /**
  39344. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39345. */
  39346. set forceWireframe(value: boolean);
  39347. get forceWireframe(): boolean;
  39348. private _skipFrustumClipping;
  39349. /**
  39350. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39351. */
  39352. set skipFrustumClipping(value: boolean);
  39353. get skipFrustumClipping(): boolean;
  39354. private _forcePointsCloud;
  39355. /**
  39356. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39357. */
  39358. set forcePointsCloud(value: boolean);
  39359. get forcePointsCloud(): boolean;
  39360. /**
  39361. * Gets or sets the active clipplane 1
  39362. */
  39363. clipPlane: Nullable<Plane>;
  39364. /**
  39365. * Gets or sets the active clipplane 2
  39366. */
  39367. clipPlane2: Nullable<Plane>;
  39368. /**
  39369. * Gets or sets the active clipplane 3
  39370. */
  39371. clipPlane3: Nullable<Plane>;
  39372. /**
  39373. * Gets or sets the active clipplane 4
  39374. */
  39375. clipPlane4: Nullable<Plane>;
  39376. /**
  39377. * Gets or sets the active clipplane 5
  39378. */
  39379. clipPlane5: Nullable<Plane>;
  39380. /**
  39381. * Gets or sets the active clipplane 6
  39382. */
  39383. clipPlane6: Nullable<Plane>;
  39384. /**
  39385. * Gets or sets a boolean indicating if animations are enabled
  39386. */
  39387. animationsEnabled: boolean;
  39388. private _animationPropertiesOverride;
  39389. /**
  39390. * Gets or sets the animation properties override
  39391. */
  39392. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39393. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39394. /**
  39395. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39396. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39397. */
  39398. useConstantAnimationDeltaTime: boolean;
  39399. /**
  39400. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39401. * Please note that it requires to run a ray cast through the scene on every frame
  39402. */
  39403. constantlyUpdateMeshUnderPointer: boolean;
  39404. /**
  39405. * Defines the HTML cursor to use when hovering over interactive elements
  39406. */
  39407. hoverCursor: string;
  39408. /**
  39409. * Defines the HTML default cursor to use (empty by default)
  39410. */
  39411. defaultCursor: string;
  39412. /**
  39413. * Defines whether cursors are handled by the scene.
  39414. */
  39415. doNotHandleCursors: boolean;
  39416. /**
  39417. * This is used to call preventDefault() on pointer down
  39418. * in order to block unwanted artifacts like system double clicks
  39419. */
  39420. preventDefaultOnPointerDown: boolean;
  39421. /**
  39422. * This is used to call preventDefault() on pointer up
  39423. * in order to block unwanted artifacts like system double clicks
  39424. */
  39425. preventDefaultOnPointerUp: boolean;
  39426. /**
  39427. * Gets or sets user defined metadata
  39428. */
  39429. metadata: any;
  39430. /**
  39431. * For internal use only. Please do not use.
  39432. */
  39433. reservedDataStore: any;
  39434. /**
  39435. * Gets the name of the plugin used to load this scene (null by default)
  39436. */
  39437. loadingPluginName: string;
  39438. /**
  39439. * Use this array to add regular expressions used to disable offline support for specific urls
  39440. */
  39441. disableOfflineSupportExceptionRules: RegExp[];
  39442. /**
  39443. * An event triggered when the scene is disposed.
  39444. */
  39445. onDisposeObservable: Observable<Scene>;
  39446. private _onDisposeObserver;
  39447. /** Sets a function to be executed when this scene is disposed. */
  39448. set onDispose(callback: () => void);
  39449. /**
  39450. * An event triggered before rendering the scene (right after animations and physics)
  39451. */
  39452. onBeforeRenderObservable: Observable<Scene>;
  39453. private _onBeforeRenderObserver;
  39454. /** Sets a function to be executed before rendering this scene */
  39455. set beforeRender(callback: Nullable<() => void>);
  39456. /**
  39457. * An event triggered after rendering the scene
  39458. */
  39459. onAfterRenderObservable: Observable<Scene>;
  39460. /**
  39461. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39462. */
  39463. onAfterRenderCameraObservable: Observable<Camera>;
  39464. private _onAfterRenderObserver;
  39465. /** Sets a function to be executed after rendering this scene */
  39466. set afterRender(callback: Nullable<() => void>);
  39467. /**
  39468. * An event triggered before animating the scene
  39469. */
  39470. onBeforeAnimationsObservable: Observable<Scene>;
  39471. /**
  39472. * An event triggered after animations processing
  39473. */
  39474. onAfterAnimationsObservable: Observable<Scene>;
  39475. /**
  39476. * An event triggered before draw calls are ready to be sent
  39477. */
  39478. onBeforeDrawPhaseObservable: Observable<Scene>;
  39479. /**
  39480. * An event triggered after draw calls have been sent
  39481. */
  39482. onAfterDrawPhaseObservable: Observable<Scene>;
  39483. /**
  39484. * An event triggered when the scene is ready
  39485. */
  39486. onReadyObservable: Observable<Scene>;
  39487. /**
  39488. * An event triggered before rendering a camera
  39489. */
  39490. onBeforeCameraRenderObservable: Observable<Camera>;
  39491. private _onBeforeCameraRenderObserver;
  39492. /** Sets a function to be executed before rendering a camera*/
  39493. set beforeCameraRender(callback: () => void);
  39494. /**
  39495. * An event triggered after rendering a camera
  39496. */
  39497. onAfterCameraRenderObservable: Observable<Camera>;
  39498. private _onAfterCameraRenderObserver;
  39499. /** Sets a function to be executed after rendering a camera*/
  39500. set afterCameraRender(callback: () => void);
  39501. /**
  39502. * An event triggered when active meshes evaluation is about to start
  39503. */
  39504. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39505. /**
  39506. * An event triggered when active meshes evaluation is done
  39507. */
  39508. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39509. /**
  39510. * An event triggered when particles rendering is about to start
  39511. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39512. */
  39513. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39514. /**
  39515. * An event triggered when particles rendering is done
  39516. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39517. */
  39518. onAfterParticlesRenderingObservable: Observable<Scene>;
  39519. /**
  39520. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39521. */
  39522. onDataLoadedObservable: Observable<Scene>;
  39523. /**
  39524. * An event triggered when a camera is created
  39525. */
  39526. onNewCameraAddedObservable: Observable<Camera>;
  39527. /**
  39528. * An event triggered when a camera is removed
  39529. */
  39530. onCameraRemovedObservable: Observable<Camera>;
  39531. /**
  39532. * An event triggered when a light is created
  39533. */
  39534. onNewLightAddedObservable: Observable<Light>;
  39535. /**
  39536. * An event triggered when a light is removed
  39537. */
  39538. onLightRemovedObservable: Observable<Light>;
  39539. /**
  39540. * An event triggered when a geometry is created
  39541. */
  39542. onNewGeometryAddedObservable: Observable<Geometry>;
  39543. /**
  39544. * An event triggered when a geometry is removed
  39545. */
  39546. onGeometryRemovedObservable: Observable<Geometry>;
  39547. /**
  39548. * An event triggered when a transform node is created
  39549. */
  39550. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39551. /**
  39552. * An event triggered when a transform node is removed
  39553. */
  39554. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39555. /**
  39556. * An event triggered when a mesh is created
  39557. */
  39558. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39559. /**
  39560. * An event triggered when a mesh is removed
  39561. */
  39562. onMeshRemovedObservable: Observable<AbstractMesh>;
  39563. /**
  39564. * An event triggered when a skeleton is created
  39565. */
  39566. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39567. /**
  39568. * An event triggered when a skeleton is removed
  39569. */
  39570. onSkeletonRemovedObservable: Observable<Skeleton>;
  39571. /**
  39572. * An event triggered when a material is created
  39573. */
  39574. onNewMaterialAddedObservable: Observable<Material>;
  39575. /**
  39576. * An event triggered when a material is removed
  39577. */
  39578. onMaterialRemovedObservable: Observable<Material>;
  39579. /**
  39580. * An event triggered when a texture is created
  39581. */
  39582. onNewTextureAddedObservable: Observable<BaseTexture>;
  39583. /**
  39584. * An event triggered when a texture is removed
  39585. */
  39586. onTextureRemovedObservable: Observable<BaseTexture>;
  39587. /**
  39588. * An event triggered when render targets are about to be rendered
  39589. * Can happen multiple times per frame.
  39590. */
  39591. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39592. /**
  39593. * An event triggered when render targets were rendered.
  39594. * Can happen multiple times per frame.
  39595. */
  39596. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39597. /**
  39598. * An event triggered before calculating deterministic simulation step
  39599. */
  39600. onBeforeStepObservable: Observable<Scene>;
  39601. /**
  39602. * An event triggered after calculating deterministic simulation step
  39603. */
  39604. onAfterStepObservable: Observable<Scene>;
  39605. /**
  39606. * An event triggered when the activeCamera property is updated
  39607. */
  39608. onActiveCameraChanged: Observable<Scene>;
  39609. /**
  39610. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39611. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39612. * 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)
  39613. */
  39614. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39615. /**
  39616. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39617. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39618. * 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)
  39619. */
  39620. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39621. /**
  39622. * This Observable will when a mesh has been imported into the scene.
  39623. */
  39624. onMeshImportedObservable: Observable<AbstractMesh>;
  39625. /**
  39626. * This Observable will when an animation file has been imported into the scene.
  39627. */
  39628. onAnimationFileImportedObservable: Observable<Scene>;
  39629. /**
  39630. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39631. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39632. */
  39633. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39634. /** @hidden */
  39635. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39636. /**
  39637. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39638. */
  39639. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39640. /**
  39641. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39642. */
  39643. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39644. /**
  39645. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39646. */
  39647. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39648. /** Callback called when a pointer move is detected */
  39649. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39650. /** Callback called when a pointer down is detected */
  39651. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39652. /** Callback called when a pointer up is detected */
  39653. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39654. /** Callback called when a pointer pick is detected */
  39655. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39656. /**
  39657. * 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).
  39658. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39659. */
  39660. onPrePointerObservable: Observable<PointerInfoPre>;
  39661. /**
  39662. * Observable event triggered each time an input event is received from the rendering canvas
  39663. */
  39664. onPointerObservable: Observable<PointerInfo>;
  39665. /**
  39666. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39667. */
  39668. get unTranslatedPointer(): Vector2;
  39669. /**
  39670. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39671. */
  39672. static get DragMovementThreshold(): number;
  39673. static set DragMovementThreshold(value: number);
  39674. /**
  39675. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39676. */
  39677. static get LongPressDelay(): number;
  39678. static set LongPressDelay(value: number);
  39679. /**
  39680. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39681. */
  39682. static get DoubleClickDelay(): number;
  39683. static set DoubleClickDelay(value: number);
  39684. /** If you need to check double click without raising a single click at first click, enable this flag */
  39685. static get ExclusiveDoubleClickMode(): boolean;
  39686. static set ExclusiveDoubleClickMode(value: boolean);
  39687. /** @hidden */
  39688. _mirroredCameraPosition: Nullable<Vector3>;
  39689. /**
  39690. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39691. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39692. */
  39693. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39694. /**
  39695. * Observable event triggered each time an keyboard event is received from the hosting window
  39696. */
  39697. onKeyboardObservable: Observable<KeyboardInfo>;
  39698. private _useRightHandedSystem;
  39699. /**
  39700. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39701. */
  39702. set useRightHandedSystem(value: boolean);
  39703. get useRightHandedSystem(): boolean;
  39704. private _timeAccumulator;
  39705. private _currentStepId;
  39706. private _currentInternalStep;
  39707. /**
  39708. * Sets the step Id used by deterministic lock step
  39709. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39710. * @param newStepId defines the step Id
  39711. */
  39712. setStepId(newStepId: number): void;
  39713. /**
  39714. * Gets the step Id used by deterministic lock step
  39715. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39716. * @returns the step Id
  39717. */
  39718. getStepId(): number;
  39719. /**
  39720. * Gets the internal step used by deterministic lock step
  39721. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39722. * @returns the internal step
  39723. */
  39724. getInternalStep(): number;
  39725. private _fogEnabled;
  39726. /**
  39727. * Gets or sets a boolean indicating if fog is enabled on this scene
  39728. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39729. * (Default is true)
  39730. */
  39731. set fogEnabled(value: boolean);
  39732. get fogEnabled(): boolean;
  39733. private _fogMode;
  39734. /**
  39735. * Gets or sets the fog mode to use
  39736. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39737. * | mode | value |
  39738. * | --- | --- |
  39739. * | FOGMODE_NONE | 0 |
  39740. * | FOGMODE_EXP | 1 |
  39741. * | FOGMODE_EXP2 | 2 |
  39742. * | FOGMODE_LINEAR | 3 |
  39743. */
  39744. set fogMode(value: number);
  39745. get fogMode(): number;
  39746. /**
  39747. * Gets or sets the fog color to use
  39748. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39749. * (Default is Color3(0.2, 0.2, 0.3))
  39750. */
  39751. fogColor: Color3;
  39752. /**
  39753. * Gets or sets the fog density to use
  39754. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39755. * (Default is 0.1)
  39756. */
  39757. fogDensity: number;
  39758. /**
  39759. * Gets or sets the fog start distance to use
  39760. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39761. * (Default is 0)
  39762. */
  39763. fogStart: number;
  39764. /**
  39765. * Gets or sets the fog end distance to use
  39766. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39767. * (Default is 1000)
  39768. */
  39769. fogEnd: number;
  39770. /**
  39771. * Flag indicating that the frame buffer binding is handled by another component
  39772. */
  39773. prePass: boolean;
  39774. private _shadowsEnabled;
  39775. /**
  39776. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39777. */
  39778. set shadowsEnabled(value: boolean);
  39779. get shadowsEnabled(): boolean;
  39780. private _lightsEnabled;
  39781. /**
  39782. * Gets or sets a boolean indicating if lights are enabled on this scene
  39783. */
  39784. set lightsEnabled(value: boolean);
  39785. get lightsEnabled(): boolean;
  39786. /** All of the active cameras added to this scene. */
  39787. activeCameras: Camera[];
  39788. /** @hidden */
  39789. _activeCamera: Nullable<Camera>;
  39790. /** Gets or sets the current active camera */
  39791. get activeCamera(): Nullable<Camera>;
  39792. set activeCamera(value: Nullable<Camera>);
  39793. private _defaultMaterial;
  39794. /** The default material used on meshes when no material is affected */
  39795. get defaultMaterial(): Material;
  39796. /** The default material used on meshes when no material is affected */
  39797. set defaultMaterial(value: Material);
  39798. private _texturesEnabled;
  39799. /**
  39800. * Gets or sets a boolean indicating if textures are enabled on this scene
  39801. */
  39802. set texturesEnabled(value: boolean);
  39803. get texturesEnabled(): boolean;
  39804. /**
  39805. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39806. */
  39807. physicsEnabled: boolean;
  39808. /**
  39809. * Gets or sets a boolean indicating if particles are enabled on this scene
  39810. */
  39811. particlesEnabled: boolean;
  39812. /**
  39813. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39814. */
  39815. spritesEnabled: boolean;
  39816. private _skeletonsEnabled;
  39817. /**
  39818. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39819. */
  39820. set skeletonsEnabled(value: boolean);
  39821. get skeletonsEnabled(): boolean;
  39822. /**
  39823. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39824. */
  39825. lensFlaresEnabled: boolean;
  39826. /**
  39827. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39828. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39829. */
  39830. collisionsEnabled: boolean;
  39831. private _collisionCoordinator;
  39832. /** @hidden */
  39833. get collisionCoordinator(): ICollisionCoordinator;
  39834. /**
  39835. * Defines the gravity applied to this scene (used only for collisions)
  39836. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39837. */
  39838. gravity: Vector3;
  39839. /**
  39840. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39841. */
  39842. postProcessesEnabled: boolean;
  39843. /**
  39844. * The list of postprocesses added to the scene
  39845. */
  39846. postProcesses: PostProcess[];
  39847. /**
  39848. * Gets the current postprocess manager
  39849. */
  39850. postProcessManager: PostProcessManager;
  39851. /**
  39852. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39853. */
  39854. renderTargetsEnabled: boolean;
  39855. /**
  39856. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39857. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39858. */
  39859. dumpNextRenderTargets: boolean;
  39860. /**
  39861. * The list of user defined render targets added to the scene
  39862. */
  39863. customRenderTargets: RenderTargetTexture[];
  39864. /**
  39865. * Defines if texture loading must be delayed
  39866. * If true, textures will only be loaded when they need to be rendered
  39867. */
  39868. useDelayedTextureLoading: boolean;
  39869. /**
  39870. * Gets the list of meshes imported to the scene through SceneLoader
  39871. */
  39872. importedMeshesFiles: String[];
  39873. /**
  39874. * Gets or sets a boolean indicating if probes are enabled on this scene
  39875. */
  39876. probesEnabled: boolean;
  39877. /**
  39878. * Gets or sets the current offline provider to use to store scene data
  39879. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39880. */
  39881. offlineProvider: IOfflineProvider;
  39882. /**
  39883. * Gets or sets the action manager associated with the scene
  39884. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39885. */
  39886. actionManager: AbstractActionManager;
  39887. private _meshesForIntersections;
  39888. /**
  39889. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39890. */
  39891. proceduralTexturesEnabled: boolean;
  39892. private _engine;
  39893. private _totalVertices;
  39894. /** @hidden */
  39895. _activeIndices: PerfCounter;
  39896. /** @hidden */
  39897. _activeParticles: PerfCounter;
  39898. /** @hidden */
  39899. _activeBones: PerfCounter;
  39900. private _animationRatio;
  39901. /** @hidden */
  39902. _animationTimeLast: number;
  39903. /** @hidden */
  39904. _animationTime: number;
  39905. /**
  39906. * Gets or sets a general scale for animation speed
  39907. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39908. */
  39909. animationTimeScale: number;
  39910. /** @hidden */
  39911. _cachedMaterial: Nullable<Material>;
  39912. /** @hidden */
  39913. _cachedEffect: Nullable<Effect>;
  39914. /** @hidden */
  39915. _cachedVisibility: Nullable<number>;
  39916. private _renderId;
  39917. private _frameId;
  39918. private _executeWhenReadyTimeoutId;
  39919. private _intermediateRendering;
  39920. private _viewUpdateFlag;
  39921. private _projectionUpdateFlag;
  39922. /** @hidden */
  39923. _toBeDisposed: Nullable<IDisposable>[];
  39924. private _activeRequests;
  39925. /** @hidden */
  39926. _pendingData: any[];
  39927. private _isDisposed;
  39928. /**
  39929. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39930. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39931. */
  39932. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39933. private _activeMeshes;
  39934. private _processedMaterials;
  39935. private _renderTargets;
  39936. /** @hidden */
  39937. _activeParticleSystems: SmartArray<IParticleSystem>;
  39938. private _activeSkeletons;
  39939. private _softwareSkinnedMeshes;
  39940. private _renderingManager;
  39941. /** @hidden */
  39942. _activeAnimatables: Animatable[];
  39943. private _transformMatrix;
  39944. private _sceneUbo;
  39945. /** @hidden */
  39946. _viewMatrix: Matrix;
  39947. private _projectionMatrix;
  39948. /** @hidden */
  39949. _forcedViewPosition: Nullable<Vector3>;
  39950. /** @hidden */
  39951. _frustumPlanes: Plane[];
  39952. /**
  39953. * Gets the list of frustum planes (built from the active camera)
  39954. */
  39955. get frustumPlanes(): Plane[];
  39956. /**
  39957. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39958. * This is useful if there are more lights that the maximum simulteanous authorized
  39959. */
  39960. requireLightSorting: boolean;
  39961. /** @hidden */
  39962. readonly useMaterialMeshMap: boolean;
  39963. /** @hidden */
  39964. readonly useClonedMeshMap: boolean;
  39965. private _externalData;
  39966. private _uid;
  39967. /**
  39968. * @hidden
  39969. * Backing store of defined scene components.
  39970. */
  39971. _components: ISceneComponent[];
  39972. /**
  39973. * @hidden
  39974. * Backing store of defined scene components.
  39975. */
  39976. _serializableComponents: ISceneSerializableComponent[];
  39977. /**
  39978. * List of components to register on the next registration step.
  39979. */
  39980. private _transientComponents;
  39981. /**
  39982. * Registers the transient components if needed.
  39983. */
  39984. private _registerTransientComponents;
  39985. /**
  39986. * @hidden
  39987. * Add a component to the scene.
  39988. * Note that the ccomponent could be registered on th next frame if this is called after
  39989. * the register component stage.
  39990. * @param component Defines the component to add to the scene
  39991. */
  39992. _addComponent(component: ISceneComponent): void;
  39993. /**
  39994. * @hidden
  39995. * Gets a component from the scene.
  39996. * @param name defines the name of the component to retrieve
  39997. * @returns the component or null if not present
  39998. */
  39999. _getComponent(name: string): Nullable<ISceneComponent>;
  40000. /**
  40001. * @hidden
  40002. * Defines the actions happening before camera updates.
  40003. */
  40004. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40005. /**
  40006. * @hidden
  40007. * Defines the actions happening before clear the canvas.
  40008. */
  40009. _beforeClearStage: Stage<SimpleStageAction>;
  40010. /**
  40011. * @hidden
  40012. * Defines the actions when collecting render targets for the frame.
  40013. */
  40014. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40015. /**
  40016. * @hidden
  40017. * Defines the actions happening for one camera in the frame.
  40018. */
  40019. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40020. /**
  40021. * @hidden
  40022. * Defines the actions happening during the per mesh ready checks.
  40023. */
  40024. _isReadyForMeshStage: Stage<MeshStageAction>;
  40025. /**
  40026. * @hidden
  40027. * Defines the actions happening before evaluate active mesh checks.
  40028. */
  40029. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40030. /**
  40031. * @hidden
  40032. * Defines the actions happening during the evaluate sub mesh checks.
  40033. */
  40034. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40035. /**
  40036. * @hidden
  40037. * Defines the actions happening during the active mesh stage.
  40038. */
  40039. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40040. /**
  40041. * @hidden
  40042. * Defines the actions happening during the per camera render target step.
  40043. */
  40044. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40045. /**
  40046. * @hidden
  40047. * Defines the actions happening just before the active camera is drawing.
  40048. */
  40049. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40050. /**
  40051. * @hidden
  40052. * Defines the actions happening just before a render target is drawing.
  40053. */
  40054. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40055. /**
  40056. * @hidden
  40057. * Defines the actions happening just before a rendering group is drawing.
  40058. */
  40059. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40060. /**
  40061. * @hidden
  40062. * Defines the actions happening just before a mesh is drawing.
  40063. */
  40064. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40065. /**
  40066. * @hidden
  40067. * Defines the actions happening just after a mesh has been drawn.
  40068. */
  40069. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40070. /**
  40071. * @hidden
  40072. * Defines the actions happening just after a rendering group has been drawn.
  40073. */
  40074. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40075. /**
  40076. * @hidden
  40077. * Defines the actions happening just after the active camera has been drawn.
  40078. */
  40079. _afterCameraDrawStage: Stage<CameraStageAction>;
  40080. /**
  40081. * @hidden
  40082. * Defines the actions happening just after a render target has been drawn.
  40083. */
  40084. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40085. /**
  40086. * @hidden
  40087. * Defines the actions happening just after rendering all cameras and computing intersections.
  40088. */
  40089. _afterRenderStage: Stage<SimpleStageAction>;
  40090. /**
  40091. * @hidden
  40092. * Defines the actions happening when a pointer move event happens.
  40093. */
  40094. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40095. /**
  40096. * @hidden
  40097. * Defines the actions happening when a pointer down event happens.
  40098. */
  40099. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40100. /**
  40101. * @hidden
  40102. * Defines the actions happening when a pointer up event happens.
  40103. */
  40104. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40105. /**
  40106. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40107. */
  40108. private geometriesByUniqueId;
  40109. /**
  40110. * Creates a new Scene
  40111. * @param engine defines the engine to use to render this scene
  40112. * @param options defines the scene options
  40113. */
  40114. constructor(engine: Engine, options?: SceneOptions);
  40115. /**
  40116. * Gets a string idenfifying the name of the class
  40117. * @returns "Scene" string
  40118. */
  40119. getClassName(): string;
  40120. private _defaultMeshCandidates;
  40121. /**
  40122. * @hidden
  40123. */
  40124. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40125. private _defaultSubMeshCandidates;
  40126. /**
  40127. * @hidden
  40128. */
  40129. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40130. /**
  40131. * Sets the default candidate providers for the scene.
  40132. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40133. * and getCollidingSubMeshCandidates to their default function
  40134. */
  40135. setDefaultCandidateProviders(): void;
  40136. /**
  40137. * Gets the mesh that is currently under the pointer
  40138. */
  40139. get meshUnderPointer(): Nullable<AbstractMesh>;
  40140. /**
  40141. * Gets or sets the current on-screen X position of the pointer
  40142. */
  40143. get pointerX(): number;
  40144. set pointerX(value: number);
  40145. /**
  40146. * Gets or sets the current on-screen Y position of the pointer
  40147. */
  40148. get pointerY(): number;
  40149. set pointerY(value: number);
  40150. /**
  40151. * Gets the cached material (ie. the latest rendered one)
  40152. * @returns the cached material
  40153. */
  40154. getCachedMaterial(): Nullable<Material>;
  40155. /**
  40156. * Gets the cached effect (ie. the latest rendered one)
  40157. * @returns the cached effect
  40158. */
  40159. getCachedEffect(): Nullable<Effect>;
  40160. /**
  40161. * Gets the cached visibility state (ie. the latest rendered one)
  40162. * @returns the cached visibility state
  40163. */
  40164. getCachedVisibility(): Nullable<number>;
  40165. /**
  40166. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40167. * @param material defines the current material
  40168. * @param effect defines the current effect
  40169. * @param visibility defines the current visibility state
  40170. * @returns true if one parameter is not cached
  40171. */
  40172. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40173. /**
  40174. * Gets the engine associated with the scene
  40175. * @returns an Engine
  40176. */
  40177. getEngine(): Engine;
  40178. /**
  40179. * Gets the total number of vertices rendered per frame
  40180. * @returns the total number of vertices rendered per frame
  40181. */
  40182. getTotalVertices(): number;
  40183. /**
  40184. * Gets the performance counter for total vertices
  40185. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40186. */
  40187. get totalVerticesPerfCounter(): PerfCounter;
  40188. /**
  40189. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40190. * @returns the total number of active indices rendered per frame
  40191. */
  40192. getActiveIndices(): number;
  40193. /**
  40194. * Gets the performance counter for active indices
  40195. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40196. */
  40197. get totalActiveIndicesPerfCounter(): PerfCounter;
  40198. /**
  40199. * Gets the total number of active particles rendered per frame
  40200. * @returns the total number of active particles rendered per frame
  40201. */
  40202. getActiveParticles(): number;
  40203. /**
  40204. * Gets the performance counter for active particles
  40205. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40206. */
  40207. get activeParticlesPerfCounter(): PerfCounter;
  40208. /**
  40209. * Gets the total number of active bones rendered per frame
  40210. * @returns the total number of active bones rendered per frame
  40211. */
  40212. getActiveBones(): number;
  40213. /**
  40214. * Gets the performance counter for active bones
  40215. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40216. */
  40217. get activeBonesPerfCounter(): PerfCounter;
  40218. /**
  40219. * Gets the array of active meshes
  40220. * @returns an array of AbstractMesh
  40221. */
  40222. getActiveMeshes(): SmartArray<AbstractMesh>;
  40223. /**
  40224. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40225. * @returns a number
  40226. */
  40227. getAnimationRatio(): number;
  40228. /**
  40229. * Gets an unique Id for the current render phase
  40230. * @returns a number
  40231. */
  40232. getRenderId(): number;
  40233. /**
  40234. * Gets an unique Id for the current frame
  40235. * @returns a number
  40236. */
  40237. getFrameId(): number;
  40238. /** Call this function if you want to manually increment the render Id*/
  40239. incrementRenderId(): void;
  40240. private _createUbo;
  40241. /**
  40242. * Use this method to simulate a pointer move on a mesh
  40243. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40244. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40245. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40246. * @returns the current scene
  40247. */
  40248. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40249. /**
  40250. * Use this method to simulate a pointer down on a mesh
  40251. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40252. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40253. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40254. * @returns the current scene
  40255. */
  40256. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40257. /**
  40258. * Use this method to simulate a pointer up on a mesh
  40259. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40260. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40261. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40262. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40263. * @returns the current scene
  40264. */
  40265. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40266. /**
  40267. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40268. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40269. * @returns true if the pointer was captured
  40270. */
  40271. isPointerCaptured(pointerId?: number): boolean;
  40272. /**
  40273. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40274. * @param attachUp defines if you want to attach events to pointerup
  40275. * @param attachDown defines if you want to attach events to pointerdown
  40276. * @param attachMove defines if you want to attach events to pointermove
  40277. */
  40278. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40279. /** Detaches all event handlers*/
  40280. detachControl(): void;
  40281. /**
  40282. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40283. * Delay loaded resources are not taking in account
  40284. * @return true if all required resources are ready
  40285. */
  40286. isReady(): boolean;
  40287. /** Resets all cached information relative to material (including effect and visibility) */
  40288. resetCachedMaterial(): void;
  40289. /**
  40290. * Registers a function to be called before every frame render
  40291. * @param func defines the function to register
  40292. */
  40293. registerBeforeRender(func: () => void): void;
  40294. /**
  40295. * Unregisters a function called before every frame render
  40296. * @param func defines the function to unregister
  40297. */
  40298. unregisterBeforeRender(func: () => void): void;
  40299. /**
  40300. * Registers a function to be called after every frame render
  40301. * @param func defines the function to register
  40302. */
  40303. registerAfterRender(func: () => void): void;
  40304. /**
  40305. * Unregisters a function called after every frame render
  40306. * @param func defines the function to unregister
  40307. */
  40308. unregisterAfterRender(func: () => void): void;
  40309. private _executeOnceBeforeRender;
  40310. /**
  40311. * The provided function will run before render once and will be disposed afterwards.
  40312. * A timeout delay can be provided so that the function will be executed in N ms.
  40313. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40314. * @param func The function to be executed.
  40315. * @param timeout optional delay in ms
  40316. */
  40317. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40318. /** @hidden */
  40319. _addPendingData(data: any): void;
  40320. /** @hidden */
  40321. _removePendingData(data: any): void;
  40322. /**
  40323. * Returns the number of items waiting to be loaded
  40324. * @returns the number of items waiting to be loaded
  40325. */
  40326. getWaitingItemsCount(): number;
  40327. /**
  40328. * Returns a boolean indicating if the scene is still loading data
  40329. */
  40330. get isLoading(): boolean;
  40331. /**
  40332. * Registers a function to be executed when the scene is ready
  40333. * @param {Function} func - the function to be executed
  40334. */
  40335. executeWhenReady(func: () => void): void;
  40336. /**
  40337. * Returns a promise that resolves when the scene is ready
  40338. * @returns A promise that resolves when the scene is ready
  40339. */
  40340. whenReadyAsync(): Promise<void>;
  40341. /** @hidden */
  40342. _checkIsReady(): void;
  40343. /**
  40344. * Gets all animatable attached to the scene
  40345. */
  40346. get animatables(): Animatable[];
  40347. /**
  40348. * Resets the last animation time frame.
  40349. * Useful to override when animations start running when loading a scene for the first time.
  40350. */
  40351. resetLastAnimationTimeFrame(): void;
  40352. /**
  40353. * Gets the current view matrix
  40354. * @returns a Matrix
  40355. */
  40356. getViewMatrix(): Matrix;
  40357. /**
  40358. * Gets the current projection matrix
  40359. * @returns a Matrix
  40360. */
  40361. getProjectionMatrix(): Matrix;
  40362. /**
  40363. * Gets the current transform matrix
  40364. * @returns a Matrix made of View * Projection
  40365. */
  40366. getTransformMatrix(): Matrix;
  40367. /**
  40368. * Sets the current transform matrix
  40369. * @param viewL defines the View matrix to use
  40370. * @param projectionL defines the Projection matrix to use
  40371. * @param viewR defines the right View matrix to use (if provided)
  40372. * @param projectionR defines the right Projection matrix to use (if provided)
  40373. */
  40374. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40375. /**
  40376. * Gets the uniform buffer used to store scene data
  40377. * @returns a UniformBuffer
  40378. */
  40379. getSceneUniformBuffer(): UniformBuffer;
  40380. /**
  40381. * Gets an unique (relatively to the current scene) Id
  40382. * @returns an unique number for the scene
  40383. */
  40384. getUniqueId(): number;
  40385. /**
  40386. * Add a mesh to the list of scene's meshes
  40387. * @param newMesh defines the mesh to add
  40388. * @param recursive if all child meshes should also be added to the scene
  40389. */
  40390. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40391. /**
  40392. * Remove a mesh for the list of scene's meshes
  40393. * @param toRemove defines the mesh to remove
  40394. * @param recursive if all child meshes should also be removed from the scene
  40395. * @returns the index where the mesh was in the mesh list
  40396. */
  40397. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40398. /**
  40399. * Add a transform node to the list of scene's transform nodes
  40400. * @param newTransformNode defines the transform node to add
  40401. */
  40402. addTransformNode(newTransformNode: TransformNode): void;
  40403. /**
  40404. * Remove a transform node for the list of scene's transform nodes
  40405. * @param toRemove defines the transform node to remove
  40406. * @returns the index where the transform node was in the transform node list
  40407. */
  40408. removeTransformNode(toRemove: TransformNode): number;
  40409. /**
  40410. * Remove a skeleton for the list of scene's skeletons
  40411. * @param toRemove defines the skeleton to remove
  40412. * @returns the index where the skeleton was in the skeleton list
  40413. */
  40414. removeSkeleton(toRemove: Skeleton): number;
  40415. /**
  40416. * Remove a morph target for the list of scene's morph targets
  40417. * @param toRemove defines the morph target to remove
  40418. * @returns the index where the morph target was in the morph target list
  40419. */
  40420. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40421. /**
  40422. * Remove a light for the list of scene's lights
  40423. * @param toRemove defines the light to remove
  40424. * @returns the index where the light was in the light list
  40425. */
  40426. removeLight(toRemove: Light): number;
  40427. /**
  40428. * Remove a camera for the list of scene's cameras
  40429. * @param toRemove defines the camera to remove
  40430. * @returns the index where the camera was in the camera list
  40431. */
  40432. removeCamera(toRemove: Camera): number;
  40433. /**
  40434. * Remove a particle system for the list of scene's particle systems
  40435. * @param toRemove defines the particle system to remove
  40436. * @returns the index where the particle system was in the particle system list
  40437. */
  40438. removeParticleSystem(toRemove: IParticleSystem): number;
  40439. /**
  40440. * Remove a animation for the list of scene's animations
  40441. * @param toRemove defines the animation to remove
  40442. * @returns the index where the animation was in the animation list
  40443. */
  40444. removeAnimation(toRemove: Animation): number;
  40445. /**
  40446. * Will stop the animation of the given target
  40447. * @param target - the target
  40448. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40449. * @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)
  40450. */
  40451. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40452. /**
  40453. * Removes the given animation group from this scene.
  40454. * @param toRemove The animation group to remove
  40455. * @returns The index of the removed animation group
  40456. */
  40457. removeAnimationGroup(toRemove: AnimationGroup): number;
  40458. /**
  40459. * Removes the given multi-material from this scene.
  40460. * @param toRemove The multi-material to remove
  40461. * @returns The index of the removed multi-material
  40462. */
  40463. removeMultiMaterial(toRemove: MultiMaterial): number;
  40464. /**
  40465. * Removes the given material from this scene.
  40466. * @param toRemove The material to remove
  40467. * @returns The index of the removed material
  40468. */
  40469. removeMaterial(toRemove: Material): number;
  40470. /**
  40471. * Removes the given action manager from this scene.
  40472. * @param toRemove The action manager to remove
  40473. * @returns The index of the removed action manager
  40474. */
  40475. removeActionManager(toRemove: AbstractActionManager): number;
  40476. /**
  40477. * Removes the given texture from this scene.
  40478. * @param toRemove The texture to remove
  40479. * @returns The index of the removed texture
  40480. */
  40481. removeTexture(toRemove: BaseTexture): number;
  40482. /**
  40483. * Adds the given light to this scene
  40484. * @param newLight The light to add
  40485. */
  40486. addLight(newLight: Light): void;
  40487. /**
  40488. * Sorts the list list based on light priorities
  40489. */
  40490. sortLightsByPriority(): void;
  40491. /**
  40492. * Adds the given camera to this scene
  40493. * @param newCamera The camera to add
  40494. */
  40495. addCamera(newCamera: Camera): void;
  40496. /**
  40497. * Adds the given skeleton to this scene
  40498. * @param newSkeleton The skeleton to add
  40499. */
  40500. addSkeleton(newSkeleton: Skeleton): void;
  40501. /**
  40502. * Adds the given particle system to this scene
  40503. * @param newParticleSystem The particle system to add
  40504. */
  40505. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40506. /**
  40507. * Adds the given animation to this scene
  40508. * @param newAnimation The animation to add
  40509. */
  40510. addAnimation(newAnimation: Animation): void;
  40511. /**
  40512. * Adds the given animation group to this scene.
  40513. * @param newAnimationGroup The animation group to add
  40514. */
  40515. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40516. /**
  40517. * Adds the given multi-material to this scene
  40518. * @param newMultiMaterial The multi-material to add
  40519. */
  40520. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40521. /**
  40522. * Adds the given material to this scene
  40523. * @param newMaterial The material to add
  40524. */
  40525. addMaterial(newMaterial: Material): void;
  40526. /**
  40527. * Adds the given morph target to this scene
  40528. * @param newMorphTargetManager The morph target to add
  40529. */
  40530. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40531. /**
  40532. * Adds the given geometry to this scene
  40533. * @param newGeometry The geometry to add
  40534. */
  40535. addGeometry(newGeometry: Geometry): void;
  40536. /**
  40537. * Adds the given action manager to this scene
  40538. * @param newActionManager The action manager to add
  40539. */
  40540. addActionManager(newActionManager: AbstractActionManager): void;
  40541. /**
  40542. * Adds the given texture to this scene.
  40543. * @param newTexture The texture to add
  40544. */
  40545. addTexture(newTexture: BaseTexture): void;
  40546. /**
  40547. * Switch active camera
  40548. * @param newCamera defines the new active camera
  40549. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40550. */
  40551. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40552. /**
  40553. * sets the active camera of the scene using its ID
  40554. * @param id defines the camera's ID
  40555. * @return the new active camera or null if none found.
  40556. */
  40557. setActiveCameraByID(id: string): Nullable<Camera>;
  40558. /**
  40559. * sets the active camera of the scene using its name
  40560. * @param name defines the camera's name
  40561. * @returns the new active camera or null if none found.
  40562. */
  40563. setActiveCameraByName(name: string): Nullable<Camera>;
  40564. /**
  40565. * get an animation group using its name
  40566. * @param name defines the material's name
  40567. * @return the animation group or null if none found.
  40568. */
  40569. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40570. /**
  40571. * Get a material using its unique id
  40572. * @param uniqueId defines the material's unique id
  40573. * @return the material or null if none found.
  40574. */
  40575. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40576. /**
  40577. * get a material using its id
  40578. * @param id defines the material's ID
  40579. * @return the material or null if none found.
  40580. */
  40581. getMaterialByID(id: string): Nullable<Material>;
  40582. /**
  40583. * Gets a the last added material using a given id
  40584. * @param id defines the material's ID
  40585. * @return the last material with the given id or null if none found.
  40586. */
  40587. getLastMaterialByID(id: string): Nullable<Material>;
  40588. /**
  40589. * Gets a material using its name
  40590. * @param name defines the material's name
  40591. * @return the material or null if none found.
  40592. */
  40593. getMaterialByName(name: string): Nullable<Material>;
  40594. /**
  40595. * Get a texture using its unique id
  40596. * @param uniqueId defines the texture's unique id
  40597. * @return the texture or null if none found.
  40598. */
  40599. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40600. /**
  40601. * Gets a camera using its id
  40602. * @param id defines the id to look for
  40603. * @returns the camera or null if not found
  40604. */
  40605. getCameraByID(id: string): Nullable<Camera>;
  40606. /**
  40607. * Gets a camera using its unique id
  40608. * @param uniqueId defines the unique id to look for
  40609. * @returns the camera or null if not found
  40610. */
  40611. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40612. /**
  40613. * Gets a camera using its name
  40614. * @param name defines the camera's name
  40615. * @return the camera or null if none found.
  40616. */
  40617. getCameraByName(name: string): Nullable<Camera>;
  40618. /**
  40619. * Gets a bone using its id
  40620. * @param id defines the bone's id
  40621. * @return the bone or null if not found
  40622. */
  40623. getBoneByID(id: string): Nullable<Bone>;
  40624. /**
  40625. * Gets a bone using its id
  40626. * @param name defines the bone's name
  40627. * @return the bone or null if not found
  40628. */
  40629. getBoneByName(name: string): Nullable<Bone>;
  40630. /**
  40631. * Gets a light node using its name
  40632. * @param name defines the the light's name
  40633. * @return the light or null if none found.
  40634. */
  40635. getLightByName(name: string): Nullable<Light>;
  40636. /**
  40637. * Gets a light node using its id
  40638. * @param id defines the light's id
  40639. * @return the light or null if none found.
  40640. */
  40641. getLightByID(id: string): Nullable<Light>;
  40642. /**
  40643. * Gets a light node using its scene-generated unique ID
  40644. * @param uniqueId defines the light's unique id
  40645. * @return the light or null if none found.
  40646. */
  40647. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40648. /**
  40649. * Gets a particle system by id
  40650. * @param id defines the particle system id
  40651. * @return the corresponding system or null if none found
  40652. */
  40653. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40654. /**
  40655. * Gets a geometry using its ID
  40656. * @param id defines the geometry's id
  40657. * @return the geometry or null if none found.
  40658. */
  40659. getGeometryByID(id: string): Nullable<Geometry>;
  40660. private _getGeometryByUniqueID;
  40661. /**
  40662. * Add a new geometry to this scene
  40663. * @param geometry defines the geometry to be added to the scene.
  40664. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40665. * @return a boolean defining if the geometry was added or not
  40666. */
  40667. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40668. /**
  40669. * Removes an existing geometry
  40670. * @param geometry defines the geometry to be removed from the scene
  40671. * @return a boolean defining if the geometry was removed or not
  40672. */
  40673. removeGeometry(geometry: Geometry): boolean;
  40674. /**
  40675. * Gets the list of geometries attached to the scene
  40676. * @returns an array of Geometry
  40677. */
  40678. getGeometries(): Geometry[];
  40679. /**
  40680. * Gets the first added mesh found of a given ID
  40681. * @param id defines the id to search for
  40682. * @return the mesh found or null if not found at all
  40683. */
  40684. getMeshByID(id: string): Nullable<AbstractMesh>;
  40685. /**
  40686. * Gets a list of meshes using their id
  40687. * @param id defines the id to search for
  40688. * @returns a list of meshes
  40689. */
  40690. getMeshesByID(id: string): Array<AbstractMesh>;
  40691. /**
  40692. * Gets the first added transform node found of a given ID
  40693. * @param id defines the id to search for
  40694. * @return the found transform node or null if not found at all.
  40695. */
  40696. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40697. /**
  40698. * Gets a transform node with its auto-generated unique id
  40699. * @param uniqueId efines the unique id to search for
  40700. * @return the found transform node or null if not found at all.
  40701. */
  40702. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40703. /**
  40704. * Gets a list of transform nodes using their id
  40705. * @param id defines the id to search for
  40706. * @returns a list of transform nodes
  40707. */
  40708. getTransformNodesByID(id: string): Array<TransformNode>;
  40709. /**
  40710. * Gets a mesh with its auto-generated unique id
  40711. * @param uniqueId defines the unique id to search for
  40712. * @return the found mesh or null if not found at all.
  40713. */
  40714. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40715. /**
  40716. * Gets a the last added mesh using a given id
  40717. * @param id defines the id to search for
  40718. * @return the found mesh or null if not found at all.
  40719. */
  40720. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40721. /**
  40722. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40723. * @param id defines the id to search for
  40724. * @return the found node or null if not found at all
  40725. */
  40726. getLastEntryByID(id: string): Nullable<Node>;
  40727. /**
  40728. * Gets a node (Mesh, Camera, Light) using a given id
  40729. * @param id defines the id to search for
  40730. * @return the found node or null if not found at all
  40731. */
  40732. getNodeByID(id: string): Nullable<Node>;
  40733. /**
  40734. * Gets a node (Mesh, Camera, Light) using a given name
  40735. * @param name defines the name to search for
  40736. * @return the found node or null if not found at all.
  40737. */
  40738. getNodeByName(name: string): Nullable<Node>;
  40739. /**
  40740. * Gets a mesh using a given name
  40741. * @param name defines the name to search for
  40742. * @return the found mesh or null if not found at all.
  40743. */
  40744. getMeshByName(name: string): Nullable<AbstractMesh>;
  40745. /**
  40746. * Gets a transform node using a given name
  40747. * @param name defines the name to search for
  40748. * @return the found transform node or null if not found at all.
  40749. */
  40750. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40751. /**
  40752. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40753. * @param id defines the id to search for
  40754. * @return the found skeleton or null if not found at all.
  40755. */
  40756. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40757. /**
  40758. * Gets a skeleton using a given auto generated unique id
  40759. * @param uniqueId defines the unique id to search for
  40760. * @return the found skeleton or null if not found at all.
  40761. */
  40762. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40763. /**
  40764. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40765. * @param id defines the id to search for
  40766. * @return the found skeleton or null if not found at all.
  40767. */
  40768. getSkeletonById(id: string): Nullable<Skeleton>;
  40769. /**
  40770. * Gets a skeleton using a given name
  40771. * @param name defines the name to search for
  40772. * @return the found skeleton or null if not found at all.
  40773. */
  40774. getSkeletonByName(name: string): Nullable<Skeleton>;
  40775. /**
  40776. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40777. * @param id defines the id to search for
  40778. * @return the found morph target manager or null if not found at all.
  40779. */
  40780. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40781. /**
  40782. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40783. * @param id defines the id to search for
  40784. * @return the found morph target or null if not found at all.
  40785. */
  40786. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40787. /**
  40788. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40789. * @param name defines the name to search for
  40790. * @return the found morph target or null if not found at all.
  40791. */
  40792. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40793. /**
  40794. * Gets a boolean indicating if the given mesh is active
  40795. * @param mesh defines the mesh to look for
  40796. * @returns true if the mesh is in the active list
  40797. */
  40798. isActiveMesh(mesh: AbstractMesh): boolean;
  40799. /**
  40800. * Return a unique id as a string which can serve as an identifier for the scene
  40801. */
  40802. get uid(): string;
  40803. /**
  40804. * Add an externaly attached data from its key.
  40805. * This method call will fail and return false, if such key already exists.
  40806. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40807. * @param key the unique key that identifies the data
  40808. * @param data the data object to associate to the key for this Engine instance
  40809. * @return true if no such key were already present and the data was added successfully, false otherwise
  40810. */
  40811. addExternalData<T>(key: string, data: T): boolean;
  40812. /**
  40813. * Get an externaly attached data from its key
  40814. * @param key the unique key that identifies the data
  40815. * @return the associated data, if present (can be null), or undefined if not present
  40816. */
  40817. getExternalData<T>(key: string): Nullable<T>;
  40818. /**
  40819. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40820. * @param key the unique key that identifies the data
  40821. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40822. * @return the associated data, can be null if the factory returned null.
  40823. */
  40824. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40825. /**
  40826. * Remove an externaly attached data from the Engine instance
  40827. * @param key the unique key that identifies the data
  40828. * @return true if the data was successfully removed, false if it doesn't exist
  40829. */
  40830. removeExternalData(key: string): boolean;
  40831. private _evaluateSubMesh;
  40832. /**
  40833. * Clear the processed materials smart array preventing retention point in material dispose.
  40834. */
  40835. freeProcessedMaterials(): void;
  40836. private _preventFreeActiveMeshesAndRenderingGroups;
  40837. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40838. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40839. * when disposing several meshes in a row or a hierarchy of meshes.
  40840. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40841. */
  40842. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40843. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40844. /**
  40845. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40846. */
  40847. freeActiveMeshes(): void;
  40848. /**
  40849. * Clear the info related to rendering groups preventing retention points during dispose.
  40850. */
  40851. freeRenderingGroups(): void;
  40852. /** @hidden */
  40853. _isInIntermediateRendering(): boolean;
  40854. /**
  40855. * Lambda returning the list of potentially active meshes.
  40856. */
  40857. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40858. /**
  40859. * Lambda returning the list of potentially active sub meshes.
  40860. */
  40861. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40862. /**
  40863. * Lambda returning the list of potentially intersecting sub meshes.
  40864. */
  40865. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40866. /**
  40867. * Lambda returning the list of potentially colliding sub meshes.
  40868. */
  40869. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40870. private _activeMeshesFrozen;
  40871. private _skipEvaluateActiveMeshesCompletely;
  40872. /**
  40873. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40874. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40875. * @returns the current scene
  40876. */
  40877. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40878. /**
  40879. * Use this function to restart evaluating active meshes on every frame
  40880. * @returns the current scene
  40881. */
  40882. unfreezeActiveMeshes(): Scene;
  40883. private _evaluateActiveMeshes;
  40884. private _activeMesh;
  40885. /**
  40886. * Update the transform matrix to update from the current active camera
  40887. * @param force defines a boolean used to force the update even if cache is up to date
  40888. */
  40889. updateTransformMatrix(force?: boolean): void;
  40890. private _bindFrameBuffer;
  40891. /** @hidden */
  40892. _allowPostProcessClearColor: boolean;
  40893. /** @hidden */
  40894. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40895. private _processSubCameras;
  40896. private _checkIntersections;
  40897. /** @hidden */
  40898. _advancePhysicsEngineStep(step: number): void;
  40899. /**
  40900. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40901. */
  40902. getDeterministicFrameTime: () => number;
  40903. /** @hidden */
  40904. _animate(): void;
  40905. /** Execute all animations (for a frame) */
  40906. animate(): void;
  40907. /**
  40908. * Render the scene
  40909. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40910. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40911. */
  40912. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40913. /**
  40914. * Freeze all materials
  40915. * A frozen material will not be updatable but should be faster to render
  40916. */
  40917. freezeMaterials(): void;
  40918. /**
  40919. * Unfreeze all materials
  40920. * A frozen material will not be updatable but should be faster to render
  40921. */
  40922. unfreezeMaterials(): void;
  40923. /**
  40924. * Releases all held ressources
  40925. */
  40926. dispose(): void;
  40927. /**
  40928. * Gets if the scene is already disposed
  40929. */
  40930. get isDisposed(): boolean;
  40931. /**
  40932. * Call this function to reduce memory footprint of the scene.
  40933. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40934. */
  40935. clearCachedVertexData(): void;
  40936. /**
  40937. * This function will remove the local cached buffer data from texture.
  40938. * It will save memory but will prevent the texture from being rebuilt
  40939. */
  40940. cleanCachedTextureBuffer(): void;
  40941. /**
  40942. * Get the world extend vectors with an optional filter
  40943. *
  40944. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40945. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40946. */
  40947. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40948. min: Vector3;
  40949. max: Vector3;
  40950. };
  40951. /**
  40952. * Creates a ray that can be used to pick in the scene
  40953. * @param x defines the x coordinate of the origin (on-screen)
  40954. * @param y defines the y coordinate of the origin (on-screen)
  40955. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40956. * @param camera defines the camera to use for the picking
  40957. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40958. * @returns a Ray
  40959. */
  40960. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40961. /**
  40962. * Creates a ray that can be used to pick in the scene
  40963. * @param x defines the x coordinate of the origin (on-screen)
  40964. * @param y defines the y coordinate of the origin (on-screen)
  40965. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40966. * @param result defines the ray where to store the picking ray
  40967. * @param camera defines the camera to use for the picking
  40968. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40969. * @returns the current scene
  40970. */
  40971. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40972. /**
  40973. * Creates a ray that can be used to pick in the scene
  40974. * @param x defines the x coordinate of the origin (on-screen)
  40975. * @param y defines the y coordinate of the origin (on-screen)
  40976. * @param camera defines the camera to use for the picking
  40977. * @returns a Ray
  40978. */
  40979. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40980. /**
  40981. * Creates a ray that can be used to pick in the scene
  40982. * @param x defines the x coordinate of the origin (on-screen)
  40983. * @param y defines the y coordinate of the origin (on-screen)
  40984. * @param result defines the ray where to store the picking ray
  40985. * @param camera defines the camera to use for the picking
  40986. * @returns the current scene
  40987. */
  40988. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40989. /** Launch a ray to try to pick a mesh in the scene
  40990. * @param x position on screen
  40991. * @param y position on screen
  40992. * @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
  40993. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40994. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40995. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40996. * @returns a PickingInfo
  40997. */
  40998. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40999. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41000. * @param x position on screen
  41001. * @param y position on screen
  41002. * @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
  41003. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41004. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41005. * @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)
  41006. */
  41007. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41008. /** Use the given ray to pick a mesh in the scene
  41009. * @param ray The ray to use to pick meshes
  41010. * @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
  41011. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41012. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41013. * @returns a PickingInfo
  41014. */
  41015. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41016. /**
  41017. * Launch a ray to try to pick a mesh in the scene
  41018. * @param x X position on screen
  41019. * @param y Y position on screen
  41020. * @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
  41021. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41022. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41023. * @returns an array of PickingInfo
  41024. */
  41025. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41026. /**
  41027. * Launch a ray to try to pick a mesh in the scene
  41028. * @param ray Ray to use
  41029. * @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
  41030. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41031. * @returns an array of PickingInfo
  41032. */
  41033. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41034. /**
  41035. * Force the value of meshUnderPointer
  41036. * @param mesh defines the mesh to use
  41037. */
  41038. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41039. /**
  41040. * Gets the mesh under the pointer
  41041. * @returns a Mesh or null if no mesh is under the pointer
  41042. */
  41043. getPointerOverMesh(): Nullable<AbstractMesh>;
  41044. /** @hidden */
  41045. _rebuildGeometries(): void;
  41046. /** @hidden */
  41047. _rebuildTextures(): void;
  41048. private _getByTags;
  41049. /**
  41050. * Get a list of meshes by tags
  41051. * @param tagsQuery defines the tags query to use
  41052. * @param forEach defines a predicate used to filter results
  41053. * @returns an array of Mesh
  41054. */
  41055. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41056. /**
  41057. * Get a list of cameras by tags
  41058. * @param tagsQuery defines the tags query to use
  41059. * @param forEach defines a predicate used to filter results
  41060. * @returns an array of Camera
  41061. */
  41062. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41063. /**
  41064. * Get a list of lights by tags
  41065. * @param tagsQuery defines the tags query to use
  41066. * @param forEach defines a predicate used to filter results
  41067. * @returns an array of Light
  41068. */
  41069. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41070. /**
  41071. * Get a list of materials by tags
  41072. * @param tagsQuery defines the tags query to use
  41073. * @param forEach defines a predicate used to filter results
  41074. * @returns an array of Material
  41075. */
  41076. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41077. /**
  41078. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41079. * This allowed control for front to back rendering or reversly depending of the special needs.
  41080. *
  41081. * @param renderingGroupId The rendering group id corresponding to its index
  41082. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41083. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41084. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41085. */
  41086. 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;
  41087. /**
  41088. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41089. *
  41090. * @param renderingGroupId The rendering group id corresponding to its index
  41091. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41092. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41093. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41094. */
  41095. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41096. /**
  41097. * Gets the current auto clear configuration for one rendering group of the rendering
  41098. * manager.
  41099. * @param index the rendering group index to get the information for
  41100. * @returns The auto clear setup for the requested rendering group
  41101. */
  41102. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41103. private _blockMaterialDirtyMechanism;
  41104. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41105. get blockMaterialDirtyMechanism(): boolean;
  41106. set blockMaterialDirtyMechanism(value: boolean);
  41107. /**
  41108. * Will flag all materials as dirty to trigger new shader compilation
  41109. * @param flag defines the flag used to specify which material part must be marked as dirty
  41110. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41111. */
  41112. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41113. /** @hidden */
  41114. _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;
  41115. /** @hidden */
  41116. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41117. /** @hidden */
  41118. _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;
  41119. /** @hidden */
  41120. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41121. /** @hidden */
  41122. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41123. /** @hidden */
  41124. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41125. }
  41126. }
  41127. declare module BABYLON {
  41128. /**
  41129. * Set of assets to keep when moving a scene into an asset container.
  41130. */
  41131. export class KeepAssets extends AbstractScene {
  41132. }
  41133. /**
  41134. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41135. */
  41136. export class InstantiatedEntries {
  41137. /**
  41138. * List of new root nodes (eg. nodes with no parent)
  41139. */
  41140. rootNodes: TransformNode[];
  41141. /**
  41142. * List of new skeletons
  41143. */
  41144. skeletons: Skeleton[];
  41145. /**
  41146. * List of new animation groups
  41147. */
  41148. animationGroups: AnimationGroup[];
  41149. }
  41150. /**
  41151. * Container with a set of assets that can be added or removed from a scene.
  41152. */
  41153. export class AssetContainer extends AbstractScene {
  41154. private _wasAddedToScene;
  41155. /**
  41156. * The scene the AssetContainer belongs to.
  41157. */
  41158. scene: Scene;
  41159. /**
  41160. * Instantiates an AssetContainer.
  41161. * @param scene The scene the AssetContainer belongs to.
  41162. */
  41163. constructor(scene: Scene);
  41164. /**
  41165. * Instantiate or clone all meshes and add the new ones to the scene.
  41166. * Skeletons and animation groups will all be cloned
  41167. * @param nameFunction defines an optional function used to get new names for clones
  41168. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41169. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41170. */
  41171. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41172. /**
  41173. * Adds all the assets from the container to the scene.
  41174. */
  41175. addAllToScene(): void;
  41176. /**
  41177. * Removes all the assets in the container from the scene
  41178. */
  41179. removeAllFromScene(): void;
  41180. /**
  41181. * Disposes all the assets in the container
  41182. */
  41183. dispose(): void;
  41184. private _moveAssets;
  41185. /**
  41186. * Removes all the assets contained in the scene and adds them to the container.
  41187. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41188. */
  41189. moveAllFromScene(keepAssets?: KeepAssets): void;
  41190. /**
  41191. * 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.
  41192. * @returns the root mesh
  41193. */
  41194. createRootMesh(): Mesh;
  41195. /**
  41196. * Merge animations (direct and animation groups) from this asset container into a scene
  41197. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41198. * @param animatables set of animatables to retarget to a node from the scene
  41199. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41200. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41201. */
  41202. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41203. }
  41204. }
  41205. declare module BABYLON {
  41206. /**
  41207. * Defines how the parser contract is defined.
  41208. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41209. */
  41210. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41211. /**
  41212. * Defines how the individual parser contract is defined.
  41213. * These parser can parse an individual asset
  41214. */
  41215. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41216. /**
  41217. * Base class of the scene acting as a container for the different elements composing a scene.
  41218. * This class is dynamically extended by the different components of the scene increasing
  41219. * flexibility and reducing coupling
  41220. */
  41221. export abstract class AbstractScene {
  41222. /**
  41223. * Stores the list of available parsers in the application.
  41224. */
  41225. private static _BabylonFileParsers;
  41226. /**
  41227. * Stores the list of available individual parsers in the application.
  41228. */
  41229. private static _IndividualBabylonFileParsers;
  41230. /**
  41231. * Adds a parser in the list of available ones
  41232. * @param name Defines the name of the parser
  41233. * @param parser Defines the parser to add
  41234. */
  41235. static AddParser(name: string, parser: BabylonFileParser): void;
  41236. /**
  41237. * Gets a general parser from the list of avaialble ones
  41238. * @param name Defines the name of the parser
  41239. * @returns the requested parser or null
  41240. */
  41241. static GetParser(name: string): Nullable<BabylonFileParser>;
  41242. /**
  41243. * Adds n individual parser in the list of available ones
  41244. * @param name Defines the name of the parser
  41245. * @param parser Defines the parser to add
  41246. */
  41247. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41248. /**
  41249. * Gets an individual parser from the list of avaialble ones
  41250. * @param name Defines the name of the parser
  41251. * @returns the requested parser or null
  41252. */
  41253. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41254. /**
  41255. * Parser json data and populate both a scene and its associated container object
  41256. * @param jsonData Defines the data to parse
  41257. * @param scene Defines the scene to parse the data for
  41258. * @param container Defines the container attached to the parsing sequence
  41259. * @param rootUrl Defines the root url of the data
  41260. */
  41261. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41262. /**
  41263. * Gets the list of root nodes (ie. nodes with no parent)
  41264. */
  41265. rootNodes: Node[];
  41266. /** All of the cameras added to this scene
  41267. * @see https://doc.babylonjs.com/babylon101/cameras
  41268. */
  41269. cameras: Camera[];
  41270. /**
  41271. * All of the lights added to this scene
  41272. * @see https://doc.babylonjs.com/babylon101/lights
  41273. */
  41274. lights: Light[];
  41275. /**
  41276. * All of the (abstract) meshes added to this scene
  41277. */
  41278. meshes: AbstractMesh[];
  41279. /**
  41280. * The list of skeletons added to the scene
  41281. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41282. */
  41283. skeletons: Skeleton[];
  41284. /**
  41285. * All of the particle systems added to this scene
  41286. * @see https://doc.babylonjs.com/babylon101/particles
  41287. */
  41288. particleSystems: IParticleSystem[];
  41289. /**
  41290. * Gets a list of Animations associated with the scene
  41291. */
  41292. animations: Animation[];
  41293. /**
  41294. * All of the animation groups added to this scene
  41295. * @see https://doc.babylonjs.com/how_to/group
  41296. */
  41297. animationGroups: AnimationGroup[];
  41298. /**
  41299. * All of the multi-materials added to this scene
  41300. * @see https://doc.babylonjs.com/how_to/multi_materials
  41301. */
  41302. multiMaterials: MultiMaterial[];
  41303. /**
  41304. * All of the materials added to this scene
  41305. * In the context of a Scene, it is not supposed to be modified manually.
  41306. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41307. * Note also that the order of the Material within the array is not significant and might change.
  41308. * @see https://doc.babylonjs.com/babylon101/materials
  41309. */
  41310. materials: Material[];
  41311. /**
  41312. * The list of morph target managers added to the scene
  41313. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41314. */
  41315. morphTargetManagers: MorphTargetManager[];
  41316. /**
  41317. * The list of geometries used in the scene.
  41318. */
  41319. geometries: Geometry[];
  41320. /**
  41321. * All of the tranform nodes added to this scene
  41322. * In the context of a Scene, it is not supposed to be modified manually.
  41323. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41324. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41325. * @see https://doc.babylonjs.com/how_to/transformnode
  41326. */
  41327. transformNodes: TransformNode[];
  41328. /**
  41329. * ActionManagers available on the scene.
  41330. */
  41331. actionManagers: AbstractActionManager[];
  41332. /**
  41333. * Textures to keep.
  41334. */
  41335. textures: BaseTexture[];
  41336. /**
  41337. * Environment texture for the scene
  41338. */
  41339. environmentTexture: Nullable<BaseTexture>;
  41340. /**
  41341. * @returns all meshes, lights, cameras, transformNodes and bones
  41342. */
  41343. getNodes(): Array<Node>;
  41344. }
  41345. }
  41346. declare module BABYLON {
  41347. /**
  41348. * Interface used to define options for Sound class
  41349. */
  41350. export interface ISoundOptions {
  41351. /**
  41352. * Does the sound autoplay once loaded.
  41353. */
  41354. autoplay?: boolean;
  41355. /**
  41356. * Does the sound loop after it finishes playing once.
  41357. */
  41358. loop?: boolean;
  41359. /**
  41360. * Sound's volume
  41361. */
  41362. volume?: number;
  41363. /**
  41364. * Is it a spatial sound?
  41365. */
  41366. spatialSound?: boolean;
  41367. /**
  41368. * Maximum distance to hear that sound
  41369. */
  41370. maxDistance?: number;
  41371. /**
  41372. * Uses user defined attenuation function
  41373. */
  41374. useCustomAttenuation?: boolean;
  41375. /**
  41376. * Define the roll off factor of spatial sounds.
  41377. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41378. */
  41379. rolloffFactor?: number;
  41380. /**
  41381. * Define the reference distance the sound should be heard perfectly.
  41382. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41383. */
  41384. refDistance?: number;
  41385. /**
  41386. * Define the distance attenuation model the sound will follow.
  41387. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41388. */
  41389. distanceModel?: string;
  41390. /**
  41391. * Defines the playback speed (1 by default)
  41392. */
  41393. playbackRate?: number;
  41394. /**
  41395. * Defines if the sound is from a streaming source
  41396. */
  41397. streaming?: boolean;
  41398. /**
  41399. * Defines an optional length (in seconds) inside the sound file
  41400. */
  41401. length?: number;
  41402. /**
  41403. * Defines an optional offset (in seconds) inside the sound file
  41404. */
  41405. offset?: number;
  41406. /**
  41407. * If true, URLs will not be required to state the audio file codec to use.
  41408. */
  41409. skipCodecCheck?: boolean;
  41410. }
  41411. /**
  41412. * Defines a sound that can be played in the application.
  41413. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41414. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41415. */
  41416. export class Sound {
  41417. /**
  41418. * The name of the sound in the scene.
  41419. */
  41420. name: string;
  41421. /**
  41422. * Does the sound autoplay once loaded.
  41423. */
  41424. autoplay: boolean;
  41425. /**
  41426. * Does the sound loop after it finishes playing once.
  41427. */
  41428. loop: boolean;
  41429. /**
  41430. * Does the sound use a custom attenuation curve to simulate the falloff
  41431. * happening when the source gets further away from the camera.
  41432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41433. */
  41434. useCustomAttenuation: boolean;
  41435. /**
  41436. * The sound track id this sound belongs to.
  41437. */
  41438. soundTrackId: number;
  41439. /**
  41440. * Is this sound currently played.
  41441. */
  41442. isPlaying: boolean;
  41443. /**
  41444. * Is this sound currently paused.
  41445. */
  41446. isPaused: boolean;
  41447. /**
  41448. * Does this sound enables spatial sound.
  41449. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41450. */
  41451. spatialSound: boolean;
  41452. /**
  41453. * Define the reference distance the sound should be heard perfectly.
  41454. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41455. */
  41456. refDistance: number;
  41457. /**
  41458. * Define the roll off factor of spatial sounds.
  41459. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41460. */
  41461. rolloffFactor: number;
  41462. /**
  41463. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41465. */
  41466. maxDistance: number;
  41467. /**
  41468. * Define the distance attenuation model the sound will follow.
  41469. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41470. */
  41471. distanceModel: string;
  41472. /**
  41473. * @hidden
  41474. * Back Compat
  41475. **/
  41476. onended: () => any;
  41477. /**
  41478. * Gets or sets an object used to store user defined information for the sound.
  41479. */
  41480. metadata: any;
  41481. /**
  41482. * Observable event when the current playing sound finishes.
  41483. */
  41484. onEndedObservable: Observable<Sound>;
  41485. private _panningModel;
  41486. private _playbackRate;
  41487. private _streaming;
  41488. private _startTime;
  41489. private _startOffset;
  41490. private _position;
  41491. /** @hidden */
  41492. _positionInEmitterSpace: boolean;
  41493. private _localDirection;
  41494. private _volume;
  41495. private _isReadyToPlay;
  41496. private _isDirectional;
  41497. private _readyToPlayCallback;
  41498. private _audioBuffer;
  41499. private _soundSource;
  41500. private _streamingSource;
  41501. private _soundPanner;
  41502. private _soundGain;
  41503. private _inputAudioNode;
  41504. private _outputAudioNode;
  41505. private _coneInnerAngle;
  41506. private _coneOuterAngle;
  41507. private _coneOuterGain;
  41508. private _scene;
  41509. private _connectedTransformNode;
  41510. private _customAttenuationFunction;
  41511. private _registerFunc;
  41512. private _isOutputConnected;
  41513. private _htmlAudioElement;
  41514. private _urlType;
  41515. private _length?;
  41516. private _offset?;
  41517. /** @hidden */
  41518. static _SceneComponentInitialization: (scene: Scene) => void;
  41519. /**
  41520. * Create a sound and attach it to a scene
  41521. * @param name Name of your sound
  41522. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41523. * @param scene defines the scene the sound belongs to
  41524. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41525. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41526. */
  41527. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41528. /**
  41529. * Release the sound and its associated resources
  41530. */
  41531. dispose(): void;
  41532. /**
  41533. * Gets if the sounds is ready to be played or not.
  41534. * @returns true if ready, otherwise false
  41535. */
  41536. isReady(): boolean;
  41537. private _soundLoaded;
  41538. /**
  41539. * Sets the data of the sound from an audiobuffer
  41540. * @param audioBuffer The audioBuffer containing the data
  41541. */
  41542. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41543. /**
  41544. * Updates the current sounds options such as maxdistance, loop...
  41545. * @param options A JSON object containing values named as the object properties
  41546. */
  41547. updateOptions(options: ISoundOptions): void;
  41548. private _createSpatialParameters;
  41549. private _updateSpatialParameters;
  41550. /**
  41551. * Switch the panning model to HRTF:
  41552. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41553. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41554. */
  41555. switchPanningModelToHRTF(): void;
  41556. /**
  41557. * Switch the panning model to Equal Power:
  41558. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41559. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41560. */
  41561. switchPanningModelToEqualPower(): void;
  41562. private _switchPanningModel;
  41563. /**
  41564. * Connect this sound to a sound track audio node like gain...
  41565. * @param soundTrackAudioNode the sound track audio node to connect to
  41566. */
  41567. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41568. /**
  41569. * Transform this sound into a directional source
  41570. * @param coneInnerAngle Size of the inner cone in degree
  41571. * @param coneOuterAngle Size of the outer cone in degree
  41572. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41573. */
  41574. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41575. /**
  41576. * Gets or sets the inner angle for the directional cone.
  41577. */
  41578. get directionalConeInnerAngle(): number;
  41579. /**
  41580. * Gets or sets the inner angle for the directional cone.
  41581. */
  41582. set directionalConeInnerAngle(value: number);
  41583. /**
  41584. * Gets or sets the outer angle for the directional cone.
  41585. */
  41586. get directionalConeOuterAngle(): number;
  41587. /**
  41588. * Gets or sets the outer angle for the directional cone.
  41589. */
  41590. set directionalConeOuterAngle(value: number);
  41591. /**
  41592. * Sets the position of the emitter if spatial sound is enabled
  41593. * @param newPosition Defines the new posisiton
  41594. */
  41595. setPosition(newPosition: Vector3): void;
  41596. /**
  41597. * Sets the local direction of the emitter if spatial sound is enabled
  41598. * @param newLocalDirection Defines the new local direction
  41599. */
  41600. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41601. private _updateDirection;
  41602. /** @hidden */
  41603. updateDistanceFromListener(): void;
  41604. /**
  41605. * Sets a new custom attenuation function for the sound.
  41606. * @param callback Defines the function used for the attenuation
  41607. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41608. */
  41609. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41610. /**
  41611. * Play the sound
  41612. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41613. * @param offset (optional) Start the sound at a specific time in seconds
  41614. * @param length (optional) Sound duration (in seconds)
  41615. */
  41616. play(time?: number, offset?: number, length?: number): void;
  41617. private _onended;
  41618. /**
  41619. * Stop the sound
  41620. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41621. */
  41622. stop(time?: number): void;
  41623. /**
  41624. * Put the sound in pause
  41625. */
  41626. pause(): void;
  41627. /**
  41628. * Sets a dedicated volume for this sounds
  41629. * @param newVolume Define the new volume of the sound
  41630. * @param time Define time for gradual change to new volume
  41631. */
  41632. setVolume(newVolume: number, time?: number): void;
  41633. /**
  41634. * Set the sound play back rate
  41635. * @param newPlaybackRate Define the playback rate the sound should be played at
  41636. */
  41637. setPlaybackRate(newPlaybackRate: number): void;
  41638. /**
  41639. * Gets the volume of the sound.
  41640. * @returns the volume of the sound
  41641. */
  41642. getVolume(): number;
  41643. /**
  41644. * Attach the sound to a dedicated mesh
  41645. * @param transformNode The transform node to connect the sound with
  41646. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41647. */
  41648. attachToMesh(transformNode: TransformNode): void;
  41649. /**
  41650. * Detach the sound from the previously attached mesh
  41651. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41652. */
  41653. detachFromMesh(): void;
  41654. private _onRegisterAfterWorldMatrixUpdate;
  41655. /**
  41656. * Clone the current sound in the scene.
  41657. * @returns the new sound clone
  41658. */
  41659. clone(): Nullable<Sound>;
  41660. /**
  41661. * Gets the current underlying audio buffer containing the data
  41662. * @returns the audio buffer
  41663. */
  41664. getAudioBuffer(): Nullable<AudioBuffer>;
  41665. /**
  41666. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41667. * @returns the source node
  41668. */
  41669. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41670. /**
  41671. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41672. * @returns the gain node
  41673. */
  41674. getSoundGain(): Nullable<GainNode>;
  41675. /**
  41676. * Serializes the Sound in a JSON representation
  41677. * @returns the JSON representation of the sound
  41678. */
  41679. serialize(): any;
  41680. /**
  41681. * Parse a JSON representation of a sound to innstantiate in a given scene
  41682. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41683. * @param scene Define the scene the new parsed sound should be created in
  41684. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41685. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41686. * @returns the newly parsed sound
  41687. */
  41688. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41689. }
  41690. }
  41691. declare module BABYLON {
  41692. /**
  41693. * This defines an action helpful to play a defined sound on a triggered action.
  41694. */
  41695. export class PlaySoundAction extends Action {
  41696. private _sound;
  41697. /**
  41698. * Instantiate the action
  41699. * @param triggerOptions defines the trigger options
  41700. * @param sound defines the sound to play
  41701. * @param condition defines the trigger related conditions
  41702. */
  41703. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41704. /** @hidden */
  41705. _prepare(): void;
  41706. /**
  41707. * Execute the action and play the sound.
  41708. */
  41709. execute(): void;
  41710. /**
  41711. * Serializes the actions and its related information.
  41712. * @param parent defines the object to serialize in
  41713. * @returns the serialized object
  41714. */
  41715. serialize(parent: any): any;
  41716. }
  41717. /**
  41718. * This defines an action helpful to stop a defined sound on a triggered action.
  41719. */
  41720. export class StopSoundAction extends Action {
  41721. private _sound;
  41722. /**
  41723. * Instantiate the action
  41724. * @param triggerOptions defines the trigger options
  41725. * @param sound defines the sound to stop
  41726. * @param condition defines the trigger related conditions
  41727. */
  41728. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41729. /** @hidden */
  41730. _prepare(): void;
  41731. /**
  41732. * Execute the action and stop the sound.
  41733. */
  41734. execute(): void;
  41735. /**
  41736. * Serializes the actions and its related information.
  41737. * @param parent defines the object to serialize in
  41738. * @returns the serialized object
  41739. */
  41740. serialize(parent: any): any;
  41741. }
  41742. }
  41743. declare module BABYLON {
  41744. /**
  41745. * This defines an action responsible to change the value of a property
  41746. * by interpolating between its current value and the newly set one once triggered.
  41747. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41748. */
  41749. export class InterpolateValueAction extends Action {
  41750. /**
  41751. * Defines the path of the property where the value should be interpolated
  41752. */
  41753. propertyPath: string;
  41754. /**
  41755. * Defines the target value at the end of the interpolation.
  41756. */
  41757. value: any;
  41758. /**
  41759. * Defines the time it will take for the property to interpolate to the value.
  41760. */
  41761. duration: number;
  41762. /**
  41763. * Defines if the other scene animations should be stopped when the action has been triggered
  41764. */
  41765. stopOtherAnimations?: boolean;
  41766. /**
  41767. * Defines a callback raised once the interpolation animation has been done.
  41768. */
  41769. onInterpolationDone?: () => void;
  41770. /**
  41771. * Observable triggered once the interpolation animation has been done.
  41772. */
  41773. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41774. private _target;
  41775. private _effectiveTarget;
  41776. private _property;
  41777. /**
  41778. * Instantiate the action
  41779. * @param triggerOptions defines the trigger options
  41780. * @param target defines the object containing the value to interpolate
  41781. * @param propertyPath defines the path to the property in the target object
  41782. * @param value defines the target value at the end of the interpolation
  41783. * @param duration deines the time it will take for the property to interpolate to the value.
  41784. * @param condition defines the trigger related conditions
  41785. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41786. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41787. */
  41788. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41789. /** @hidden */
  41790. _prepare(): void;
  41791. /**
  41792. * Execute the action starts the value interpolation.
  41793. */
  41794. execute(): void;
  41795. /**
  41796. * Serializes the actions and its related information.
  41797. * @param parent defines the object to serialize in
  41798. * @returns the serialized object
  41799. */
  41800. serialize(parent: any): any;
  41801. }
  41802. }
  41803. declare module BABYLON {
  41804. /**
  41805. * Options allowed during the creation of a sound track.
  41806. */
  41807. export interface ISoundTrackOptions {
  41808. /**
  41809. * The volume the sound track should take during creation
  41810. */
  41811. volume?: number;
  41812. /**
  41813. * Define if the sound track is the main sound track of the scene
  41814. */
  41815. mainTrack?: boolean;
  41816. }
  41817. /**
  41818. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41819. * It will be also used in a future release to apply effects on a specific track.
  41820. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41821. */
  41822. export class SoundTrack {
  41823. /**
  41824. * The unique identifier of the sound track in the scene.
  41825. */
  41826. id: number;
  41827. /**
  41828. * The list of sounds included in the sound track.
  41829. */
  41830. soundCollection: Array<Sound>;
  41831. private _outputAudioNode;
  41832. private _scene;
  41833. private _connectedAnalyser;
  41834. private _options;
  41835. private _isInitialized;
  41836. /**
  41837. * Creates a new sound track.
  41838. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41839. * @param scene Define the scene the sound track belongs to
  41840. * @param options
  41841. */
  41842. constructor(scene: Scene, options?: ISoundTrackOptions);
  41843. private _initializeSoundTrackAudioGraph;
  41844. /**
  41845. * Release the sound track and its associated resources
  41846. */
  41847. dispose(): void;
  41848. /**
  41849. * Adds a sound to this sound track
  41850. * @param sound define the cound to add
  41851. * @ignoreNaming
  41852. */
  41853. AddSound(sound: Sound): void;
  41854. /**
  41855. * Removes a sound to this sound track
  41856. * @param sound define the cound to remove
  41857. * @ignoreNaming
  41858. */
  41859. RemoveSound(sound: Sound): void;
  41860. /**
  41861. * Set a global volume for the full sound track.
  41862. * @param newVolume Define the new volume of the sound track
  41863. */
  41864. setVolume(newVolume: number): void;
  41865. /**
  41866. * Switch the panning model to HRTF:
  41867. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41869. */
  41870. switchPanningModelToHRTF(): void;
  41871. /**
  41872. * Switch the panning model to Equal Power:
  41873. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41874. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41875. */
  41876. switchPanningModelToEqualPower(): void;
  41877. /**
  41878. * Connect the sound track to an audio analyser allowing some amazing
  41879. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41880. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41881. * @param analyser The analyser to connect to the engine
  41882. */
  41883. connectToAnalyser(analyser: Analyser): void;
  41884. }
  41885. }
  41886. declare module BABYLON {
  41887. interface AbstractScene {
  41888. /**
  41889. * The list of sounds used in the scene.
  41890. */
  41891. sounds: Nullable<Array<Sound>>;
  41892. }
  41893. interface Scene {
  41894. /**
  41895. * @hidden
  41896. * Backing field
  41897. */
  41898. _mainSoundTrack: SoundTrack;
  41899. /**
  41900. * The main sound track played by the scene.
  41901. * It cotains your primary collection of sounds.
  41902. */
  41903. mainSoundTrack: SoundTrack;
  41904. /**
  41905. * The list of sound tracks added to the scene
  41906. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41907. */
  41908. soundTracks: Nullable<Array<SoundTrack>>;
  41909. /**
  41910. * Gets a sound using a given name
  41911. * @param name defines the name to search for
  41912. * @return the found sound or null if not found at all.
  41913. */
  41914. getSoundByName(name: string): Nullable<Sound>;
  41915. /**
  41916. * Gets or sets if audio support is enabled
  41917. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41918. */
  41919. audioEnabled: boolean;
  41920. /**
  41921. * Gets or sets if audio will be output to headphones
  41922. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41923. */
  41924. headphone: boolean;
  41925. /**
  41926. * Gets or sets custom audio listener position provider
  41927. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41928. */
  41929. audioListenerPositionProvider: Nullable<() => Vector3>;
  41930. /**
  41931. * Gets or sets a refresh rate when using 3D audio positioning
  41932. */
  41933. audioPositioningRefreshRate: number;
  41934. }
  41935. /**
  41936. * Defines the sound scene component responsible to manage any sounds
  41937. * in a given scene.
  41938. */
  41939. export class AudioSceneComponent implements ISceneSerializableComponent {
  41940. /**
  41941. * The component name helpfull to identify the component in the list of scene components.
  41942. */
  41943. readonly name: string;
  41944. /**
  41945. * The scene the component belongs to.
  41946. */
  41947. scene: Scene;
  41948. private _audioEnabled;
  41949. /**
  41950. * Gets whether audio is enabled or not.
  41951. * Please use related enable/disable method to switch state.
  41952. */
  41953. get audioEnabled(): boolean;
  41954. private _headphone;
  41955. /**
  41956. * Gets whether audio is outputing to headphone or not.
  41957. * Please use the according Switch methods to change output.
  41958. */
  41959. get headphone(): boolean;
  41960. /**
  41961. * Gets or sets a refresh rate when using 3D audio positioning
  41962. */
  41963. audioPositioningRefreshRate: number;
  41964. private _audioListenerPositionProvider;
  41965. /**
  41966. * Gets the current audio listener position provider
  41967. */
  41968. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41969. /**
  41970. * Sets a custom listener position for all sounds in the scene
  41971. * By default, this is the position of the first active camera
  41972. */
  41973. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41974. /**
  41975. * Creates a new instance of the component for the given scene
  41976. * @param scene Defines the scene to register the component in
  41977. */
  41978. constructor(scene: Scene);
  41979. /**
  41980. * Registers the component in a given scene
  41981. */
  41982. register(): void;
  41983. /**
  41984. * Rebuilds the elements related to this component in case of
  41985. * context lost for instance.
  41986. */
  41987. rebuild(): void;
  41988. /**
  41989. * Serializes the component data to the specified json object
  41990. * @param serializationObject The object to serialize to
  41991. */
  41992. serialize(serializationObject: any): void;
  41993. /**
  41994. * Adds all the elements from the container to the scene
  41995. * @param container the container holding the elements
  41996. */
  41997. addFromContainer(container: AbstractScene): void;
  41998. /**
  41999. * Removes all the elements in the container from the scene
  42000. * @param container contains the elements to remove
  42001. * @param dispose if the removed element should be disposed (default: false)
  42002. */
  42003. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42004. /**
  42005. * Disposes the component and the associated ressources.
  42006. */
  42007. dispose(): void;
  42008. /**
  42009. * Disables audio in the associated scene.
  42010. */
  42011. disableAudio(): void;
  42012. /**
  42013. * Enables audio in the associated scene.
  42014. */
  42015. enableAudio(): void;
  42016. /**
  42017. * Switch audio to headphone output.
  42018. */
  42019. switchAudioModeForHeadphones(): void;
  42020. /**
  42021. * Switch audio to normal speakers.
  42022. */
  42023. switchAudioModeForNormalSpeakers(): void;
  42024. private _cachedCameraDirection;
  42025. private _cachedCameraPosition;
  42026. private _lastCheck;
  42027. private _afterRender;
  42028. }
  42029. }
  42030. declare module BABYLON {
  42031. /**
  42032. * Wraps one or more Sound objects and selects one with random weight for playback.
  42033. */
  42034. export class WeightedSound {
  42035. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42036. loop: boolean;
  42037. private _coneInnerAngle;
  42038. private _coneOuterAngle;
  42039. private _volume;
  42040. /** A Sound is currently playing. */
  42041. isPlaying: boolean;
  42042. /** A Sound is currently paused. */
  42043. isPaused: boolean;
  42044. private _sounds;
  42045. private _weights;
  42046. private _currentIndex?;
  42047. /**
  42048. * Creates a new WeightedSound from the list of sounds given.
  42049. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42050. * @param sounds Array of Sounds that will be selected from.
  42051. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42052. */
  42053. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42054. /**
  42055. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42056. */
  42057. get directionalConeInnerAngle(): number;
  42058. /**
  42059. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42060. */
  42061. set directionalConeInnerAngle(value: number);
  42062. /**
  42063. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42064. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42065. */
  42066. get directionalConeOuterAngle(): number;
  42067. /**
  42068. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42069. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42070. */
  42071. set directionalConeOuterAngle(value: number);
  42072. /**
  42073. * Playback volume.
  42074. */
  42075. get volume(): number;
  42076. /**
  42077. * Playback volume.
  42078. */
  42079. set volume(value: number);
  42080. private _onended;
  42081. /**
  42082. * Suspend playback
  42083. */
  42084. pause(): void;
  42085. /**
  42086. * Stop playback
  42087. */
  42088. stop(): void;
  42089. /**
  42090. * Start playback.
  42091. * @param startOffset Position the clip head at a specific time in seconds.
  42092. */
  42093. play(startOffset?: number): void;
  42094. }
  42095. }
  42096. declare module BABYLON {
  42097. /**
  42098. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42099. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42100. */
  42101. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42102. /**
  42103. * Gets the name of the behavior.
  42104. */
  42105. get name(): string;
  42106. /**
  42107. * The easing function used by animations
  42108. */
  42109. static EasingFunction: BackEase;
  42110. /**
  42111. * The easing mode used by animations
  42112. */
  42113. static EasingMode: number;
  42114. /**
  42115. * The duration of the animation, in milliseconds
  42116. */
  42117. transitionDuration: number;
  42118. /**
  42119. * Length of the distance animated by the transition when lower radius is reached
  42120. */
  42121. lowerRadiusTransitionRange: number;
  42122. /**
  42123. * Length of the distance animated by the transition when upper radius is reached
  42124. */
  42125. upperRadiusTransitionRange: number;
  42126. private _autoTransitionRange;
  42127. /**
  42128. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42129. */
  42130. get autoTransitionRange(): boolean;
  42131. /**
  42132. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42133. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42134. */
  42135. set autoTransitionRange(value: boolean);
  42136. private _attachedCamera;
  42137. private _onAfterCheckInputsObserver;
  42138. private _onMeshTargetChangedObserver;
  42139. /**
  42140. * Initializes the behavior.
  42141. */
  42142. init(): void;
  42143. /**
  42144. * Attaches the behavior to its arc rotate camera.
  42145. * @param camera Defines the camera to attach the behavior to
  42146. */
  42147. attach(camera: ArcRotateCamera): void;
  42148. /**
  42149. * Detaches the behavior from its current arc rotate camera.
  42150. */
  42151. detach(): void;
  42152. private _radiusIsAnimating;
  42153. private _radiusBounceTransition;
  42154. private _animatables;
  42155. private _cachedWheelPrecision;
  42156. /**
  42157. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42158. * @param radiusLimit The limit to check against.
  42159. * @return Bool to indicate if at limit.
  42160. */
  42161. private _isRadiusAtLimit;
  42162. /**
  42163. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42164. * @param radiusDelta The delta by which to animate to. Can be negative.
  42165. */
  42166. private _applyBoundRadiusAnimation;
  42167. /**
  42168. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42169. */
  42170. protected _clearAnimationLocks(): void;
  42171. /**
  42172. * Stops and removes all animations that have been applied to the camera
  42173. */
  42174. stopAllAnimations(): void;
  42175. }
  42176. }
  42177. declare module BABYLON {
  42178. /**
  42179. * 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.
  42180. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42181. */
  42182. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42183. /**
  42184. * Gets the name of the behavior.
  42185. */
  42186. get name(): string;
  42187. private _mode;
  42188. private _radiusScale;
  42189. private _positionScale;
  42190. private _defaultElevation;
  42191. private _elevationReturnTime;
  42192. private _elevationReturnWaitTime;
  42193. private _zoomStopsAnimation;
  42194. private _framingTime;
  42195. /**
  42196. * The easing function used by animations
  42197. */
  42198. static EasingFunction: ExponentialEase;
  42199. /**
  42200. * The easing mode used by animations
  42201. */
  42202. static EasingMode: number;
  42203. /**
  42204. * Sets the current mode used by the behavior
  42205. */
  42206. set mode(mode: number);
  42207. /**
  42208. * Gets current mode used by the behavior.
  42209. */
  42210. get mode(): number;
  42211. /**
  42212. * Sets the scale applied to the radius (1 by default)
  42213. */
  42214. set radiusScale(radius: number);
  42215. /**
  42216. * Gets the scale applied to the radius
  42217. */
  42218. get radiusScale(): number;
  42219. /**
  42220. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42221. */
  42222. set positionScale(scale: number);
  42223. /**
  42224. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42225. */
  42226. get positionScale(): number;
  42227. /**
  42228. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42229. * behaviour is triggered, in radians.
  42230. */
  42231. set defaultElevation(elevation: number);
  42232. /**
  42233. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42234. * behaviour is triggered, in radians.
  42235. */
  42236. get defaultElevation(): number;
  42237. /**
  42238. * Sets the time (in milliseconds) taken to return to the default beta position.
  42239. * Negative value indicates camera should not return to default.
  42240. */
  42241. set elevationReturnTime(speed: number);
  42242. /**
  42243. * Gets the time (in milliseconds) taken to return to the default beta position.
  42244. * Negative value indicates camera should not return to default.
  42245. */
  42246. get elevationReturnTime(): number;
  42247. /**
  42248. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42249. */
  42250. set elevationReturnWaitTime(time: number);
  42251. /**
  42252. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42253. */
  42254. get elevationReturnWaitTime(): number;
  42255. /**
  42256. * Sets the flag that indicates if user zooming should stop animation.
  42257. */
  42258. set zoomStopsAnimation(flag: boolean);
  42259. /**
  42260. * Gets the flag that indicates if user zooming should stop animation.
  42261. */
  42262. get zoomStopsAnimation(): boolean;
  42263. /**
  42264. * Sets the transition time when framing the mesh, in milliseconds
  42265. */
  42266. set framingTime(time: number);
  42267. /**
  42268. * Gets the transition time when framing the mesh, in milliseconds
  42269. */
  42270. get framingTime(): number;
  42271. /**
  42272. * Define if the behavior should automatically change the configured
  42273. * camera limits and sensibilities.
  42274. */
  42275. autoCorrectCameraLimitsAndSensibility: boolean;
  42276. private _onPrePointerObservableObserver;
  42277. private _onAfterCheckInputsObserver;
  42278. private _onMeshTargetChangedObserver;
  42279. private _attachedCamera;
  42280. private _isPointerDown;
  42281. private _lastInteractionTime;
  42282. /**
  42283. * Initializes the behavior.
  42284. */
  42285. init(): void;
  42286. /**
  42287. * Attaches the behavior to its arc rotate camera.
  42288. * @param camera Defines the camera to attach the behavior to
  42289. */
  42290. attach(camera: ArcRotateCamera): void;
  42291. /**
  42292. * Detaches the behavior from its current arc rotate camera.
  42293. */
  42294. detach(): void;
  42295. private _animatables;
  42296. private _betaIsAnimating;
  42297. private _betaTransition;
  42298. private _radiusTransition;
  42299. private _vectorTransition;
  42300. /**
  42301. * Targets the given mesh and updates zoom level accordingly.
  42302. * @param mesh The mesh to target.
  42303. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42304. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42305. */
  42306. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42307. /**
  42308. * Targets the given mesh with its children and updates zoom level accordingly.
  42309. * @param mesh The mesh to target.
  42310. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42311. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42312. */
  42313. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42314. /**
  42315. * Targets the given meshes with their children and updates zoom level accordingly.
  42316. * @param meshes The mesh to target.
  42317. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42318. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42319. */
  42320. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42321. /**
  42322. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42323. * @param minimumWorld Determines the smaller position of the bounding box extend
  42324. * @param maximumWorld Determines the bigger position of the bounding box extend
  42325. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42326. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42327. */
  42328. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42329. /**
  42330. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42331. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42332. * frustum width.
  42333. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42334. * to fully enclose the mesh in the viewing frustum.
  42335. */
  42336. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42337. /**
  42338. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42339. * is automatically returned to its default position (expected to be above ground plane).
  42340. */
  42341. private _maintainCameraAboveGround;
  42342. /**
  42343. * Returns the frustum slope based on the canvas ratio and camera FOV
  42344. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42345. */
  42346. private _getFrustumSlope;
  42347. /**
  42348. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42349. */
  42350. private _clearAnimationLocks;
  42351. /**
  42352. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42353. */
  42354. private _applyUserInteraction;
  42355. /**
  42356. * Stops and removes all animations that have been applied to the camera
  42357. */
  42358. stopAllAnimations(): void;
  42359. /**
  42360. * Gets a value indicating if the user is moving the camera
  42361. */
  42362. get isUserIsMoving(): boolean;
  42363. /**
  42364. * The camera can move all the way towards the mesh.
  42365. */
  42366. static IgnoreBoundsSizeMode: number;
  42367. /**
  42368. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42369. */
  42370. static FitFrustumSidesMode: number;
  42371. }
  42372. }
  42373. declare module BABYLON {
  42374. /**
  42375. * Base class for Camera Pointer Inputs.
  42376. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42377. * for example usage.
  42378. */
  42379. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42380. /**
  42381. * Defines the camera the input is attached to.
  42382. */
  42383. abstract camera: Camera;
  42384. /**
  42385. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42386. */
  42387. protected _altKey: boolean;
  42388. protected _ctrlKey: boolean;
  42389. protected _metaKey: boolean;
  42390. protected _shiftKey: boolean;
  42391. /**
  42392. * Which mouse buttons were pressed at time of last mouse event.
  42393. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42394. */
  42395. protected _buttonsPressed: number;
  42396. /**
  42397. * Defines the buttons associated with the input to handle camera move.
  42398. */
  42399. buttons: number[];
  42400. /**
  42401. * Attach the input controls to a specific dom element to get the input from.
  42402. * @param element Defines the element the controls should be listened from
  42403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42404. */
  42405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42406. /**
  42407. * Detach the current controls from the specified dom element.
  42408. * @param element Defines the element to stop listening the inputs from
  42409. */
  42410. detachControl(element: Nullable<HTMLElement>): void;
  42411. /**
  42412. * Gets the class name of the current input.
  42413. * @returns the class name
  42414. */
  42415. getClassName(): string;
  42416. /**
  42417. * Get the friendly name associated with the input class.
  42418. * @returns the input friendly name
  42419. */
  42420. getSimpleName(): string;
  42421. /**
  42422. * Called on pointer POINTERDOUBLETAP event.
  42423. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42424. */
  42425. protected onDoubleTap(type: string): void;
  42426. /**
  42427. * Called on pointer POINTERMOVE event if only a single touch is active.
  42428. * Override this method to provide functionality.
  42429. */
  42430. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42431. /**
  42432. * Called on pointer POINTERMOVE event if multiple touches are active.
  42433. * Override this method to provide functionality.
  42434. */
  42435. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42436. /**
  42437. * Called on JS contextmenu event.
  42438. * Override this method to provide functionality.
  42439. */
  42440. protected onContextMenu(evt: PointerEvent): void;
  42441. /**
  42442. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42443. * press.
  42444. * Override this method to provide functionality.
  42445. */
  42446. protected onButtonDown(evt: PointerEvent): void;
  42447. /**
  42448. * Called each time a new POINTERUP event occurs. Ie, for each button
  42449. * release.
  42450. * Override this method to provide functionality.
  42451. */
  42452. protected onButtonUp(evt: PointerEvent): void;
  42453. /**
  42454. * Called when window becomes inactive.
  42455. * Override this method to provide functionality.
  42456. */
  42457. protected onLostFocus(): void;
  42458. private _pointerInput;
  42459. private _observer;
  42460. private _onLostFocus;
  42461. private pointA;
  42462. private pointB;
  42463. }
  42464. }
  42465. declare module BABYLON {
  42466. /**
  42467. * Manage the pointers inputs to control an arc rotate camera.
  42468. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42469. */
  42470. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42471. /**
  42472. * Defines the camera the input is attached to.
  42473. */
  42474. camera: ArcRotateCamera;
  42475. /**
  42476. * Gets the class name of the current input.
  42477. * @returns the class name
  42478. */
  42479. getClassName(): string;
  42480. /**
  42481. * Defines the buttons associated with the input to handle camera move.
  42482. */
  42483. buttons: number[];
  42484. /**
  42485. * Defines the pointer angular sensibility along the X axis or how fast is
  42486. * the camera rotating.
  42487. */
  42488. angularSensibilityX: number;
  42489. /**
  42490. * Defines the pointer angular sensibility along the Y axis or how fast is
  42491. * the camera rotating.
  42492. */
  42493. angularSensibilityY: number;
  42494. /**
  42495. * Defines the pointer pinch precision or how fast is the camera zooming.
  42496. */
  42497. pinchPrecision: number;
  42498. /**
  42499. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42500. * from 0.
  42501. * It defines the percentage of current camera.radius to use as delta when
  42502. * pinch zoom is used.
  42503. */
  42504. pinchDeltaPercentage: number;
  42505. /**
  42506. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42507. * that any object in the plane at the camera's target point will scale
  42508. * perfectly with finger motion.
  42509. * Overrides pinchDeltaPercentage and pinchPrecision.
  42510. */
  42511. useNaturalPinchZoom: boolean;
  42512. /**
  42513. * Defines the pointer panning sensibility or how fast is the camera moving.
  42514. */
  42515. panningSensibility: number;
  42516. /**
  42517. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42518. */
  42519. multiTouchPanning: boolean;
  42520. /**
  42521. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42522. * zoom (pinch) through multitouch.
  42523. */
  42524. multiTouchPanAndZoom: boolean;
  42525. /**
  42526. * Revers pinch action direction.
  42527. */
  42528. pinchInwards: boolean;
  42529. private _isPanClick;
  42530. private _twoFingerActivityCount;
  42531. private _isPinching;
  42532. /**
  42533. * Called on pointer POINTERMOVE event if only a single touch is active.
  42534. */
  42535. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42536. /**
  42537. * Called on pointer POINTERDOUBLETAP event.
  42538. */
  42539. protected onDoubleTap(type: string): void;
  42540. /**
  42541. * Called on pointer POINTERMOVE event if multiple touches are active.
  42542. */
  42543. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42544. /**
  42545. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42546. * press.
  42547. */
  42548. protected onButtonDown(evt: PointerEvent): void;
  42549. /**
  42550. * Called each time a new POINTERUP event occurs. Ie, for each button
  42551. * release.
  42552. */
  42553. protected onButtonUp(evt: PointerEvent): void;
  42554. /**
  42555. * Called when window becomes inactive.
  42556. */
  42557. protected onLostFocus(): void;
  42558. }
  42559. }
  42560. declare module BABYLON {
  42561. /**
  42562. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42563. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42564. */
  42565. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42566. /**
  42567. * Defines the camera the input is attached to.
  42568. */
  42569. camera: ArcRotateCamera;
  42570. /**
  42571. * Defines the list of key codes associated with the up action (increase alpha)
  42572. */
  42573. keysUp: number[];
  42574. /**
  42575. * Defines the list of key codes associated with the down action (decrease alpha)
  42576. */
  42577. keysDown: number[];
  42578. /**
  42579. * Defines the list of key codes associated with the left action (increase beta)
  42580. */
  42581. keysLeft: number[];
  42582. /**
  42583. * Defines the list of key codes associated with the right action (decrease beta)
  42584. */
  42585. keysRight: number[];
  42586. /**
  42587. * Defines the list of key codes associated with the reset action.
  42588. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42589. */
  42590. keysReset: number[];
  42591. /**
  42592. * Defines the panning sensibility of the inputs.
  42593. * (How fast is the camera panning)
  42594. */
  42595. panningSensibility: number;
  42596. /**
  42597. * Defines the zooming sensibility of the inputs.
  42598. * (How fast is the camera zooming)
  42599. */
  42600. zoomingSensibility: number;
  42601. /**
  42602. * Defines whether maintaining the alt key down switch the movement mode from
  42603. * orientation to zoom.
  42604. */
  42605. useAltToZoom: boolean;
  42606. /**
  42607. * Rotation speed of the camera
  42608. */
  42609. angularSpeed: number;
  42610. private _keys;
  42611. private _ctrlPressed;
  42612. private _altPressed;
  42613. private _onCanvasBlurObserver;
  42614. private _onKeyboardObserver;
  42615. private _engine;
  42616. private _scene;
  42617. /**
  42618. * Attach the input controls to a specific dom element to get the input from.
  42619. * @param element Defines the element the controls should be listened from
  42620. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42621. */
  42622. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42623. /**
  42624. * Detach the current controls from the specified dom element.
  42625. * @param element Defines the element to stop listening the inputs from
  42626. */
  42627. detachControl(element: Nullable<HTMLElement>): void;
  42628. /**
  42629. * Update the current camera state depending on the inputs that have been used this frame.
  42630. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42631. */
  42632. checkInputs(): void;
  42633. /**
  42634. * Gets the class name of the current intput.
  42635. * @returns the class name
  42636. */
  42637. getClassName(): string;
  42638. /**
  42639. * Get the friendly name associated with the input class.
  42640. * @returns the input friendly name
  42641. */
  42642. getSimpleName(): string;
  42643. }
  42644. }
  42645. declare module BABYLON {
  42646. /**
  42647. * Manage the mouse wheel inputs to control an arc rotate camera.
  42648. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42649. */
  42650. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42651. /**
  42652. * Defines the camera the input is attached to.
  42653. */
  42654. camera: ArcRotateCamera;
  42655. /**
  42656. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42657. */
  42658. wheelPrecision: number;
  42659. /**
  42660. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42661. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42662. */
  42663. wheelDeltaPercentage: number;
  42664. private _wheel;
  42665. private _observer;
  42666. private computeDeltaFromMouseWheelLegacyEvent;
  42667. /**
  42668. * Attach the input controls to a specific dom element to get the input from.
  42669. * @param element Defines the element the controls should be listened from
  42670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42671. */
  42672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42673. /**
  42674. * Detach the current controls from the specified dom element.
  42675. * @param element Defines the element to stop listening the inputs from
  42676. */
  42677. detachControl(element: Nullable<HTMLElement>): void;
  42678. /**
  42679. * Gets the class name of the current intput.
  42680. * @returns the class name
  42681. */
  42682. getClassName(): string;
  42683. /**
  42684. * Get the friendly name associated with the input class.
  42685. * @returns the input friendly name
  42686. */
  42687. getSimpleName(): string;
  42688. }
  42689. }
  42690. declare module BABYLON {
  42691. /**
  42692. * Default Inputs manager for the ArcRotateCamera.
  42693. * It groups all the default supported inputs for ease of use.
  42694. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42695. */
  42696. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42697. /**
  42698. * Instantiates a new ArcRotateCameraInputsManager.
  42699. * @param camera Defines the camera the inputs belong to
  42700. */
  42701. constructor(camera: ArcRotateCamera);
  42702. /**
  42703. * Add mouse wheel input support to the input manager.
  42704. * @returns the current input manager
  42705. */
  42706. addMouseWheel(): ArcRotateCameraInputsManager;
  42707. /**
  42708. * Add pointers input support to the input manager.
  42709. * @returns the current input manager
  42710. */
  42711. addPointers(): ArcRotateCameraInputsManager;
  42712. /**
  42713. * Add keyboard input support to the input manager.
  42714. * @returns the current input manager
  42715. */
  42716. addKeyboard(): ArcRotateCameraInputsManager;
  42717. }
  42718. }
  42719. declare module BABYLON {
  42720. /**
  42721. * This represents an orbital type of camera.
  42722. *
  42723. * 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.
  42724. * 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.
  42725. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42726. */
  42727. export class ArcRotateCamera extends TargetCamera {
  42728. /**
  42729. * Defines the rotation angle of the camera along the longitudinal axis.
  42730. */
  42731. alpha: number;
  42732. /**
  42733. * Defines the rotation angle of the camera along the latitudinal axis.
  42734. */
  42735. beta: number;
  42736. /**
  42737. * Defines the radius of the camera from it s target point.
  42738. */
  42739. radius: number;
  42740. protected _target: Vector3;
  42741. protected _targetHost: Nullable<AbstractMesh>;
  42742. /**
  42743. * Defines the target point of the camera.
  42744. * The camera looks towards it form the radius distance.
  42745. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42746. */
  42747. get target(): Vector3;
  42748. set target(value: Vector3);
  42749. /**
  42750. * Define the current local position of the camera in the scene
  42751. */
  42752. get position(): Vector3;
  42753. set position(newPosition: Vector3);
  42754. protected _upVector: Vector3;
  42755. protected _upToYMatrix: Matrix;
  42756. protected _YToUpMatrix: Matrix;
  42757. /**
  42758. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42759. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42760. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42761. */
  42762. set upVector(vec: Vector3);
  42763. get upVector(): Vector3;
  42764. /**
  42765. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42766. */
  42767. setMatUp(): void;
  42768. /**
  42769. * Current inertia value on the longitudinal axis.
  42770. * The bigger this number the longer it will take for the camera to stop.
  42771. */
  42772. inertialAlphaOffset: number;
  42773. /**
  42774. * Current inertia value on the latitudinal axis.
  42775. * The bigger this number the longer it will take for the camera to stop.
  42776. */
  42777. inertialBetaOffset: number;
  42778. /**
  42779. * Current inertia value on the radius axis.
  42780. * The bigger this number the longer it will take for the camera to stop.
  42781. */
  42782. inertialRadiusOffset: number;
  42783. /**
  42784. * Minimum allowed angle on the longitudinal axis.
  42785. * This can help limiting how the Camera is able to move in the scene.
  42786. */
  42787. lowerAlphaLimit: Nullable<number>;
  42788. /**
  42789. * Maximum allowed angle on the longitudinal axis.
  42790. * This can help limiting how the Camera is able to move in the scene.
  42791. */
  42792. upperAlphaLimit: Nullable<number>;
  42793. /**
  42794. * Minimum allowed angle on the latitudinal axis.
  42795. * This can help limiting how the Camera is able to move in the scene.
  42796. */
  42797. lowerBetaLimit: number;
  42798. /**
  42799. * Maximum allowed angle on the latitudinal axis.
  42800. * This can help limiting how the Camera is able to move in the scene.
  42801. */
  42802. upperBetaLimit: number;
  42803. /**
  42804. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42805. * This can help limiting how the Camera is able to move in the scene.
  42806. */
  42807. lowerRadiusLimit: Nullable<number>;
  42808. /**
  42809. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42810. * This can help limiting how the Camera is able to move in the scene.
  42811. */
  42812. upperRadiusLimit: Nullable<number>;
  42813. /**
  42814. * Defines the current inertia value used during panning of the camera along the X axis.
  42815. */
  42816. inertialPanningX: number;
  42817. /**
  42818. * Defines the current inertia value used during panning of the camera along the Y axis.
  42819. */
  42820. inertialPanningY: number;
  42821. /**
  42822. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42823. * Basically if your fingers moves away from more than this distance you will be considered
  42824. * in pinch mode.
  42825. */
  42826. pinchToPanMaxDistance: number;
  42827. /**
  42828. * Defines the maximum distance the camera can pan.
  42829. * This could help keeping the cammera always in your scene.
  42830. */
  42831. panningDistanceLimit: Nullable<number>;
  42832. /**
  42833. * Defines the target of the camera before paning.
  42834. */
  42835. panningOriginTarget: Vector3;
  42836. /**
  42837. * Defines the value of the inertia used during panning.
  42838. * 0 would mean stop inertia and one would mean no decelleration at all.
  42839. */
  42840. panningInertia: number;
  42841. /**
  42842. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42843. */
  42844. get angularSensibilityX(): number;
  42845. set angularSensibilityX(value: number);
  42846. /**
  42847. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42848. */
  42849. get angularSensibilityY(): number;
  42850. set angularSensibilityY(value: number);
  42851. /**
  42852. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42853. */
  42854. get pinchPrecision(): number;
  42855. set pinchPrecision(value: number);
  42856. /**
  42857. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42858. * It will be used instead of pinchDeltaPrecision if different from 0.
  42859. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42860. */
  42861. get pinchDeltaPercentage(): number;
  42862. set pinchDeltaPercentage(value: number);
  42863. /**
  42864. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42865. * and pinch delta percentage.
  42866. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42867. * that any object in the plane at the camera's target point will scale
  42868. * perfectly with finger motion.
  42869. */
  42870. get useNaturalPinchZoom(): boolean;
  42871. set useNaturalPinchZoom(value: boolean);
  42872. /**
  42873. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42874. */
  42875. get panningSensibility(): number;
  42876. set panningSensibility(value: number);
  42877. /**
  42878. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42879. */
  42880. get keysUp(): number[];
  42881. set keysUp(value: number[]);
  42882. /**
  42883. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42884. */
  42885. get keysDown(): number[];
  42886. set keysDown(value: number[]);
  42887. /**
  42888. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42889. */
  42890. get keysLeft(): number[];
  42891. set keysLeft(value: number[]);
  42892. /**
  42893. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42894. */
  42895. get keysRight(): number[];
  42896. set keysRight(value: number[]);
  42897. /**
  42898. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42899. */
  42900. get wheelPrecision(): number;
  42901. set wheelPrecision(value: number);
  42902. /**
  42903. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42904. * It will be used instead of pinchDeltaPrecision if different from 0.
  42905. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42906. */
  42907. get wheelDeltaPercentage(): number;
  42908. set wheelDeltaPercentage(value: number);
  42909. /**
  42910. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42911. */
  42912. zoomOnFactor: number;
  42913. /**
  42914. * Defines a screen offset for the camera position.
  42915. */
  42916. targetScreenOffset: Vector2;
  42917. /**
  42918. * Allows the camera to be completely reversed.
  42919. * If false the camera can not arrive upside down.
  42920. */
  42921. allowUpsideDown: boolean;
  42922. /**
  42923. * Define if double tap/click is used to restore the previously saved state of the camera.
  42924. */
  42925. useInputToRestoreState: boolean;
  42926. /** @hidden */
  42927. _viewMatrix: Matrix;
  42928. /** @hidden */
  42929. _useCtrlForPanning: boolean;
  42930. /** @hidden */
  42931. _panningMouseButton: number;
  42932. /**
  42933. * Defines the input associated to the camera.
  42934. */
  42935. inputs: ArcRotateCameraInputsManager;
  42936. /** @hidden */
  42937. _reset: () => void;
  42938. /**
  42939. * Defines the allowed panning axis.
  42940. */
  42941. panningAxis: Vector3;
  42942. protected _localDirection: Vector3;
  42943. protected _transformedDirection: Vector3;
  42944. private _bouncingBehavior;
  42945. /**
  42946. * Gets the bouncing behavior of the camera if it has been enabled.
  42947. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42948. */
  42949. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42950. /**
  42951. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42952. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42953. */
  42954. get useBouncingBehavior(): boolean;
  42955. set useBouncingBehavior(value: boolean);
  42956. private _framingBehavior;
  42957. /**
  42958. * Gets the framing behavior of the camera if it has been enabled.
  42959. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42960. */
  42961. get framingBehavior(): Nullable<FramingBehavior>;
  42962. /**
  42963. * Defines if the framing behavior of the camera is enabled on the camera.
  42964. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42965. */
  42966. get useFramingBehavior(): boolean;
  42967. set useFramingBehavior(value: boolean);
  42968. private _autoRotationBehavior;
  42969. /**
  42970. * Gets the auto rotation behavior of the camera if it has been enabled.
  42971. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42972. */
  42973. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42974. /**
  42975. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42976. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42977. */
  42978. get useAutoRotationBehavior(): boolean;
  42979. set useAutoRotationBehavior(value: boolean);
  42980. /**
  42981. * Observable triggered when the mesh target has been changed on the camera.
  42982. */
  42983. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42984. /**
  42985. * Event raised when the camera is colliding with a mesh.
  42986. */
  42987. onCollide: (collidedMesh: AbstractMesh) => void;
  42988. /**
  42989. * Defines whether the camera should check collision with the objects oh the scene.
  42990. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42991. */
  42992. checkCollisions: boolean;
  42993. /**
  42994. * Defines the collision radius of the camera.
  42995. * This simulates a sphere around the camera.
  42996. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42997. */
  42998. collisionRadius: Vector3;
  42999. protected _collider: Collider;
  43000. protected _previousPosition: Vector3;
  43001. protected _collisionVelocity: Vector3;
  43002. protected _newPosition: Vector3;
  43003. protected _previousAlpha: number;
  43004. protected _previousBeta: number;
  43005. protected _previousRadius: number;
  43006. protected _collisionTriggered: boolean;
  43007. protected _targetBoundingCenter: Nullable<Vector3>;
  43008. private _computationVector;
  43009. /**
  43010. * Instantiates a new ArcRotateCamera in a given scene
  43011. * @param name Defines the name of the camera
  43012. * @param alpha Defines the camera rotation along the logitudinal axis
  43013. * @param beta Defines the camera rotation along the latitudinal axis
  43014. * @param radius Defines the camera distance from its target
  43015. * @param target Defines the camera target
  43016. * @param scene Defines the scene the camera belongs to
  43017. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43018. */
  43019. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43020. /** @hidden */
  43021. _initCache(): void;
  43022. /** @hidden */
  43023. _updateCache(ignoreParentClass?: boolean): void;
  43024. protected _getTargetPosition(): Vector3;
  43025. private _storedAlpha;
  43026. private _storedBeta;
  43027. private _storedRadius;
  43028. private _storedTarget;
  43029. private _storedTargetScreenOffset;
  43030. /**
  43031. * Stores the current state of the camera (alpha, beta, radius and target)
  43032. * @returns the camera itself
  43033. */
  43034. storeState(): Camera;
  43035. /**
  43036. * @hidden
  43037. * Restored camera state. You must call storeState() first
  43038. */
  43039. _restoreStateValues(): boolean;
  43040. /** @hidden */
  43041. _isSynchronizedViewMatrix(): boolean;
  43042. /**
  43043. * Attached controls to the current camera.
  43044. * @param element Defines the element the controls should be listened from
  43045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43046. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43047. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43048. */
  43049. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43050. /**
  43051. * Detach the current controls from the camera.
  43052. * The camera will stop reacting to inputs.
  43053. * @param element Defines the element to stop listening the inputs from
  43054. */
  43055. detachControl(element: HTMLElement): void;
  43056. /** @hidden */
  43057. _checkInputs(): void;
  43058. protected _checkLimits(): void;
  43059. /**
  43060. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43061. */
  43062. rebuildAnglesAndRadius(): void;
  43063. /**
  43064. * Use a position to define the current camera related information like alpha, beta and radius
  43065. * @param position Defines the position to set the camera at
  43066. */
  43067. setPosition(position: Vector3): void;
  43068. /**
  43069. * Defines the target the camera should look at.
  43070. * This will automatically adapt alpha beta and radius to fit within the new target.
  43071. * @param target Defines the new target as a Vector or a mesh
  43072. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43073. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43074. */
  43075. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43076. /** @hidden */
  43077. _getViewMatrix(): Matrix;
  43078. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43079. /**
  43080. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43081. * @param meshes Defines the mesh to zoom on
  43082. * @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)
  43083. */
  43084. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43085. /**
  43086. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43087. * The target will be changed but the radius
  43088. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43089. * @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)
  43090. */
  43091. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43092. min: Vector3;
  43093. max: Vector3;
  43094. distance: number;
  43095. }, doNotUpdateMaxZ?: boolean): void;
  43096. /**
  43097. * @override
  43098. * Override Camera.createRigCamera
  43099. */
  43100. createRigCamera(name: string, cameraIndex: number): Camera;
  43101. /**
  43102. * @hidden
  43103. * @override
  43104. * Override Camera._updateRigCameras
  43105. */
  43106. _updateRigCameras(): void;
  43107. /**
  43108. * Destroy the camera and release the current resources hold by it.
  43109. */
  43110. dispose(): void;
  43111. /**
  43112. * Gets the current object class name.
  43113. * @return the class name
  43114. */
  43115. getClassName(): string;
  43116. }
  43117. }
  43118. declare module BABYLON {
  43119. /**
  43120. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43121. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43122. */
  43123. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43124. /**
  43125. * Gets the name of the behavior.
  43126. */
  43127. get name(): string;
  43128. private _zoomStopsAnimation;
  43129. private _idleRotationSpeed;
  43130. private _idleRotationWaitTime;
  43131. private _idleRotationSpinupTime;
  43132. /**
  43133. * Sets the flag that indicates if user zooming should stop animation.
  43134. */
  43135. set zoomStopsAnimation(flag: boolean);
  43136. /**
  43137. * Gets the flag that indicates if user zooming should stop animation.
  43138. */
  43139. get zoomStopsAnimation(): boolean;
  43140. /**
  43141. * Sets the default speed at which the camera rotates around the model.
  43142. */
  43143. set idleRotationSpeed(speed: number);
  43144. /**
  43145. * Gets the default speed at which the camera rotates around the model.
  43146. */
  43147. get idleRotationSpeed(): number;
  43148. /**
  43149. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43150. */
  43151. set idleRotationWaitTime(time: number);
  43152. /**
  43153. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43154. */
  43155. get idleRotationWaitTime(): number;
  43156. /**
  43157. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43158. */
  43159. set idleRotationSpinupTime(time: number);
  43160. /**
  43161. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43162. */
  43163. get idleRotationSpinupTime(): number;
  43164. /**
  43165. * Gets a value indicating if the camera is currently rotating because of this behavior
  43166. */
  43167. get rotationInProgress(): boolean;
  43168. private _onPrePointerObservableObserver;
  43169. private _onAfterCheckInputsObserver;
  43170. private _attachedCamera;
  43171. private _isPointerDown;
  43172. private _lastFrameTime;
  43173. private _lastInteractionTime;
  43174. private _cameraRotationSpeed;
  43175. /**
  43176. * Initializes the behavior.
  43177. */
  43178. init(): void;
  43179. /**
  43180. * Attaches the behavior to its arc rotate camera.
  43181. * @param camera Defines the camera to attach the behavior to
  43182. */
  43183. attach(camera: ArcRotateCamera): void;
  43184. /**
  43185. * Detaches the behavior from its current arc rotate camera.
  43186. */
  43187. detach(): void;
  43188. /**
  43189. * Returns true if user is scrolling.
  43190. * @return true if user is scrolling.
  43191. */
  43192. private _userIsZooming;
  43193. private _lastFrameRadius;
  43194. private _shouldAnimationStopForInteraction;
  43195. /**
  43196. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43197. */
  43198. private _applyUserInteraction;
  43199. private _userIsMoving;
  43200. }
  43201. }
  43202. declare module BABYLON {
  43203. /**
  43204. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43205. */
  43206. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43207. private ui;
  43208. /**
  43209. * The name of the behavior
  43210. */
  43211. name: string;
  43212. /**
  43213. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43214. */
  43215. distanceAwayFromFace: number;
  43216. /**
  43217. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43218. */
  43219. distanceAwayFromBottomOfFace: number;
  43220. private _faceVectors;
  43221. private _target;
  43222. private _scene;
  43223. private _onRenderObserver;
  43224. private _tmpMatrix;
  43225. private _tmpVector;
  43226. /**
  43227. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43228. * @param ui The transform node that should be attched to the mesh
  43229. */
  43230. constructor(ui: TransformNode);
  43231. /**
  43232. * Initializes the behavior
  43233. */
  43234. init(): void;
  43235. private _closestFace;
  43236. private _zeroVector;
  43237. private _lookAtTmpMatrix;
  43238. private _lookAtToRef;
  43239. /**
  43240. * Attaches the AttachToBoxBehavior to the passed in mesh
  43241. * @param target The mesh that the specified node will be attached to
  43242. */
  43243. attach(target: Mesh): void;
  43244. /**
  43245. * Detaches the behavior from the mesh
  43246. */
  43247. detach(): void;
  43248. }
  43249. }
  43250. declare module BABYLON {
  43251. /**
  43252. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43253. */
  43254. export class FadeInOutBehavior implements Behavior<Mesh> {
  43255. /**
  43256. * Time in milliseconds to delay before fading in (Default: 0)
  43257. */
  43258. delay: number;
  43259. /**
  43260. * Time in milliseconds for the mesh to fade in (Default: 300)
  43261. */
  43262. fadeInTime: number;
  43263. private _millisecondsPerFrame;
  43264. private _hovered;
  43265. private _hoverValue;
  43266. private _ownerNode;
  43267. /**
  43268. * Instatiates the FadeInOutBehavior
  43269. */
  43270. constructor();
  43271. /**
  43272. * The name of the behavior
  43273. */
  43274. get name(): string;
  43275. /**
  43276. * Initializes the behavior
  43277. */
  43278. init(): void;
  43279. /**
  43280. * Attaches the fade behavior on the passed in mesh
  43281. * @param ownerNode The mesh that will be faded in/out once attached
  43282. */
  43283. attach(ownerNode: Mesh): void;
  43284. /**
  43285. * Detaches the behavior from the mesh
  43286. */
  43287. detach(): void;
  43288. /**
  43289. * Triggers the mesh to begin fading in or out
  43290. * @param value if the object should fade in or out (true to fade in)
  43291. */
  43292. fadeIn(value: boolean): void;
  43293. private _update;
  43294. private _setAllVisibility;
  43295. }
  43296. }
  43297. declare module BABYLON {
  43298. /**
  43299. * Class containing a set of static utilities functions for managing Pivots
  43300. * @hidden
  43301. */
  43302. export class PivotTools {
  43303. private static _PivotCached;
  43304. private static _OldPivotPoint;
  43305. private static _PivotTranslation;
  43306. private static _PivotTmpVector;
  43307. /** @hidden */
  43308. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43309. /** @hidden */
  43310. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43311. }
  43312. }
  43313. declare module BABYLON {
  43314. /**
  43315. * Class containing static functions to help procedurally build meshes
  43316. */
  43317. export class PlaneBuilder {
  43318. /**
  43319. * Creates a plane mesh
  43320. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43321. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43322. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43324. * * 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
  43325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43326. * @param name defines the name of the mesh
  43327. * @param options defines the options used to create the mesh
  43328. * @param scene defines the hosting scene
  43329. * @returns the plane mesh
  43330. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43331. */
  43332. static CreatePlane(name: string, options: {
  43333. size?: number;
  43334. width?: number;
  43335. height?: number;
  43336. sideOrientation?: number;
  43337. frontUVs?: Vector4;
  43338. backUVs?: Vector4;
  43339. updatable?: boolean;
  43340. sourcePlane?: Plane;
  43341. }, scene?: Nullable<Scene>): Mesh;
  43342. }
  43343. }
  43344. declare module BABYLON {
  43345. /**
  43346. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43347. */
  43348. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43349. private static _AnyMouseID;
  43350. /**
  43351. * Abstract mesh the behavior is set on
  43352. */
  43353. attachedNode: AbstractMesh;
  43354. private _dragPlane;
  43355. private _scene;
  43356. private _pointerObserver;
  43357. private _beforeRenderObserver;
  43358. private static _planeScene;
  43359. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43360. /**
  43361. * 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)
  43362. */
  43363. maxDragAngle: number;
  43364. /**
  43365. * @hidden
  43366. */
  43367. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43368. /**
  43369. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43370. */
  43371. currentDraggingPointerID: number;
  43372. /**
  43373. * The last position where the pointer hit the drag plane in world space
  43374. */
  43375. lastDragPosition: Vector3;
  43376. /**
  43377. * If the behavior is currently in a dragging state
  43378. */
  43379. dragging: boolean;
  43380. /**
  43381. * 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)
  43382. */
  43383. dragDeltaRatio: number;
  43384. /**
  43385. * If the drag plane orientation should be updated during the dragging (Default: true)
  43386. */
  43387. updateDragPlane: boolean;
  43388. private _debugMode;
  43389. private _moving;
  43390. /**
  43391. * Fires each time the attached mesh is dragged with the pointer
  43392. * * delta between last drag position and current drag position in world space
  43393. * * dragDistance along the drag axis
  43394. * * dragPlaneNormal normal of the current drag plane used during the drag
  43395. * * dragPlanePoint in world space where the drag intersects the drag plane
  43396. */
  43397. onDragObservable: Observable<{
  43398. delta: Vector3;
  43399. dragPlanePoint: Vector3;
  43400. dragPlaneNormal: Vector3;
  43401. dragDistance: number;
  43402. pointerId: number;
  43403. }>;
  43404. /**
  43405. * Fires each time a drag begins (eg. mouse down on mesh)
  43406. */
  43407. onDragStartObservable: Observable<{
  43408. dragPlanePoint: Vector3;
  43409. pointerId: number;
  43410. }>;
  43411. /**
  43412. * Fires each time a drag ends (eg. mouse release after drag)
  43413. */
  43414. onDragEndObservable: Observable<{
  43415. dragPlanePoint: Vector3;
  43416. pointerId: number;
  43417. }>;
  43418. /**
  43419. * If the attached mesh should be moved when dragged
  43420. */
  43421. moveAttached: boolean;
  43422. /**
  43423. * If the drag behavior will react to drag events (Default: true)
  43424. */
  43425. enabled: boolean;
  43426. /**
  43427. * If pointer events should start and release the drag (Default: true)
  43428. */
  43429. startAndReleaseDragOnPointerEvents: boolean;
  43430. /**
  43431. * If camera controls should be detached during the drag
  43432. */
  43433. detachCameraControls: boolean;
  43434. /**
  43435. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43436. */
  43437. useObjectOrientationForDragging: boolean;
  43438. private _options;
  43439. /**
  43440. * Gets the options used by the behavior
  43441. */
  43442. get options(): {
  43443. dragAxis?: Vector3;
  43444. dragPlaneNormal?: Vector3;
  43445. };
  43446. /**
  43447. * Sets the options used by the behavior
  43448. */
  43449. set options(options: {
  43450. dragAxis?: Vector3;
  43451. dragPlaneNormal?: Vector3;
  43452. });
  43453. /**
  43454. * Creates a pointer drag behavior that can be attached to a mesh
  43455. * @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)
  43456. */
  43457. constructor(options?: {
  43458. dragAxis?: Vector3;
  43459. dragPlaneNormal?: Vector3;
  43460. });
  43461. /**
  43462. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43463. */
  43464. validateDrag: (targetPosition: Vector3) => boolean;
  43465. /**
  43466. * The name of the behavior
  43467. */
  43468. get name(): string;
  43469. /**
  43470. * Initializes the behavior
  43471. */
  43472. init(): void;
  43473. private _tmpVector;
  43474. private _alternatePickedPoint;
  43475. private _worldDragAxis;
  43476. private _targetPosition;
  43477. private _attachedElement;
  43478. /**
  43479. * Attaches the drag behavior the passed in mesh
  43480. * @param ownerNode The mesh that will be dragged around once attached
  43481. * @param predicate Predicate to use for pick filtering
  43482. */
  43483. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43484. /**
  43485. * Force relase the drag action by code.
  43486. */
  43487. releaseDrag(): void;
  43488. private _startDragRay;
  43489. private _lastPointerRay;
  43490. /**
  43491. * Simulates the start of a pointer drag event on the behavior
  43492. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43493. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43494. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43495. */
  43496. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43497. private _startDrag;
  43498. private _dragDelta;
  43499. private _moveDrag;
  43500. private _pickWithRayOnDragPlane;
  43501. private _pointA;
  43502. private _pointC;
  43503. private _localAxis;
  43504. private _lookAt;
  43505. private _updateDragPlanePosition;
  43506. /**
  43507. * Detaches the behavior from the mesh
  43508. */
  43509. detach(): void;
  43510. }
  43511. }
  43512. declare module BABYLON {
  43513. /**
  43514. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43515. */
  43516. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43517. private _dragBehaviorA;
  43518. private _dragBehaviorB;
  43519. private _startDistance;
  43520. private _initialScale;
  43521. private _targetScale;
  43522. private _ownerNode;
  43523. private _sceneRenderObserver;
  43524. /**
  43525. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43526. */
  43527. constructor();
  43528. /**
  43529. * The name of the behavior
  43530. */
  43531. get name(): string;
  43532. /**
  43533. * Initializes the behavior
  43534. */
  43535. init(): void;
  43536. private _getCurrentDistance;
  43537. /**
  43538. * Attaches the scale behavior the passed in mesh
  43539. * @param ownerNode The mesh that will be scaled around once attached
  43540. */
  43541. attach(ownerNode: Mesh): void;
  43542. /**
  43543. * Detaches the behavior from the mesh
  43544. */
  43545. detach(): void;
  43546. }
  43547. }
  43548. declare module BABYLON {
  43549. /**
  43550. * 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
  43551. */
  43552. export class SixDofDragBehavior implements Behavior<Mesh> {
  43553. private static _virtualScene;
  43554. private _ownerNode;
  43555. private _sceneRenderObserver;
  43556. private _scene;
  43557. private _targetPosition;
  43558. private _virtualOriginMesh;
  43559. private _virtualDragMesh;
  43560. private _pointerObserver;
  43561. private _moving;
  43562. private _startingOrientation;
  43563. private _attachedElement;
  43564. /**
  43565. * 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)
  43566. */
  43567. private zDragFactor;
  43568. /**
  43569. * If the object should rotate to face the drag origin
  43570. */
  43571. rotateDraggedObject: boolean;
  43572. /**
  43573. * If the behavior is currently in a dragging state
  43574. */
  43575. dragging: boolean;
  43576. /**
  43577. * 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)
  43578. */
  43579. dragDeltaRatio: number;
  43580. /**
  43581. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43582. */
  43583. currentDraggingPointerID: number;
  43584. /**
  43585. * If camera controls should be detached during the drag
  43586. */
  43587. detachCameraControls: boolean;
  43588. /**
  43589. * Fires each time a drag starts
  43590. */
  43591. onDragStartObservable: Observable<{}>;
  43592. /**
  43593. * Fires each time a drag ends (eg. mouse release after drag)
  43594. */
  43595. onDragEndObservable: Observable<{}>;
  43596. /**
  43597. * 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
  43598. */
  43599. constructor();
  43600. /**
  43601. * The name of the behavior
  43602. */
  43603. get name(): string;
  43604. /**
  43605. * Initializes the behavior
  43606. */
  43607. init(): void;
  43608. /**
  43609. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43610. */
  43611. private get _pointerCamera();
  43612. /**
  43613. * Attaches the scale behavior the passed in mesh
  43614. * @param ownerNode The mesh that will be scaled around once attached
  43615. */
  43616. attach(ownerNode: Mesh): void;
  43617. /**
  43618. * Detaches the behavior from the mesh
  43619. */
  43620. detach(): void;
  43621. }
  43622. }
  43623. declare module BABYLON {
  43624. /**
  43625. * Class used to apply inverse kinematics to bones
  43626. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43627. */
  43628. export class BoneIKController {
  43629. private static _tmpVecs;
  43630. private static _tmpQuat;
  43631. private static _tmpMats;
  43632. /**
  43633. * Gets or sets the target mesh
  43634. */
  43635. targetMesh: AbstractMesh;
  43636. /** Gets or sets the mesh used as pole */
  43637. poleTargetMesh: AbstractMesh;
  43638. /**
  43639. * Gets or sets the bone used as pole
  43640. */
  43641. poleTargetBone: Nullable<Bone>;
  43642. /**
  43643. * Gets or sets the target position
  43644. */
  43645. targetPosition: Vector3;
  43646. /**
  43647. * Gets or sets the pole target position
  43648. */
  43649. poleTargetPosition: Vector3;
  43650. /**
  43651. * Gets or sets the pole target local offset
  43652. */
  43653. poleTargetLocalOffset: Vector3;
  43654. /**
  43655. * Gets or sets the pole angle
  43656. */
  43657. poleAngle: number;
  43658. /**
  43659. * Gets or sets the mesh associated with the controller
  43660. */
  43661. mesh: AbstractMesh;
  43662. /**
  43663. * 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)
  43664. */
  43665. slerpAmount: number;
  43666. private _bone1Quat;
  43667. private _bone1Mat;
  43668. private _bone2Ang;
  43669. private _bone1;
  43670. private _bone2;
  43671. private _bone1Length;
  43672. private _bone2Length;
  43673. private _maxAngle;
  43674. private _maxReach;
  43675. private _rightHandedSystem;
  43676. private _bendAxis;
  43677. private _slerping;
  43678. private _adjustRoll;
  43679. /**
  43680. * Gets or sets maximum allowed angle
  43681. */
  43682. get maxAngle(): number;
  43683. set maxAngle(value: number);
  43684. /**
  43685. * Creates a new BoneIKController
  43686. * @param mesh defines the mesh to control
  43687. * @param bone defines the bone to control
  43688. * @param options defines options to set up the controller
  43689. */
  43690. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43691. targetMesh?: AbstractMesh;
  43692. poleTargetMesh?: AbstractMesh;
  43693. poleTargetBone?: Bone;
  43694. poleTargetLocalOffset?: Vector3;
  43695. poleAngle?: number;
  43696. bendAxis?: Vector3;
  43697. maxAngle?: number;
  43698. slerpAmount?: number;
  43699. });
  43700. private _setMaxAngle;
  43701. /**
  43702. * Force the controller to update the bones
  43703. */
  43704. update(): void;
  43705. }
  43706. }
  43707. declare module BABYLON {
  43708. /**
  43709. * Class used to make a bone look toward a point in space
  43710. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43711. */
  43712. export class BoneLookController {
  43713. private static _tmpVecs;
  43714. private static _tmpQuat;
  43715. private static _tmpMats;
  43716. /**
  43717. * The target Vector3 that the bone will look at
  43718. */
  43719. target: Vector3;
  43720. /**
  43721. * The mesh that the bone is attached to
  43722. */
  43723. mesh: AbstractMesh;
  43724. /**
  43725. * The bone that will be looking to the target
  43726. */
  43727. bone: Bone;
  43728. /**
  43729. * The up axis of the coordinate system that is used when the bone is rotated
  43730. */
  43731. upAxis: Vector3;
  43732. /**
  43733. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43734. */
  43735. upAxisSpace: Space;
  43736. /**
  43737. * Used to make an adjustment to the yaw of the bone
  43738. */
  43739. adjustYaw: number;
  43740. /**
  43741. * Used to make an adjustment to the pitch of the bone
  43742. */
  43743. adjustPitch: number;
  43744. /**
  43745. * Used to make an adjustment to the roll of the bone
  43746. */
  43747. adjustRoll: number;
  43748. /**
  43749. * 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)
  43750. */
  43751. slerpAmount: number;
  43752. private _minYaw;
  43753. private _maxYaw;
  43754. private _minPitch;
  43755. private _maxPitch;
  43756. private _minYawSin;
  43757. private _minYawCos;
  43758. private _maxYawSin;
  43759. private _maxYawCos;
  43760. private _midYawConstraint;
  43761. private _minPitchTan;
  43762. private _maxPitchTan;
  43763. private _boneQuat;
  43764. private _slerping;
  43765. private _transformYawPitch;
  43766. private _transformYawPitchInv;
  43767. private _firstFrameSkipped;
  43768. private _yawRange;
  43769. private _fowardAxis;
  43770. /**
  43771. * Gets or sets the minimum yaw angle that the bone can look to
  43772. */
  43773. get minYaw(): number;
  43774. set minYaw(value: number);
  43775. /**
  43776. * Gets or sets the maximum yaw angle that the bone can look to
  43777. */
  43778. get maxYaw(): number;
  43779. set maxYaw(value: number);
  43780. /**
  43781. * Gets or sets the minimum pitch angle that the bone can look to
  43782. */
  43783. get minPitch(): number;
  43784. set minPitch(value: number);
  43785. /**
  43786. * Gets or sets the maximum pitch angle that the bone can look to
  43787. */
  43788. get maxPitch(): number;
  43789. set maxPitch(value: number);
  43790. /**
  43791. * Create a BoneLookController
  43792. * @param mesh the mesh that the bone belongs to
  43793. * @param bone the bone that will be looking to the target
  43794. * @param target the target Vector3 to look at
  43795. * @param options optional settings:
  43796. * * maxYaw: the maximum angle the bone will yaw to
  43797. * * minYaw: the minimum angle the bone will yaw to
  43798. * * maxPitch: the maximum angle the bone will pitch to
  43799. * * minPitch: the minimum angle the bone will yaw to
  43800. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43801. * * upAxis: the up axis of the coordinate system
  43802. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43803. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43804. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43805. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43806. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43807. * * adjustRoll: used to make an adjustment to the roll of the bone
  43808. **/
  43809. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43810. maxYaw?: number;
  43811. minYaw?: number;
  43812. maxPitch?: number;
  43813. minPitch?: number;
  43814. slerpAmount?: number;
  43815. upAxis?: Vector3;
  43816. upAxisSpace?: Space;
  43817. yawAxis?: Vector3;
  43818. pitchAxis?: Vector3;
  43819. adjustYaw?: number;
  43820. adjustPitch?: number;
  43821. adjustRoll?: number;
  43822. });
  43823. /**
  43824. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43825. */
  43826. update(): void;
  43827. private _getAngleDiff;
  43828. private _getAngleBetween;
  43829. private _isAngleBetween;
  43830. }
  43831. }
  43832. declare module BABYLON {
  43833. /**
  43834. * Manage the gamepad inputs to control an arc rotate camera.
  43835. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43836. */
  43837. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43838. /**
  43839. * Defines the camera the input is attached to.
  43840. */
  43841. camera: ArcRotateCamera;
  43842. /**
  43843. * Defines the gamepad the input is gathering event from.
  43844. */
  43845. gamepad: Nullable<Gamepad>;
  43846. /**
  43847. * Defines the gamepad rotation sensiblity.
  43848. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43849. */
  43850. gamepadRotationSensibility: number;
  43851. /**
  43852. * Defines the gamepad move sensiblity.
  43853. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43854. */
  43855. gamepadMoveSensibility: number;
  43856. private _yAxisScale;
  43857. /**
  43858. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43859. */
  43860. get invertYAxis(): boolean;
  43861. set invertYAxis(value: boolean);
  43862. private _onGamepadConnectedObserver;
  43863. private _onGamepadDisconnectedObserver;
  43864. /**
  43865. * Attach the input controls to a specific dom element to get the input from.
  43866. * @param element Defines the element the controls should be listened from
  43867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43868. */
  43869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43870. /**
  43871. * Detach the current controls from the specified dom element.
  43872. * @param element Defines the element to stop listening the inputs from
  43873. */
  43874. detachControl(element: Nullable<HTMLElement>): void;
  43875. /**
  43876. * Update the current camera state depending on the inputs that have been used this frame.
  43877. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43878. */
  43879. checkInputs(): void;
  43880. /**
  43881. * Gets the class name of the current intput.
  43882. * @returns the class name
  43883. */
  43884. getClassName(): string;
  43885. /**
  43886. * Get the friendly name associated with the input class.
  43887. * @returns the input friendly name
  43888. */
  43889. getSimpleName(): string;
  43890. }
  43891. }
  43892. declare module BABYLON {
  43893. interface ArcRotateCameraInputsManager {
  43894. /**
  43895. * Add orientation input support to the input manager.
  43896. * @returns the current input manager
  43897. */
  43898. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43899. }
  43900. /**
  43901. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43902. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43903. */
  43904. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43905. /**
  43906. * Defines the camera the input is attached to.
  43907. */
  43908. camera: ArcRotateCamera;
  43909. /**
  43910. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43911. */
  43912. alphaCorrection: number;
  43913. /**
  43914. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43915. */
  43916. gammaCorrection: number;
  43917. private _alpha;
  43918. private _gamma;
  43919. private _dirty;
  43920. private _deviceOrientationHandler;
  43921. /**
  43922. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43923. */
  43924. constructor();
  43925. /**
  43926. * Attach the input controls to a specific dom element to get the input from.
  43927. * @param element Defines the element the controls should be listened from
  43928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43929. */
  43930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43931. /** @hidden */
  43932. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43933. /**
  43934. * Update the current camera state depending on the inputs that have been used this frame.
  43935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43936. */
  43937. checkInputs(): void;
  43938. /**
  43939. * Detach the current controls from the specified dom element.
  43940. * @param element Defines the element to stop listening the inputs from
  43941. */
  43942. detachControl(element: Nullable<HTMLElement>): void;
  43943. /**
  43944. * Gets the class name of the current intput.
  43945. * @returns the class name
  43946. */
  43947. getClassName(): string;
  43948. /**
  43949. * Get the friendly name associated with the input class.
  43950. * @returns the input friendly name
  43951. */
  43952. getSimpleName(): string;
  43953. }
  43954. }
  43955. declare module BABYLON {
  43956. /**
  43957. * Listen to mouse events to control the camera.
  43958. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43959. */
  43960. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43961. /**
  43962. * Defines the camera the input is attached to.
  43963. */
  43964. camera: FlyCamera;
  43965. /**
  43966. * Defines if touch is enabled. (Default is true.)
  43967. */
  43968. touchEnabled: boolean;
  43969. /**
  43970. * Defines the buttons associated with the input to handle camera rotation.
  43971. */
  43972. buttons: number[];
  43973. /**
  43974. * Assign buttons for Yaw control.
  43975. */
  43976. buttonsYaw: number[];
  43977. /**
  43978. * Assign buttons for Pitch control.
  43979. */
  43980. buttonsPitch: number[];
  43981. /**
  43982. * Assign buttons for Roll control.
  43983. */
  43984. buttonsRoll: number[];
  43985. /**
  43986. * Detect if any button is being pressed while mouse is moved.
  43987. * -1 = Mouse locked.
  43988. * 0 = Left button.
  43989. * 1 = Middle Button.
  43990. * 2 = Right Button.
  43991. */
  43992. activeButton: number;
  43993. /**
  43994. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43995. * Higher values reduce its sensitivity.
  43996. */
  43997. angularSensibility: number;
  43998. private _mousemoveCallback;
  43999. private _observer;
  44000. private _rollObserver;
  44001. private previousPosition;
  44002. private noPreventDefault;
  44003. private element;
  44004. /**
  44005. * Listen to mouse events to control the camera.
  44006. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44007. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44008. */
  44009. constructor(touchEnabled?: boolean);
  44010. /**
  44011. * Attach the mouse control to the HTML DOM element.
  44012. * @param element Defines the element that listens to the input events.
  44013. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44014. */
  44015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44016. /**
  44017. * Detach the current controls from the specified dom element.
  44018. * @param element Defines the element to stop listening the inputs from
  44019. */
  44020. detachControl(element: Nullable<HTMLElement>): void;
  44021. /**
  44022. * Gets the class name of the current input.
  44023. * @returns the class name.
  44024. */
  44025. getClassName(): string;
  44026. /**
  44027. * Get the friendly name associated with the input class.
  44028. * @returns the input's friendly name.
  44029. */
  44030. getSimpleName(): string;
  44031. private _pointerInput;
  44032. private _onMouseMove;
  44033. /**
  44034. * Rotate camera by mouse offset.
  44035. */
  44036. private rotateCamera;
  44037. }
  44038. }
  44039. declare module BABYLON {
  44040. /**
  44041. * Default Inputs manager for the FlyCamera.
  44042. * It groups all the default supported inputs for ease of use.
  44043. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44044. */
  44045. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44046. /**
  44047. * Instantiates a new FlyCameraInputsManager.
  44048. * @param camera Defines the camera the inputs belong to.
  44049. */
  44050. constructor(camera: FlyCamera);
  44051. /**
  44052. * Add keyboard input support to the input manager.
  44053. * @returns the new FlyCameraKeyboardMoveInput().
  44054. */
  44055. addKeyboard(): FlyCameraInputsManager;
  44056. /**
  44057. * Add mouse input support to the input manager.
  44058. * @param touchEnabled Enable touch screen support.
  44059. * @returns the new FlyCameraMouseInput().
  44060. */
  44061. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44062. }
  44063. }
  44064. declare module BABYLON {
  44065. /**
  44066. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44067. * such as in a 3D Space Shooter or a Flight Simulator.
  44068. */
  44069. export class FlyCamera extends TargetCamera {
  44070. /**
  44071. * Define the collision ellipsoid of the camera.
  44072. * This is helpful for simulating a camera body, like a player's body.
  44073. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44074. */
  44075. ellipsoid: Vector3;
  44076. /**
  44077. * Define an offset for the position of the ellipsoid around the camera.
  44078. * This can be helpful if the camera is attached away from the player's body center,
  44079. * such as at its head.
  44080. */
  44081. ellipsoidOffset: Vector3;
  44082. /**
  44083. * Enable or disable collisions of the camera with the rest of the scene objects.
  44084. */
  44085. checkCollisions: boolean;
  44086. /**
  44087. * Enable or disable gravity on the camera.
  44088. */
  44089. applyGravity: boolean;
  44090. /**
  44091. * Define the current direction the camera is moving to.
  44092. */
  44093. cameraDirection: Vector3;
  44094. /**
  44095. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44096. * This overrides and empties cameraRotation.
  44097. */
  44098. rotationQuaternion: Quaternion;
  44099. /**
  44100. * Track Roll to maintain the wanted Rolling when looking around.
  44101. */
  44102. _trackRoll: number;
  44103. /**
  44104. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44105. */
  44106. rollCorrect: number;
  44107. /**
  44108. * Mimic a banked turn, Rolling the camera when Yawing.
  44109. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44110. */
  44111. bankedTurn: boolean;
  44112. /**
  44113. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44114. */
  44115. bankedTurnLimit: number;
  44116. /**
  44117. * Value of 0 disables the banked Roll.
  44118. * Value of 1 is equal to the Yaw angle in radians.
  44119. */
  44120. bankedTurnMultiplier: number;
  44121. /**
  44122. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44123. */
  44124. inputs: FlyCameraInputsManager;
  44125. /**
  44126. * Gets the input sensibility for mouse input.
  44127. * Higher values reduce sensitivity.
  44128. */
  44129. get angularSensibility(): number;
  44130. /**
  44131. * Sets the input sensibility for a mouse input.
  44132. * Higher values reduce sensitivity.
  44133. */
  44134. set angularSensibility(value: number);
  44135. /**
  44136. * Get the keys for camera movement forward.
  44137. */
  44138. get keysForward(): number[];
  44139. /**
  44140. * Set the keys for camera movement forward.
  44141. */
  44142. set keysForward(value: number[]);
  44143. /**
  44144. * Get the keys for camera movement backward.
  44145. */
  44146. get keysBackward(): number[];
  44147. set keysBackward(value: number[]);
  44148. /**
  44149. * Get the keys for camera movement up.
  44150. */
  44151. get keysUp(): number[];
  44152. /**
  44153. * Set the keys for camera movement up.
  44154. */
  44155. set keysUp(value: number[]);
  44156. /**
  44157. * Get the keys for camera movement down.
  44158. */
  44159. get keysDown(): number[];
  44160. /**
  44161. * Set the keys for camera movement down.
  44162. */
  44163. set keysDown(value: number[]);
  44164. /**
  44165. * Get the keys for camera movement left.
  44166. */
  44167. get keysLeft(): number[];
  44168. /**
  44169. * Set the keys for camera movement left.
  44170. */
  44171. set keysLeft(value: number[]);
  44172. /**
  44173. * Set the keys for camera movement right.
  44174. */
  44175. get keysRight(): number[];
  44176. /**
  44177. * Set the keys for camera movement right.
  44178. */
  44179. set keysRight(value: number[]);
  44180. /**
  44181. * Event raised when the camera collides with a mesh in the scene.
  44182. */
  44183. onCollide: (collidedMesh: AbstractMesh) => void;
  44184. private _collider;
  44185. private _needMoveForGravity;
  44186. private _oldPosition;
  44187. private _diffPosition;
  44188. private _newPosition;
  44189. /** @hidden */
  44190. _localDirection: Vector3;
  44191. /** @hidden */
  44192. _transformedDirection: Vector3;
  44193. /**
  44194. * Instantiates a FlyCamera.
  44195. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44196. * such as in a 3D Space Shooter or a Flight Simulator.
  44197. * @param name Define the name of the camera in the scene.
  44198. * @param position Define the starting position of the camera in the scene.
  44199. * @param scene Define the scene the camera belongs to.
  44200. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44201. */
  44202. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44203. /**
  44204. * Attach a control to the HTML DOM element.
  44205. * @param element Defines the element that listens to the input events.
  44206. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44207. */
  44208. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44209. /**
  44210. * Detach a control from the HTML DOM element.
  44211. * The camera will stop reacting to that input.
  44212. * @param element Defines the element that listens to the input events.
  44213. */
  44214. detachControl(element: HTMLElement): void;
  44215. private _collisionMask;
  44216. /**
  44217. * Get the mask that the camera ignores in collision events.
  44218. */
  44219. get collisionMask(): number;
  44220. /**
  44221. * Set the mask that the camera ignores in collision events.
  44222. */
  44223. set collisionMask(mask: number);
  44224. /** @hidden */
  44225. _collideWithWorld(displacement: Vector3): void;
  44226. /** @hidden */
  44227. private _onCollisionPositionChange;
  44228. /** @hidden */
  44229. _checkInputs(): void;
  44230. /** @hidden */
  44231. _decideIfNeedsToMove(): boolean;
  44232. /** @hidden */
  44233. _updatePosition(): void;
  44234. /**
  44235. * Restore the Roll to its target value at the rate specified.
  44236. * @param rate - Higher means slower restoring.
  44237. * @hidden
  44238. */
  44239. restoreRoll(rate: number): void;
  44240. /**
  44241. * Destroy the camera and release the current resources held by it.
  44242. */
  44243. dispose(): void;
  44244. /**
  44245. * Get the current object class name.
  44246. * @returns the class name.
  44247. */
  44248. getClassName(): string;
  44249. }
  44250. }
  44251. declare module BABYLON {
  44252. /**
  44253. * Listen to keyboard events to control the camera.
  44254. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44255. */
  44256. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44257. /**
  44258. * Defines the camera the input is attached to.
  44259. */
  44260. camera: FlyCamera;
  44261. /**
  44262. * The list of keyboard keys used to control the forward move of the camera.
  44263. */
  44264. keysForward: number[];
  44265. /**
  44266. * The list of keyboard keys used to control the backward move of the camera.
  44267. */
  44268. keysBackward: number[];
  44269. /**
  44270. * The list of keyboard keys used to control the forward move of the camera.
  44271. */
  44272. keysUp: number[];
  44273. /**
  44274. * The list of keyboard keys used to control the backward move of the camera.
  44275. */
  44276. keysDown: number[];
  44277. /**
  44278. * The list of keyboard keys used to control the right strafe move of the camera.
  44279. */
  44280. keysRight: number[];
  44281. /**
  44282. * The list of keyboard keys used to control the left strafe move of the camera.
  44283. */
  44284. keysLeft: number[];
  44285. private _keys;
  44286. private _onCanvasBlurObserver;
  44287. private _onKeyboardObserver;
  44288. private _engine;
  44289. private _scene;
  44290. /**
  44291. * Attach the input controls to a specific dom element to get the input from.
  44292. * @param element Defines the element the controls should be listened from
  44293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44294. */
  44295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44296. /**
  44297. * Detach the current controls from the specified dom element.
  44298. * @param element Defines the element to stop listening the inputs from
  44299. */
  44300. detachControl(element: Nullable<HTMLElement>): void;
  44301. /**
  44302. * Gets the class name of the current intput.
  44303. * @returns the class name
  44304. */
  44305. getClassName(): string;
  44306. /** @hidden */
  44307. _onLostFocus(e: FocusEvent): void;
  44308. /**
  44309. * Get the friendly name associated with the input class.
  44310. * @returns the input friendly name
  44311. */
  44312. getSimpleName(): string;
  44313. /**
  44314. * Update the current camera state depending on the inputs that have been used this frame.
  44315. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44316. */
  44317. checkInputs(): void;
  44318. }
  44319. }
  44320. declare module BABYLON {
  44321. /**
  44322. * Manage the mouse wheel inputs to control a follow camera.
  44323. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44324. */
  44325. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44326. /**
  44327. * Defines the camera the input is attached to.
  44328. */
  44329. camera: FollowCamera;
  44330. /**
  44331. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44332. */
  44333. axisControlRadius: boolean;
  44334. /**
  44335. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44336. */
  44337. axisControlHeight: boolean;
  44338. /**
  44339. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44340. */
  44341. axisControlRotation: boolean;
  44342. /**
  44343. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44344. * relation to mouseWheel events.
  44345. */
  44346. wheelPrecision: number;
  44347. /**
  44348. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44349. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44350. */
  44351. wheelDeltaPercentage: number;
  44352. private _wheel;
  44353. private _observer;
  44354. /**
  44355. * Attach the input controls to a specific dom element to get the input from.
  44356. * @param element Defines the element the controls should be listened from
  44357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44358. */
  44359. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44360. /**
  44361. * Detach the current controls from the specified dom element.
  44362. * @param element Defines the element to stop listening the inputs from
  44363. */
  44364. detachControl(element: Nullable<HTMLElement>): void;
  44365. /**
  44366. * Gets the class name of the current intput.
  44367. * @returns the class name
  44368. */
  44369. getClassName(): string;
  44370. /**
  44371. * Get the friendly name associated with the input class.
  44372. * @returns the input friendly name
  44373. */
  44374. getSimpleName(): string;
  44375. }
  44376. }
  44377. declare module BABYLON {
  44378. /**
  44379. * Manage the pointers inputs to control an follow camera.
  44380. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44381. */
  44382. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44383. /**
  44384. * Defines the camera the input is attached to.
  44385. */
  44386. camera: FollowCamera;
  44387. /**
  44388. * Gets the class name of the current input.
  44389. * @returns the class name
  44390. */
  44391. getClassName(): string;
  44392. /**
  44393. * Defines the pointer angular sensibility along the X axis or how fast is
  44394. * the camera rotating.
  44395. * A negative number will reverse the axis direction.
  44396. */
  44397. angularSensibilityX: number;
  44398. /**
  44399. * Defines the pointer angular sensibility along the Y axis or how fast is
  44400. * the camera rotating.
  44401. * A negative number will reverse the axis direction.
  44402. */
  44403. angularSensibilityY: number;
  44404. /**
  44405. * Defines the pointer pinch precision or how fast is the camera zooming.
  44406. * A negative number will reverse the axis direction.
  44407. */
  44408. pinchPrecision: number;
  44409. /**
  44410. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44411. * from 0.
  44412. * It defines the percentage of current camera.radius to use as delta when
  44413. * pinch zoom is used.
  44414. */
  44415. pinchDeltaPercentage: number;
  44416. /**
  44417. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44418. */
  44419. axisXControlRadius: boolean;
  44420. /**
  44421. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44422. */
  44423. axisXControlHeight: boolean;
  44424. /**
  44425. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44426. */
  44427. axisXControlRotation: boolean;
  44428. /**
  44429. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44430. */
  44431. axisYControlRadius: boolean;
  44432. /**
  44433. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44434. */
  44435. axisYControlHeight: boolean;
  44436. /**
  44437. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44438. */
  44439. axisYControlRotation: boolean;
  44440. /**
  44441. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44442. */
  44443. axisPinchControlRadius: boolean;
  44444. /**
  44445. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44446. */
  44447. axisPinchControlHeight: boolean;
  44448. /**
  44449. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44450. */
  44451. axisPinchControlRotation: boolean;
  44452. /**
  44453. * Log error messages if basic misconfiguration has occurred.
  44454. */
  44455. warningEnable: boolean;
  44456. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44457. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44458. private _warningCounter;
  44459. private _warning;
  44460. }
  44461. }
  44462. declare module BABYLON {
  44463. /**
  44464. * Default Inputs manager for the FollowCamera.
  44465. * It groups all the default supported inputs for ease of use.
  44466. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44467. */
  44468. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44469. /**
  44470. * Instantiates a new FollowCameraInputsManager.
  44471. * @param camera Defines the camera the inputs belong to
  44472. */
  44473. constructor(camera: FollowCamera);
  44474. /**
  44475. * Add keyboard input support to the input manager.
  44476. * @returns the current input manager
  44477. */
  44478. addKeyboard(): FollowCameraInputsManager;
  44479. /**
  44480. * Add mouse wheel input support to the input manager.
  44481. * @returns the current input manager
  44482. */
  44483. addMouseWheel(): FollowCameraInputsManager;
  44484. /**
  44485. * Add pointers input support to the input manager.
  44486. * @returns the current input manager
  44487. */
  44488. addPointers(): FollowCameraInputsManager;
  44489. /**
  44490. * Add orientation input support to the input manager.
  44491. * @returns the current input manager
  44492. */
  44493. addVRDeviceOrientation(): FollowCameraInputsManager;
  44494. }
  44495. }
  44496. declare module BABYLON {
  44497. /**
  44498. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44499. * an arc rotate version arcFollowCamera are available.
  44500. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44501. */
  44502. export class FollowCamera extends TargetCamera {
  44503. /**
  44504. * Distance the follow camera should follow an object at
  44505. */
  44506. radius: number;
  44507. /**
  44508. * Minimum allowed distance of the camera to the axis of rotation
  44509. * (The camera can not get closer).
  44510. * This can help limiting how the Camera is able to move in the scene.
  44511. */
  44512. lowerRadiusLimit: Nullable<number>;
  44513. /**
  44514. * Maximum allowed distance of the camera to the axis of rotation
  44515. * (The camera can not get further).
  44516. * This can help limiting how the Camera is able to move in the scene.
  44517. */
  44518. upperRadiusLimit: Nullable<number>;
  44519. /**
  44520. * Define a rotation offset between the camera and the object it follows
  44521. */
  44522. rotationOffset: number;
  44523. /**
  44524. * Minimum allowed angle to camera position relative to target object.
  44525. * This can help limiting how the Camera is able to move in the scene.
  44526. */
  44527. lowerRotationOffsetLimit: Nullable<number>;
  44528. /**
  44529. * Maximum allowed angle to camera position relative to target object.
  44530. * This can help limiting how the Camera is able to move in the scene.
  44531. */
  44532. upperRotationOffsetLimit: Nullable<number>;
  44533. /**
  44534. * Define a height offset between the camera and the object it follows.
  44535. * It can help following an object from the top (like a car chaing a plane)
  44536. */
  44537. heightOffset: number;
  44538. /**
  44539. * Minimum allowed height of camera position relative to target object.
  44540. * This can help limiting how the Camera is able to move in the scene.
  44541. */
  44542. lowerHeightOffsetLimit: Nullable<number>;
  44543. /**
  44544. * Maximum allowed height of camera position relative to target object.
  44545. * This can help limiting how the Camera is able to move in the scene.
  44546. */
  44547. upperHeightOffsetLimit: Nullable<number>;
  44548. /**
  44549. * Define how fast the camera can accelerate to follow it s target.
  44550. */
  44551. cameraAcceleration: number;
  44552. /**
  44553. * Define the speed limit of the camera following an object.
  44554. */
  44555. maxCameraSpeed: number;
  44556. /**
  44557. * Define the target of the camera.
  44558. */
  44559. lockedTarget: Nullable<AbstractMesh>;
  44560. /**
  44561. * Defines the input associated with the camera.
  44562. */
  44563. inputs: FollowCameraInputsManager;
  44564. /**
  44565. * Instantiates the follow camera.
  44566. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44567. * @param name Define the name of the camera in the scene
  44568. * @param position Define the position of the camera
  44569. * @param scene Define the scene the camera belong to
  44570. * @param lockedTarget Define the target of the camera
  44571. */
  44572. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44573. private _follow;
  44574. /**
  44575. * Attached controls to the current camera.
  44576. * @param element Defines the element the controls should be listened from
  44577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44578. */
  44579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44580. /**
  44581. * Detach the current controls from the camera.
  44582. * The camera will stop reacting to inputs.
  44583. * @param element Defines the element to stop listening the inputs from
  44584. */
  44585. detachControl(element: HTMLElement): void;
  44586. /** @hidden */
  44587. _checkInputs(): void;
  44588. private _checkLimits;
  44589. /**
  44590. * Gets the camera class name.
  44591. * @returns the class name
  44592. */
  44593. getClassName(): string;
  44594. }
  44595. /**
  44596. * Arc Rotate version of the follow camera.
  44597. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44598. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44599. */
  44600. export class ArcFollowCamera extends TargetCamera {
  44601. /** The longitudinal angle of the camera */
  44602. alpha: number;
  44603. /** The latitudinal angle of the camera */
  44604. beta: number;
  44605. /** The radius of the camera from its target */
  44606. radius: number;
  44607. private _cartesianCoordinates;
  44608. /** Define the camera target (the mesh it should follow) */
  44609. private _meshTarget;
  44610. /**
  44611. * Instantiates a new ArcFollowCamera
  44612. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44613. * @param name Define the name of the camera
  44614. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44615. * @param beta Define the rotation angle of the camera around the elevation axis
  44616. * @param radius Define the radius of the camera from its target point
  44617. * @param target Define the target of the camera
  44618. * @param scene Define the scene the camera belongs to
  44619. */
  44620. constructor(name: string,
  44621. /** The longitudinal angle of the camera */
  44622. alpha: number,
  44623. /** The latitudinal angle of the camera */
  44624. beta: number,
  44625. /** The radius of the camera from its target */
  44626. radius: number,
  44627. /** Define the camera target (the mesh it should follow) */
  44628. target: Nullable<AbstractMesh>, scene: Scene);
  44629. private _follow;
  44630. /** @hidden */
  44631. _checkInputs(): void;
  44632. /**
  44633. * Returns the class name of the object.
  44634. * It is mostly used internally for serialization purposes.
  44635. */
  44636. getClassName(): string;
  44637. }
  44638. }
  44639. declare module BABYLON {
  44640. /**
  44641. * Manage the keyboard inputs to control the movement of a follow camera.
  44642. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44643. */
  44644. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44645. /**
  44646. * Defines the camera the input is attached to.
  44647. */
  44648. camera: FollowCamera;
  44649. /**
  44650. * Defines the list of key codes associated with the up action (increase heightOffset)
  44651. */
  44652. keysHeightOffsetIncr: number[];
  44653. /**
  44654. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44655. */
  44656. keysHeightOffsetDecr: number[];
  44657. /**
  44658. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44659. */
  44660. keysHeightOffsetModifierAlt: boolean;
  44661. /**
  44662. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44663. */
  44664. keysHeightOffsetModifierCtrl: boolean;
  44665. /**
  44666. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44667. */
  44668. keysHeightOffsetModifierShift: boolean;
  44669. /**
  44670. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44671. */
  44672. keysRotationOffsetIncr: number[];
  44673. /**
  44674. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44675. */
  44676. keysRotationOffsetDecr: number[];
  44677. /**
  44678. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44679. */
  44680. keysRotationOffsetModifierAlt: boolean;
  44681. /**
  44682. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44683. */
  44684. keysRotationOffsetModifierCtrl: boolean;
  44685. /**
  44686. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44687. */
  44688. keysRotationOffsetModifierShift: boolean;
  44689. /**
  44690. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44691. */
  44692. keysRadiusIncr: number[];
  44693. /**
  44694. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44695. */
  44696. keysRadiusDecr: number[];
  44697. /**
  44698. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44699. */
  44700. keysRadiusModifierAlt: boolean;
  44701. /**
  44702. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44703. */
  44704. keysRadiusModifierCtrl: boolean;
  44705. /**
  44706. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44707. */
  44708. keysRadiusModifierShift: boolean;
  44709. /**
  44710. * Defines the rate of change of heightOffset.
  44711. */
  44712. heightSensibility: number;
  44713. /**
  44714. * Defines the rate of change of rotationOffset.
  44715. */
  44716. rotationSensibility: number;
  44717. /**
  44718. * Defines the rate of change of radius.
  44719. */
  44720. radiusSensibility: number;
  44721. private _keys;
  44722. private _ctrlPressed;
  44723. private _altPressed;
  44724. private _shiftPressed;
  44725. private _onCanvasBlurObserver;
  44726. private _onKeyboardObserver;
  44727. private _engine;
  44728. private _scene;
  44729. /**
  44730. * Attach the input controls to a specific dom element to get the input from.
  44731. * @param element Defines the element the controls should be listened from
  44732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44733. */
  44734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44735. /**
  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 input.
  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. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44757. * allow modification of the heightOffset value.
  44758. */
  44759. private _modifierHeightOffset;
  44760. /**
  44761. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44762. * allow modification of the rotationOffset value.
  44763. */
  44764. private _modifierRotationOffset;
  44765. /**
  44766. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44767. * allow modification of the radius value.
  44768. */
  44769. private _modifierRadius;
  44770. }
  44771. }
  44772. declare module BABYLON {
  44773. interface FreeCameraInputsManager {
  44774. /**
  44775. * @hidden
  44776. */
  44777. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44778. /**
  44779. * Add orientation input support to the input manager.
  44780. * @returns the current input manager
  44781. */
  44782. addDeviceOrientation(): FreeCameraInputsManager;
  44783. }
  44784. /**
  44785. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44786. * Screen rotation is taken into account.
  44787. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44788. */
  44789. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44790. private _camera;
  44791. private _screenOrientationAngle;
  44792. private _constantTranform;
  44793. private _screenQuaternion;
  44794. private _alpha;
  44795. private _beta;
  44796. private _gamma;
  44797. /**
  44798. * Can be used to detect if a device orientation sensor is available on a device
  44799. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44800. * @returns a promise that will resolve on orientation change
  44801. */
  44802. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44803. /**
  44804. * @hidden
  44805. */
  44806. _onDeviceOrientationChangedObservable: Observable<void>;
  44807. /**
  44808. * Instantiates a new input
  44809. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44810. */
  44811. constructor();
  44812. /**
  44813. * Define the camera controlled by the input.
  44814. */
  44815. get camera(): FreeCamera;
  44816. set camera(camera: FreeCamera);
  44817. /**
  44818. * Attach the input controls to a specific dom element to get the input from.
  44819. * @param element Defines the element the controls should be listened from
  44820. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44821. */
  44822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44823. private _orientationChanged;
  44824. private _deviceOrientation;
  44825. /**
  44826. * Detach the current controls from the specified dom element.
  44827. * @param element Defines the element to stop listening the inputs from
  44828. */
  44829. detachControl(element: Nullable<HTMLElement>): void;
  44830. /**
  44831. * Update the current camera state depending on the inputs that have been used this frame.
  44832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44833. */
  44834. checkInputs(): void;
  44835. /**
  44836. * Gets the class name of the current intput.
  44837. * @returns the class name
  44838. */
  44839. getClassName(): string;
  44840. /**
  44841. * Get the friendly name associated with the input class.
  44842. * @returns the input friendly name
  44843. */
  44844. getSimpleName(): string;
  44845. }
  44846. }
  44847. declare module BABYLON {
  44848. /**
  44849. * Manage the gamepad inputs to control a free camera.
  44850. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44851. */
  44852. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44853. /**
  44854. * Define the camera the input is attached to.
  44855. */
  44856. camera: FreeCamera;
  44857. /**
  44858. * Define the Gamepad controlling the input
  44859. */
  44860. gamepad: Nullable<Gamepad>;
  44861. /**
  44862. * Defines the gamepad rotation sensiblity.
  44863. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44864. */
  44865. gamepadAngularSensibility: number;
  44866. /**
  44867. * Defines the gamepad move sensiblity.
  44868. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44869. */
  44870. gamepadMoveSensibility: number;
  44871. private _yAxisScale;
  44872. /**
  44873. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44874. */
  44875. get invertYAxis(): boolean;
  44876. set invertYAxis(value: boolean);
  44877. private _onGamepadConnectedObserver;
  44878. private _onGamepadDisconnectedObserver;
  44879. private _cameraTransform;
  44880. private _deltaTransform;
  44881. private _vector3;
  44882. private _vector2;
  44883. /**
  44884. * Attach the input controls to a specific dom element to get the input from.
  44885. * @param element Defines the element the controls should be listened from
  44886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44887. */
  44888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44889. /**
  44890. * Detach the current controls from the specified dom element.
  44891. * @param element Defines the element to stop listening the inputs from
  44892. */
  44893. detachControl(element: Nullable<HTMLElement>): void;
  44894. /**
  44895. * Update the current camera state depending on the inputs that have been used this frame.
  44896. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44897. */
  44898. checkInputs(): void;
  44899. /**
  44900. * Gets the class name of the current intput.
  44901. * @returns the class name
  44902. */
  44903. getClassName(): string;
  44904. /**
  44905. * Get the friendly name associated with the input class.
  44906. * @returns the input friendly name
  44907. */
  44908. getSimpleName(): string;
  44909. }
  44910. }
  44911. declare module BABYLON {
  44912. /**
  44913. * Defines the potential axis of a Joystick
  44914. */
  44915. export enum JoystickAxis {
  44916. /** X axis */
  44917. X = 0,
  44918. /** Y axis */
  44919. Y = 1,
  44920. /** Z axis */
  44921. Z = 2
  44922. }
  44923. /**
  44924. * Represents the different customization options available
  44925. * for VirtualJoystick
  44926. */
  44927. interface VirtualJoystickCustomizations {
  44928. /**
  44929. * Size of the joystick's puck
  44930. */
  44931. puckSize: number;
  44932. /**
  44933. * Size of the joystick's container
  44934. */
  44935. containerSize: number;
  44936. /**
  44937. * Color of the joystick && puck
  44938. */
  44939. color: string;
  44940. /**
  44941. * Image URL for the joystick's puck
  44942. */
  44943. puckImage?: string;
  44944. /**
  44945. * Image URL for the joystick's container
  44946. */
  44947. containerImage?: string;
  44948. /**
  44949. * Defines the unmoving position of the joystick container
  44950. */
  44951. position?: {
  44952. x: number;
  44953. y: number;
  44954. };
  44955. /**
  44956. * Defines whether or not the joystick container is always visible
  44957. */
  44958. alwaysVisible: boolean;
  44959. /**
  44960. * Defines whether or not to limit the movement of the puck to the joystick's container
  44961. */
  44962. limitToContainer: boolean;
  44963. }
  44964. /**
  44965. * Class used to define virtual joystick (used in touch mode)
  44966. */
  44967. export class VirtualJoystick {
  44968. /**
  44969. * Gets or sets a boolean indicating that left and right values must be inverted
  44970. */
  44971. reverseLeftRight: boolean;
  44972. /**
  44973. * Gets or sets a boolean indicating that up and down values must be inverted
  44974. */
  44975. reverseUpDown: boolean;
  44976. /**
  44977. * Gets the offset value for the position (ie. the change of the position value)
  44978. */
  44979. deltaPosition: Vector3;
  44980. /**
  44981. * Gets a boolean indicating if the virtual joystick was pressed
  44982. */
  44983. pressed: boolean;
  44984. /**
  44985. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44986. */
  44987. static Canvas: Nullable<HTMLCanvasElement>;
  44988. /**
  44989. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44990. */
  44991. limitToContainer: boolean;
  44992. private static _globalJoystickIndex;
  44993. private static _alwaysVisibleSticks;
  44994. private static vjCanvasContext;
  44995. private static vjCanvasWidth;
  44996. private static vjCanvasHeight;
  44997. private static halfWidth;
  44998. private static _GetDefaultOptions;
  44999. private _action;
  45000. private _axisTargetedByLeftAndRight;
  45001. private _axisTargetedByUpAndDown;
  45002. private _joystickSensibility;
  45003. private _inversedSensibility;
  45004. private _joystickPointerID;
  45005. private _joystickColor;
  45006. private _joystickPointerPos;
  45007. private _joystickPreviousPointerPos;
  45008. private _joystickPointerStartPos;
  45009. private _deltaJoystickVector;
  45010. private _leftJoystick;
  45011. private _touches;
  45012. private _joystickPosition;
  45013. private _alwaysVisible;
  45014. private _puckImage;
  45015. private _containerImage;
  45016. private _joystickPuckSize;
  45017. private _joystickContainerSize;
  45018. private _clearPuckSize;
  45019. private _clearContainerSize;
  45020. private _clearPuckSizeOffset;
  45021. private _clearContainerSizeOffset;
  45022. private _onPointerDownHandlerRef;
  45023. private _onPointerMoveHandlerRef;
  45024. private _onPointerUpHandlerRef;
  45025. private _onResize;
  45026. /**
  45027. * Creates a new virtual joystick
  45028. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45029. * @param customizations Defines the options we want to customize the VirtualJoystick
  45030. */
  45031. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45032. /**
  45033. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45034. * @param newJoystickSensibility defines the new sensibility
  45035. */
  45036. setJoystickSensibility(newJoystickSensibility: number): void;
  45037. private _onPointerDown;
  45038. private _onPointerMove;
  45039. private _onPointerUp;
  45040. /**
  45041. * Change the color of the virtual joystick
  45042. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45043. */
  45044. setJoystickColor(newColor: string): void;
  45045. /**
  45046. * Size of the joystick's container
  45047. */
  45048. set containerSize(newSize: number);
  45049. get containerSize(): number;
  45050. /**
  45051. * Size of the joystick's puck
  45052. */
  45053. set puckSize(newSize: number);
  45054. get puckSize(): number;
  45055. /**
  45056. * Clears the set position of the joystick
  45057. */
  45058. clearPosition(): void;
  45059. /**
  45060. * Defines whether or not the joystick container is always visible
  45061. */
  45062. set alwaysVisible(value: boolean);
  45063. get alwaysVisible(): boolean;
  45064. /**
  45065. * Sets the constant position of the Joystick container
  45066. * @param x X axis coordinate
  45067. * @param y Y axis coordinate
  45068. */
  45069. setPosition(x: number, y: number): void;
  45070. /**
  45071. * Defines a callback to call when the joystick is touched
  45072. * @param action defines the callback
  45073. */
  45074. setActionOnTouch(action: () => any): void;
  45075. /**
  45076. * Defines which axis you'd like to control for left & right
  45077. * @param axis defines the axis to use
  45078. */
  45079. setAxisForLeftRight(axis: JoystickAxis): void;
  45080. /**
  45081. * Defines which axis you'd like to control for up & down
  45082. * @param axis defines the axis to use
  45083. */
  45084. setAxisForUpDown(axis: JoystickAxis): void;
  45085. /**
  45086. * Clears the canvas from the previous puck / container draw
  45087. */
  45088. private _clearPreviousDraw;
  45089. /**
  45090. * Loads `urlPath` to be used for the container's image
  45091. * @param urlPath defines the urlPath of an image to use
  45092. */
  45093. setContainerImage(urlPath: string): void;
  45094. /**
  45095. * Loads `urlPath` to be used for the puck's image
  45096. * @param urlPath defines the urlPath of an image to use
  45097. */
  45098. setPuckImage(urlPath: string): void;
  45099. /**
  45100. * Draws the Virtual Joystick's container
  45101. */
  45102. private _drawContainer;
  45103. /**
  45104. * Draws the Virtual Joystick's puck
  45105. */
  45106. private _drawPuck;
  45107. private _drawVirtualJoystick;
  45108. /**
  45109. * Release internal HTML canvas
  45110. */
  45111. releaseCanvas(): void;
  45112. }
  45113. }
  45114. declare module BABYLON {
  45115. interface FreeCameraInputsManager {
  45116. /**
  45117. * Add virtual joystick input support to the input manager.
  45118. * @returns the current input manager
  45119. */
  45120. addVirtualJoystick(): FreeCameraInputsManager;
  45121. }
  45122. /**
  45123. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45124. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45125. */
  45126. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45127. /**
  45128. * Defines the camera the input is attached to.
  45129. */
  45130. camera: FreeCamera;
  45131. private _leftjoystick;
  45132. private _rightjoystick;
  45133. /**
  45134. * Gets the left stick of the virtual joystick.
  45135. * @returns The virtual Joystick
  45136. */
  45137. getLeftJoystick(): VirtualJoystick;
  45138. /**
  45139. * Gets the right stick of the virtual joystick.
  45140. * @returns The virtual Joystick
  45141. */
  45142. getRightJoystick(): VirtualJoystick;
  45143. /**
  45144. * Update the current camera state depending on the inputs that have been used this frame.
  45145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45146. */
  45147. checkInputs(): void;
  45148. /**
  45149. * Attach the input controls to a specific dom element to get the input from.
  45150. * @param element Defines the element the controls should be listened from
  45151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45152. */
  45153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45154. /**
  45155. * Detach the current controls from the specified dom element.
  45156. * @param element Defines the element to stop listening the inputs from
  45157. */
  45158. detachControl(element: Nullable<HTMLElement>): void;
  45159. /**
  45160. * Gets the class name of the current intput.
  45161. * @returns the class name
  45162. */
  45163. getClassName(): string;
  45164. /**
  45165. * Get the friendly name associated with the input class.
  45166. * @returns the input friendly name
  45167. */
  45168. getSimpleName(): string;
  45169. }
  45170. }
  45171. declare module BABYLON {
  45172. /**
  45173. * This represents a FPS type of camera controlled by touch.
  45174. * This is like a universal camera minus the Gamepad controls.
  45175. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45176. */
  45177. export class TouchCamera extends FreeCamera {
  45178. /**
  45179. * Defines the touch sensibility for rotation.
  45180. * The higher the faster.
  45181. */
  45182. get touchAngularSensibility(): number;
  45183. set touchAngularSensibility(value: number);
  45184. /**
  45185. * Defines the touch sensibility for move.
  45186. * The higher the faster.
  45187. */
  45188. get touchMoveSensibility(): number;
  45189. set touchMoveSensibility(value: number);
  45190. /**
  45191. * Instantiates a new touch camera.
  45192. * This represents a FPS type of camera controlled by touch.
  45193. * This is like a universal camera minus the Gamepad controls.
  45194. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45195. * @param name Define the name of the camera in the scene
  45196. * @param position Define the start position of the camera in the scene
  45197. * @param scene Define the scene the camera belongs to
  45198. */
  45199. constructor(name: string, position: Vector3, scene: Scene);
  45200. /**
  45201. * Gets the current object class name.
  45202. * @return the class name
  45203. */
  45204. getClassName(): string;
  45205. /** @hidden */
  45206. _setupInputs(): void;
  45207. }
  45208. }
  45209. declare module BABYLON {
  45210. /**
  45211. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45212. * being tilted forward or back and left or right.
  45213. */
  45214. export class DeviceOrientationCamera extends FreeCamera {
  45215. private _initialQuaternion;
  45216. private _quaternionCache;
  45217. private _tmpDragQuaternion;
  45218. private _disablePointerInputWhenUsingDeviceOrientation;
  45219. /**
  45220. * Creates a new device orientation camera
  45221. * @param name The name of the camera
  45222. * @param position The start position camera
  45223. * @param scene The scene the camera belongs to
  45224. */
  45225. constructor(name: string, position: Vector3, scene: Scene);
  45226. /**
  45227. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45228. */
  45229. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45230. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45231. private _dragFactor;
  45232. /**
  45233. * Enabled turning on the y axis when the orientation sensor is active
  45234. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45235. */
  45236. enableHorizontalDragging(dragFactor?: number): void;
  45237. /**
  45238. * Gets the current instance class name ("DeviceOrientationCamera").
  45239. * This helps avoiding instanceof at run time.
  45240. * @returns the class name
  45241. */
  45242. getClassName(): string;
  45243. /**
  45244. * @hidden
  45245. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45246. */
  45247. _checkInputs(): void;
  45248. /**
  45249. * Reset the camera to its default orientation on the specified axis only.
  45250. * @param axis The axis to reset
  45251. */
  45252. resetToCurrentRotation(axis?: Axis): void;
  45253. }
  45254. }
  45255. declare module BABYLON {
  45256. /**
  45257. * Defines supported buttons for XBox360 compatible gamepads
  45258. */
  45259. export enum Xbox360Button {
  45260. /** A */
  45261. A = 0,
  45262. /** B */
  45263. B = 1,
  45264. /** X */
  45265. X = 2,
  45266. /** Y */
  45267. Y = 3,
  45268. /** Left button */
  45269. LB = 4,
  45270. /** Right button */
  45271. RB = 5,
  45272. /** Back */
  45273. Back = 8,
  45274. /** Start */
  45275. Start = 9,
  45276. /** Left stick */
  45277. LeftStick = 10,
  45278. /** Right stick */
  45279. RightStick = 11
  45280. }
  45281. /** Defines values for XBox360 DPad */
  45282. export enum Xbox360Dpad {
  45283. /** Up */
  45284. Up = 12,
  45285. /** Down */
  45286. Down = 13,
  45287. /** Left */
  45288. Left = 14,
  45289. /** Right */
  45290. Right = 15
  45291. }
  45292. /**
  45293. * Defines a XBox360 gamepad
  45294. */
  45295. export class Xbox360Pad extends Gamepad {
  45296. private _leftTrigger;
  45297. private _rightTrigger;
  45298. private _onlefttriggerchanged;
  45299. private _onrighttriggerchanged;
  45300. private _onbuttondown;
  45301. private _onbuttonup;
  45302. private _ondpaddown;
  45303. private _ondpadup;
  45304. /** Observable raised when a button is pressed */
  45305. onButtonDownObservable: Observable<Xbox360Button>;
  45306. /** Observable raised when a button is released */
  45307. onButtonUpObservable: Observable<Xbox360Button>;
  45308. /** Observable raised when a pad is pressed */
  45309. onPadDownObservable: Observable<Xbox360Dpad>;
  45310. /** Observable raised when a pad is released */
  45311. onPadUpObservable: Observable<Xbox360Dpad>;
  45312. private _buttonA;
  45313. private _buttonB;
  45314. private _buttonX;
  45315. private _buttonY;
  45316. private _buttonBack;
  45317. private _buttonStart;
  45318. private _buttonLB;
  45319. private _buttonRB;
  45320. private _buttonLeftStick;
  45321. private _buttonRightStick;
  45322. private _dPadUp;
  45323. private _dPadDown;
  45324. private _dPadLeft;
  45325. private _dPadRight;
  45326. private _isXboxOnePad;
  45327. /**
  45328. * Creates a new XBox360 gamepad object
  45329. * @param id defines the id of this gamepad
  45330. * @param index defines its index
  45331. * @param gamepad defines the internal HTML gamepad object
  45332. * @param xboxOne defines if it is a XBox One gamepad
  45333. */
  45334. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45335. /**
  45336. * Defines the callback to call when left trigger is pressed
  45337. * @param callback defines the callback to use
  45338. */
  45339. onlefttriggerchanged(callback: (value: number) => void): void;
  45340. /**
  45341. * Defines the callback to call when right trigger is pressed
  45342. * @param callback defines the callback to use
  45343. */
  45344. onrighttriggerchanged(callback: (value: number) => void): void;
  45345. /**
  45346. * Gets the left trigger value
  45347. */
  45348. get leftTrigger(): number;
  45349. /**
  45350. * Sets the left trigger value
  45351. */
  45352. set leftTrigger(newValue: number);
  45353. /**
  45354. * Gets the right trigger value
  45355. */
  45356. get rightTrigger(): number;
  45357. /**
  45358. * Sets the right trigger value
  45359. */
  45360. set rightTrigger(newValue: number);
  45361. /**
  45362. * Defines the callback to call when a button is pressed
  45363. * @param callback defines the callback to use
  45364. */
  45365. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45366. /**
  45367. * Defines the callback to call when a button is released
  45368. * @param callback defines the callback to use
  45369. */
  45370. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45371. /**
  45372. * Defines the callback to call when a pad is pressed
  45373. * @param callback defines the callback to use
  45374. */
  45375. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45376. /**
  45377. * Defines the callback to call when a pad is released
  45378. * @param callback defines the callback to use
  45379. */
  45380. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45381. private _setButtonValue;
  45382. private _setDPadValue;
  45383. /**
  45384. * Gets the value of the `A` button
  45385. */
  45386. get buttonA(): number;
  45387. /**
  45388. * Sets the value of the `A` button
  45389. */
  45390. set buttonA(value: number);
  45391. /**
  45392. * Gets the value of the `B` button
  45393. */
  45394. get buttonB(): number;
  45395. /**
  45396. * Sets the value of the `B` button
  45397. */
  45398. set buttonB(value: number);
  45399. /**
  45400. * Gets the value of the `X` button
  45401. */
  45402. get buttonX(): number;
  45403. /**
  45404. * Sets the value of the `X` button
  45405. */
  45406. set buttonX(value: number);
  45407. /**
  45408. * Gets the value of the `Y` button
  45409. */
  45410. get buttonY(): number;
  45411. /**
  45412. * Sets the value of the `Y` button
  45413. */
  45414. set buttonY(value: number);
  45415. /**
  45416. * Gets the value of the `Start` button
  45417. */
  45418. get buttonStart(): number;
  45419. /**
  45420. * Sets the value of the `Start` button
  45421. */
  45422. set buttonStart(value: number);
  45423. /**
  45424. * Gets the value of the `Back` button
  45425. */
  45426. get buttonBack(): number;
  45427. /**
  45428. * Sets the value of the `Back` button
  45429. */
  45430. set buttonBack(value: number);
  45431. /**
  45432. * Gets the value of the `Left` button
  45433. */
  45434. get buttonLB(): number;
  45435. /**
  45436. * Sets the value of the `Left` button
  45437. */
  45438. set buttonLB(value: number);
  45439. /**
  45440. * Gets the value of the `Right` button
  45441. */
  45442. get buttonRB(): number;
  45443. /**
  45444. * Sets the value of the `Right` button
  45445. */
  45446. set buttonRB(value: number);
  45447. /**
  45448. * Gets the value of the Left joystick
  45449. */
  45450. get buttonLeftStick(): number;
  45451. /**
  45452. * Sets the value of the Left joystick
  45453. */
  45454. set buttonLeftStick(value: number);
  45455. /**
  45456. * Gets the value of the Right joystick
  45457. */
  45458. get buttonRightStick(): number;
  45459. /**
  45460. * Sets the value of the Right joystick
  45461. */
  45462. set buttonRightStick(value: number);
  45463. /**
  45464. * Gets the value of D-pad up
  45465. */
  45466. get dPadUp(): number;
  45467. /**
  45468. * Sets the value of D-pad up
  45469. */
  45470. set dPadUp(value: number);
  45471. /**
  45472. * Gets the value of D-pad down
  45473. */
  45474. get dPadDown(): number;
  45475. /**
  45476. * Sets the value of D-pad down
  45477. */
  45478. set dPadDown(value: number);
  45479. /**
  45480. * Gets the value of D-pad left
  45481. */
  45482. get dPadLeft(): number;
  45483. /**
  45484. * Sets the value of D-pad left
  45485. */
  45486. set dPadLeft(value: number);
  45487. /**
  45488. * Gets the value of D-pad right
  45489. */
  45490. get dPadRight(): number;
  45491. /**
  45492. * Sets the value of D-pad right
  45493. */
  45494. set dPadRight(value: number);
  45495. /**
  45496. * Force the gamepad to synchronize with device values
  45497. */
  45498. update(): void;
  45499. /**
  45500. * Disposes the gamepad
  45501. */
  45502. dispose(): void;
  45503. }
  45504. }
  45505. declare module BABYLON {
  45506. /**
  45507. * Defines supported buttons for DualShock compatible gamepads
  45508. */
  45509. export enum DualShockButton {
  45510. /** Cross */
  45511. Cross = 0,
  45512. /** Circle */
  45513. Circle = 1,
  45514. /** Square */
  45515. Square = 2,
  45516. /** Triangle */
  45517. Triangle = 3,
  45518. /** L1 */
  45519. L1 = 4,
  45520. /** R1 */
  45521. R1 = 5,
  45522. /** Share */
  45523. Share = 8,
  45524. /** Options */
  45525. Options = 9,
  45526. /** Left stick */
  45527. LeftStick = 10,
  45528. /** Right stick */
  45529. RightStick = 11
  45530. }
  45531. /** Defines values for DualShock DPad */
  45532. export enum DualShockDpad {
  45533. /** Up */
  45534. Up = 12,
  45535. /** Down */
  45536. Down = 13,
  45537. /** Left */
  45538. Left = 14,
  45539. /** Right */
  45540. Right = 15
  45541. }
  45542. /**
  45543. * Defines a DualShock gamepad
  45544. */
  45545. export class DualShockPad extends Gamepad {
  45546. private _leftTrigger;
  45547. private _rightTrigger;
  45548. private _onlefttriggerchanged;
  45549. private _onrighttriggerchanged;
  45550. private _onbuttondown;
  45551. private _onbuttonup;
  45552. private _ondpaddown;
  45553. private _ondpadup;
  45554. /** Observable raised when a button is pressed */
  45555. onButtonDownObservable: Observable<DualShockButton>;
  45556. /** Observable raised when a button is released */
  45557. onButtonUpObservable: Observable<DualShockButton>;
  45558. /** Observable raised when a pad is pressed */
  45559. onPadDownObservable: Observable<DualShockDpad>;
  45560. /** Observable raised when a pad is released */
  45561. onPadUpObservable: Observable<DualShockDpad>;
  45562. private _buttonCross;
  45563. private _buttonCircle;
  45564. private _buttonSquare;
  45565. private _buttonTriangle;
  45566. private _buttonShare;
  45567. private _buttonOptions;
  45568. private _buttonL1;
  45569. private _buttonR1;
  45570. private _buttonLeftStick;
  45571. private _buttonRightStick;
  45572. private _dPadUp;
  45573. private _dPadDown;
  45574. private _dPadLeft;
  45575. private _dPadRight;
  45576. /**
  45577. * Creates a new DualShock gamepad object
  45578. * @param id defines the id of this gamepad
  45579. * @param index defines its index
  45580. * @param gamepad defines the internal HTML gamepad object
  45581. */
  45582. constructor(id: string, index: number, gamepad: any);
  45583. /**
  45584. * Defines the callback to call when left trigger is pressed
  45585. * @param callback defines the callback to use
  45586. */
  45587. onlefttriggerchanged(callback: (value: number) => void): void;
  45588. /**
  45589. * Defines the callback to call when right trigger is pressed
  45590. * @param callback defines the callback to use
  45591. */
  45592. onrighttriggerchanged(callback: (value: number) => void): void;
  45593. /**
  45594. * Gets the left trigger value
  45595. */
  45596. get leftTrigger(): number;
  45597. /**
  45598. * Sets the left trigger value
  45599. */
  45600. set leftTrigger(newValue: number);
  45601. /**
  45602. * Gets the right trigger value
  45603. */
  45604. get rightTrigger(): number;
  45605. /**
  45606. * Sets the right trigger value
  45607. */
  45608. set rightTrigger(newValue: number);
  45609. /**
  45610. * Defines the callback to call when a button is pressed
  45611. * @param callback defines the callback to use
  45612. */
  45613. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45614. /**
  45615. * Defines the callback to call when a button is released
  45616. * @param callback defines the callback to use
  45617. */
  45618. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45619. /**
  45620. * Defines the callback to call when a pad is pressed
  45621. * @param callback defines the callback to use
  45622. */
  45623. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45624. /**
  45625. * Defines the callback to call when a pad is released
  45626. * @param callback defines the callback to use
  45627. */
  45628. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45629. private _setButtonValue;
  45630. private _setDPadValue;
  45631. /**
  45632. * Gets the value of the `Cross` button
  45633. */
  45634. get buttonCross(): number;
  45635. /**
  45636. * Sets the value of the `Cross` button
  45637. */
  45638. set buttonCross(value: number);
  45639. /**
  45640. * Gets the value of the `Circle` button
  45641. */
  45642. get buttonCircle(): number;
  45643. /**
  45644. * Sets the value of the `Circle` button
  45645. */
  45646. set buttonCircle(value: number);
  45647. /**
  45648. * Gets the value of the `Square` button
  45649. */
  45650. get buttonSquare(): number;
  45651. /**
  45652. * Sets the value of the `Square` button
  45653. */
  45654. set buttonSquare(value: number);
  45655. /**
  45656. * Gets the value of the `Triangle` button
  45657. */
  45658. get buttonTriangle(): number;
  45659. /**
  45660. * Sets the value of the `Triangle` button
  45661. */
  45662. set buttonTriangle(value: number);
  45663. /**
  45664. * Gets the value of the `Options` button
  45665. */
  45666. get buttonOptions(): number;
  45667. /**
  45668. * Sets the value of the `Options` button
  45669. */
  45670. set buttonOptions(value: number);
  45671. /**
  45672. * Gets the value of the `Share` button
  45673. */
  45674. get buttonShare(): number;
  45675. /**
  45676. * Sets the value of the `Share` button
  45677. */
  45678. set buttonShare(value: number);
  45679. /**
  45680. * Gets the value of the `L1` button
  45681. */
  45682. get buttonL1(): number;
  45683. /**
  45684. * Sets the value of the `L1` button
  45685. */
  45686. set buttonL1(value: number);
  45687. /**
  45688. * Gets the value of the `R1` button
  45689. */
  45690. get buttonR1(): number;
  45691. /**
  45692. * Sets the value of the `R1` button
  45693. */
  45694. set buttonR1(value: number);
  45695. /**
  45696. * Gets the value of the Left joystick
  45697. */
  45698. get buttonLeftStick(): number;
  45699. /**
  45700. * Sets the value of the Left joystick
  45701. */
  45702. set buttonLeftStick(value: number);
  45703. /**
  45704. * Gets the value of the Right joystick
  45705. */
  45706. get buttonRightStick(): number;
  45707. /**
  45708. * Sets the value of the Right joystick
  45709. */
  45710. set buttonRightStick(value: number);
  45711. /**
  45712. * Gets the value of D-pad up
  45713. */
  45714. get dPadUp(): number;
  45715. /**
  45716. * Sets the value of D-pad up
  45717. */
  45718. set dPadUp(value: number);
  45719. /**
  45720. * Gets the value of D-pad down
  45721. */
  45722. get dPadDown(): number;
  45723. /**
  45724. * Sets the value of D-pad down
  45725. */
  45726. set dPadDown(value: number);
  45727. /**
  45728. * Gets the value of D-pad left
  45729. */
  45730. get dPadLeft(): number;
  45731. /**
  45732. * Sets the value of D-pad left
  45733. */
  45734. set dPadLeft(value: number);
  45735. /**
  45736. * Gets the value of D-pad right
  45737. */
  45738. get dPadRight(): number;
  45739. /**
  45740. * Sets the value of D-pad right
  45741. */
  45742. set dPadRight(value: number);
  45743. /**
  45744. * Force the gamepad to synchronize with device values
  45745. */
  45746. update(): void;
  45747. /**
  45748. * Disposes the gamepad
  45749. */
  45750. dispose(): void;
  45751. }
  45752. }
  45753. declare module BABYLON {
  45754. /**
  45755. * Manager for handling gamepads
  45756. */
  45757. export class GamepadManager {
  45758. private _scene?;
  45759. private _babylonGamepads;
  45760. private _oneGamepadConnected;
  45761. /** @hidden */
  45762. _isMonitoring: boolean;
  45763. private _gamepadEventSupported;
  45764. private _gamepadSupport?;
  45765. /**
  45766. * observable to be triggered when the gamepad controller has been connected
  45767. */
  45768. onGamepadConnectedObservable: Observable<Gamepad>;
  45769. /**
  45770. * observable to be triggered when the gamepad controller has been disconnected
  45771. */
  45772. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45773. private _onGamepadConnectedEvent;
  45774. private _onGamepadDisconnectedEvent;
  45775. /**
  45776. * Initializes the gamepad manager
  45777. * @param _scene BabylonJS scene
  45778. */
  45779. constructor(_scene?: Scene | undefined);
  45780. /**
  45781. * The gamepads in the game pad manager
  45782. */
  45783. get gamepads(): Gamepad[];
  45784. /**
  45785. * Get the gamepad controllers based on type
  45786. * @param type The type of gamepad controller
  45787. * @returns Nullable gamepad
  45788. */
  45789. getGamepadByType(type?: number): Nullable<Gamepad>;
  45790. /**
  45791. * Disposes the gamepad manager
  45792. */
  45793. dispose(): void;
  45794. private _addNewGamepad;
  45795. private _startMonitoringGamepads;
  45796. private _stopMonitoringGamepads;
  45797. /** @hidden */
  45798. _checkGamepadsStatus(): void;
  45799. private _updateGamepadObjects;
  45800. }
  45801. }
  45802. declare module BABYLON {
  45803. interface Scene {
  45804. /** @hidden */
  45805. _gamepadManager: Nullable<GamepadManager>;
  45806. /**
  45807. * Gets the gamepad manager associated with the scene
  45808. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45809. */
  45810. gamepadManager: GamepadManager;
  45811. }
  45812. /**
  45813. * Interface representing a free camera inputs manager
  45814. */
  45815. interface FreeCameraInputsManager {
  45816. /**
  45817. * Adds gamepad input support to the FreeCameraInputsManager.
  45818. * @returns the FreeCameraInputsManager
  45819. */
  45820. addGamepad(): FreeCameraInputsManager;
  45821. }
  45822. /**
  45823. * Interface representing an arc rotate camera inputs manager
  45824. */
  45825. interface ArcRotateCameraInputsManager {
  45826. /**
  45827. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45828. * @returns the camera inputs manager
  45829. */
  45830. addGamepad(): ArcRotateCameraInputsManager;
  45831. }
  45832. /**
  45833. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45834. */
  45835. export class GamepadSystemSceneComponent implements ISceneComponent {
  45836. /**
  45837. * The component name helpfull to identify the component in the list of scene components.
  45838. */
  45839. readonly name: string;
  45840. /**
  45841. * The scene the component belongs to.
  45842. */
  45843. scene: Scene;
  45844. /**
  45845. * Creates a new instance of the component for the given scene
  45846. * @param scene Defines the scene to register the component in
  45847. */
  45848. constructor(scene: Scene);
  45849. /**
  45850. * Registers the component in a given scene
  45851. */
  45852. register(): void;
  45853. /**
  45854. * Rebuilds the elements related to this component in case of
  45855. * context lost for instance.
  45856. */
  45857. rebuild(): void;
  45858. /**
  45859. * Disposes the component and the associated ressources
  45860. */
  45861. dispose(): void;
  45862. private _beforeCameraUpdate;
  45863. }
  45864. }
  45865. declare module BABYLON {
  45866. /**
  45867. * 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,
  45868. * which still works and will still be found in many Playgrounds.
  45869. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45870. */
  45871. export class UniversalCamera extends TouchCamera {
  45872. /**
  45873. * Defines the gamepad rotation sensiblity.
  45874. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45875. */
  45876. get gamepadAngularSensibility(): number;
  45877. set gamepadAngularSensibility(value: number);
  45878. /**
  45879. * Defines the gamepad move sensiblity.
  45880. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45881. */
  45882. get gamepadMoveSensibility(): number;
  45883. set gamepadMoveSensibility(value: number);
  45884. /**
  45885. * 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,
  45886. * which still works and will still be found in many Playgrounds.
  45887. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45888. * @param name Define the name of the camera in the scene
  45889. * @param position Define the start position of the camera in the scene
  45890. * @param scene Define the scene the camera belongs to
  45891. */
  45892. constructor(name: string, position: Vector3, scene: Scene);
  45893. /**
  45894. * Gets the current object class name.
  45895. * @return the class name
  45896. */
  45897. getClassName(): string;
  45898. }
  45899. }
  45900. declare module BABYLON {
  45901. /**
  45902. * This represents a FPS type of camera. This is only here for back compat purpose.
  45903. * Please use the UniversalCamera instead as both are identical.
  45904. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45905. */
  45906. export class GamepadCamera extends UniversalCamera {
  45907. /**
  45908. * Instantiates a new Gamepad Camera
  45909. * This represents a FPS type of camera. This is only here for back compat purpose.
  45910. * Please use the UniversalCamera instead as both are identical.
  45911. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45912. * @param name Define the name of the camera in the scene
  45913. * @param position Define the start position of the camera in the scene
  45914. * @param scene Define the scene the camera belongs to
  45915. */
  45916. constructor(name: string, position: Vector3, scene: Scene);
  45917. /**
  45918. * Gets the current object class name.
  45919. * @return the class name
  45920. */
  45921. getClassName(): string;
  45922. }
  45923. }
  45924. declare module BABYLON {
  45925. /** @hidden */
  45926. export var passPixelShader: {
  45927. name: string;
  45928. shader: string;
  45929. };
  45930. }
  45931. declare module BABYLON {
  45932. /** @hidden */
  45933. export var passCubePixelShader: {
  45934. name: string;
  45935. shader: string;
  45936. };
  45937. }
  45938. declare module BABYLON {
  45939. /**
  45940. * PassPostProcess which produces an output the same as it's input
  45941. */
  45942. export class PassPostProcess extends PostProcess {
  45943. /**
  45944. * Creates the PassPostProcess
  45945. * @param name The name of the effect.
  45946. * @param options The required width/height ratio to downsize to before computing the render pass.
  45947. * @param camera The camera to apply the render pass to.
  45948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45949. * @param engine The engine which the post process will be applied. (default: current engine)
  45950. * @param reusable If the post process can be reused on the same frame. (default: false)
  45951. * @param textureType The type of texture to be used when performing the post processing.
  45952. * @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)
  45953. */
  45954. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45955. }
  45956. /**
  45957. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45958. */
  45959. export class PassCubePostProcess extends PostProcess {
  45960. private _face;
  45961. /**
  45962. * Gets or sets the cube face to display.
  45963. * * 0 is +X
  45964. * * 1 is -X
  45965. * * 2 is +Y
  45966. * * 3 is -Y
  45967. * * 4 is +Z
  45968. * * 5 is -Z
  45969. */
  45970. get face(): number;
  45971. set face(value: number);
  45972. /**
  45973. * Creates the PassCubePostProcess
  45974. * @param name The name of the effect.
  45975. * @param options The required width/height ratio to downsize to before computing the render pass.
  45976. * @param camera The camera to apply the render pass to.
  45977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45978. * @param engine The engine which the post process will be applied. (default: current engine)
  45979. * @param reusable If the post process can be reused on the same frame. (default: false)
  45980. * @param textureType The type of texture to be used when performing the post processing.
  45981. * @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)
  45982. */
  45983. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45984. }
  45985. }
  45986. declare module BABYLON {
  45987. /** @hidden */
  45988. export var anaglyphPixelShader: {
  45989. name: string;
  45990. shader: string;
  45991. };
  45992. }
  45993. declare module BABYLON {
  45994. /**
  45995. * Postprocess used to generate anaglyphic rendering
  45996. */
  45997. export class AnaglyphPostProcess extends PostProcess {
  45998. private _passedProcess;
  45999. /**
  46000. * Creates a new AnaglyphPostProcess
  46001. * @param name defines postprocess name
  46002. * @param options defines creation options or target ratio scale
  46003. * @param rigCameras defines cameras using this postprocess
  46004. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46005. * @param engine defines hosting engine
  46006. * @param reusable defines if the postprocess will be reused multiple times per frame
  46007. */
  46008. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46009. }
  46010. }
  46011. declare module BABYLON {
  46012. /**
  46013. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46014. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46015. */
  46016. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46017. /**
  46018. * Creates a new AnaglyphArcRotateCamera
  46019. * @param name defines camera name
  46020. * @param alpha defines alpha angle (in radians)
  46021. * @param beta defines beta angle (in radians)
  46022. * @param radius defines radius
  46023. * @param target defines camera target
  46024. * @param interaxialDistance defines distance between each color axis
  46025. * @param scene defines the hosting scene
  46026. */
  46027. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46028. /**
  46029. * Gets camera class name
  46030. * @returns AnaglyphArcRotateCamera
  46031. */
  46032. getClassName(): string;
  46033. }
  46034. }
  46035. declare module BABYLON {
  46036. /**
  46037. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46038. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46039. */
  46040. export class AnaglyphFreeCamera extends FreeCamera {
  46041. /**
  46042. * Creates a new AnaglyphFreeCamera
  46043. * @param name defines camera name
  46044. * @param position defines initial position
  46045. * @param interaxialDistance defines distance between each color axis
  46046. * @param scene defines the hosting scene
  46047. */
  46048. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46049. /**
  46050. * Gets camera class name
  46051. * @returns AnaglyphFreeCamera
  46052. */
  46053. getClassName(): string;
  46054. }
  46055. }
  46056. declare module BABYLON {
  46057. /**
  46058. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46059. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46060. */
  46061. export class AnaglyphGamepadCamera extends GamepadCamera {
  46062. /**
  46063. * Creates a new AnaglyphGamepadCamera
  46064. * @param name defines camera name
  46065. * @param position defines initial position
  46066. * @param interaxialDistance defines distance between each color axis
  46067. * @param scene defines the hosting scene
  46068. */
  46069. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46070. /**
  46071. * Gets camera class name
  46072. * @returns AnaglyphGamepadCamera
  46073. */
  46074. getClassName(): string;
  46075. }
  46076. }
  46077. declare module BABYLON {
  46078. /**
  46079. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46080. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46081. */
  46082. export class AnaglyphUniversalCamera extends UniversalCamera {
  46083. /**
  46084. * Creates a new AnaglyphUniversalCamera
  46085. * @param name defines camera name
  46086. * @param position defines initial position
  46087. * @param interaxialDistance defines distance between each color axis
  46088. * @param scene defines the hosting scene
  46089. */
  46090. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46091. /**
  46092. * Gets camera class name
  46093. * @returns AnaglyphUniversalCamera
  46094. */
  46095. getClassName(): string;
  46096. }
  46097. }
  46098. declare module BABYLON {
  46099. /**
  46100. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46101. * @see https://doc.babylonjs.com/features/cameras
  46102. */
  46103. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46104. /**
  46105. * Creates a new StereoscopicArcRotateCamera
  46106. * @param name defines camera name
  46107. * @param alpha defines alpha angle (in radians)
  46108. * @param beta defines beta angle (in radians)
  46109. * @param radius defines radius
  46110. * @param target defines camera target
  46111. * @param interaxialDistance defines distance between each color axis
  46112. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46113. * @param scene defines the hosting scene
  46114. */
  46115. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46116. /**
  46117. * Gets camera class name
  46118. * @returns StereoscopicArcRotateCamera
  46119. */
  46120. getClassName(): string;
  46121. }
  46122. }
  46123. declare module BABYLON {
  46124. /**
  46125. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46126. * @see https://doc.babylonjs.com/features/cameras
  46127. */
  46128. export class StereoscopicFreeCamera extends FreeCamera {
  46129. /**
  46130. * Creates a new StereoscopicFreeCamera
  46131. * @param name defines camera name
  46132. * @param position defines initial position
  46133. * @param interaxialDistance defines distance between each color axis
  46134. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46135. * @param scene defines the hosting scene
  46136. */
  46137. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46138. /**
  46139. * Gets camera class name
  46140. * @returns StereoscopicFreeCamera
  46141. */
  46142. getClassName(): string;
  46143. }
  46144. }
  46145. declare module BABYLON {
  46146. /**
  46147. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46148. * @see https://doc.babylonjs.com/features/cameras
  46149. */
  46150. export class StereoscopicGamepadCamera extends GamepadCamera {
  46151. /**
  46152. * Creates a new StereoscopicGamepadCamera
  46153. * @param name defines camera name
  46154. * @param position defines initial position
  46155. * @param interaxialDistance defines distance between each color axis
  46156. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46157. * @param scene defines the hosting scene
  46158. */
  46159. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46160. /**
  46161. * Gets camera class name
  46162. * @returns StereoscopicGamepadCamera
  46163. */
  46164. getClassName(): string;
  46165. }
  46166. }
  46167. declare module BABYLON {
  46168. /**
  46169. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46170. * @see https://doc.babylonjs.com/features/cameras
  46171. */
  46172. export class StereoscopicUniversalCamera extends UniversalCamera {
  46173. /**
  46174. * Creates a new StereoscopicUniversalCamera
  46175. * @param name defines camera name
  46176. * @param position defines initial position
  46177. * @param interaxialDistance defines distance between each color axis
  46178. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46179. * @param scene defines the hosting scene
  46180. */
  46181. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46182. /**
  46183. * Gets camera class name
  46184. * @returns StereoscopicUniversalCamera
  46185. */
  46186. getClassName(): string;
  46187. }
  46188. }
  46189. declare module BABYLON {
  46190. /**
  46191. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46192. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46193. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46194. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46195. */
  46196. export class VirtualJoysticksCamera extends FreeCamera {
  46197. /**
  46198. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46199. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46200. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46201. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46202. * @param name Define the name of the camera in the scene
  46203. * @param position Define the start position of the camera in the scene
  46204. * @param scene Define the scene the camera belongs to
  46205. */
  46206. constructor(name: string, position: Vector3, scene: Scene);
  46207. /**
  46208. * Gets the current object class name.
  46209. * @return the class name
  46210. */
  46211. getClassName(): string;
  46212. }
  46213. }
  46214. declare module BABYLON {
  46215. /**
  46216. * This represents all the required metrics to create a VR camera.
  46217. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46218. */
  46219. export class VRCameraMetrics {
  46220. /**
  46221. * Define the horizontal resolution off the screen.
  46222. */
  46223. hResolution: number;
  46224. /**
  46225. * Define the vertical resolution off the screen.
  46226. */
  46227. vResolution: number;
  46228. /**
  46229. * Define the horizontal screen size.
  46230. */
  46231. hScreenSize: number;
  46232. /**
  46233. * Define the vertical screen size.
  46234. */
  46235. vScreenSize: number;
  46236. /**
  46237. * Define the vertical screen center position.
  46238. */
  46239. vScreenCenter: number;
  46240. /**
  46241. * Define the distance of the eyes to the screen.
  46242. */
  46243. eyeToScreenDistance: number;
  46244. /**
  46245. * Define the distance between both lenses
  46246. */
  46247. lensSeparationDistance: number;
  46248. /**
  46249. * Define the distance between both viewer's eyes.
  46250. */
  46251. interpupillaryDistance: number;
  46252. /**
  46253. * Define the distortion factor of the VR postprocess.
  46254. * Please, touch with care.
  46255. */
  46256. distortionK: number[];
  46257. /**
  46258. * Define the chromatic aberration correction factors for the VR post process.
  46259. */
  46260. chromaAbCorrection: number[];
  46261. /**
  46262. * Define the scale factor of the post process.
  46263. * The smaller the better but the slower.
  46264. */
  46265. postProcessScaleFactor: number;
  46266. /**
  46267. * Define an offset for the lens center.
  46268. */
  46269. lensCenterOffset: number;
  46270. /**
  46271. * Define if the current vr camera should compensate the distortion of the lense or not.
  46272. */
  46273. compensateDistortion: boolean;
  46274. /**
  46275. * Defines if multiview should be enabled when rendering (Default: false)
  46276. */
  46277. multiviewEnabled: boolean;
  46278. /**
  46279. * Gets the rendering aspect ratio based on the provided resolutions.
  46280. */
  46281. get aspectRatio(): number;
  46282. /**
  46283. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46284. */
  46285. get aspectRatioFov(): number;
  46286. /**
  46287. * @hidden
  46288. */
  46289. get leftHMatrix(): Matrix;
  46290. /**
  46291. * @hidden
  46292. */
  46293. get rightHMatrix(): Matrix;
  46294. /**
  46295. * @hidden
  46296. */
  46297. get leftPreViewMatrix(): Matrix;
  46298. /**
  46299. * @hidden
  46300. */
  46301. get rightPreViewMatrix(): Matrix;
  46302. /**
  46303. * Get the default VRMetrics based on the most generic setup.
  46304. * @returns the default vr metrics
  46305. */
  46306. static GetDefault(): VRCameraMetrics;
  46307. }
  46308. }
  46309. declare module BABYLON {
  46310. /** @hidden */
  46311. export var vrDistortionCorrectionPixelShader: {
  46312. name: string;
  46313. shader: string;
  46314. };
  46315. }
  46316. declare module BABYLON {
  46317. /**
  46318. * VRDistortionCorrectionPostProcess used for mobile VR
  46319. */
  46320. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46321. private _isRightEye;
  46322. private _distortionFactors;
  46323. private _postProcessScaleFactor;
  46324. private _lensCenterOffset;
  46325. private _scaleIn;
  46326. private _scaleFactor;
  46327. private _lensCenter;
  46328. /**
  46329. * Initializes the VRDistortionCorrectionPostProcess
  46330. * @param name The name of the effect.
  46331. * @param camera The camera to apply the render pass to.
  46332. * @param isRightEye If this is for the right eye distortion
  46333. * @param vrMetrics All the required metrics for the VR camera
  46334. */
  46335. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46336. }
  46337. }
  46338. declare module BABYLON {
  46339. /**
  46340. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46341. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46342. */
  46343. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46344. /**
  46345. * Creates a new VRDeviceOrientationArcRotateCamera
  46346. * @param name defines camera name
  46347. * @param alpha defines the camera rotation along the logitudinal axis
  46348. * @param beta defines the camera rotation along the latitudinal axis
  46349. * @param radius defines the camera distance from its target
  46350. * @param target defines the camera target
  46351. * @param scene defines the scene the camera belongs to
  46352. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46353. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46354. */
  46355. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46356. /**
  46357. * Gets camera class name
  46358. * @returns VRDeviceOrientationArcRotateCamera
  46359. */
  46360. getClassName(): string;
  46361. }
  46362. }
  46363. declare module BABYLON {
  46364. /**
  46365. * Camera used to simulate VR rendering (based on FreeCamera)
  46366. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46367. */
  46368. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46369. /**
  46370. * Creates a new VRDeviceOrientationFreeCamera
  46371. * @param name defines camera name
  46372. * @param position defines the start position of the camera
  46373. * @param scene defines the scene the camera belongs to
  46374. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46375. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46376. */
  46377. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46378. /**
  46379. * Gets camera class name
  46380. * @returns VRDeviceOrientationFreeCamera
  46381. */
  46382. getClassName(): string;
  46383. }
  46384. }
  46385. declare module BABYLON {
  46386. /**
  46387. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46388. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46389. */
  46390. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46391. /**
  46392. * Creates a new VRDeviceOrientationGamepadCamera
  46393. * @param name defines camera name
  46394. * @param position defines the start position of the camera
  46395. * @param scene defines the scene the camera belongs to
  46396. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46397. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46398. */
  46399. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46400. /**
  46401. * Gets camera class name
  46402. * @returns VRDeviceOrientationGamepadCamera
  46403. */
  46404. getClassName(): string;
  46405. }
  46406. }
  46407. declare module BABYLON {
  46408. /**
  46409. * A class extending Texture allowing drawing on a texture
  46410. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46411. */
  46412. export class DynamicTexture extends Texture {
  46413. private _generateMipMaps;
  46414. private _canvas;
  46415. private _context;
  46416. /**
  46417. * Creates a DynamicTexture
  46418. * @param name defines the name of the texture
  46419. * @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
  46420. * @param scene defines the scene where you want the texture
  46421. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46422. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46423. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46424. */
  46425. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46426. /**
  46427. * Get the current class name of the texture useful for serialization or dynamic coding.
  46428. * @returns "DynamicTexture"
  46429. */
  46430. getClassName(): string;
  46431. /**
  46432. * Gets the current state of canRescale
  46433. */
  46434. get canRescale(): boolean;
  46435. private _recreate;
  46436. /**
  46437. * Scales the texture
  46438. * @param ratio the scale factor to apply to both width and height
  46439. */
  46440. scale(ratio: number): void;
  46441. /**
  46442. * Resizes the texture
  46443. * @param width the new width
  46444. * @param height the new height
  46445. */
  46446. scaleTo(width: number, height: number): void;
  46447. /**
  46448. * Gets the context of the canvas used by the texture
  46449. * @returns the canvas context of the dynamic texture
  46450. */
  46451. getContext(): CanvasRenderingContext2D;
  46452. /**
  46453. * Clears the texture
  46454. */
  46455. clear(): void;
  46456. /**
  46457. * Updates the texture
  46458. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46459. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46460. */
  46461. update(invertY?: boolean, premulAlpha?: boolean): void;
  46462. /**
  46463. * Draws text onto the texture
  46464. * @param text defines the text to be drawn
  46465. * @param x defines the placement of the text from the left
  46466. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46467. * @param font defines the font to be used with font-style, font-size, font-name
  46468. * @param color defines the color used for the text
  46469. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46470. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46471. * @param update defines whether texture is immediately update (default is true)
  46472. */
  46473. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46474. /**
  46475. * Clones the texture
  46476. * @returns the clone of the texture.
  46477. */
  46478. clone(): DynamicTexture;
  46479. /**
  46480. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46481. * @returns a serialized dynamic texture object
  46482. */
  46483. serialize(): any;
  46484. private _IsCanvasElement;
  46485. /** @hidden */
  46486. _rebuild(): void;
  46487. }
  46488. }
  46489. declare module BABYLON {
  46490. /**
  46491. * Class containing static functions to help procedurally build meshes
  46492. */
  46493. export class GroundBuilder {
  46494. /**
  46495. * Creates a ground mesh
  46496. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46497. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46499. * @param name defines the name of the mesh
  46500. * @param options defines the options used to create the mesh
  46501. * @param scene defines the hosting scene
  46502. * @returns the ground mesh
  46503. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46504. */
  46505. static CreateGround(name: string, options: {
  46506. width?: number;
  46507. height?: number;
  46508. subdivisions?: number;
  46509. subdivisionsX?: number;
  46510. subdivisionsY?: number;
  46511. updatable?: boolean;
  46512. }, scene: any): Mesh;
  46513. /**
  46514. * Creates a tiled ground mesh
  46515. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46516. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46517. * * 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
  46518. * * 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
  46519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46520. * @param name defines the name of the mesh
  46521. * @param options defines the options used to create the mesh
  46522. * @param scene defines the hosting scene
  46523. * @returns the tiled ground mesh
  46524. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46525. */
  46526. static CreateTiledGround(name: string, options: {
  46527. xmin: number;
  46528. zmin: number;
  46529. xmax: number;
  46530. zmax: number;
  46531. subdivisions?: {
  46532. w: number;
  46533. h: number;
  46534. };
  46535. precision?: {
  46536. w: number;
  46537. h: number;
  46538. };
  46539. updatable?: boolean;
  46540. }, scene?: Nullable<Scene>): Mesh;
  46541. /**
  46542. * Creates a ground mesh from a height map
  46543. * * The parameter `url` sets the URL of the height map image resource.
  46544. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46545. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46546. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46547. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46548. * * 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.
  46549. * * 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).
  46550. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46552. * @param name defines the name of the mesh
  46553. * @param url defines the url to the height map
  46554. * @param options defines the options used to create the mesh
  46555. * @param scene defines the hosting scene
  46556. * @returns the ground mesh
  46557. * @see https://doc.babylonjs.com/babylon101/height_map
  46558. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46559. */
  46560. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46561. width?: number;
  46562. height?: number;
  46563. subdivisions?: number;
  46564. minHeight?: number;
  46565. maxHeight?: number;
  46566. colorFilter?: Color3;
  46567. alphaFilter?: number;
  46568. updatable?: boolean;
  46569. onReady?: (mesh: GroundMesh) => void;
  46570. }, scene?: Nullable<Scene>): GroundMesh;
  46571. }
  46572. }
  46573. declare module BABYLON {
  46574. /**
  46575. * Class containing static functions to help procedurally build meshes
  46576. */
  46577. export class TorusBuilder {
  46578. /**
  46579. * Creates a torus mesh
  46580. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46581. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46582. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46584. * * 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
  46585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46586. * @param name defines the name of the mesh
  46587. * @param options defines the options used to create the mesh
  46588. * @param scene defines the hosting scene
  46589. * @returns the torus mesh
  46590. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46591. */
  46592. static CreateTorus(name: string, options: {
  46593. diameter?: number;
  46594. thickness?: number;
  46595. tessellation?: number;
  46596. updatable?: boolean;
  46597. sideOrientation?: number;
  46598. frontUVs?: Vector4;
  46599. backUVs?: Vector4;
  46600. }, scene: any): Mesh;
  46601. }
  46602. }
  46603. declare module BABYLON {
  46604. /**
  46605. * Class containing static functions to help procedurally build meshes
  46606. */
  46607. export class CylinderBuilder {
  46608. /**
  46609. * Creates a cylinder or a cone mesh
  46610. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46611. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46612. * * 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.
  46613. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46614. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46615. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46616. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46617. * * 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).
  46618. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46619. * * 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).
  46620. * * 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
  46621. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46622. * * 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
  46623. * * 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.
  46624. * * If `enclose` is false, a ring surface is one element.
  46625. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46626. * * 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
  46627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46628. * * 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
  46629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46630. * @param name defines the name of the mesh
  46631. * @param options defines the options used to create the mesh
  46632. * @param scene defines the hosting scene
  46633. * @returns the cylinder mesh
  46634. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46635. */
  46636. static CreateCylinder(name: string, options: {
  46637. height?: number;
  46638. diameterTop?: number;
  46639. diameterBottom?: number;
  46640. diameter?: number;
  46641. tessellation?: number;
  46642. subdivisions?: number;
  46643. arc?: number;
  46644. faceColors?: Color4[];
  46645. faceUV?: Vector4[];
  46646. updatable?: boolean;
  46647. hasRings?: boolean;
  46648. enclose?: boolean;
  46649. cap?: number;
  46650. sideOrientation?: number;
  46651. frontUVs?: Vector4;
  46652. backUVs?: Vector4;
  46653. }, scene: any): Mesh;
  46654. }
  46655. }
  46656. declare module BABYLON {
  46657. /**
  46658. * States of the webXR experience
  46659. */
  46660. export enum WebXRState {
  46661. /**
  46662. * Transitioning to being in XR mode
  46663. */
  46664. ENTERING_XR = 0,
  46665. /**
  46666. * Transitioning to non XR mode
  46667. */
  46668. EXITING_XR = 1,
  46669. /**
  46670. * In XR mode and presenting
  46671. */
  46672. IN_XR = 2,
  46673. /**
  46674. * Not entered XR mode
  46675. */
  46676. NOT_IN_XR = 3
  46677. }
  46678. /**
  46679. * Abstraction of the XR render target
  46680. */
  46681. export interface WebXRRenderTarget extends IDisposable {
  46682. /**
  46683. * xrpresent context of the canvas which can be used to display/mirror xr content
  46684. */
  46685. canvasContext: WebGLRenderingContext;
  46686. /**
  46687. * xr layer for the canvas
  46688. */
  46689. xrLayer: Nullable<XRWebGLLayer>;
  46690. /**
  46691. * Initializes the xr layer for the session
  46692. * @param xrSession xr session
  46693. * @returns a promise that will resolve once the XR Layer has been created
  46694. */
  46695. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46696. }
  46697. }
  46698. declare module BABYLON {
  46699. /**
  46700. * COnfiguration object for WebXR output canvas
  46701. */
  46702. export class WebXRManagedOutputCanvasOptions {
  46703. /**
  46704. * An optional canvas in case you wish to create it yourself and provide it here.
  46705. * If not provided, a new canvas will be created
  46706. */
  46707. canvasElement?: HTMLCanvasElement;
  46708. /**
  46709. * Options for this XR Layer output
  46710. */
  46711. canvasOptions?: XRWebGLLayerOptions;
  46712. /**
  46713. * CSS styling for a newly created canvas (if not provided)
  46714. */
  46715. newCanvasCssStyle?: string;
  46716. /**
  46717. * Get the default values of the configuration object
  46718. * @returns default values of this configuration object
  46719. */
  46720. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46721. }
  46722. /**
  46723. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46724. */
  46725. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46726. private _options;
  46727. private _canvas;
  46728. private _engine;
  46729. private _originalCanvasSize;
  46730. /**
  46731. * Rendering context of the canvas which can be used to display/mirror xr content
  46732. */
  46733. canvasContext: WebGLRenderingContext;
  46734. /**
  46735. * xr layer for the canvas
  46736. */
  46737. xrLayer: Nullable<XRWebGLLayer>;
  46738. /**
  46739. * Obseervers registered here will be triggered when the xr layer was initialized
  46740. */
  46741. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46742. /**
  46743. * Initializes the canvas to be added/removed upon entering/exiting xr
  46744. * @param _xrSessionManager The XR Session manager
  46745. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46746. */
  46747. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46748. /**
  46749. * Disposes of the object
  46750. */
  46751. dispose(): void;
  46752. /**
  46753. * Initializes the xr layer for the session
  46754. * @param xrSession xr session
  46755. * @returns a promise that will resolve once the XR Layer has been created
  46756. */
  46757. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46758. private _addCanvas;
  46759. private _removeCanvas;
  46760. private _setCanvasSize;
  46761. private _setManagedOutputCanvas;
  46762. }
  46763. }
  46764. declare module BABYLON {
  46765. /**
  46766. * Manages an XRSession to work with Babylon's engine
  46767. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46768. */
  46769. export class WebXRSessionManager implements IDisposable {
  46770. /** The scene which the session should be created for */
  46771. scene: Scene;
  46772. private _referenceSpace;
  46773. private _rttProvider;
  46774. private _sessionEnded;
  46775. private _xrNavigator;
  46776. private baseLayer;
  46777. /**
  46778. * The base reference space from which the session started. good if you want to reset your
  46779. * reference space
  46780. */
  46781. baseReferenceSpace: XRReferenceSpace;
  46782. /**
  46783. * Current XR frame
  46784. */
  46785. currentFrame: Nullable<XRFrame>;
  46786. /** WebXR timestamp updated every frame */
  46787. currentTimestamp: number;
  46788. /**
  46789. * Used just in case of a failure to initialize an immersive session.
  46790. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46791. */
  46792. defaultHeightCompensation: number;
  46793. /**
  46794. * Fires every time a new xrFrame arrives which can be used to update the camera
  46795. */
  46796. onXRFrameObservable: Observable<XRFrame>;
  46797. /**
  46798. * Fires when the reference space changed
  46799. */
  46800. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46801. /**
  46802. * Fires when the xr session is ended either by the device or manually done
  46803. */
  46804. onXRSessionEnded: Observable<any>;
  46805. /**
  46806. * Fires when the xr session is ended either by the device or manually done
  46807. */
  46808. onXRSessionInit: Observable<XRSession>;
  46809. /**
  46810. * Underlying xr session
  46811. */
  46812. session: XRSession;
  46813. /**
  46814. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46815. * or get the offset the player is currently at.
  46816. */
  46817. viewerReferenceSpace: XRReferenceSpace;
  46818. /**
  46819. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46820. * @param scene The scene which the session should be created for
  46821. */
  46822. constructor(
  46823. /** The scene which the session should be created for */
  46824. scene: Scene);
  46825. /**
  46826. * The current reference space used in this session. This reference space can constantly change!
  46827. * It is mainly used to offset the camera's position.
  46828. */
  46829. get referenceSpace(): XRReferenceSpace;
  46830. /**
  46831. * Set a new reference space and triggers the observable
  46832. */
  46833. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46834. /**
  46835. * Disposes of the session manager
  46836. */
  46837. dispose(): void;
  46838. /**
  46839. * Stops the xrSession and restores the render loop
  46840. * @returns Promise which resolves after it exits XR
  46841. */
  46842. exitXRAsync(): Promise<void>;
  46843. /**
  46844. * Gets the correct render target texture to be rendered this frame for this eye
  46845. * @param eye the eye for which to get the render target
  46846. * @returns the render target for the specified eye
  46847. */
  46848. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46849. /**
  46850. * Creates a WebXRRenderTarget object for the XR session
  46851. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46852. * @param options optional options to provide when creating a new render target
  46853. * @returns a WebXR render target to which the session can render
  46854. */
  46855. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46856. /**
  46857. * Initializes the manager
  46858. * After initialization enterXR can be called to start an XR session
  46859. * @returns Promise which resolves after it is initialized
  46860. */
  46861. initializeAsync(): Promise<void>;
  46862. /**
  46863. * Initializes an xr session
  46864. * @param xrSessionMode mode to initialize
  46865. * @param xrSessionInit defines optional and required values to pass to the session builder
  46866. * @returns a promise which will resolve once the session has been initialized
  46867. */
  46868. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46869. /**
  46870. * Checks if a session would be supported for the creation options specified
  46871. * @param sessionMode session mode to check if supported eg. immersive-vr
  46872. * @returns A Promise that resolves to true if supported and false if not
  46873. */
  46874. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46875. /**
  46876. * Resets the reference space to the one started the session
  46877. */
  46878. resetReferenceSpace(): void;
  46879. /**
  46880. * Starts rendering to the xr layer
  46881. */
  46882. runXRRenderLoop(): void;
  46883. /**
  46884. * Sets the reference space on the xr session
  46885. * @param referenceSpaceType space to set
  46886. * @returns a promise that will resolve once the reference space has been set
  46887. */
  46888. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46889. /**
  46890. * Updates the render state of the session
  46891. * @param state state to set
  46892. * @returns a promise that resolves once the render state has been updated
  46893. */
  46894. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46895. /**
  46896. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46897. * @param sessionMode defines the session to test
  46898. * @returns a promise with boolean as final value
  46899. */
  46900. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46901. private _createRenderTargetTexture;
  46902. }
  46903. }
  46904. declare module BABYLON {
  46905. /**
  46906. * WebXR Camera which holds the views for the xrSession
  46907. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46908. */
  46909. export class WebXRCamera extends FreeCamera {
  46910. private _xrSessionManager;
  46911. private _firstFrame;
  46912. private _referenceQuaternion;
  46913. private _referencedPosition;
  46914. private _xrInvPositionCache;
  46915. private _xrInvQuaternionCache;
  46916. /**
  46917. * Observable raised before camera teleportation
  46918. */
  46919. onBeforeCameraTeleport: Observable<Vector3>;
  46920. /**
  46921. * Observable raised after camera teleportation
  46922. */
  46923. onAfterCameraTeleport: Observable<Vector3>;
  46924. /**
  46925. * Should position compensation execute on first frame.
  46926. * This is used when copying the position from a native (non XR) camera
  46927. */
  46928. compensateOnFirstFrame: boolean;
  46929. /**
  46930. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46931. * @param name the name of the camera
  46932. * @param scene the scene to add the camera to
  46933. * @param _xrSessionManager a constructed xr session manager
  46934. */
  46935. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46936. /**
  46937. * Return the user's height, unrelated to the current ground.
  46938. * This will be the y position of this camera, when ground level is 0.
  46939. */
  46940. get realWorldHeight(): number;
  46941. /** @hidden */
  46942. _updateForDualEyeDebugging(): void;
  46943. /**
  46944. * Sets this camera's transformation based on a non-vr camera
  46945. * @param otherCamera the non-vr camera to copy the transformation from
  46946. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46947. */
  46948. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46949. /**
  46950. * Gets the current instance class name ("WebXRCamera").
  46951. * @returns the class name
  46952. */
  46953. getClassName(): string;
  46954. private _rotate180;
  46955. private _updateFromXRSession;
  46956. private _updateNumberOfRigCameras;
  46957. private _updateReferenceSpace;
  46958. private _updateReferenceSpaceOffset;
  46959. }
  46960. }
  46961. declare module BABYLON {
  46962. /**
  46963. * Defining the interface required for a (webxr) feature
  46964. */
  46965. export interface IWebXRFeature extends IDisposable {
  46966. /**
  46967. * Is this feature attached
  46968. */
  46969. attached: boolean;
  46970. /**
  46971. * Should auto-attach be disabled?
  46972. */
  46973. disableAutoAttach: boolean;
  46974. /**
  46975. * Attach the feature to the session
  46976. * Will usually be called by the features manager
  46977. *
  46978. * @param force should attachment be forced (even when already attached)
  46979. * @returns true if successful.
  46980. */
  46981. attach(force?: boolean): boolean;
  46982. /**
  46983. * Detach the feature from the session
  46984. * Will usually be called by the features manager
  46985. *
  46986. * @returns true if successful.
  46987. */
  46988. detach(): boolean;
  46989. /**
  46990. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  46991. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  46992. *
  46993. * @returns whether or not the feature is compatible in this environment
  46994. */
  46995. isCompatible(): boolean;
  46996. /**
  46997. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  46998. */
  46999. xrNativeFeatureName?: string;
  47000. }
  47001. /**
  47002. * A list of the currently available features without referencing them
  47003. */
  47004. export class WebXRFeatureName {
  47005. /**
  47006. * The name of the anchor system feature
  47007. */
  47008. static ANCHOR_SYSTEM: string;
  47009. /**
  47010. * The name of the background remover feature
  47011. */
  47012. static BACKGROUND_REMOVER: string;
  47013. /**
  47014. * The name of the hit test feature
  47015. */
  47016. static HIT_TEST: string;
  47017. /**
  47018. * physics impostors for xr controllers feature
  47019. */
  47020. static PHYSICS_CONTROLLERS: string;
  47021. /**
  47022. * The name of the plane detection feature
  47023. */
  47024. static PLANE_DETECTION: string;
  47025. /**
  47026. * The name of the pointer selection feature
  47027. */
  47028. static POINTER_SELECTION: string;
  47029. /**
  47030. * The name of the teleportation feature
  47031. */
  47032. static TELEPORTATION: string;
  47033. }
  47034. /**
  47035. * Defining the constructor of a feature. Used to register the modules.
  47036. */
  47037. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47038. /**
  47039. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47040. * It is mainly used in AR sessions.
  47041. *
  47042. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47043. */
  47044. export class WebXRFeaturesManager implements IDisposable {
  47045. private _xrSessionManager;
  47046. private static readonly _AvailableFeatures;
  47047. private _features;
  47048. /**
  47049. * constructs a new features manages.
  47050. *
  47051. * @param _xrSessionManager an instance of WebXRSessionManager
  47052. */
  47053. constructor(_xrSessionManager: WebXRSessionManager);
  47054. /**
  47055. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47056. * Mainly used internally.
  47057. *
  47058. * @param featureName the name of the feature to register
  47059. * @param constructorFunction the function used to construct the module
  47060. * @param version the (babylon) version of the module
  47061. * @param stable is that a stable version of this module
  47062. */
  47063. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47064. /**
  47065. * Returns a constructor of a specific feature.
  47066. *
  47067. * @param featureName the name of the feature to construct
  47068. * @param version the version of the feature to load
  47069. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47070. * @param options optional options provided to the module.
  47071. * @returns a function that, when called, will return a new instance of this feature
  47072. */
  47073. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47074. /**
  47075. * Can be used to return the list of features currently registered
  47076. *
  47077. * @returns an Array of available features
  47078. */
  47079. static GetAvailableFeatures(): string[];
  47080. /**
  47081. * Gets the versions available for a specific feature
  47082. * @param featureName the name of the feature
  47083. * @returns an array with the available versions
  47084. */
  47085. static GetAvailableVersions(featureName: string): string[];
  47086. /**
  47087. * Return the latest unstable version of this feature
  47088. * @param featureName the name of the feature to search
  47089. * @returns the version number. if not found will return -1
  47090. */
  47091. static GetLatestVersionOfFeature(featureName: string): number;
  47092. /**
  47093. * Return the latest stable version of this feature
  47094. * @param featureName the name of the feature to search
  47095. * @returns the version number. if not found will return -1
  47096. */
  47097. static GetStableVersionOfFeature(featureName: string): number;
  47098. /**
  47099. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47100. * Can be used during a session to start a feature
  47101. * @param featureName the name of feature to attach
  47102. */
  47103. attachFeature(featureName: string): void;
  47104. /**
  47105. * Can be used inside a session or when the session ends to detach a specific feature
  47106. * @param featureName the name of the feature to detach
  47107. */
  47108. detachFeature(featureName: string): void;
  47109. /**
  47110. * Used to disable an already-enabled feature
  47111. * The feature will be disposed and will be recreated once enabled.
  47112. * @param featureName the feature to disable
  47113. * @returns true if disable was successful
  47114. */
  47115. disableFeature(featureName: string | {
  47116. Name: string;
  47117. }): boolean;
  47118. /**
  47119. * dispose this features manager
  47120. */
  47121. dispose(): void;
  47122. /**
  47123. * 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.
  47124. * 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.
  47125. *
  47126. * @param featureName the name of the feature to load or the class of the feature
  47127. * @param version optional version to load. if not provided the latest version will be enabled
  47128. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47129. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47130. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47131. * @returns a new constructed feature or throws an error if feature not found.
  47132. */
  47133. enableFeature(featureName: string | {
  47134. Name: string;
  47135. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47136. /**
  47137. * get the implementation of an enabled feature.
  47138. * @param featureName the name of the feature to load
  47139. * @returns the feature class, if found
  47140. */
  47141. getEnabledFeature(featureName: string): IWebXRFeature;
  47142. /**
  47143. * Get the list of enabled features
  47144. * @returns an array of enabled features
  47145. */
  47146. getEnabledFeatures(): string[];
  47147. /**
  47148. * This function will exten the session creation configuration object with enabled features.
  47149. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47150. * according to the defined "required" variable, provided during enableFeature call
  47151. * @param xrSessionInit the xr Session init object to extend
  47152. *
  47153. * @returns an extended XRSessionInit object
  47154. */
  47155. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47156. }
  47157. }
  47158. declare module BABYLON {
  47159. /**
  47160. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47161. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47162. */
  47163. export class WebXRExperienceHelper implements IDisposable {
  47164. private scene;
  47165. private _nonVRCamera;
  47166. private _originalSceneAutoClear;
  47167. private _supported;
  47168. /**
  47169. * Camera used to render xr content
  47170. */
  47171. camera: WebXRCamera;
  47172. /** A features manager for this xr session */
  47173. featuresManager: WebXRFeaturesManager;
  47174. /**
  47175. * Observers registered here will be triggered after the camera's initial transformation is set
  47176. * This can be used to set a different ground level or an extra rotation.
  47177. *
  47178. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47179. * to the position set after this observable is done executing.
  47180. */
  47181. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47182. /**
  47183. * Fires when the state of the experience helper has changed
  47184. */
  47185. onStateChangedObservable: Observable<WebXRState>;
  47186. /** Session manager used to keep track of xr session */
  47187. sessionManager: WebXRSessionManager;
  47188. /**
  47189. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47190. */
  47191. state: WebXRState;
  47192. /**
  47193. * Creates a WebXRExperienceHelper
  47194. * @param scene The scene the helper should be created in
  47195. */
  47196. private constructor();
  47197. /**
  47198. * Creates the experience helper
  47199. * @param scene the scene to attach the experience helper to
  47200. * @returns a promise for the experience helper
  47201. */
  47202. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47203. /**
  47204. * Disposes of the experience helper
  47205. */
  47206. dispose(): void;
  47207. /**
  47208. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47209. * @param sessionMode options for the XR session
  47210. * @param referenceSpaceType frame of reference of the XR session
  47211. * @param renderTarget the output canvas that will be used to enter XR mode
  47212. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47213. * @returns promise that resolves after xr mode has entered
  47214. */
  47215. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47216. /**
  47217. * Exits XR mode and returns the scene to its original state
  47218. * @returns promise that resolves after xr mode has exited
  47219. */
  47220. exitXRAsync(): Promise<void>;
  47221. private _nonXRToXRCamera;
  47222. private _setState;
  47223. }
  47224. }
  47225. declare module BABYLON {
  47226. /**
  47227. * X-Y values for axes in WebXR
  47228. */
  47229. export interface IWebXRMotionControllerAxesValue {
  47230. /**
  47231. * The value of the x axis
  47232. */
  47233. x: number;
  47234. /**
  47235. * The value of the y-axis
  47236. */
  47237. y: number;
  47238. }
  47239. /**
  47240. * changed / previous values for the values of this component
  47241. */
  47242. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47243. /**
  47244. * current (this frame) value
  47245. */
  47246. current: T;
  47247. /**
  47248. * previous (last change) value
  47249. */
  47250. previous: T;
  47251. }
  47252. /**
  47253. * Represents changes in the component between current frame and last values recorded
  47254. */
  47255. export interface IWebXRMotionControllerComponentChanges {
  47256. /**
  47257. * will be populated with previous and current values if axes changed
  47258. */
  47259. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47260. /**
  47261. * will be populated with previous and current values if pressed changed
  47262. */
  47263. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47264. /**
  47265. * will be populated with previous and current values if touched changed
  47266. */
  47267. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47268. /**
  47269. * will be populated with previous and current values if value changed
  47270. */
  47271. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47272. }
  47273. /**
  47274. * This class represents a single component (for example button or thumbstick) of a motion controller
  47275. */
  47276. export class WebXRControllerComponent implements IDisposable {
  47277. /**
  47278. * the id of this component
  47279. */
  47280. id: string;
  47281. /**
  47282. * the type of the component
  47283. */
  47284. type: MotionControllerComponentType;
  47285. private _buttonIndex;
  47286. private _axesIndices;
  47287. private _axes;
  47288. private _changes;
  47289. private _currentValue;
  47290. private _hasChanges;
  47291. private _pressed;
  47292. private _touched;
  47293. /**
  47294. * button component type
  47295. */
  47296. static BUTTON_TYPE: MotionControllerComponentType;
  47297. /**
  47298. * squeeze component type
  47299. */
  47300. static SQUEEZE_TYPE: MotionControllerComponentType;
  47301. /**
  47302. * Thumbstick component type
  47303. */
  47304. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47305. /**
  47306. * Touchpad component type
  47307. */
  47308. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47309. /**
  47310. * trigger component type
  47311. */
  47312. static TRIGGER_TYPE: MotionControllerComponentType;
  47313. /**
  47314. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47315. * the axes data changes
  47316. */
  47317. onAxisValueChangedObservable: Observable<{
  47318. x: number;
  47319. y: number;
  47320. }>;
  47321. /**
  47322. * Observers registered here will be triggered when the state of a button changes
  47323. * State change is either pressed / touched / value
  47324. */
  47325. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47326. /**
  47327. * Creates a new component for a motion controller.
  47328. * It is created by the motion controller itself
  47329. *
  47330. * @param id the id of this component
  47331. * @param type the type of the component
  47332. * @param _buttonIndex index in the buttons array of the gamepad
  47333. * @param _axesIndices indices of the values in the axes array of the gamepad
  47334. */
  47335. constructor(
  47336. /**
  47337. * the id of this component
  47338. */
  47339. id: string,
  47340. /**
  47341. * the type of the component
  47342. */
  47343. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47344. /**
  47345. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47346. */
  47347. get axes(): IWebXRMotionControllerAxesValue;
  47348. /**
  47349. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47350. */
  47351. get changes(): IWebXRMotionControllerComponentChanges;
  47352. /**
  47353. * Return whether or not the component changed the last frame
  47354. */
  47355. get hasChanges(): boolean;
  47356. /**
  47357. * is the button currently pressed
  47358. */
  47359. get pressed(): boolean;
  47360. /**
  47361. * is the button currently touched
  47362. */
  47363. get touched(): boolean;
  47364. /**
  47365. * Get the current value of this component
  47366. */
  47367. get value(): number;
  47368. /**
  47369. * Dispose this component
  47370. */
  47371. dispose(): void;
  47372. /**
  47373. * Are there axes correlating to this component
  47374. * @return true is axes data is available
  47375. */
  47376. isAxes(): boolean;
  47377. /**
  47378. * Is this component a button (hence - pressable)
  47379. * @returns true if can be pressed
  47380. */
  47381. isButton(): boolean;
  47382. /**
  47383. * update this component using the gamepad object it is in. Called on every frame
  47384. * @param nativeController the native gamepad controller object
  47385. */
  47386. update(nativeController: IMinimalMotionControllerObject): void;
  47387. }
  47388. }
  47389. declare module BABYLON {
  47390. /**
  47391. * Interface used to represent data loading progression
  47392. */
  47393. export interface ISceneLoaderProgressEvent {
  47394. /**
  47395. * Defines if data length to load can be evaluated
  47396. */
  47397. readonly lengthComputable: boolean;
  47398. /**
  47399. * Defines the loaded data length
  47400. */
  47401. readonly loaded: number;
  47402. /**
  47403. * Defines the data length to load
  47404. */
  47405. readonly total: number;
  47406. }
  47407. /**
  47408. * Interface used by SceneLoader plugins to define supported file extensions
  47409. */
  47410. export interface ISceneLoaderPluginExtensions {
  47411. /**
  47412. * Defines the list of supported extensions
  47413. */
  47414. [extension: string]: {
  47415. isBinary: boolean;
  47416. };
  47417. }
  47418. /**
  47419. * Interface used by SceneLoader plugin factory
  47420. */
  47421. export interface ISceneLoaderPluginFactory {
  47422. /**
  47423. * Defines the name of the factory
  47424. */
  47425. name: string;
  47426. /**
  47427. * Function called to create a new plugin
  47428. * @return the new plugin
  47429. */
  47430. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47431. /**
  47432. * The callback that returns true if the data can be directly loaded.
  47433. * @param data string containing the file data
  47434. * @returns if the data can be loaded directly
  47435. */
  47436. canDirectLoad?(data: string): boolean;
  47437. }
  47438. /**
  47439. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47440. */
  47441. export interface ISceneLoaderPluginBase {
  47442. /**
  47443. * The friendly name of this plugin.
  47444. */
  47445. name: string;
  47446. /**
  47447. * The file extensions supported by this plugin.
  47448. */
  47449. extensions: string | ISceneLoaderPluginExtensions;
  47450. /**
  47451. * The callback called when loading from a url.
  47452. * @param scene scene loading this url
  47453. * @param url url to load
  47454. * @param onSuccess callback called when the file successfully loads
  47455. * @param onProgress callback called while file is loading (if the server supports this mode)
  47456. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47457. * @param onError callback called when the file fails to load
  47458. * @returns a file request object
  47459. */
  47460. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47461. /**
  47462. * The callback called when loading from a file object.
  47463. * @param scene scene loading this file
  47464. * @param file defines the file to load
  47465. * @param onSuccess defines the callback to call when data is loaded
  47466. * @param onProgress defines the callback to call during loading process
  47467. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47468. * @param onError defines the callback to call when an error occurs
  47469. * @returns a file request object
  47470. */
  47471. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47472. /**
  47473. * The callback that returns true if the data can be directly loaded.
  47474. * @param data string containing the file data
  47475. * @returns if the data can be loaded directly
  47476. */
  47477. canDirectLoad?(data: string): boolean;
  47478. /**
  47479. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47480. * @param scene scene loading this data
  47481. * @param data string containing the data
  47482. * @returns data to pass to the plugin
  47483. */
  47484. directLoad?(scene: Scene, data: string): any;
  47485. /**
  47486. * The callback that allows custom handling of the root url based on the response url.
  47487. * @param rootUrl the original root url
  47488. * @param responseURL the response url if available
  47489. * @returns the new root url
  47490. */
  47491. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47492. }
  47493. /**
  47494. * Interface used to define a SceneLoader plugin
  47495. */
  47496. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47497. /**
  47498. * Import meshes into a scene.
  47499. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47500. * @param scene The scene to import into
  47501. * @param data The data to import
  47502. * @param rootUrl The root url for scene and resources
  47503. * @param meshes The meshes array to import into
  47504. * @param particleSystems The particle systems array to import into
  47505. * @param skeletons The skeletons array to import into
  47506. * @param onError The callback when import fails
  47507. * @returns True if successful or false otherwise
  47508. */
  47509. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47510. /**
  47511. * Load into a scene.
  47512. * @param scene The scene to load into
  47513. * @param data The data to import
  47514. * @param rootUrl The root url for scene and resources
  47515. * @param onError The callback when import fails
  47516. * @returns True if successful or false otherwise
  47517. */
  47518. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47519. /**
  47520. * Load into an asset container.
  47521. * @param scene The scene to load into
  47522. * @param data The data to import
  47523. * @param rootUrl The root url for scene and resources
  47524. * @param onError The callback when import fails
  47525. * @returns The loaded asset container
  47526. */
  47527. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47528. }
  47529. /**
  47530. * Interface used to define an async SceneLoader plugin
  47531. */
  47532. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47533. /**
  47534. * Import meshes into a scene.
  47535. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47536. * @param scene The scene to import into
  47537. * @param data The data to import
  47538. * @param rootUrl The root url for scene and resources
  47539. * @param onProgress The callback when the load progresses
  47540. * @param fileName Defines the name of the file to load
  47541. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47542. */
  47543. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47544. meshes: AbstractMesh[];
  47545. particleSystems: IParticleSystem[];
  47546. skeletons: Skeleton[];
  47547. animationGroups: AnimationGroup[];
  47548. }>;
  47549. /**
  47550. * Load into a scene.
  47551. * @param scene The scene to load into
  47552. * @param data The data to import
  47553. * @param rootUrl The root url for scene and resources
  47554. * @param onProgress The callback when the load progresses
  47555. * @param fileName Defines the name of the file to load
  47556. * @returns Nothing
  47557. */
  47558. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47559. /**
  47560. * Load into an asset container.
  47561. * @param scene The scene to load into
  47562. * @param data The data to import
  47563. * @param rootUrl The root url for scene and resources
  47564. * @param onProgress The callback when the load progresses
  47565. * @param fileName Defines the name of the file to load
  47566. * @returns The loaded asset container
  47567. */
  47568. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47569. }
  47570. /**
  47571. * Mode that determines how to handle old animation groups before loading new ones.
  47572. */
  47573. export enum SceneLoaderAnimationGroupLoadingMode {
  47574. /**
  47575. * Reset all old animations to initial state then dispose them.
  47576. */
  47577. Clean = 0,
  47578. /**
  47579. * Stop all old animations.
  47580. */
  47581. Stop = 1,
  47582. /**
  47583. * Restart old animations from first frame.
  47584. */
  47585. Sync = 2,
  47586. /**
  47587. * Old animations remains untouched.
  47588. */
  47589. NoSync = 3
  47590. }
  47591. /**
  47592. * Defines a plugin registered by the SceneLoader
  47593. */
  47594. interface IRegisteredPlugin {
  47595. /**
  47596. * Defines the plugin to use
  47597. */
  47598. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47599. /**
  47600. * Defines if the plugin supports binary data
  47601. */
  47602. isBinary: boolean;
  47603. }
  47604. /**
  47605. * Class used to load scene from various file formats using registered plugins
  47606. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47607. */
  47608. export class SceneLoader {
  47609. /**
  47610. * No logging while loading
  47611. */
  47612. static readonly NO_LOGGING: number;
  47613. /**
  47614. * Minimal logging while loading
  47615. */
  47616. static readonly MINIMAL_LOGGING: number;
  47617. /**
  47618. * Summary logging while loading
  47619. */
  47620. static readonly SUMMARY_LOGGING: number;
  47621. /**
  47622. * Detailled logging while loading
  47623. */
  47624. static readonly DETAILED_LOGGING: number;
  47625. /**
  47626. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47627. */
  47628. static get ForceFullSceneLoadingForIncremental(): boolean;
  47629. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47630. /**
  47631. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47632. */
  47633. static get ShowLoadingScreen(): boolean;
  47634. static set ShowLoadingScreen(value: boolean);
  47635. /**
  47636. * Defines the current logging level (while loading the scene)
  47637. * @ignorenaming
  47638. */
  47639. static get loggingLevel(): number;
  47640. static set loggingLevel(value: number);
  47641. /**
  47642. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47643. */
  47644. static get CleanBoneMatrixWeights(): boolean;
  47645. static set CleanBoneMatrixWeights(value: boolean);
  47646. /**
  47647. * Event raised when a plugin is used to load a scene
  47648. */
  47649. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47650. private static _registeredPlugins;
  47651. private static _showingLoadingScreen;
  47652. /**
  47653. * Gets the default plugin (used to load Babylon files)
  47654. * @returns the .babylon plugin
  47655. */
  47656. static GetDefaultPlugin(): IRegisteredPlugin;
  47657. private static _GetPluginForExtension;
  47658. private static _GetPluginForDirectLoad;
  47659. private static _GetPluginForFilename;
  47660. private static _GetDirectLoad;
  47661. private static _LoadData;
  47662. private static _GetFileInfo;
  47663. /**
  47664. * Gets a plugin that can load the given extension
  47665. * @param extension defines the extension to load
  47666. * @returns a plugin or null if none works
  47667. */
  47668. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47669. /**
  47670. * Gets a boolean indicating that the given extension can be loaded
  47671. * @param extension defines the extension to load
  47672. * @returns true if the extension is supported
  47673. */
  47674. static IsPluginForExtensionAvailable(extension: string): boolean;
  47675. /**
  47676. * Adds a new plugin to the list of registered plugins
  47677. * @param plugin defines the plugin to add
  47678. */
  47679. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47680. /**
  47681. * Import meshes into a scene
  47682. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47683. * @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)
  47684. * @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)
  47685. * @param scene the instance of BABYLON.Scene to append to
  47686. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47687. * @param onProgress a callback with a progress event for each file being loaded
  47688. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47689. * @param pluginExtension the extension used to determine the plugin
  47690. * @returns The loaded plugin
  47691. */
  47692. 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>;
  47693. /**
  47694. * Import meshes into a scene
  47695. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47696. * @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)
  47697. * @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)
  47698. * @param scene the instance of BABYLON.Scene to append to
  47699. * @param onProgress a callback with a progress event for each file being loaded
  47700. * @param pluginExtension the extension used to determine the plugin
  47701. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47702. */
  47703. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47704. meshes: AbstractMesh[];
  47705. particleSystems: IParticleSystem[];
  47706. skeletons: Skeleton[];
  47707. animationGroups: AnimationGroup[];
  47708. }>;
  47709. /**
  47710. * Load a scene
  47711. * @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)
  47712. * @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)
  47713. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47714. * @param onSuccess a callback with the scene when import succeeds
  47715. * @param onProgress a callback with a progress event for each file being loaded
  47716. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47717. * @param pluginExtension the extension used to determine the plugin
  47718. * @returns The loaded plugin
  47719. */
  47720. 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>;
  47721. /**
  47722. * Load a scene
  47723. * @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)
  47724. * @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)
  47725. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47726. * @param onProgress a callback with a progress event for each file being loaded
  47727. * @param pluginExtension the extension used to determine the plugin
  47728. * @returns The loaded scene
  47729. */
  47730. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47731. /**
  47732. * Append a scene
  47733. * @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)
  47734. * @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)
  47735. * @param scene is the instance of BABYLON.Scene to append to
  47736. * @param onSuccess a callback with the scene when import succeeds
  47737. * @param onProgress a callback with a progress event for each file being loaded
  47738. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47739. * @param pluginExtension the extension used to determine the plugin
  47740. * @returns The loaded plugin
  47741. */
  47742. 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>;
  47743. /**
  47744. * Append a scene
  47745. * @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)
  47746. * @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)
  47747. * @param scene is the instance of BABYLON.Scene to append to
  47748. * @param onProgress a callback with a progress event for each file being loaded
  47749. * @param pluginExtension the extension used to determine the plugin
  47750. * @returns The given scene
  47751. */
  47752. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47753. /**
  47754. * Load a scene into an asset container
  47755. * @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)
  47756. * @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)
  47757. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47758. * @param onSuccess a callback with the scene when import succeeds
  47759. * @param onProgress a callback with a progress event for each file being loaded
  47760. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47761. * @param pluginExtension the extension used to determine the plugin
  47762. * @returns The loaded plugin
  47763. */
  47764. 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>;
  47765. /**
  47766. * Load a scene into an asset container
  47767. * @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)
  47768. * @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)
  47769. * @param scene is the instance of Scene to append to
  47770. * @param onProgress a callback with a progress event for each file being loaded
  47771. * @param pluginExtension the extension used to determine the plugin
  47772. * @returns The loaded asset container
  47773. */
  47774. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47775. /**
  47776. * Import animations from a file into a scene
  47777. * @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)
  47778. * @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)
  47779. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47780. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47781. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47782. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47783. * @param onSuccess a callback with the scene when import succeeds
  47784. * @param onProgress a callback with a progress event for each file being loaded
  47785. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47786. * @param pluginExtension the extension used to determine the plugin
  47787. */
  47788. 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;
  47789. /**
  47790. * Import animations from a file into a scene
  47791. * @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)
  47792. * @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)
  47793. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47794. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47795. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47796. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47797. * @param onSuccess a callback with the scene when import succeeds
  47798. * @param onProgress a callback with a progress event for each file being loaded
  47799. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47800. * @param pluginExtension the extension used to determine the plugin
  47801. * @returns the updated scene with imported animations
  47802. */
  47803. 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>;
  47804. }
  47805. }
  47806. declare module BABYLON {
  47807. /**
  47808. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47809. */
  47810. export type MotionControllerHandedness = "none" | "left" | "right";
  47811. /**
  47812. * The type of components available in motion controllers.
  47813. * This is not the name of the component.
  47814. */
  47815. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47816. /**
  47817. * The state of a controller component
  47818. */
  47819. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47820. /**
  47821. * The schema of motion controller layout.
  47822. * No object will be initialized using this interface
  47823. * This is used just to define the profile.
  47824. */
  47825. export interface IMotionControllerLayout {
  47826. /**
  47827. * Path to load the assets. Usually relative to the base path
  47828. */
  47829. assetPath: string;
  47830. /**
  47831. * Available components (unsorted)
  47832. */
  47833. components: {
  47834. /**
  47835. * A map of component Ids
  47836. */
  47837. [componentId: string]: {
  47838. /**
  47839. * The type of input the component outputs
  47840. */
  47841. type: MotionControllerComponentType;
  47842. /**
  47843. * The indices of this component in the gamepad object
  47844. */
  47845. gamepadIndices: {
  47846. /**
  47847. * Index of button
  47848. */
  47849. button?: number;
  47850. /**
  47851. * If available, index of x-axis
  47852. */
  47853. xAxis?: number;
  47854. /**
  47855. * If available, index of y-axis
  47856. */
  47857. yAxis?: number;
  47858. };
  47859. /**
  47860. * The mesh's root node name
  47861. */
  47862. rootNodeName: string;
  47863. /**
  47864. * Animation definitions for this model
  47865. */
  47866. visualResponses: {
  47867. [stateKey: string]: {
  47868. /**
  47869. * What property will be animated
  47870. */
  47871. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47872. /**
  47873. * What states influence this visual response
  47874. */
  47875. states: MotionControllerComponentStateType[];
  47876. /**
  47877. * Type of animation - movement or visibility
  47878. */
  47879. valueNodeProperty: "transform" | "visibility";
  47880. /**
  47881. * Base node name to move. Its position will be calculated according to the min and max nodes
  47882. */
  47883. valueNodeName?: string;
  47884. /**
  47885. * Minimum movement node
  47886. */
  47887. minNodeName?: string;
  47888. /**
  47889. * Max movement node
  47890. */
  47891. maxNodeName?: string;
  47892. };
  47893. };
  47894. /**
  47895. * If touch enabled, what is the name of node to display user feedback
  47896. */
  47897. touchPointNodeName?: string;
  47898. };
  47899. };
  47900. /**
  47901. * Is it xr standard mapping or not
  47902. */
  47903. gamepadMapping: "" | "xr-standard";
  47904. /**
  47905. * Base root node of this entire model
  47906. */
  47907. rootNodeName: string;
  47908. /**
  47909. * Defines the main button component id
  47910. */
  47911. selectComponentId: string;
  47912. }
  47913. /**
  47914. * A definition for the layout map in the input profile
  47915. */
  47916. export interface IMotionControllerLayoutMap {
  47917. /**
  47918. * Layouts with handedness type as a key
  47919. */
  47920. [handedness: string]: IMotionControllerLayout;
  47921. }
  47922. /**
  47923. * The XR Input profile schema
  47924. * Profiles can be found here:
  47925. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47926. */
  47927. export interface IMotionControllerProfile {
  47928. /**
  47929. * fallback profiles for this profileId
  47930. */
  47931. fallbackProfileIds: string[];
  47932. /**
  47933. * The layout map, with handedness as key
  47934. */
  47935. layouts: IMotionControllerLayoutMap;
  47936. /**
  47937. * The id of this profile
  47938. * correlates to the profile(s) in the xrInput.profiles array
  47939. */
  47940. profileId: string;
  47941. }
  47942. /**
  47943. * A helper-interface for the 3 meshes needed for controller button animation
  47944. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47945. */
  47946. export interface IMotionControllerButtonMeshMap {
  47947. /**
  47948. * the mesh that defines the pressed value mesh position.
  47949. * This is used to find the max-position of this button
  47950. */
  47951. pressedMesh: AbstractMesh;
  47952. /**
  47953. * the mesh that defines the unpressed value mesh position.
  47954. * This is used to find the min (or initial) position of this button
  47955. */
  47956. unpressedMesh: AbstractMesh;
  47957. /**
  47958. * The mesh that will be changed when value changes
  47959. */
  47960. valueMesh: AbstractMesh;
  47961. }
  47962. /**
  47963. * A helper-interface for the 3 meshes needed for controller axis animation.
  47964. * This will be expanded when touchpad animations are fully supported
  47965. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47966. */
  47967. export interface IMotionControllerMeshMap {
  47968. /**
  47969. * the mesh that defines the maximum value mesh position.
  47970. */
  47971. maxMesh?: AbstractMesh;
  47972. /**
  47973. * the mesh that defines the minimum value mesh position.
  47974. */
  47975. minMesh?: AbstractMesh;
  47976. /**
  47977. * The mesh that will be changed when axis value changes
  47978. */
  47979. valueMesh: AbstractMesh;
  47980. }
  47981. /**
  47982. * The elements needed for change-detection of the gamepad objects in motion controllers
  47983. */
  47984. export interface IMinimalMotionControllerObject {
  47985. /**
  47986. * Available axes of this controller
  47987. */
  47988. axes: number[];
  47989. /**
  47990. * An array of available buttons
  47991. */
  47992. buttons: Array<{
  47993. /**
  47994. * Value of the button/trigger
  47995. */
  47996. value: number;
  47997. /**
  47998. * If the button/trigger is currently touched
  47999. */
  48000. touched: boolean;
  48001. /**
  48002. * If the button/trigger is currently pressed
  48003. */
  48004. pressed: boolean;
  48005. }>;
  48006. /**
  48007. * EXPERIMENTAL haptic support.
  48008. */
  48009. hapticActuators?: Array<{
  48010. pulse: (value: number, duration: number) => Promise<boolean>;
  48011. }>;
  48012. }
  48013. /**
  48014. * An Abstract Motion controller
  48015. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48016. * Each component has an observable to check for changes in value and state
  48017. */
  48018. export abstract class WebXRAbstractMotionController implements IDisposable {
  48019. protected scene: Scene;
  48020. protected layout: IMotionControllerLayout;
  48021. /**
  48022. * The gamepad object correlating to this controller
  48023. */
  48024. gamepadObject: IMinimalMotionControllerObject;
  48025. /**
  48026. * handedness (left/right/none) of this controller
  48027. */
  48028. handedness: MotionControllerHandedness;
  48029. private _initComponent;
  48030. private _modelReady;
  48031. /**
  48032. * A map of components (WebXRControllerComponent) in this motion controller
  48033. * Components have a ComponentType and can also have both button and axis definitions
  48034. */
  48035. readonly components: {
  48036. [id: string]: WebXRControllerComponent;
  48037. };
  48038. /**
  48039. * Disable the model's animation. Can be set at any time.
  48040. */
  48041. disableAnimation: boolean;
  48042. /**
  48043. * Observers registered here will be triggered when the model of this controller is done loading
  48044. */
  48045. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48046. /**
  48047. * The profile id of this motion controller
  48048. */
  48049. abstract profileId: string;
  48050. /**
  48051. * The root mesh of the model. It is null if the model was not yet initialized
  48052. */
  48053. rootMesh: Nullable<AbstractMesh>;
  48054. /**
  48055. * constructs a new abstract motion controller
  48056. * @param scene the scene to which the model of the controller will be added
  48057. * @param layout The profile layout to load
  48058. * @param gamepadObject The gamepad object correlating to this controller
  48059. * @param handedness handedness (left/right/none) of this controller
  48060. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48061. */
  48062. constructor(scene: Scene, layout: IMotionControllerLayout,
  48063. /**
  48064. * The gamepad object correlating to this controller
  48065. */
  48066. gamepadObject: IMinimalMotionControllerObject,
  48067. /**
  48068. * handedness (left/right/none) of this controller
  48069. */
  48070. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48071. /**
  48072. * Dispose this controller, the model mesh and all its components
  48073. */
  48074. dispose(): void;
  48075. /**
  48076. * Returns all components of specific type
  48077. * @param type the type to search for
  48078. * @return an array of components with this type
  48079. */
  48080. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48081. /**
  48082. * get a component based an its component id as defined in layout.components
  48083. * @param id the id of the component
  48084. * @returns the component correlates to the id or undefined if not found
  48085. */
  48086. getComponent(id: string): WebXRControllerComponent;
  48087. /**
  48088. * Get the list of components available in this motion controller
  48089. * @returns an array of strings correlating to available components
  48090. */
  48091. getComponentIds(): string[];
  48092. /**
  48093. * Get the first component of specific type
  48094. * @param type type of component to find
  48095. * @return a controller component or null if not found
  48096. */
  48097. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48098. /**
  48099. * Get the main (Select) component of this controller as defined in the layout
  48100. * @returns the main component of this controller
  48101. */
  48102. getMainComponent(): WebXRControllerComponent;
  48103. /**
  48104. * Loads the model correlating to this controller
  48105. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48106. * @returns A promise fulfilled with the result of the model loading
  48107. */
  48108. loadModel(): Promise<boolean>;
  48109. /**
  48110. * Update this model using the current XRFrame
  48111. * @param xrFrame the current xr frame to use and update the model
  48112. */
  48113. updateFromXRFrame(xrFrame: XRFrame): void;
  48114. /**
  48115. * Backwards compatibility due to a deeply-integrated typo
  48116. */
  48117. get handness(): XREye;
  48118. /**
  48119. * Pulse (vibrate) this controller
  48120. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48121. * Consecutive calls to this function will cancel the last pulse call
  48122. *
  48123. * @param value the strength of the pulse in 0.0...1.0 range
  48124. * @param duration Duration of the pulse in milliseconds
  48125. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48126. * @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
  48127. */
  48128. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48129. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48130. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48131. /**
  48132. * Moves the axis on the controller mesh based on its current state
  48133. * @param axis the index of the axis
  48134. * @param axisValue the value of the axis which determines the meshes new position
  48135. * @hidden
  48136. */
  48137. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48138. /**
  48139. * Update the model itself with the current frame data
  48140. * @param xrFrame the frame to use for updating the model mesh
  48141. */
  48142. protected updateModel(xrFrame: XRFrame): void;
  48143. /**
  48144. * Get the filename and path for this controller's model
  48145. * @returns a map of filename and path
  48146. */
  48147. protected abstract _getFilenameAndPath(): {
  48148. filename: string;
  48149. path: string;
  48150. };
  48151. /**
  48152. * This function is called before the mesh is loaded. It checks for loading constraints.
  48153. * For example, this function can check if the GLB loader is available
  48154. * If this function returns false, the generic controller will be loaded instead
  48155. * @returns Is the client ready to load the mesh
  48156. */
  48157. protected abstract _getModelLoadingConstraints(): boolean;
  48158. /**
  48159. * This function will be called after the model was successfully loaded and can be used
  48160. * for mesh transformations before it is available for the user
  48161. * @param meshes the loaded meshes
  48162. */
  48163. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48164. /**
  48165. * Set the root mesh for this controller. Important for the WebXR controller class
  48166. * @param meshes the loaded meshes
  48167. */
  48168. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48169. /**
  48170. * A function executed each frame that updates the mesh (if needed)
  48171. * @param xrFrame the current xrFrame
  48172. */
  48173. protected abstract _updateModel(xrFrame: XRFrame): void;
  48174. private _getGenericFilenameAndPath;
  48175. private _getGenericParentMesh;
  48176. }
  48177. }
  48178. declare module BABYLON {
  48179. /**
  48180. * A generic trigger-only motion controller for WebXR
  48181. */
  48182. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48183. /**
  48184. * Static version of the profile id of this controller
  48185. */
  48186. static ProfileId: string;
  48187. profileId: string;
  48188. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48189. protected _getFilenameAndPath(): {
  48190. filename: string;
  48191. path: string;
  48192. };
  48193. protected _getModelLoadingConstraints(): boolean;
  48194. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48195. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48196. protected _updateModel(): void;
  48197. }
  48198. }
  48199. declare module BABYLON {
  48200. /**
  48201. * Class containing static functions to help procedurally build meshes
  48202. */
  48203. export class SphereBuilder {
  48204. /**
  48205. * Creates a sphere mesh
  48206. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48207. * * 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`)
  48208. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48209. * * 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
  48210. * * 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)
  48211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48212. * * 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
  48213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48214. * @param name defines the name of the mesh
  48215. * @param options defines the options used to create the mesh
  48216. * @param scene defines the hosting scene
  48217. * @returns the sphere mesh
  48218. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48219. */
  48220. static CreateSphere(name: string, options: {
  48221. segments?: number;
  48222. diameter?: number;
  48223. diameterX?: number;
  48224. diameterY?: number;
  48225. diameterZ?: number;
  48226. arc?: number;
  48227. slice?: number;
  48228. sideOrientation?: number;
  48229. frontUVs?: Vector4;
  48230. backUVs?: Vector4;
  48231. updatable?: boolean;
  48232. }, scene?: Nullable<Scene>): Mesh;
  48233. }
  48234. }
  48235. declare module BABYLON {
  48236. /**
  48237. * A profiled motion controller has its profile loaded from an online repository.
  48238. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48239. */
  48240. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48241. private _repositoryUrl;
  48242. private _buttonMeshMapping;
  48243. private _touchDots;
  48244. /**
  48245. * The profile ID of this controller. Will be populated when the controller initializes.
  48246. */
  48247. profileId: string;
  48248. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48249. dispose(): void;
  48250. protected _getFilenameAndPath(): {
  48251. filename: string;
  48252. path: string;
  48253. };
  48254. protected _getModelLoadingConstraints(): boolean;
  48255. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48256. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48257. protected _updateModel(_xrFrame: XRFrame): void;
  48258. }
  48259. }
  48260. declare module BABYLON {
  48261. /**
  48262. * A construction function type to create a new controller based on an xrInput object
  48263. */
  48264. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48265. /**
  48266. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48267. *
  48268. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48269. * it should be replaced with auto-loaded controllers.
  48270. *
  48271. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48272. */
  48273. export class WebXRMotionControllerManager {
  48274. private static _AvailableControllers;
  48275. private static _Fallbacks;
  48276. private static _ProfileLoadingPromises;
  48277. private static _ProfilesList;
  48278. /**
  48279. * The base URL of the online controller repository. Can be changed at any time.
  48280. */
  48281. static BaseRepositoryUrl: string;
  48282. /**
  48283. * Which repository gets priority - local or online
  48284. */
  48285. static PrioritizeOnlineRepository: boolean;
  48286. /**
  48287. * Use the online repository, or use only locally-defined controllers
  48288. */
  48289. static UseOnlineRepository: boolean;
  48290. /**
  48291. * Clear the cache used for profile loading and reload when requested again
  48292. */
  48293. static ClearProfilesCache(): void;
  48294. /**
  48295. * Register the default fallbacks.
  48296. * This function is called automatically when this file is imported.
  48297. */
  48298. static DefaultFallbacks(): void;
  48299. /**
  48300. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48301. * @param profileId the profile to which a fallback needs to be found
  48302. * @return an array with corresponding fallback profiles
  48303. */
  48304. static FindFallbackWithProfileId(profileId: string): string[];
  48305. /**
  48306. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48307. * The order of search:
  48308. *
  48309. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48310. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48311. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48312. * 4) return the generic trigger controller if none were found
  48313. *
  48314. * @param xrInput the xrInput to which a new controller is initialized
  48315. * @param scene the scene to which the model will be added
  48316. * @param forceProfile force a certain profile for this controller
  48317. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48318. */
  48319. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48320. /**
  48321. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48322. *
  48323. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48324. *
  48325. * @param type the profile type to register
  48326. * @param constructFunction the function to be called when loading this profile
  48327. */
  48328. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48329. /**
  48330. * Register a fallback to a specific profile.
  48331. * @param profileId the profileId that will receive the fallbacks
  48332. * @param fallbacks A list of fallback profiles
  48333. */
  48334. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48335. /**
  48336. * Will update the list of profiles available in the repository
  48337. * @return a promise that resolves to a map of profiles available online
  48338. */
  48339. static UpdateProfilesList(): Promise<{
  48340. [profile: string]: string;
  48341. }>;
  48342. private static _LoadProfileFromRepository;
  48343. private static _LoadProfilesFromAvailableControllers;
  48344. }
  48345. }
  48346. declare module BABYLON {
  48347. /**
  48348. * Configuration options for the WebXR controller creation
  48349. */
  48350. export interface IWebXRControllerOptions {
  48351. /**
  48352. * Should the controller mesh be animated when a user interacts with it
  48353. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48354. */
  48355. disableMotionControllerAnimation?: boolean;
  48356. /**
  48357. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48358. */
  48359. doNotLoadControllerMesh?: boolean;
  48360. /**
  48361. * Force a specific controller type for this controller.
  48362. * This can be used when creating your own profile or when testing different controllers
  48363. */
  48364. forceControllerProfile?: string;
  48365. /**
  48366. * Defines a rendering group ID for meshes that will be loaded.
  48367. * This is for the default controllers only.
  48368. */
  48369. renderingGroupId?: number;
  48370. }
  48371. /**
  48372. * Represents an XR controller
  48373. */
  48374. export class WebXRInputSource {
  48375. private _scene;
  48376. /** The underlying input source for the controller */
  48377. inputSource: XRInputSource;
  48378. private _options;
  48379. private _tmpVector;
  48380. private _uniqueId;
  48381. /**
  48382. * 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
  48383. */
  48384. grip?: AbstractMesh;
  48385. /**
  48386. * If available, this is the gamepad object related to this controller.
  48387. * Using this object it is possible to get click events and trackpad changes of the
  48388. * webxr controller that is currently being used.
  48389. */
  48390. motionController?: WebXRAbstractMotionController;
  48391. /**
  48392. * Event that fires when the controller is removed/disposed.
  48393. * The object provided as event data is this controller, after associated assets were disposed.
  48394. * uniqueId is still available.
  48395. */
  48396. onDisposeObservable: Observable<WebXRInputSource>;
  48397. /**
  48398. * Will be triggered when the mesh associated with the motion controller is done loading.
  48399. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48400. * A shortened version of controller -> motion controller -> on mesh loaded.
  48401. */
  48402. onMeshLoadedObservable: Observable<AbstractMesh>;
  48403. /**
  48404. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48405. */
  48406. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48407. /**
  48408. * Pointer which can be used to select objects or attach a visible laser to
  48409. */
  48410. pointer: AbstractMesh;
  48411. /**
  48412. * Creates the input source object
  48413. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48414. * @param _scene the scene which the controller should be associated to
  48415. * @param inputSource the underlying input source for the controller
  48416. * @param _options options for this controller creation
  48417. */
  48418. constructor(_scene: Scene,
  48419. /** The underlying input source for the controller */
  48420. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48421. /**
  48422. * Get this controllers unique id
  48423. */
  48424. get uniqueId(): string;
  48425. /**
  48426. * Disposes of the object
  48427. */
  48428. dispose(): void;
  48429. /**
  48430. * Gets a world space ray coming from the pointer or grip
  48431. * @param result the resulting ray
  48432. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48433. */
  48434. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48435. /**
  48436. * Updates the controller pose based on the given XRFrame
  48437. * @param xrFrame xr frame to update the pose with
  48438. * @param referenceSpace reference space to use
  48439. */
  48440. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48441. }
  48442. }
  48443. declare module BABYLON {
  48444. /**
  48445. * The schema for initialization options of the XR Input class
  48446. */
  48447. export interface IWebXRInputOptions {
  48448. /**
  48449. * If set to true no model will be automatically loaded
  48450. */
  48451. doNotLoadControllerMeshes?: boolean;
  48452. /**
  48453. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48454. * If not found, the xr input profile data will be used.
  48455. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48456. */
  48457. forceInputProfile?: string;
  48458. /**
  48459. * Do not send a request to the controller repository to load the profile.
  48460. *
  48461. * Instead, use the controllers available in babylon itself.
  48462. */
  48463. disableOnlineControllerRepository?: boolean;
  48464. /**
  48465. * A custom URL for the controllers repository
  48466. */
  48467. customControllersRepositoryURL?: string;
  48468. /**
  48469. * Should the controller model's components not move according to the user input
  48470. */
  48471. disableControllerAnimation?: boolean;
  48472. /**
  48473. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48474. */
  48475. controllerOptions?: IWebXRControllerOptions;
  48476. }
  48477. /**
  48478. * XR input used to track XR inputs such as controllers/rays
  48479. */
  48480. export class WebXRInput implements IDisposable {
  48481. /**
  48482. * the xr session manager for this session
  48483. */
  48484. xrSessionManager: WebXRSessionManager;
  48485. /**
  48486. * the WebXR camera for this session. Mainly used for teleportation
  48487. */
  48488. xrCamera: WebXRCamera;
  48489. private readonly options;
  48490. /**
  48491. * XR controllers being tracked
  48492. */
  48493. controllers: Array<WebXRInputSource>;
  48494. private _frameObserver;
  48495. private _sessionEndedObserver;
  48496. private _sessionInitObserver;
  48497. /**
  48498. * Event when a controller has been connected/added
  48499. */
  48500. onControllerAddedObservable: Observable<WebXRInputSource>;
  48501. /**
  48502. * Event when a controller has been removed/disconnected
  48503. */
  48504. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48505. /**
  48506. * Initializes the WebXRInput
  48507. * @param xrSessionManager the xr session manager for this session
  48508. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48509. * @param options = initialization options for this xr input
  48510. */
  48511. constructor(
  48512. /**
  48513. * the xr session manager for this session
  48514. */
  48515. xrSessionManager: WebXRSessionManager,
  48516. /**
  48517. * the WebXR camera for this session. Mainly used for teleportation
  48518. */
  48519. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48520. private _onInputSourcesChange;
  48521. private _addAndRemoveControllers;
  48522. /**
  48523. * Disposes of the object
  48524. */
  48525. dispose(): void;
  48526. }
  48527. }
  48528. declare module BABYLON {
  48529. /**
  48530. * This is the base class for all WebXR features.
  48531. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48532. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48533. */
  48534. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48535. protected _xrSessionManager: WebXRSessionManager;
  48536. private _attached;
  48537. private _removeOnDetach;
  48538. /**
  48539. * Should auto-attach be disabled?
  48540. */
  48541. disableAutoAttach: boolean;
  48542. /**
  48543. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48544. */
  48545. xrNativeFeatureName: string;
  48546. /**
  48547. * Construct a new (abstract) WebXR feature
  48548. * @param _xrSessionManager the xr session manager for this feature
  48549. */
  48550. constructor(_xrSessionManager: WebXRSessionManager);
  48551. /**
  48552. * Is this feature attached
  48553. */
  48554. get attached(): boolean;
  48555. /**
  48556. * attach this feature
  48557. *
  48558. * @param force should attachment be forced (even when already attached)
  48559. * @returns true if successful, false is failed or already attached
  48560. */
  48561. attach(force?: boolean): boolean;
  48562. /**
  48563. * detach this feature.
  48564. *
  48565. * @returns true if successful, false if failed or already detached
  48566. */
  48567. detach(): boolean;
  48568. /**
  48569. * Dispose this feature and all of the resources attached
  48570. */
  48571. dispose(): void;
  48572. /**
  48573. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48574. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48575. *
  48576. * @returns whether or not the feature is compatible in this environment
  48577. */
  48578. isCompatible(): boolean;
  48579. /**
  48580. * This is used to register callbacks that will automatically be removed when detach is called.
  48581. * @param observable the observable to which the observer will be attached
  48582. * @param callback the callback to register
  48583. */
  48584. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48585. /**
  48586. * Code in this function will be executed on each xrFrame received from the browser.
  48587. * This function will not execute after the feature is detached.
  48588. * @param _xrFrame the current frame
  48589. */
  48590. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48591. }
  48592. }
  48593. declare module BABYLON {
  48594. /**
  48595. * Renders a layer on top of an existing scene
  48596. */
  48597. export class UtilityLayerRenderer implements IDisposable {
  48598. /** the original scene that will be rendered on top of */
  48599. originalScene: Scene;
  48600. private _pointerCaptures;
  48601. private _lastPointerEvents;
  48602. private static _DefaultUtilityLayer;
  48603. private static _DefaultKeepDepthUtilityLayer;
  48604. private _sharedGizmoLight;
  48605. private _renderCamera;
  48606. /**
  48607. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48608. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48609. * @returns the camera that is used when rendering the utility layer
  48610. */
  48611. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48612. /**
  48613. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48614. * @param cam the camera that should be used when rendering the utility layer
  48615. */
  48616. setRenderCamera(cam: Nullable<Camera>): void;
  48617. /**
  48618. * @hidden
  48619. * Light which used by gizmos to get light shading
  48620. */
  48621. _getSharedGizmoLight(): HemisphericLight;
  48622. /**
  48623. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48624. */
  48625. pickUtilitySceneFirst: boolean;
  48626. /**
  48627. * 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)
  48628. */
  48629. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48630. /**
  48631. * 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)
  48632. */
  48633. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48634. /**
  48635. * The scene that is rendered on top of the original scene
  48636. */
  48637. utilityLayerScene: Scene;
  48638. /**
  48639. * If the utility layer should automatically be rendered on top of existing scene
  48640. */
  48641. shouldRender: boolean;
  48642. /**
  48643. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48644. */
  48645. onlyCheckPointerDownEvents: boolean;
  48646. /**
  48647. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48648. */
  48649. processAllEvents: boolean;
  48650. /**
  48651. * Observable raised when the pointer move from the utility layer scene to the main scene
  48652. */
  48653. onPointerOutObservable: Observable<number>;
  48654. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48655. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48656. private _afterRenderObserver;
  48657. private _sceneDisposeObserver;
  48658. private _originalPointerObserver;
  48659. /**
  48660. * Instantiates a UtilityLayerRenderer
  48661. * @param originalScene the original scene that will be rendered on top of
  48662. * @param handleEvents boolean indicating if the utility layer should handle events
  48663. */
  48664. constructor(
  48665. /** the original scene that will be rendered on top of */
  48666. originalScene: Scene, handleEvents?: boolean);
  48667. private _notifyObservers;
  48668. /**
  48669. * Renders the utility layers scene on top of the original scene
  48670. */
  48671. render(): void;
  48672. /**
  48673. * Disposes of the renderer
  48674. */
  48675. dispose(): void;
  48676. private _updateCamera;
  48677. }
  48678. }
  48679. declare module BABYLON {
  48680. /**
  48681. * Options interface for the pointer selection module
  48682. */
  48683. export interface IWebXRControllerPointerSelectionOptions {
  48684. /**
  48685. * if provided, this scene will be used to render meshes.
  48686. */
  48687. customUtilityLayerScene?: Scene;
  48688. /**
  48689. * 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)
  48690. * If not disabled, the last picked point will be used to execute a pointer up event
  48691. * If disabled, pointer up event will be triggered right after the pointer down event.
  48692. * Used in screen and gaze target ray mode only
  48693. */
  48694. disablePointerUpOnTouchOut: boolean;
  48695. /**
  48696. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48697. */
  48698. forceGazeMode: boolean;
  48699. /**
  48700. * 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
  48701. * to start a new countdown to the pointer down event.
  48702. * Defaults to 1.
  48703. */
  48704. gazeModePointerMovedFactor?: number;
  48705. /**
  48706. * Different button type to use instead of the main component
  48707. */
  48708. overrideButtonId?: string;
  48709. /**
  48710. * use this rendering group id for the meshes (optional)
  48711. */
  48712. renderingGroupId?: number;
  48713. /**
  48714. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48715. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48716. * 3000 means 3 seconds between pointing at something and selecting it
  48717. */
  48718. timeToSelect?: number;
  48719. /**
  48720. * Should meshes created here be added to a utility layer or the main scene
  48721. */
  48722. useUtilityLayer?: boolean;
  48723. /**
  48724. * Optional WebXR camera to be used for gaze selection
  48725. */
  48726. gazeCamera?: WebXRCamera;
  48727. /**
  48728. * the xr input to use with this pointer selection
  48729. */
  48730. xrInput: WebXRInput;
  48731. }
  48732. /**
  48733. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48734. */
  48735. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48736. private readonly _options;
  48737. private static _idCounter;
  48738. private _attachController;
  48739. private _controllers;
  48740. private _scene;
  48741. private _tmpVectorForPickCompare;
  48742. /**
  48743. * The module's name
  48744. */
  48745. static readonly Name: string;
  48746. /**
  48747. * The (Babylon) version of this module.
  48748. * This is an integer representing the implementation version.
  48749. * This number does not correspond to the WebXR specs version
  48750. */
  48751. static readonly Version: number;
  48752. /**
  48753. * Disable lighting on the laser pointer (so it will always be visible)
  48754. */
  48755. disablePointerLighting: boolean;
  48756. /**
  48757. * Disable lighting on the selection mesh (so it will always be visible)
  48758. */
  48759. disableSelectionMeshLighting: boolean;
  48760. /**
  48761. * Should the laser pointer be displayed
  48762. */
  48763. displayLaserPointer: boolean;
  48764. /**
  48765. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48766. */
  48767. displaySelectionMesh: boolean;
  48768. /**
  48769. * This color will be set to the laser pointer when selection is triggered
  48770. */
  48771. laserPointerPickedColor: Color3;
  48772. /**
  48773. * Default color of the laser pointer
  48774. */
  48775. laserPointerDefaultColor: Color3;
  48776. /**
  48777. * default color of the selection ring
  48778. */
  48779. selectionMeshDefaultColor: Color3;
  48780. /**
  48781. * This color will be applied to the selection ring when selection is triggered
  48782. */
  48783. selectionMeshPickedColor: Color3;
  48784. /**
  48785. * Optional filter to be used for ray selection. This predicate shares behavior with
  48786. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48787. */
  48788. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48789. /**
  48790. * constructs a new background remover module
  48791. * @param _xrSessionManager the session manager for this module
  48792. * @param _options read-only options to be used in this module
  48793. */
  48794. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48795. /**
  48796. * attach this feature
  48797. * Will usually be called by the features manager
  48798. *
  48799. * @returns true if successful.
  48800. */
  48801. attach(): boolean;
  48802. /**
  48803. * detach this feature.
  48804. * Will usually be called by the features manager
  48805. *
  48806. * @returns true if successful.
  48807. */
  48808. detach(): boolean;
  48809. /**
  48810. * Will get the mesh under a specific pointer.
  48811. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48812. * @param controllerId the controllerId to check
  48813. * @returns The mesh under pointer or null if no mesh is under the pointer
  48814. */
  48815. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48816. /**
  48817. * Get the xr controller that correlates to the pointer id in the pointer event
  48818. *
  48819. * @param id the pointer id to search for
  48820. * @returns the controller that correlates to this id or null if not found
  48821. */
  48822. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48823. protected _onXRFrame(_xrFrame: XRFrame): void;
  48824. private _attachGazeMode;
  48825. private _attachScreenRayMode;
  48826. private _attachTrackedPointerRayMode;
  48827. private _convertNormalToDirectionOfRay;
  48828. private _detachController;
  48829. private _generateNewMeshPair;
  48830. private _pickingMoved;
  48831. private _updatePointerDistance;
  48832. /** @hidden */
  48833. get lasterPointerDefaultColor(): Color3;
  48834. }
  48835. }
  48836. declare module BABYLON {
  48837. /**
  48838. * Button which can be used to enter a different mode of XR
  48839. */
  48840. export class WebXREnterExitUIButton {
  48841. /** button element */
  48842. element: HTMLElement;
  48843. /** XR initialization options for the button */
  48844. sessionMode: XRSessionMode;
  48845. /** Reference space type */
  48846. referenceSpaceType: XRReferenceSpaceType;
  48847. /**
  48848. * Creates a WebXREnterExitUIButton
  48849. * @param element button element
  48850. * @param sessionMode XR initialization session mode
  48851. * @param referenceSpaceType the type of reference space to be used
  48852. */
  48853. constructor(
  48854. /** button element */
  48855. element: HTMLElement,
  48856. /** XR initialization options for the button */
  48857. sessionMode: XRSessionMode,
  48858. /** Reference space type */
  48859. referenceSpaceType: XRReferenceSpaceType);
  48860. /**
  48861. * Extendable function which can be used to update the button's visuals when the state changes
  48862. * @param activeButton the current active button in the UI
  48863. */
  48864. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48865. }
  48866. /**
  48867. * Options to create the webXR UI
  48868. */
  48869. export class WebXREnterExitUIOptions {
  48870. /**
  48871. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48872. */
  48873. customButtons?: Array<WebXREnterExitUIButton>;
  48874. /**
  48875. * A reference space type to use when creating the default button.
  48876. * Default is local-floor
  48877. */
  48878. referenceSpaceType?: XRReferenceSpaceType;
  48879. /**
  48880. * Context to enter xr with
  48881. */
  48882. renderTarget?: Nullable<WebXRRenderTarget>;
  48883. /**
  48884. * A session mode to use when creating the default button.
  48885. * Default is immersive-vr
  48886. */
  48887. sessionMode?: XRSessionMode;
  48888. /**
  48889. * A list of optional features to init the session with
  48890. */
  48891. optionalFeatures?: string[];
  48892. /**
  48893. * A list of optional features to init the session with
  48894. */
  48895. requiredFeatures?: string[];
  48896. }
  48897. /**
  48898. * UI to allow the user to enter/exit XR mode
  48899. */
  48900. export class WebXREnterExitUI implements IDisposable {
  48901. private scene;
  48902. /** version of the options passed to this UI */
  48903. options: WebXREnterExitUIOptions;
  48904. private _activeButton;
  48905. private _buttons;
  48906. private _overlay;
  48907. /**
  48908. * Fired every time the active button is changed.
  48909. *
  48910. * When xr is entered via a button that launches xr that button will be the callback parameter
  48911. *
  48912. * When exiting xr the callback parameter will be null)
  48913. */
  48914. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48915. /**
  48916. *
  48917. * @param scene babylon scene object to use
  48918. * @param options (read-only) version of the options passed to this UI
  48919. */
  48920. private constructor();
  48921. /**
  48922. * Creates UI to allow the user to enter/exit XR mode
  48923. * @param scene the scene to add the ui to
  48924. * @param helper the xr experience helper to enter/exit xr with
  48925. * @param options options to configure the UI
  48926. * @returns the created ui
  48927. */
  48928. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48929. /**
  48930. * Disposes of the XR UI component
  48931. */
  48932. dispose(): void;
  48933. private _updateButtons;
  48934. }
  48935. }
  48936. declare module BABYLON {
  48937. /**
  48938. * Class containing static functions to help procedurally build meshes
  48939. */
  48940. export class LinesBuilder {
  48941. /**
  48942. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48943. * * 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
  48944. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48945. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48946. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48947. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48948. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48949. * * 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
  48950. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48953. * @param name defines the name of the new line system
  48954. * @param options defines the options used to create the line system
  48955. * @param scene defines the hosting scene
  48956. * @returns a new line system mesh
  48957. */
  48958. static CreateLineSystem(name: string, options: {
  48959. lines: Vector3[][];
  48960. updatable?: boolean;
  48961. instance?: Nullable<LinesMesh>;
  48962. colors?: Nullable<Color4[][]>;
  48963. useVertexAlpha?: boolean;
  48964. }, scene: Nullable<Scene>): LinesMesh;
  48965. /**
  48966. * Creates a line mesh
  48967. * 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
  48968. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48969. * * The parameter `points` is an array successive Vector3
  48970. * * 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
  48971. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48972. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48973. * * When updating an instance, remember that only point positions can change, not the number of points
  48974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48976. * @param name defines the name of the new line system
  48977. * @param options defines the options used to create the line system
  48978. * @param scene defines the hosting scene
  48979. * @returns a new line mesh
  48980. */
  48981. static CreateLines(name: string, options: {
  48982. points: Vector3[];
  48983. updatable?: boolean;
  48984. instance?: Nullable<LinesMesh>;
  48985. colors?: Color4[];
  48986. useVertexAlpha?: boolean;
  48987. }, scene?: Nullable<Scene>): LinesMesh;
  48988. /**
  48989. * Creates a dashed line mesh
  48990. * * 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
  48991. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48992. * * The parameter `points` is an array successive Vector3
  48993. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48994. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48995. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48996. * * 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
  48997. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48998. * * When updating an instance, remember that only point positions can change, not the number of points
  48999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49000. * @param name defines the name of the mesh
  49001. * @param options defines the options used to create the mesh
  49002. * @param scene defines the hosting scene
  49003. * @returns the dashed line mesh
  49004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49005. */
  49006. static CreateDashedLines(name: string, options: {
  49007. points: Vector3[];
  49008. dashSize?: number;
  49009. gapSize?: number;
  49010. dashNb?: number;
  49011. updatable?: boolean;
  49012. instance?: LinesMesh;
  49013. useVertexAlpha?: boolean;
  49014. }, scene?: Nullable<Scene>): LinesMesh;
  49015. }
  49016. }
  49017. declare module BABYLON {
  49018. /**
  49019. * Construction options for a timer
  49020. */
  49021. export interface ITimerOptions<T> {
  49022. /**
  49023. * Time-to-end
  49024. */
  49025. timeout: number;
  49026. /**
  49027. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49028. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49029. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49030. */
  49031. contextObservable: Observable<T>;
  49032. /**
  49033. * Optional parameters when adding an observer to the observable
  49034. */
  49035. observableParameters?: {
  49036. mask?: number;
  49037. insertFirst?: boolean;
  49038. scope?: any;
  49039. };
  49040. /**
  49041. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49042. */
  49043. breakCondition?: (data?: ITimerData<T>) => boolean;
  49044. /**
  49045. * Will be triggered when the time condition has met
  49046. */
  49047. onEnded?: (data: ITimerData<any>) => void;
  49048. /**
  49049. * Will be triggered when the break condition has met (prematurely ended)
  49050. */
  49051. onAborted?: (data: ITimerData<any>) => void;
  49052. /**
  49053. * Optional function to execute on each tick (or count)
  49054. */
  49055. onTick?: (data: ITimerData<any>) => void;
  49056. }
  49057. /**
  49058. * An interface defining the data sent by the timer
  49059. */
  49060. export interface ITimerData<T> {
  49061. /**
  49062. * When did it start
  49063. */
  49064. startTime: number;
  49065. /**
  49066. * Time now
  49067. */
  49068. currentTime: number;
  49069. /**
  49070. * Time passed since started
  49071. */
  49072. deltaTime: number;
  49073. /**
  49074. * How much is completed, in [0.0...1.0].
  49075. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49076. */
  49077. completeRate: number;
  49078. /**
  49079. * What the registered observable sent in the last count
  49080. */
  49081. payload: T;
  49082. }
  49083. /**
  49084. * The current state of the timer
  49085. */
  49086. export enum TimerState {
  49087. /**
  49088. * Timer initialized, not yet started
  49089. */
  49090. INIT = 0,
  49091. /**
  49092. * Timer started and counting
  49093. */
  49094. STARTED = 1,
  49095. /**
  49096. * Timer ended (whether aborted or time reached)
  49097. */
  49098. ENDED = 2
  49099. }
  49100. /**
  49101. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49102. *
  49103. * @param options options with which to initialize this timer
  49104. */
  49105. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49106. /**
  49107. * An advanced implementation of a timer class
  49108. */
  49109. export class AdvancedTimer<T = any> implements IDisposable {
  49110. /**
  49111. * Will notify each time the timer calculates the remaining time
  49112. */
  49113. onEachCountObservable: Observable<ITimerData<T>>;
  49114. /**
  49115. * Will trigger when the timer was aborted due to the break condition
  49116. */
  49117. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49118. /**
  49119. * Will trigger when the timer ended successfully
  49120. */
  49121. onTimerEndedObservable: Observable<ITimerData<T>>;
  49122. /**
  49123. * Will trigger when the timer state has changed
  49124. */
  49125. onStateChangedObservable: Observable<TimerState>;
  49126. private _observer;
  49127. private _contextObservable;
  49128. private _observableParameters;
  49129. private _startTime;
  49130. private _timer;
  49131. private _state;
  49132. private _breakCondition;
  49133. private _timeToEnd;
  49134. private _breakOnNextTick;
  49135. /**
  49136. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49137. * @param options construction options for this advanced timer
  49138. */
  49139. constructor(options: ITimerOptions<T>);
  49140. /**
  49141. * set a breaking condition for this timer. Default is to never break during count
  49142. * @param predicate the new break condition. Returns true to break, false otherwise
  49143. */
  49144. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49145. /**
  49146. * Reset ALL associated observables in this advanced timer
  49147. */
  49148. clearObservables(): void;
  49149. /**
  49150. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49151. *
  49152. * @param timeToEnd how much time to measure until timer ended
  49153. */
  49154. start(timeToEnd?: number): void;
  49155. /**
  49156. * Will force a stop on the next tick.
  49157. */
  49158. stop(): void;
  49159. /**
  49160. * Dispose this timer, clearing all resources
  49161. */
  49162. dispose(): void;
  49163. private _setState;
  49164. private _tick;
  49165. private _stop;
  49166. }
  49167. }
  49168. declare module BABYLON {
  49169. /**
  49170. * The options container for the teleportation module
  49171. */
  49172. export interface IWebXRTeleportationOptions {
  49173. /**
  49174. * if provided, this scene will be used to render meshes.
  49175. */
  49176. customUtilityLayerScene?: Scene;
  49177. /**
  49178. * Values to configure the default target mesh
  49179. */
  49180. defaultTargetMeshOptions?: {
  49181. /**
  49182. * Fill color of the teleportation area
  49183. */
  49184. teleportationFillColor?: string;
  49185. /**
  49186. * Border color for the teleportation area
  49187. */
  49188. teleportationBorderColor?: string;
  49189. /**
  49190. * Disable the mesh's animation sequence
  49191. */
  49192. disableAnimation?: boolean;
  49193. /**
  49194. * Disable lighting on the material or the ring and arrow
  49195. */
  49196. disableLighting?: boolean;
  49197. /**
  49198. * Override the default material of the torus and arrow
  49199. */
  49200. torusArrowMaterial?: Material;
  49201. };
  49202. /**
  49203. * A list of meshes to use as floor meshes.
  49204. * Meshes can be added and removed after initializing the feature using the
  49205. * addFloorMesh and removeFloorMesh functions
  49206. * If empty, rotation will still work
  49207. */
  49208. floorMeshes?: AbstractMesh[];
  49209. /**
  49210. * use this rendering group id for the meshes (optional)
  49211. */
  49212. renderingGroupId?: number;
  49213. /**
  49214. * Should teleportation move only to snap points
  49215. */
  49216. snapPointsOnly?: boolean;
  49217. /**
  49218. * An array of points to which the teleportation will snap to.
  49219. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49220. */
  49221. snapPositions?: Vector3[];
  49222. /**
  49223. * How close should the teleportation ray be in order to snap to position.
  49224. * Default to 0.8 units (meters)
  49225. */
  49226. snapToPositionRadius?: number;
  49227. /**
  49228. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49229. * If you want to support rotation, make sure your mesh has a direction indicator.
  49230. *
  49231. * When left untouched, the default mesh will be initialized.
  49232. */
  49233. teleportationTargetMesh?: AbstractMesh;
  49234. /**
  49235. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49236. */
  49237. timeToTeleport?: number;
  49238. /**
  49239. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49240. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49241. */
  49242. useMainComponentOnly?: boolean;
  49243. /**
  49244. * Should meshes created here be added to a utility layer or the main scene
  49245. */
  49246. useUtilityLayer?: boolean;
  49247. /**
  49248. * Babylon XR Input class for controller
  49249. */
  49250. xrInput: WebXRInput;
  49251. }
  49252. /**
  49253. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49254. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49255. * the input of the attached controllers.
  49256. */
  49257. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49258. private _options;
  49259. private _controllers;
  49260. private _currentTeleportationControllerId;
  49261. private _floorMeshes;
  49262. private _quadraticBezierCurve;
  49263. private _selectionFeature;
  49264. private _snapToPositions;
  49265. private _snappedToPoint;
  49266. private _teleportationRingMaterial?;
  49267. private _tmpRay;
  49268. private _tmpVector;
  49269. /**
  49270. * The module's name
  49271. */
  49272. static readonly Name: string;
  49273. /**
  49274. * The (Babylon) version of this module.
  49275. * This is an integer representing the implementation version.
  49276. * This number does not correspond to the webxr specs version
  49277. */
  49278. static readonly Version: number;
  49279. /**
  49280. * Is movement backwards enabled
  49281. */
  49282. backwardsMovementEnabled: boolean;
  49283. /**
  49284. * Distance to travel when moving backwards
  49285. */
  49286. backwardsTeleportationDistance: number;
  49287. /**
  49288. * The distance from the user to the inspection point in the direction of the controller
  49289. * A higher number will allow the user to move further
  49290. * defaults to 5 (meters, in xr units)
  49291. */
  49292. parabolicCheckRadius: number;
  49293. /**
  49294. * Should the module support parabolic ray on top of direct ray
  49295. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49296. * Very helpful when moving between floors / different heights
  49297. */
  49298. parabolicRayEnabled: boolean;
  49299. /**
  49300. * How much rotation should be applied when rotating right and left
  49301. */
  49302. rotationAngle: number;
  49303. /**
  49304. * Is rotation enabled when moving forward?
  49305. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49306. */
  49307. rotationEnabled: boolean;
  49308. /**
  49309. * constructs a new anchor system
  49310. * @param _xrSessionManager an instance of WebXRSessionManager
  49311. * @param _options configuration object for this feature
  49312. */
  49313. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49314. /**
  49315. * Get the snapPointsOnly flag
  49316. */
  49317. get snapPointsOnly(): boolean;
  49318. /**
  49319. * Sets the snapPointsOnly flag
  49320. * @param snapToPoints should teleportation be exclusively to snap points
  49321. */
  49322. set snapPointsOnly(snapToPoints: boolean);
  49323. /**
  49324. * Add a new mesh to the floor meshes array
  49325. * @param mesh the mesh to use as floor mesh
  49326. */
  49327. addFloorMesh(mesh: AbstractMesh): void;
  49328. /**
  49329. * Add a new snap-to point to fix teleportation to this position
  49330. * @param newSnapPoint The new Snap-To point
  49331. */
  49332. addSnapPoint(newSnapPoint: Vector3): void;
  49333. attach(): boolean;
  49334. detach(): boolean;
  49335. dispose(): void;
  49336. /**
  49337. * Remove a mesh from the floor meshes array
  49338. * @param mesh the mesh to remove
  49339. */
  49340. removeFloorMesh(mesh: AbstractMesh): void;
  49341. /**
  49342. * Remove a mesh from the floor meshes array using its name
  49343. * @param name the mesh name to remove
  49344. */
  49345. removeFloorMeshByName(name: string): void;
  49346. /**
  49347. * 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
  49348. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49349. * @returns was the point found and removed or not
  49350. */
  49351. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49352. /**
  49353. * This function sets a selection feature that will be disabled when
  49354. * the forward ray is shown and will be reattached when hidden.
  49355. * This is used to remove the selection rays when moving.
  49356. * @param selectionFeature the feature to disable when forward movement is enabled
  49357. */
  49358. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49359. protected _onXRFrame(_xrFrame: XRFrame): void;
  49360. private _attachController;
  49361. private _createDefaultTargetMesh;
  49362. private _detachController;
  49363. private _findClosestSnapPointWithRadius;
  49364. private _setTargetMeshPosition;
  49365. private _setTargetMeshVisibility;
  49366. private _showParabolicPath;
  49367. private _teleportForward;
  49368. }
  49369. }
  49370. declare module BABYLON {
  49371. /**
  49372. * Options for the default xr helper
  49373. */
  49374. export class WebXRDefaultExperienceOptions {
  49375. /**
  49376. * Enable or disable default UI to enter XR
  49377. */
  49378. disableDefaultUI?: boolean;
  49379. /**
  49380. * Should teleportation not initialize. defaults to false.
  49381. */
  49382. disableTeleportation?: boolean;
  49383. /**
  49384. * Floor meshes that will be used for teleport
  49385. */
  49386. floorMeshes?: Array<AbstractMesh>;
  49387. /**
  49388. * If set to true, the first frame will not be used to reset position
  49389. * The first frame is mainly used when copying transformation from the old camera
  49390. * Mainly used in AR
  49391. */
  49392. ignoreNativeCameraTransformation?: boolean;
  49393. /**
  49394. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49395. */
  49396. inputOptions?: IWebXRInputOptions;
  49397. /**
  49398. * optional configuration for the output canvas
  49399. */
  49400. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49401. /**
  49402. * optional UI options. This can be used among other to change session mode and reference space type
  49403. */
  49404. uiOptions?: WebXREnterExitUIOptions;
  49405. /**
  49406. * When loading teleportation and pointer select, use stable versions instead of latest.
  49407. */
  49408. useStablePlugins?: boolean;
  49409. /**
  49410. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49411. */
  49412. renderingGroupId?: number;
  49413. /**
  49414. * A list of optional features to init the session with
  49415. * If set to true, all features we support will be added
  49416. */
  49417. optionalFeatures?: boolean | string[];
  49418. }
  49419. /**
  49420. * Default experience which provides a similar setup to the previous webVRExperience
  49421. */
  49422. export class WebXRDefaultExperience {
  49423. /**
  49424. * Base experience
  49425. */
  49426. baseExperience: WebXRExperienceHelper;
  49427. /**
  49428. * Enables ui for entering/exiting xr
  49429. */
  49430. enterExitUI: WebXREnterExitUI;
  49431. /**
  49432. * Input experience extension
  49433. */
  49434. input: WebXRInput;
  49435. /**
  49436. * Enables laser pointer and selection
  49437. */
  49438. pointerSelection: WebXRControllerPointerSelection;
  49439. /**
  49440. * Default target xr should render to
  49441. */
  49442. renderTarget: WebXRRenderTarget;
  49443. /**
  49444. * Enables teleportation
  49445. */
  49446. teleportation: WebXRMotionControllerTeleportation;
  49447. private constructor();
  49448. /**
  49449. * Creates the default xr experience
  49450. * @param scene scene
  49451. * @param options options for basic configuration
  49452. * @returns resulting WebXRDefaultExperience
  49453. */
  49454. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49455. /**
  49456. * DIsposes of the experience helper
  49457. */
  49458. dispose(): void;
  49459. }
  49460. }
  49461. declare module BABYLON {
  49462. /**
  49463. * Options to modify the vr teleportation behavior.
  49464. */
  49465. export interface VRTeleportationOptions {
  49466. /**
  49467. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49468. */
  49469. floorMeshName?: string;
  49470. /**
  49471. * A list of meshes to be used as the teleportation floor. (default: empty)
  49472. */
  49473. floorMeshes?: Mesh[];
  49474. /**
  49475. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49476. */
  49477. teleportationMode?: number;
  49478. /**
  49479. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49480. */
  49481. teleportationTime?: number;
  49482. /**
  49483. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49484. */
  49485. teleportationSpeed?: number;
  49486. /**
  49487. * The easing function used in the animation or null for Linear. (default CircleEase)
  49488. */
  49489. easingFunction?: EasingFunction;
  49490. }
  49491. /**
  49492. * Options to modify the vr experience helper's behavior.
  49493. */
  49494. export interface VRExperienceHelperOptions extends WebVROptions {
  49495. /**
  49496. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49497. */
  49498. createDeviceOrientationCamera?: boolean;
  49499. /**
  49500. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49501. */
  49502. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49503. /**
  49504. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49505. */
  49506. laserToggle?: boolean;
  49507. /**
  49508. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49509. */
  49510. floorMeshes?: Mesh[];
  49511. /**
  49512. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49513. */
  49514. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49515. /**
  49516. * Defines if WebXR should be used instead of WebVR (if available)
  49517. */
  49518. useXR?: boolean;
  49519. }
  49520. /**
  49521. * Event containing information after VR has been entered
  49522. */
  49523. export class OnAfterEnteringVRObservableEvent {
  49524. /**
  49525. * If entering vr was successful
  49526. */
  49527. success: boolean;
  49528. }
  49529. /**
  49530. * Helps to quickly add VR support to an existing scene.
  49531. * See https://doc.babylonjs.com/how_to/webvr_helper
  49532. */
  49533. export class VRExperienceHelper {
  49534. /** Options to modify the vr experience helper's behavior. */
  49535. webVROptions: VRExperienceHelperOptions;
  49536. private _scene;
  49537. private _position;
  49538. private _btnVR;
  49539. private _btnVRDisplayed;
  49540. private _webVRsupported;
  49541. private _webVRready;
  49542. private _webVRrequesting;
  49543. private _webVRpresenting;
  49544. private _hasEnteredVR;
  49545. private _fullscreenVRpresenting;
  49546. private _inputElement;
  49547. private _webVRCamera;
  49548. private _vrDeviceOrientationCamera;
  49549. private _deviceOrientationCamera;
  49550. private _existingCamera;
  49551. private _onKeyDown;
  49552. private _onVrDisplayPresentChange;
  49553. private _onVRDisplayChanged;
  49554. private _onVRRequestPresentStart;
  49555. private _onVRRequestPresentComplete;
  49556. /**
  49557. * 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)
  49558. */
  49559. enableGazeEvenWhenNoPointerLock: boolean;
  49560. /**
  49561. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49562. */
  49563. exitVROnDoubleTap: boolean;
  49564. /**
  49565. * Observable raised right before entering VR.
  49566. */
  49567. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49568. /**
  49569. * Observable raised when entering VR has completed.
  49570. */
  49571. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49572. /**
  49573. * Observable raised when exiting VR.
  49574. */
  49575. onExitingVRObservable: Observable<VRExperienceHelper>;
  49576. /**
  49577. * Observable raised when controller mesh is loaded.
  49578. */
  49579. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49580. /** Return this.onEnteringVRObservable
  49581. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49582. */
  49583. get onEnteringVR(): Observable<VRExperienceHelper>;
  49584. /** Return this.onExitingVRObservable
  49585. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49586. */
  49587. get onExitingVR(): Observable<VRExperienceHelper>;
  49588. /** Return this.onControllerMeshLoadedObservable
  49589. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49590. */
  49591. get onControllerMeshLoaded(): Observable<WebVRController>;
  49592. private _rayLength;
  49593. private _useCustomVRButton;
  49594. private _teleportationRequested;
  49595. private _teleportActive;
  49596. private _floorMeshName;
  49597. private _floorMeshesCollection;
  49598. private _teleportationMode;
  49599. private _teleportationTime;
  49600. private _teleportationSpeed;
  49601. private _teleportationEasing;
  49602. private _rotationAllowed;
  49603. private _teleportBackwardsVector;
  49604. private _teleportationTarget;
  49605. private _isDefaultTeleportationTarget;
  49606. private _postProcessMove;
  49607. private _teleportationFillColor;
  49608. private _teleportationBorderColor;
  49609. private _rotationAngle;
  49610. private _haloCenter;
  49611. private _cameraGazer;
  49612. private _padSensibilityUp;
  49613. private _padSensibilityDown;
  49614. private _leftController;
  49615. private _rightController;
  49616. private _gazeColor;
  49617. private _laserColor;
  49618. private _pickedLaserColor;
  49619. private _pickedGazeColor;
  49620. /**
  49621. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49622. */
  49623. onNewMeshSelected: Observable<AbstractMesh>;
  49624. /**
  49625. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49626. * This observable will provide the mesh and the controller used to select the mesh
  49627. */
  49628. onMeshSelectedWithController: Observable<{
  49629. mesh: AbstractMesh;
  49630. controller: WebVRController;
  49631. }>;
  49632. /**
  49633. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49634. */
  49635. onNewMeshPicked: Observable<PickingInfo>;
  49636. private _circleEase;
  49637. /**
  49638. * Observable raised before camera teleportation
  49639. */
  49640. onBeforeCameraTeleport: Observable<Vector3>;
  49641. /**
  49642. * Observable raised after camera teleportation
  49643. */
  49644. onAfterCameraTeleport: Observable<Vector3>;
  49645. /**
  49646. * Observable raised when current selected mesh gets unselected
  49647. */
  49648. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49649. private _raySelectionPredicate;
  49650. /**
  49651. * To be optionaly changed by user to define custom ray selection
  49652. */
  49653. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49654. /**
  49655. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49656. */
  49657. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49658. /**
  49659. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49660. */
  49661. teleportationEnabled: boolean;
  49662. private _defaultHeight;
  49663. private _teleportationInitialized;
  49664. private _interactionsEnabled;
  49665. private _interactionsRequested;
  49666. private _displayGaze;
  49667. private _displayLaserPointer;
  49668. /**
  49669. * The mesh used to display where the user is going to teleport.
  49670. */
  49671. get teleportationTarget(): Mesh;
  49672. /**
  49673. * Sets the mesh to be used to display where the user is going to teleport.
  49674. */
  49675. set teleportationTarget(value: Mesh);
  49676. /**
  49677. * 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
  49678. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49679. * See https://doc.babylonjs.com/resources/baking_transformations
  49680. */
  49681. get gazeTrackerMesh(): Mesh;
  49682. set gazeTrackerMesh(value: Mesh);
  49683. /**
  49684. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49685. */
  49686. updateGazeTrackerScale: boolean;
  49687. /**
  49688. * If the gaze trackers color should be updated when selecting meshes
  49689. */
  49690. updateGazeTrackerColor: boolean;
  49691. /**
  49692. * If the controller laser color should be updated when selecting meshes
  49693. */
  49694. updateControllerLaserColor: boolean;
  49695. /**
  49696. * The gaze tracking mesh corresponding to the left controller
  49697. */
  49698. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49699. /**
  49700. * The gaze tracking mesh corresponding to the right controller
  49701. */
  49702. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49703. /**
  49704. * If the ray of the gaze should be displayed.
  49705. */
  49706. get displayGaze(): boolean;
  49707. /**
  49708. * Sets if the ray of the gaze should be displayed.
  49709. */
  49710. set displayGaze(value: boolean);
  49711. /**
  49712. * If the ray of the LaserPointer should be displayed.
  49713. */
  49714. get displayLaserPointer(): boolean;
  49715. /**
  49716. * Sets if the ray of the LaserPointer should be displayed.
  49717. */
  49718. set displayLaserPointer(value: boolean);
  49719. /**
  49720. * The deviceOrientationCamera used as the camera when not in VR.
  49721. */
  49722. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49723. /**
  49724. * Based on the current WebVR support, returns the current VR camera used.
  49725. */
  49726. get currentVRCamera(): Nullable<Camera>;
  49727. /**
  49728. * The webVRCamera which is used when in VR.
  49729. */
  49730. get webVRCamera(): WebVRFreeCamera;
  49731. /**
  49732. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49733. */
  49734. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49735. /**
  49736. * The html button that is used to trigger entering into VR.
  49737. */
  49738. get vrButton(): Nullable<HTMLButtonElement>;
  49739. private get _teleportationRequestInitiated();
  49740. /**
  49741. * Defines whether or not Pointer lock should be requested when switching to
  49742. * full screen.
  49743. */
  49744. requestPointerLockOnFullScreen: boolean;
  49745. /**
  49746. * If asking to force XR, this will be populated with the default xr experience
  49747. */
  49748. xr: WebXRDefaultExperience;
  49749. /**
  49750. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49751. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49752. */
  49753. xrTestDone: boolean;
  49754. /**
  49755. * Instantiates a VRExperienceHelper.
  49756. * Helps to quickly add VR support to an existing scene.
  49757. * @param scene The scene the VRExperienceHelper belongs to.
  49758. * @param webVROptions Options to modify the vr experience helper's behavior.
  49759. */
  49760. constructor(scene: Scene,
  49761. /** Options to modify the vr experience helper's behavior. */
  49762. webVROptions?: VRExperienceHelperOptions);
  49763. private completeVRInit;
  49764. private _onDefaultMeshLoaded;
  49765. private _onResize;
  49766. private _onFullscreenChange;
  49767. /**
  49768. * Gets a value indicating if we are currently in VR mode.
  49769. */
  49770. get isInVRMode(): boolean;
  49771. private onVrDisplayPresentChange;
  49772. private onVRDisplayChanged;
  49773. private moveButtonToBottomRight;
  49774. private displayVRButton;
  49775. private updateButtonVisibility;
  49776. private _cachedAngularSensibility;
  49777. /**
  49778. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49779. * Otherwise, will use the fullscreen API.
  49780. */
  49781. enterVR(): void;
  49782. /**
  49783. * Attempt to exit VR, or fullscreen.
  49784. */
  49785. exitVR(): void;
  49786. /**
  49787. * The position of the vr experience helper.
  49788. */
  49789. get position(): Vector3;
  49790. /**
  49791. * Sets the position of the vr experience helper.
  49792. */
  49793. set position(value: Vector3);
  49794. /**
  49795. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49796. */
  49797. enableInteractions(): void;
  49798. private get _noControllerIsActive();
  49799. private beforeRender;
  49800. private _isTeleportationFloor;
  49801. /**
  49802. * Adds a floor mesh to be used for teleportation.
  49803. * @param floorMesh the mesh to be used for teleportation.
  49804. */
  49805. addFloorMesh(floorMesh: Mesh): void;
  49806. /**
  49807. * Removes a floor mesh from being used for teleportation.
  49808. * @param floorMesh the mesh to be removed.
  49809. */
  49810. removeFloorMesh(floorMesh: Mesh): void;
  49811. /**
  49812. * Enables interactions and teleportation using the VR controllers and gaze.
  49813. * @param vrTeleportationOptions options to modify teleportation behavior.
  49814. */
  49815. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49816. private _onNewGamepadConnected;
  49817. private _tryEnableInteractionOnController;
  49818. private _onNewGamepadDisconnected;
  49819. private _enableInteractionOnController;
  49820. private _checkTeleportWithRay;
  49821. private _checkRotate;
  49822. private _checkTeleportBackwards;
  49823. private _enableTeleportationOnController;
  49824. private _createTeleportationCircles;
  49825. private _displayTeleportationTarget;
  49826. private _hideTeleportationTarget;
  49827. private _rotateCamera;
  49828. private _moveTeleportationSelectorTo;
  49829. private _workingVector;
  49830. private _workingQuaternion;
  49831. private _workingMatrix;
  49832. /**
  49833. * Time Constant Teleportation Mode
  49834. */
  49835. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49836. /**
  49837. * Speed Constant Teleportation Mode
  49838. */
  49839. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49840. /**
  49841. * Teleports the users feet to the desired location
  49842. * @param location The location where the user's feet should be placed
  49843. */
  49844. teleportCamera(location: Vector3): void;
  49845. private _convertNormalToDirectionOfRay;
  49846. private _castRayAndSelectObject;
  49847. private _notifySelectedMeshUnselected;
  49848. /**
  49849. * Permanently set new colors for the laser pointer
  49850. * @param color the new laser color
  49851. * @param pickedColor the new laser color when picked mesh detected
  49852. */
  49853. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49854. /**
  49855. * Set lighting enabled / disabled on the laser pointer of both controllers
  49856. * @param enabled should the lighting be enabled on the laser pointer
  49857. */
  49858. setLaserLightingState(enabled?: boolean): void;
  49859. /**
  49860. * Permanently set new colors for the gaze pointer
  49861. * @param color the new gaze color
  49862. * @param pickedColor the new gaze color when picked mesh detected
  49863. */
  49864. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49865. /**
  49866. * Sets the color of the laser ray from the vr controllers.
  49867. * @param color new color for the ray.
  49868. */
  49869. changeLaserColor(color: Color3): void;
  49870. /**
  49871. * Sets the color of the ray from the vr headsets gaze.
  49872. * @param color new color for the ray.
  49873. */
  49874. changeGazeColor(color: Color3): void;
  49875. /**
  49876. * Exits VR and disposes of the vr experience helper
  49877. */
  49878. dispose(): void;
  49879. /**
  49880. * Gets the name of the VRExperienceHelper class
  49881. * @returns "VRExperienceHelper"
  49882. */
  49883. getClassName(): string;
  49884. }
  49885. }
  49886. declare module BABYLON {
  49887. /**
  49888. * Contains an array of blocks representing the octree
  49889. */
  49890. export interface IOctreeContainer<T> {
  49891. /**
  49892. * Blocks within the octree
  49893. */
  49894. blocks: Array<OctreeBlock<T>>;
  49895. }
  49896. /**
  49897. * Class used to store a cell in an octree
  49898. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49899. */
  49900. export class OctreeBlock<T> {
  49901. /**
  49902. * Gets the content of the current block
  49903. */
  49904. entries: T[];
  49905. /**
  49906. * Gets the list of block children
  49907. */
  49908. blocks: Array<OctreeBlock<T>>;
  49909. private _depth;
  49910. private _maxDepth;
  49911. private _capacity;
  49912. private _minPoint;
  49913. private _maxPoint;
  49914. private _boundingVectors;
  49915. private _creationFunc;
  49916. /**
  49917. * Creates a new block
  49918. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49919. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49920. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49921. * @param depth defines the current depth of this block in the octree
  49922. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49923. * @param creationFunc defines a callback to call when an element is added to the block
  49924. */
  49925. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49926. /**
  49927. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49928. */
  49929. get capacity(): number;
  49930. /**
  49931. * Gets the minimum vector (in world space) of the block's bounding box
  49932. */
  49933. get minPoint(): Vector3;
  49934. /**
  49935. * Gets the maximum vector (in world space) of the block's bounding box
  49936. */
  49937. get maxPoint(): Vector3;
  49938. /**
  49939. * Add a new element to this block
  49940. * @param entry defines the element to add
  49941. */
  49942. addEntry(entry: T): void;
  49943. /**
  49944. * Remove an element from this block
  49945. * @param entry defines the element to remove
  49946. */
  49947. removeEntry(entry: T): void;
  49948. /**
  49949. * Add an array of elements to this block
  49950. * @param entries defines the array of elements to add
  49951. */
  49952. addEntries(entries: T[]): void;
  49953. /**
  49954. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49955. * @param frustumPlanes defines the frustum planes to test
  49956. * @param selection defines the array to store current content if selection is positive
  49957. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49958. */
  49959. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49960. /**
  49961. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49962. * @param sphereCenter defines the bounding sphere center
  49963. * @param sphereRadius defines the bounding sphere radius
  49964. * @param selection defines the array to store current content if selection is positive
  49965. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49966. */
  49967. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49968. /**
  49969. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49970. * @param ray defines the ray to test with
  49971. * @param selection defines the array to store current content if selection is positive
  49972. */
  49973. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49974. /**
  49975. * Subdivide the content into child blocks (this block will then be empty)
  49976. */
  49977. createInnerBlocks(): void;
  49978. /**
  49979. * @hidden
  49980. */
  49981. 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;
  49982. }
  49983. }
  49984. declare module BABYLON {
  49985. /**
  49986. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49987. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49988. */
  49989. export class Octree<T> {
  49990. /** 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.) */
  49991. maxDepth: number;
  49992. /**
  49993. * Blocks within the octree containing objects
  49994. */
  49995. blocks: Array<OctreeBlock<T>>;
  49996. /**
  49997. * Content stored in the octree
  49998. */
  49999. dynamicContent: T[];
  50000. private _maxBlockCapacity;
  50001. private _selectionContent;
  50002. private _creationFunc;
  50003. /**
  50004. * Creates a octree
  50005. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50006. * @param creationFunc function to be used to instatiate the octree
  50007. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50008. * @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.)
  50009. */
  50010. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50011. /** 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.) */
  50012. maxDepth?: number);
  50013. /**
  50014. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50015. * @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);
  50016. * @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);
  50017. * @param entries meshes to be added to the octree blocks
  50018. */
  50019. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50020. /**
  50021. * Adds a mesh to the octree
  50022. * @param entry Mesh to add to the octree
  50023. */
  50024. addMesh(entry: T): void;
  50025. /**
  50026. * Remove an element from the octree
  50027. * @param entry defines the element to remove
  50028. */
  50029. removeMesh(entry: T): void;
  50030. /**
  50031. * Selects an array of meshes within the frustum
  50032. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50033. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50034. * @returns array of meshes within the frustum
  50035. */
  50036. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50037. /**
  50038. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50039. * @param sphereCenter defines the bounding sphere center
  50040. * @param sphereRadius defines the bounding sphere radius
  50041. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50042. * @returns an array of objects that intersect the sphere
  50043. */
  50044. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50045. /**
  50046. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50047. * @param ray defines the ray to test with
  50048. * @returns array of intersected objects
  50049. */
  50050. intersectsRay(ray: Ray): SmartArray<T>;
  50051. /**
  50052. * Adds a mesh into the octree block if it intersects the block
  50053. */
  50054. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50055. /**
  50056. * Adds a submesh into the octree block if it intersects the block
  50057. */
  50058. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50059. }
  50060. }
  50061. declare module BABYLON {
  50062. interface Scene {
  50063. /**
  50064. * @hidden
  50065. * Backing Filed
  50066. */
  50067. _selectionOctree: Octree<AbstractMesh>;
  50068. /**
  50069. * Gets the octree used to boost mesh selection (picking)
  50070. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50071. */
  50072. selectionOctree: Octree<AbstractMesh>;
  50073. /**
  50074. * Creates or updates the octree used to boost selection (picking)
  50075. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50076. * @param maxCapacity defines the maximum capacity per leaf
  50077. * @param maxDepth defines the maximum depth of the octree
  50078. * @returns an octree of AbstractMesh
  50079. */
  50080. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50081. }
  50082. interface AbstractMesh {
  50083. /**
  50084. * @hidden
  50085. * Backing Field
  50086. */
  50087. _submeshesOctree: Octree<SubMesh>;
  50088. /**
  50089. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50090. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50091. * @param maxCapacity defines the maximum size of each block (64 by default)
  50092. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50093. * @returns the new octree
  50094. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50095. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50096. */
  50097. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50098. }
  50099. /**
  50100. * Defines the octree scene component responsible to manage any octrees
  50101. * in a given scene.
  50102. */
  50103. export class OctreeSceneComponent {
  50104. /**
  50105. * The component name help to identify the component in the list of scene components.
  50106. */
  50107. readonly name: string;
  50108. /**
  50109. * The scene the component belongs to.
  50110. */
  50111. scene: Scene;
  50112. /**
  50113. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50114. */
  50115. readonly checksIsEnabled: boolean;
  50116. /**
  50117. * Creates a new instance of the component for the given scene
  50118. * @param scene Defines the scene to register the component in
  50119. */
  50120. constructor(scene: Scene);
  50121. /**
  50122. * Registers the component in a given scene
  50123. */
  50124. register(): void;
  50125. /**
  50126. * Return the list of active meshes
  50127. * @returns the list of active meshes
  50128. */
  50129. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50130. /**
  50131. * Return the list of active sub meshes
  50132. * @param mesh The mesh to get the candidates sub meshes from
  50133. * @returns the list of active sub meshes
  50134. */
  50135. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50136. private _tempRay;
  50137. /**
  50138. * Return the list of sub meshes intersecting with a given local ray
  50139. * @param mesh defines the mesh to find the submesh for
  50140. * @param localRay defines the ray in local space
  50141. * @returns the list of intersecting sub meshes
  50142. */
  50143. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50144. /**
  50145. * Return the list of sub meshes colliding with a collider
  50146. * @param mesh defines the mesh to find the submesh for
  50147. * @param collider defines the collider to evaluate the collision against
  50148. * @returns the list of colliding sub meshes
  50149. */
  50150. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50151. /**
  50152. * Rebuilds the elements related to this component in case of
  50153. * context lost for instance.
  50154. */
  50155. rebuild(): void;
  50156. /**
  50157. * Disposes the component and the associated ressources.
  50158. */
  50159. dispose(): void;
  50160. }
  50161. }
  50162. declare module BABYLON {
  50163. /**
  50164. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50165. */
  50166. export class Gizmo implements IDisposable {
  50167. /** The utility layer the gizmo will be added to */
  50168. gizmoLayer: UtilityLayerRenderer;
  50169. /**
  50170. * The root mesh of the gizmo
  50171. */
  50172. _rootMesh: Mesh;
  50173. private _attachedMesh;
  50174. private _attachedNode;
  50175. /**
  50176. * Ratio for the scale of the gizmo (Default: 1)
  50177. */
  50178. scaleRatio: number;
  50179. /**
  50180. * If a custom mesh has been set (Default: false)
  50181. */
  50182. protected _customMeshSet: boolean;
  50183. /**
  50184. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50185. * * When set, interactions will be enabled
  50186. */
  50187. get attachedMesh(): Nullable<AbstractMesh>;
  50188. set attachedMesh(value: Nullable<AbstractMesh>);
  50189. /**
  50190. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50191. * * When set, interactions will be enabled
  50192. */
  50193. get attachedNode(): Nullable<Node>;
  50194. set attachedNode(value: Nullable<Node>);
  50195. /**
  50196. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50197. * @param mesh The mesh to replace the default mesh of the gizmo
  50198. */
  50199. setCustomMesh(mesh: Mesh): void;
  50200. /**
  50201. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50202. */
  50203. updateGizmoRotationToMatchAttachedMesh: boolean;
  50204. /**
  50205. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50206. */
  50207. updateGizmoPositionToMatchAttachedMesh: boolean;
  50208. /**
  50209. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50210. */
  50211. updateScale: boolean;
  50212. protected _interactionsEnabled: boolean;
  50213. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50214. private _beforeRenderObserver;
  50215. private _tempQuaternion;
  50216. private _tempVector;
  50217. private _tempVector2;
  50218. /**
  50219. * Creates a gizmo
  50220. * @param gizmoLayer The utility layer the gizmo will be added to
  50221. */
  50222. constructor(
  50223. /** The utility layer the gizmo will be added to */
  50224. gizmoLayer?: UtilityLayerRenderer);
  50225. /**
  50226. * Updates the gizmo to match the attached mesh's position/rotation
  50227. */
  50228. protected _update(): void;
  50229. /**
  50230. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50231. * @param value Node, TransformNode or mesh
  50232. */
  50233. protected _matrixChanged(): void;
  50234. /**
  50235. * Disposes of the gizmo
  50236. */
  50237. dispose(): void;
  50238. }
  50239. }
  50240. declare module BABYLON {
  50241. /**
  50242. * Single plane drag gizmo
  50243. */
  50244. export class PlaneDragGizmo extends Gizmo {
  50245. /**
  50246. * Drag behavior responsible for the gizmos dragging interactions
  50247. */
  50248. dragBehavior: PointerDragBehavior;
  50249. private _pointerObserver;
  50250. /**
  50251. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50252. */
  50253. snapDistance: number;
  50254. /**
  50255. * Event that fires each time the gizmo snaps to a new location.
  50256. * * snapDistance is the the change in distance
  50257. */
  50258. onSnapObservable: Observable<{
  50259. snapDistance: number;
  50260. }>;
  50261. private _plane;
  50262. private _coloredMaterial;
  50263. private _hoverMaterial;
  50264. private _isEnabled;
  50265. private _parent;
  50266. /** @hidden */
  50267. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50268. /** @hidden */
  50269. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50270. /**
  50271. * Creates a PlaneDragGizmo
  50272. * @param gizmoLayer The utility layer the gizmo will be added to
  50273. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50274. * @param color The color of the gizmo
  50275. */
  50276. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50277. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50278. /**
  50279. * If the gizmo is enabled
  50280. */
  50281. set isEnabled(value: boolean);
  50282. get isEnabled(): boolean;
  50283. /**
  50284. * Disposes of the gizmo
  50285. */
  50286. dispose(): void;
  50287. }
  50288. }
  50289. declare module BABYLON {
  50290. /**
  50291. * Gizmo that enables dragging a mesh along 3 axis
  50292. */
  50293. export class PositionGizmo extends Gizmo {
  50294. /**
  50295. * Internal gizmo used for interactions on the x axis
  50296. */
  50297. xGizmo: AxisDragGizmo;
  50298. /**
  50299. * Internal gizmo used for interactions on the y axis
  50300. */
  50301. yGizmo: AxisDragGizmo;
  50302. /**
  50303. * Internal gizmo used for interactions on the z axis
  50304. */
  50305. zGizmo: AxisDragGizmo;
  50306. /**
  50307. * Internal gizmo used for interactions on the yz plane
  50308. */
  50309. xPlaneGizmo: PlaneDragGizmo;
  50310. /**
  50311. * Internal gizmo used for interactions on the xz plane
  50312. */
  50313. yPlaneGizmo: PlaneDragGizmo;
  50314. /**
  50315. * Internal gizmo used for interactions on the xy plane
  50316. */
  50317. zPlaneGizmo: PlaneDragGizmo;
  50318. /**
  50319. * private variables
  50320. */
  50321. private _meshAttached;
  50322. private _nodeAttached;
  50323. private _updateGizmoRotationToMatchAttachedMesh;
  50324. private _snapDistance;
  50325. private _scaleRatio;
  50326. /** Fires an event when any of it's sub gizmos are dragged */
  50327. onDragStartObservable: Observable<unknown>;
  50328. /** Fires an event when any of it's sub gizmos are released from dragging */
  50329. onDragEndObservable: Observable<unknown>;
  50330. /**
  50331. * If set to true, planar drag is enabled
  50332. */
  50333. private _planarGizmoEnabled;
  50334. get attachedMesh(): Nullable<AbstractMesh>;
  50335. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50336. get attachedNode(): Nullable<Node>;
  50337. set attachedNode(node: Nullable<Node>);
  50338. /**
  50339. * Creates a PositionGizmo
  50340. * @param gizmoLayer The utility layer the gizmo will be added to
  50341. @param thickness display gizmo axis thickness
  50342. */
  50343. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50344. /**
  50345. * If the planar drag gizmo is enabled
  50346. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50347. */
  50348. set planarGizmoEnabled(value: boolean);
  50349. get planarGizmoEnabled(): boolean;
  50350. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50351. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50352. /**
  50353. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50354. */
  50355. set snapDistance(value: number);
  50356. get snapDistance(): number;
  50357. /**
  50358. * Ratio for the scale of the gizmo (Default: 1)
  50359. */
  50360. set scaleRatio(value: number);
  50361. get scaleRatio(): number;
  50362. /**
  50363. * Disposes of the gizmo
  50364. */
  50365. dispose(): void;
  50366. /**
  50367. * CustomMeshes are not supported by this gizmo
  50368. * @param mesh The mesh to replace the default mesh of the gizmo
  50369. */
  50370. setCustomMesh(mesh: Mesh): void;
  50371. }
  50372. }
  50373. declare module BABYLON {
  50374. /**
  50375. * Single axis drag gizmo
  50376. */
  50377. export class AxisDragGizmo extends Gizmo {
  50378. /**
  50379. * Drag behavior responsible for the gizmos dragging interactions
  50380. */
  50381. dragBehavior: PointerDragBehavior;
  50382. private _pointerObserver;
  50383. /**
  50384. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50385. */
  50386. snapDistance: number;
  50387. /**
  50388. * Event that fires each time the gizmo snaps to a new location.
  50389. * * snapDistance is the the change in distance
  50390. */
  50391. onSnapObservable: Observable<{
  50392. snapDistance: number;
  50393. }>;
  50394. private _isEnabled;
  50395. private _parent;
  50396. private _arrow;
  50397. private _coloredMaterial;
  50398. private _hoverMaterial;
  50399. /** @hidden */
  50400. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50401. /** @hidden */
  50402. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50403. /**
  50404. * Creates an AxisDragGizmo
  50405. * @param gizmoLayer The utility layer the gizmo will be added to
  50406. * @param dragAxis The axis which the gizmo will be able to drag on
  50407. * @param color The color of the gizmo
  50408. * @param thickness display gizmo axis thickness
  50409. */
  50410. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50411. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50412. /**
  50413. * If the gizmo is enabled
  50414. */
  50415. set isEnabled(value: boolean);
  50416. get isEnabled(): boolean;
  50417. /**
  50418. * Disposes of the gizmo
  50419. */
  50420. dispose(): void;
  50421. }
  50422. }
  50423. declare module BABYLON.Debug {
  50424. /**
  50425. * The Axes viewer will show 3 axes in a specific point in space
  50426. */
  50427. export class AxesViewer {
  50428. private _xAxis;
  50429. private _yAxis;
  50430. private _zAxis;
  50431. private _scaleLinesFactor;
  50432. private _instanced;
  50433. /**
  50434. * Gets the hosting scene
  50435. */
  50436. scene: Scene;
  50437. /**
  50438. * Gets or sets a number used to scale line length
  50439. */
  50440. scaleLines: number;
  50441. /** Gets the node hierarchy used to render x-axis */
  50442. get xAxis(): TransformNode;
  50443. /** Gets the node hierarchy used to render y-axis */
  50444. get yAxis(): TransformNode;
  50445. /** Gets the node hierarchy used to render z-axis */
  50446. get zAxis(): TransformNode;
  50447. /**
  50448. * Creates a new AxesViewer
  50449. * @param scene defines the hosting scene
  50450. * @param scaleLines defines a number used to scale line length (1 by default)
  50451. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50452. * @param xAxis defines the node hierarchy used to render the x-axis
  50453. * @param yAxis defines the node hierarchy used to render the y-axis
  50454. * @param zAxis defines the node hierarchy used to render the z-axis
  50455. */
  50456. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50457. /**
  50458. * Force the viewer to update
  50459. * @param position defines the position of the viewer
  50460. * @param xaxis defines the x axis of the viewer
  50461. * @param yaxis defines the y axis of the viewer
  50462. * @param zaxis defines the z axis of the viewer
  50463. */
  50464. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50465. /**
  50466. * Creates an instance of this axes viewer.
  50467. * @returns a new axes viewer with instanced meshes
  50468. */
  50469. createInstance(): AxesViewer;
  50470. /** Releases resources */
  50471. dispose(): void;
  50472. private static _SetRenderingGroupId;
  50473. }
  50474. }
  50475. declare module BABYLON.Debug {
  50476. /**
  50477. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50478. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50479. */
  50480. export class BoneAxesViewer extends AxesViewer {
  50481. /**
  50482. * Gets or sets the target mesh where to display the axes viewer
  50483. */
  50484. mesh: Nullable<Mesh>;
  50485. /**
  50486. * Gets or sets the target bone where to display the axes viewer
  50487. */
  50488. bone: Nullable<Bone>;
  50489. /** Gets current position */
  50490. pos: Vector3;
  50491. /** Gets direction of X axis */
  50492. xaxis: Vector3;
  50493. /** Gets direction of Y axis */
  50494. yaxis: Vector3;
  50495. /** Gets direction of Z axis */
  50496. zaxis: Vector3;
  50497. /**
  50498. * Creates a new BoneAxesViewer
  50499. * @param scene defines the hosting scene
  50500. * @param bone defines the target bone
  50501. * @param mesh defines the target mesh
  50502. * @param scaleLines defines a scaling factor for line length (1 by default)
  50503. */
  50504. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50505. /**
  50506. * Force the viewer to update
  50507. */
  50508. update(): void;
  50509. /** Releases resources */
  50510. dispose(): void;
  50511. }
  50512. }
  50513. declare module BABYLON {
  50514. /**
  50515. * Interface used to define scene explorer extensibility option
  50516. */
  50517. export interface IExplorerExtensibilityOption {
  50518. /**
  50519. * Define the option label
  50520. */
  50521. label: string;
  50522. /**
  50523. * Defines the action to execute on click
  50524. */
  50525. action: (entity: any) => void;
  50526. }
  50527. /**
  50528. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50529. */
  50530. export interface IExplorerExtensibilityGroup {
  50531. /**
  50532. * Defines a predicate to test if a given type mut be extended
  50533. */
  50534. predicate: (entity: any) => boolean;
  50535. /**
  50536. * Gets the list of options added to a type
  50537. */
  50538. entries: IExplorerExtensibilityOption[];
  50539. }
  50540. /**
  50541. * Interface used to define the options to use to create the Inspector
  50542. */
  50543. export interface IInspectorOptions {
  50544. /**
  50545. * Display in overlay mode (default: false)
  50546. */
  50547. overlay?: boolean;
  50548. /**
  50549. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50550. */
  50551. globalRoot?: HTMLElement;
  50552. /**
  50553. * Display the Scene explorer
  50554. */
  50555. showExplorer?: boolean;
  50556. /**
  50557. * Display the property inspector
  50558. */
  50559. showInspector?: boolean;
  50560. /**
  50561. * Display in embed mode (both panes on the right)
  50562. */
  50563. embedMode?: boolean;
  50564. /**
  50565. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50566. */
  50567. handleResize?: boolean;
  50568. /**
  50569. * Allow the panes to popup (default: true)
  50570. */
  50571. enablePopup?: boolean;
  50572. /**
  50573. * Allow the panes to be closed by users (default: true)
  50574. */
  50575. enableClose?: boolean;
  50576. /**
  50577. * Optional list of extensibility entries
  50578. */
  50579. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50580. /**
  50581. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50582. */
  50583. inspectorURL?: string;
  50584. /**
  50585. * Optional initial tab (default to DebugLayerTab.Properties)
  50586. */
  50587. initialTab?: DebugLayerTab;
  50588. }
  50589. interface Scene {
  50590. /**
  50591. * @hidden
  50592. * Backing field
  50593. */
  50594. _debugLayer: DebugLayer;
  50595. /**
  50596. * Gets the debug layer (aka Inspector) associated with the scene
  50597. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50598. */
  50599. debugLayer: DebugLayer;
  50600. }
  50601. /**
  50602. * Enum of inspector action tab
  50603. */
  50604. export enum DebugLayerTab {
  50605. /**
  50606. * Properties tag (default)
  50607. */
  50608. Properties = 0,
  50609. /**
  50610. * Debug tab
  50611. */
  50612. Debug = 1,
  50613. /**
  50614. * Statistics tab
  50615. */
  50616. Statistics = 2,
  50617. /**
  50618. * Tools tab
  50619. */
  50620. Tools = 3,
  50621. /**
  50622. * Settings tab
  50623. */
  50624. Settings = 4
  50625. }
  50626. /**
  50627. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50628. * what is happening in your scene
  50629. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50630. */
  50631. export class DebugLayer {
  50632. /**
  50633. * Define the url to get the inspector script from.
  50634. * By default it uses the babylonjs CDN.
  50635. * @ignoreNaming
  50636. */
  50637. static InspectorURL: string;
  50638. private _scene;
  50639. private BJSINSPECTOR;
  50640. private _onPropertyChangedObservable?;
  50641. /**
  50642. * Observable triggered when a property is changed through the inspector.
  50643. */
  50644. get onPropertyChangedObservable(): any;
  50645. /**
  50646. * Instantiates a new debug layer.
  50647. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50648. * what is happening in your scene
  50649. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50650. * @param scene Defines the scene to inspect
  50651. */
  50652. constructor(scene: Scene);
  50653. /** Creates the inspector window. */
  50654. private _createInspector;
  50655. /**
  50656. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50657. * @param entity defines the entity to select
  50658. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50659. */
  50660. select(entity: any, lineContainerTitles?: string | string[]): void;
  50661. /** Get the inspector from bundle or global */
  50662. private _getGlobalInspector;
  50663. /**
  50664. * Get if the inspector is visible or not.
  50665. * @returns true if visible otherwise, false
  50666. */
  50667. isVisible(): boolean;
  50668. /**
  50669. * Hide the inspector and close its window.
  50670. */
  50671. hide(): void;
  50672. /**
  50673. * Update the scene in the inspector
  50674. */
  50675. setAsActiveScene(): void;
  50676. /**
  50677. * Launch the debugLayer.
  50678. * @param config Define the configuration of the inspector
  50679. * @return a promise fulfilled when the debug layer is visible
  50680. */
  50681. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50682. }
  50683. }
  50684. declare module BABYLON {
  50685. /**
  50686. * Class containing static functions to help procedurally build meshes
  50687. */
  50688. export class BoxBuilder {
  50689. /**
  50690. * Creates a box mesh
  50691. * * The parameter `size` sets the size (float) of each box side (default 1)
  50692. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50693. * * 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)
  50694. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50696. * * 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
  50697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50698. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50699. * @param name defines the name of the mesh
  50700. * @param options defines the options used to create the mesh
  50701. * @param scene defines the hosting scene
  50702. * @returns the box mesh
  50703. */
  50704. static CreateBox(name: string, options: {
  50705. size?: number;
  50706. width?: number;
  50707. height?: number;
  50708. depth?: number;
  50709. faceUV?: Vector4[];
  50710. faceColors?: Color4[];
  50711. sideOrientation?: number;
  50712. frontUVs?: Vector4;
  50713. backUVs?: Vector4;
  50714. wrap?: boolean;
  50715. topBaseAt?: number;
  50716. bottomBaseAt?: number;
  50717. updatable?: boolean;
  50718. }, scene?: Nullable<Scene>): Mesh;
  50719. }
  50720. }
  50721. declare module BABYLON.Debug {
  50722. /**
  50723. * Used to show the physics impostor around the specific mesh
  50724. */
  50725. export class PhysicsViewer {
  50726. /** @hidden */
  50727. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50728. /** @hidden */
  50729. protected _meshes: Array<Nullable<AbstractMesh>>;
  50730. /** @hidden */
  50731. protected _scene: Nullable<Scene>;
  50732. /** @hidden */
  50733. protected _numMeshes: number;
  50734. /** @hidden */
  50735. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50736. private _renderFunction;
  50737. private _utilityLayer;
  50738. private _debugBoxMesh;
  50739. private _debugSphereMesh;
  50740. private _debugCylinderMesh;
  50741. private _debugMaterial;
  50742. private _debugMeshMeshes;
  50743. /**
  50744. * Creates a new PhysicsViewer
  50745. * @param scene defines the hosting scene
  50746. */
  50747. constructor(scene: Scene);
  50748. /** @hidden */
  50749. protected _updateDebugMeshes(): void;
  50750. /**
  50751. * Renders a specified physic impostor
  50752. * @param impostor defines the impostor to render
  50753. * @param targetMesh defines the mesh represented by the impostor
  50754. * @returns the new debug mesh used to render the impostor
  50755. */
  50756. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50757. /**
  50758. * Hides a specified physic impostor
  50759. * @param impostor defines the impostor to hide
  50760. */
  50761. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50762. private _getDebugMaterial;
  50763. private _getDebugBoxMesh;
  50764. private _getDebugSphereMesh;
  50765. private _getDebugCylinderMesh;
  50766. private _getDebugMeshMesh;
  50767. private _getDebugMesh;
  50768. /** Releases all resources */
  50769. dispose(): void;
  50770. }
  50771. }
  50772. declare module BABYLON {
  50773. /**
  50774. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50775. * in order to better appreciate the issue one might have.
  50776. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50777. */
  50778. export class RayHelper {
  50779. /**
  50780. * Defines the ray we are currently tryin to visualize.
  50781. */
  50782. ray: Nullable<Ray>;
  50783. private _renderPoints;
  50784. private _renderLine;
  50785. private _renderFunction;
  50786. private _scene;
  50787. private _onAfterRenderObserver;
  50788. private _onAfterStepObserver;
  50789. private _attachedToMesh;
  50790. private _meshSpaceDirection;
  50791. private _meshSpaceOrigin;
  50792. /**
  50793. * Helper function to create a colored helper in a scene in one line.
  50794. * @param ray Defines the ray we are currently tryin to visualize
  50795. * @param scene Defines the scene the ray is used in
  50796. * @param color Defines the color we want to see the ray in
  50797. * @returns The newly created ray helper.
  50798. */
  50799. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50800. /**
  50801. * Instantiate a new ray helper.
  50802. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50803. * in order to better appreciate the issue one might have.
  50804. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50805. * @param ray Defines the ray we are currently tryin to visualize
  50806. */
  50807. constructor(ray: Ray);
  50808. /**
  50809. * Shows the ray we are willing to debug.
  50810. * @param scene Defines the scene the ray needs to be rendered in
  50811. * @param color Defines the color the ray needs to be rendered in
  50812. */
  50813. show(scene: Scene, color?: Color3): void;
  50814. /**
  50815. * Hides the ray we are debugging.
  50816. */
  50817. hide(): void;
  50818. private _render;
  50819. /**
  50820. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50821. * @param mesh Defines the mesh we want the helper attached to
  50822. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50823. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50824. * @param length Defines the length of the ray
  50825. */
  50826. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50827. /**
  50828. * Detach the ray helper from the mesh it has previously been attached to.
  50829. */
  50830. detachFromMesh(): void;
  50831. private _updateToMesh;
  50832. /**
  50833. * Dispose the helper and release its associated resources.
  50834. */
  50835. dispose(): void;
  50836. }
  50837. }
  50838. declare module BABYLON {
  50839. /**
  50840. * Defines the options associated with the creation of a SkeletonViewer.
  50841. */
  50842. export interface ISkeletonViewerOptions {
  50843. /** Should the system pause animations before building the Viewer? */
  50844. pauseAnimations: boolean;
  50845. /** Should the system return the skeleton to rest before building? */
  50846. returnToRest: boolean;
  50847. /** public Display Mode of the Viewer */
  50848. displayMode: number;
  50849. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50850. displayOptions: ISkeletonViewerDisplayOptions;
  50851. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50852. computeBonesUsingShaders: boolean;
  50853. }
  50854. /**
  50855. * Defines how to display the various bone meshes for the viewer.
  50856. */
  50857. export interface ISkeletonViewerDisplayOptions {
  50858. /** How far down to start tapering the bone spurs */
  50859. midStep?: number;
  50860. /** How big is the midStep? */
  50861. midStepFactor?: number;
  50862. /** Base for the Sphere Size */
  50863. sphereBaseSize?: number;
  50864. /** The ratio of the sphere to the longest bone in units */
  50865. sphereScaleUnit?: number;
  50866. /** Ratio for the Sphere Size */
  50867. sphereFactor?: number;
  50868. }
  50869. }
  50870. declare module BABYLON {
  50871. /**
  50872. * Class containing static functions to help procedurally build meshes
  50873. */
  50874. export class RibbonBuilder {
  50875. /**
  50876. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50877. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50878. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50879. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50880. * * 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
  50881. * * 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
  50882. * * 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
  50883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50884. * * 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
  50885. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50886. * * 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
  50887. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50888. * * 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
  50889. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50891. * @param name defines the name of the mesh
  50892. * @param options defines the options used to create the mesh
  50893. * @param scene defines the hosting scene
  50894. * @returns the ribbon mesh
  50895. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50896. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50897. */
  50898. static CreateRibbon(name: string, options: {
  50899. pathArray: Vector3[][];
  50900. closeArray?: boolean;
  50901. closePath?: boolean;
  50902. offset?: number;
  50903. updatable?: boolean;
  50904. sideOrientation?: number;
  50905. frontUVs?: Vector4;
  50906. backUVs?: Vector4;
  50907. instance?: Mesh;
  50908. invertUV?: boolean;
  50909. uvs?: Vector2[];
  50910. colors?: Color4[];
  50911. }, scene?: Nullable<Scene>): Mesh;
  50912. }
  50913. }
  50914. declare module BABYLON {
  50915. /**
  50916. * Class containing static functions to help procedurally build meshes
  50917. */
  50918. export class ShapeBuilder {
  50919. /**
  50920. * 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.
  50921. * * 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.
  50922. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50923. * * 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.
  50924. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50925. * * 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
  50926. * * 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
  50927. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50929. * * 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
  50930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50932. * @param name defines the name of the mesh
  50933. * @param options defines the options used to create the mesh
  50934. * @param scene defines the hosting scene
  50935. * @returns the extruded shape mesh
  50936. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50938. */
  50939. static ExtrudeShape(name: string, options: {
  50940. shape: Vector3[];
  50941. path: Vector3[];
  50942. scale?: number;
  50943. rotation?: number;
  50944. cap?: number;
  50945. updatable?: boolean;
  50946. sideOrientation?: number;
  50947. frontUVs?: Vector4;
  50948. backUVs?: Vector4;
  50949. instance?: Mesh;
  50950. invertUV?: boolean;
  50951. }, scene?: Nullable<Scene>): Mesh;
  50952. /**
  50953. * Creates an custom extruded shape mesh.
  50954. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50955. * * 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.
  50956. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50957. * * 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
  50958. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50959. * * 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
  50960. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50961. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50962. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50963. * * 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
  50964. * * 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
  50965. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50967. * * 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
  50968. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50970. * @param name defines the name of the mesh
  50971. * @param options defines the options used to create the mesh
  50972. * @param scene defines the hosting scene
  50973. * @returns the custom extruded shape mesh
  50974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50975. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50977. */
  50978. static ExtrudeShapeCustom(name: string, options: {
  50979. shape: Vector3[];
  50980. path: Vector3[];
  50981. scaleFunction?: any;
  50982. rotationFunction?: any;
  50983. ribbonCloseArray?: boolean;
  50984. ribbonClosePath?: boolean;
  50985. cap?: number;
  50986. updatable?: boolean;
  50987. sideOrientation?: number;
  50988. frontUVs?: Vector4;
  50989. backUVs?: Vector4;
  50990. instance?: Mesh;
  50991. invertUV?: boolean;
  50992. }, scene?: Nullable<Scene>): Mesh;
  50993. private static _ExtrudeShapeGeneric;
  50994. }
  50995. }
  50996. declare module BABYLON.Debug {
  50997. /**
  50998. * Class used to render a debug view of a given skeleton
  50999. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51000. */
  51001. export class SkeletonViewer {
  51002. /** defines the skeleton to render */
  51003. skeleton: Skeleton;
  51004. /** defines the mesh attached to the skeleton */
  51005. mesh: AbstractMesh;
  51006. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51007. autoUpdateBonesMatrices: boolean;
  51008. /** defines the rendering group id to use with the viewer */
  51009. renderingGroupId: number;
  51010. /** is the options for the viewer */
  51011. options: Partial<ISkeletonViewerOptions>;
  51012. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51013. static readonly DISPLAY_LINES: number;
  51014. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51015. static readonly DISPLAY_SPHERES: number;
  51016. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51017. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51018. /** If SkeletonViewer scene scope. */
  51019. private _scene;
  51020. /** Gets or sets the color used to render the skeleton */
  51021. color: Color3;
  51022. /** Array of the points of the skeleton fo the line view. */
  51023. private _debugLines;
  51024. /** The SkeletonViewers Mesh. */
  51025. private _debugMesh;
  51026. /** If SkeletonViewer is enabled. */
  51027. private _isEnabled;
  51028. /** If SkeletonViewer is ready. */
  51029. private _ready;
  51030. /** SkeletonViewer render observable. */
  51031. private _obs;
  51032. /** The Utility Layer to render the gizmos in. */
  51033. private _utilityLayer;
  51034. private _boneIndices;
  51035. /** Gets the Scene. */
  51036. get scene(): Scene;
  51037. /** Gets the utilityLayer. */
  51038. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51039. /** Checks Ready Status. */
  51040. get isReady(): Boolean;
  51041. /** Sets Ready Status. */
  51042. set ready(value: boolean);
  51043. /** Gets the debugMesh */
  51044. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51045. /** Sets the debugMesh */
  51046. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51047. /** Gets the material */
  51048. get material(): StandardMaterial;
  51049. /** Sets the material */
  51050. set material(value: StandardMaterial);
  51051. /** Gets the material */
  51052. get displayMode(): number;
  51053. /** Sets the material */
  51054. set displayMode(value: number);
  51055. /**
  51056. * Creates a new SkeletonViewer
  51057. * @param skeleton defines the skeleton to render
  51058. * @param mesh defines the mesh attached to the skeleton
  51059. * @param scene defines the hosting scene
  51060. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51061. * @param renderingGroupId defines the rendering group id to use with the viewer
  51062. * @param options All of the extra constructor options for the SkeletonViewer
  51063. */
  51064. constructor(
  51065. /** defines the skeleton to render */
  51066. skeleton: Skeleton,
  51067. /** defines the mesh attached to the skeleton */
  51068. mesh: AbstractMesh,
  51069. /** The Scene scope*/
  51070. scene: Scene,
  51071. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51072. autoUpdateBonesMatrices?: boolean,
  51073. /** defines the rendering group id to use with the viewer */
  51074. renderingGroupId?: number,
  51075. /** is the options for the viewer */
  51076. options?: Partial<ISkeletonViewerOptions>);
  51077. /** The Dynamic bindings for the update functions */
  51078. private _bindObs;
  51079. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51080. update(): void;
  51081. /** Gets or sets a boolean indicating if the viewer is enabled */
  51082. set isEnabled(value: boolean);
  51083. get isEnabled(): boolean;
  51084. private _getBonePosition;
  51085. private _getLinesForBonesWithLength;
  51086. private _getLinesForBonesNoLength;
  51087. /** function to revert the mesh and scene back to the initial state. */
  51088. private _revert;
  51089. /** function to build and bind sphere joint points and spur bone representations. */
  51090. private _buildSpheresAndSpurs;
  51091. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51092. private _displayLinesUpdate;
  51093. /** Changes the displayMode of the skeleton viewer
  51094. * @param mode The displayMode numerical value
  51095. */
  51096. changeDisplayMode(mode: number): void;
  51097. /** Changes the displayMode of the skeleton viewer
  51098. * @param option String of the option name
  51099. * @param value The numerical option value
  51100. */
  51101. changeDisplayOptions(option: string, value: number): void;
  51102. /** Release associated resources */
  51103. dispose(): void;
  51104. }
  51105. }
  51106. declare module BABYLON {
  51107. /**
  51108. * Enum for Device Types
  51109. */
  51110. export enum DeviceType {
  51111. /** Generic */
  51112. Generic = 0,
  51113. /** Keyboard */
  51114. Keyboard = 1,
  51115. /** Mouse */
  51116. Mouse = 2,
  51117. /** Touch Pointers */
  51118. Touch = 3,
  51119. /** PS4 Dual Shock */
  51120. DualShock = 4,
  51121. /** Xbox */
  51122. Xbox = 5,
  51123. /** Switch Controller */
  51124. Switch = 6
  51125. }
  51126. /**
  51127. * Enum for All Pointers (Touch/Mouse)
  51128. */
  51129. export enum PointerInput {
  51130. /** Horizontal Axis */
  51131. Horizontal = 0,
  51132. /** Vertical Axis */
  51133. Vertical = 1,
  51134. /** Left Click or Touch */
  51135. LeftClick = 2,
  51136. /** Middle Click */
  51137. MiddleClick = 3,
  51138. /** Right Click */
  51139. RightClick = 4,
  51140. /** Browser Back */
  51141. BrowserBack = 5,
  51142. /** Browser Forward */
  51143. BrowserForward = 6
  51144. }
  51145. /**
  51146. * Enum for Dual Shock Gamepad
  51147. */
  51148. export enum DualShockInput {
  51149. /** Cross */
  51150. Cross = 0,
  51151. /** Circle */
  51152. Circle = 1,
  51153. /** Square */
  51154. Square = 2,
  51155. /** Triangle */
  51156. Triangle = 3,
  51157. /** L1 */
  51158. L1 = 4,
  51159. /** R1 */
  51160. R1 = 5,
  51161. /** L2 */
  51162. L2 = 6,
  51163. /** R2 */
  51164. R2 = 7,
  51165. /** Share */
  51166. Share = 8,
  51167. /** Options */
  51168. Options = 9,
  51169. /** L3 */
  51170. L3 = 10,
  51171. /** R3 */
  51172. R3 = 11,
  51173. /** DPadUp */
  51174. DPadUp = 12,
  51175. /** DPadDown */
  51176. DPadDown = 13,
  51177. /** DPadLeft */
  51178. DPadLeft = 14,
  51179. /** DRight */
  51180. DPadRight = 15,
  51181. /** Home */
  51182. Home = 16,
  51183. /** TouchPad */
  51184. TouchPad = 17,
  51185. /** LStickXAxis */
  51186. LStickXAxis = 18,
  51187. /** LStickYAxis */
  51188. LStickYAxis = 19,
  51189. /** RStickXAxis */
  51190. RStickXAxis = 20,
  51191. /** RStickYAxis */
  51192. RStickYAxis = 21
  51193. }
  51194. /**
  51195. * Enum for Xbox Gamepad
  51196. */
  51197. export enum XboxInput {
  51198. /** A */
  51199. A = 0,
  51200. /** B */
  51201. B = 1,
  51202. /** X */
  51203. X = 2,
  51204. /** Y */
  51205. Y = 3,
  51206. /** LB */
  51207. LB = 4,
  51208. /** RB */
  51209. RB = 5,
  51210. /** LT */
  51211. LT = 6,
  51212. /** RT */
  51213. RT = 7,
  51214. /** Back */
  51215. Back = 8,
  51216. /** Start */
  51217. Start = 9,
  51218. /** LS */
  51219. LS = 10,
  51220. /** RS */
  51221. RS = 11,
  51222. /** DPadUp */
  51223. DPadUp = 12,
  51224. /** DPadDown */
  51225. DPadDown = 13,
  51226. /** DPadLeft */
  51227. DPadLeft = 14,
  51228. /** DRight */
  51229. DPadRight = 15,
  51230. /** Home */
  51231. Home = 16,
  51232. /** LStickXAxis */
  51233. LStickXAxis = 17,
  51234. /** LStickYAxis */
  51235. LStickYAxis = 18,
  51236. /** RStickXAxis */
  51237. RStickXAxis = 19,
  51238. /** RStickYAxis */
  51239. RStickYAxis = 20
  51240. }
  51241. /**
  51242. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51243. */
  51244. export enum SwitchInput {
  51245. /** B */
  51246. B = 0,
  51247. /** A */
  51248. A = 1,
  51249. /** Y */
  51250. Y = 2,
  51251. /** X */
  51252. X = 3,
  51253. /** L */
  51254. L = 4,
  51255. /** R */
  51256. R = 5,
  51257. /** ZL */
  51258. ZL = 6,
  51259. /** ZR */
  51260. ZR = 7,
  51261. /** Minus */
  51262. Minus = 8,
  51263. /** Plus */
  51264. Plus = 9,
  51265. /** LS */
  51266. LS = 10,
  51267. /** RS */
  51268. RS = 11,
  51269. /** DPadUp */
  51270. DPadUp = 12,
  51271. /** DPadDown */
  51272. DPadDown = 13,
  51273. /** DPadLeft */
  51274. DPadLeft = 14,
  51275. /** DRight */
  51276. DPadRight = 15,
  51277. /** Home */
  51278. Home = 16,
  51279. /** Capture */
  51280. Capture = 17,
  51281. /** LStickXAxis */
  51282. LStickXAxis = 18,
  51283. /** LStickYAxis */
  51284. LStickYAxis = 19,
  51285. /** RStickXAxis */
  51286. RStickXAxis = 20,
  51287. /** RStickYAxis */
  51288. RStickYAxis = 21
  51289. }
  51290. }
  51291. declare module BABYLON {
  51292. /**
  51293. * This class will take all inputs from Keyboard, Pointer, and
  51294. * any Gamepads and provide a polling system that all devices
  51295. * will use. This class assumes that there will only be one
  51296. * pointer device and one keyboard.
  51297. */
  51298. export class DeviceInputSystem implements IDisposable {
  51299. /**
  51300. * Callback to be triggered when a device is connected
  51301. */
  51302. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51303. /**
  51304. * Callback to be triggered when a device is disconnected
  51305. */
  51306. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51307. /**
  51308. * Callback to be triggered when event driven input is updated
  51309. */
  51310. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51311. private _inputs;
  51312. private _gamepads;
  51313. private _keyboardActive;
  51314. private _pointerActive;
  51315. private _elementToAttachTo;
  51316. private _keyboardDownEvent;
  51317. private _keyboardUpEvent;
  51318. private _pointerMoveEvent;
  51319. private _pointerDownEvent;
  51320. private _pointerUpEvent;
  51321. private _gamepadConnectedEvent;
  51322. private _gamepadDisconnectedEvent;
  51323. private static _MAX_KEYCODES;
  51324. private static _MAX_POINTER_INPUTS;
  51325. private constructor();
  51326. /**
  51327. * Creates a new DeviceInputSystem instance
  51328. * @param engine Engine to pull input element from
  51329. * @returns The new instance
  51330. */
  51331. static Create(engine: Engine): DeviceInputSystem;
  51332. /**
  51333. * Checks for current device input value, given an id and input index
  51334. * @param deviceName Id of connected device
  51335. * @param inputIndex Index of device input
  51336. * @returns Current value of input
  51337. */
  51338. /**
  51339. * Checks for current device input value, given an id and input index
  51340. * @param deviceType Enum specifiying device type
  51341. * @param deviceSlot "Slot" or index that device is referenced in
  51342. * @param inputIndex Id of input to be checked
  51343. * @returns Current value of input
  51344. */
  51345. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51346. /**
  51347. * Dispose of all the eventlisteners
  51348. */
  51349. dispose(): void;
  51350. /**
  51351. * Add device and inputs to device array
  51352. * @param deviceType Enum specifiying device type
  51353. * @param deviceSlot "Slot" or index that device is referenced in
  51354. * @param numberOfInputs Number of input entries to create for given device
  51355. */
  51356. private _registerDevice;
  51357. /**
  51358. * Given a specific device name, remove that device from the device map
  51359. * @param deviceType Enum specifiying device type
  51360. * @param deviceSlot "Slot" or index that device is referenced in
  51361. */
  51362. private _unregisterDevice;
  51363. /**
  51364. * Handle all actions that come from keyboard interaction
  51365. */
  51366. private _handleKeyActions;
  51367. /**
  51368. * Handle all actions that come from pointer interaction
  51369. */
  51370. private _handlePointerActions;
  51371. /**
  51372. * Handle all actions that come from gamepad interaction
  51373. */
  51374. private _handleGamepadActions;
  51375. /**
  51376. * Update all non-event based devices with each frame
  51377. * @param deviceType Enum specifiying device type
  51378. * @param deviceSlot "Slot" or index that device is referenced in
  51379. * @param inputIndex Id of input to be checked
  51380. */
  51381. private _updateDevice;
  51382. /**
  51383. * Gets DeviceType from the device name
  51384. * @param deviceName Name of Device from DeviceInputSystem
  51385. * @returns DeviceType enum value
  51386. */
  51387. private _getGamepadDeviceType;
  51388. }
  51389. }
  51390. declare module BABYLON {
  51391. /**
  51392. * Type to handle enforcement of inputs
  51393. */
  51394. 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;
  51395. }
  51396. declare module BABYLON {
  51397. /**
  51398. * Class that handles all input for a specific device
  51399. */
  51400. export class DeviceSource<T extends DeviceType> {
  51401. /** Type of device */
  51402. readonly deviceType: DeviceType;
  51403. /** "Slot" or index that device is referenced in */
  51404. readonly deviceSlot: number;
  51405. /**
  51406. * Observable to handle device input changes per device
  51407. */
  51408. readonly onInputChangedObservable: Observable<{
  51409. inputIndex: DeviceInput<T>;
  51410. previousState: Nullable<number>;
  51411. currentState: Nullable<number>;
  51412. }>;
  51413. private readonly _deviceInputSystem;
  51414. /**
  51415. * Default Constructor
  51416. * @param deviceInputSystem Reference to DeviceInputSystem
  51417. * @param deviceType Type of device
  51418. * @param deviceSlot "Slot" or index that device is referenced in
  51419. */
  51420. constructor(deviceInputSystem: DeviceInputSystem,
  51421. /** Type of device */
  51422. deviceType: DeviceType,
  51423. /** "Slot" or index that device is referenced in */
  51424. deviceSlot?: number);
  51425. /**
  51426. * Get input for specific input
  51427. * @param inputIndex index of specific input on device
  51428. * @returns Input value from DeviceInputSystem
  51429. */
  51430. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51431. }
  51432. /**
  51433. * Class to keep track of devices
  51434. */
  51435. export class DeviceSourceManager implements IDisposable {
  51436. /**
  51437. * Observable to be triggered when before a device is connected
  51438. */
  51439. readonly onBeforeDeviceConnectedObservable: Observable<{
  51440. deviceType: DeviceType;
  51441. deviceSlot: number;
  51442. }>;
  51443. /**
  51444. * Observable to be triggered when before a device is disconnected
  51445. */
  51446. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51447. deviceType: DeviceType;
  51448. deviceSlot: number;
  51449. }>;
  51450. /**
  51451. * Observable to be triggered when after a device is connected
  51452. */
  51453. readonly onAfterDeviceConnectedObservable: Observable<{
  51454. deviceType: DeviceType;
  51455. deviceSlot: number;
  51456. }>;
  51457. /**
  51458. * Observable to be triggered when after a device is disconnected
  51459. */
  51460. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51461. deviceType: DeviceType;
  51462. deviceSlot: number;
  51463. }>;
  51464. private readonly _devices;
  51465. private readonly _firstDevice;
  51466. private readonly _deviceInputSystem;
  51467. /**
  51468. * Default Constructor
  51469. * @param engine engine to pull input element from
  51470. */
  51471. constructor(engine: Engine);
  51472. /**
  51473. * Gets a DeviceSource, given a type and slot
  51474. * @param deviceType Enum specifying device type
  51475. * @param deviceSlot "Slot" or index that device is referenced in
  51476. * @returns DeviceSource object
  51477. */
  51478. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51479. /**
  51480. * Gets an array of DeviceSource objects for a given device type
  51481. * @param deviceType Enum specifying device type
  51482. * @returns Array of DeviceSource objects
  51483. */
  51484. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51485. /**
  51486. * Dispose of DeviceInputSystem and other parts
  51487. */
  51488. dispose(): void;
  51489. /**
  51490. * Function to add device name to device list
  51491. * @param deviceType Enum specifying device type
  51492. * @param deviceSlot "Slot" or index that device is referenced in
  51493. */
  51494. private _addDevice;
  51495. /**
  51496. * Function to remove device name to device list
  51497. * @param deviceType Enum specifying device type
  51498. * @param deviceSlot "Slot" or index that device is referenced in
  51499. */
  51500. private _removeDevice;
  51501. /**
  51502. * Updates array storing first connected device of each type
  51503. * @param type Type of Device
  51504. */
  51505. private _updateFirstDevices;
  51506. }
  51507. }
  51508. declare module BABYLON {
  51509. /**
  51510. * Options to create the null engine
  51511. */
  51512. export class NullEngineOptions {
  51513. /**
  51514. * Render width (Default: 512)
  51515. */
  51516. renderWidth: number;
  51517. /**
  51518. * Render height (Default: 256)
  51519. */
  51520. renderHeight: number;
  51521. /**
  51522. * Texture size (Default: 512)
  51523. */
  51524. textureSize: number;
  51525. /**
  51526. * If delta time between frames should be constant
  51527. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51528. */
  51529. deterministicLockstep: boolean;
  51530. /**
  51531. * Maximum about of steps between frames (Default: 4)
  51532. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51533. */
  51534. lockstepMaxSteps: number;
  51535. /**
  51536. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51537. */
  51538. useHighPrecisionMatrix?: boolean;
  51539. }
  51540. /**
  51541. * The null engine class provides support for headless version of babylon.js.
  51542. * This can be used in server side scenario or for testing purposes
  51543. */
  51544. export class NullEngine extends Engine {
  51545. private _options;
  51546. /**
  51547. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51548. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51549. * @returns true if engine is in deterministic lock step mode
  51550. */
  51551. isDeterministicLockStep(): boolean;
  51552. /**
  51553. * Gets the max steps when engine is running in deterministic lock step
  51554. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51555. * @returns the max steps
  51556. */
  51557. getLockstepMaxSteps(): number;
  51558. /**
  51559. * Gets the current hardware scaling level.
  51560. * By default the hardware scaling level is computed from the window device ratio.
  51561. * 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.
  51562. * @returns a number indicating the current hardware scaling level
  51563. */
  51564. getHardwareScalingLevel(): number;
  51565. constructor(options?: NullEngineOptions);
  51566. /**
  51567. * Creates a vertex buffer
  51568. * @param vertices the data for the vertex buffer
  51569. * @returns the new WebGL static buffer
  51570. */
  51571. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51572. /**
  51573. * Creates a new index buffer
  51574. * @param indices defines the content of the index buffer
  51575. * @param updatable defines if the index buffer must be updatable
  51576. * @returns a new webGL buffer
  51577. */
  51578. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51579. /**
  51580. * Clear the current render buffer or the current render target (if any is set up)
  51581. * @param color defines the color to use
  51582. * @param backBuffer defines if the back buffer must be cleared
  51583. * @param depth defines if the depth buffer must be cleared
  51584. * @param stencil defines if the stencil buffer must be cleared
  51585. */
  51586. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51587. /**
  51588. * Gets the current render width
  51589. * @param useScreen defines if screen size must be used (or the current render target if any)
  51590. * @returns a number defining the current render width
  51591. */
  51592. getRenderWidth(useScreen?: boolean): number;
  51593. /**
  51594. * Gets the current render height
  51595. * @param useScreen defines if screen size must be used (or the current render target if any)
  51596. * @returns a number defining the current render height
  51597. */
  51598. getRenderHeight(useScreen?: boolean): number;
  51599. /**
  51600. * Set the WebGL's viewport
  51601. * @param viewport defines the viewport element to be used
  51602. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51603. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51604. */
  51605. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51606. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51607. /**
  51608. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51609. * @param pipelineContext defines the pipeline context to use
  51610. * @param uniformsNames defines the list of uniform names
  51611. * @returns an array of webGL uniform locations
  51612. */
  51613. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51614. /**
  51615. * Gets the lsit of active attributes for a given webGL program
  51616. * @param pipelineContext defines the pipeline context to use
  51617. * @param attributesNames defines the list of attribute names to get
  51618. * @returns an array of indices indicating the offset of each attribute
  51619. */
  51620. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51621. /**
  51622. * Binds an effect to the webGL context
  51623. * @param effect defines the effect to bind
  51624. */
  51625. bindSamplers(effect: Effect): void;
  51626. /**
  51627. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51628. * @param effect defines the effect to activate
  51629. */
  51630. enableEffect(effect: Effect): void;
  51631. /**
  51632. * Set various states to the webGL context
  51633. * @param culling defines backface culling state
  51634. * @param zOffset defines the value to apply to zOffset (0 by default)
  51635. * @param force defines if states must be applied even if cache is up to date
  51636. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51637. */
  51638. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51639. /**
  51640. * Set the value of an uniform to an array of int32
  51641. * @param uniform defines the webGL uniform location where to store the value
  51642. * @param array defines the array of int32 to store
  51643. */
  51644. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51645. /**
  51646. * Set the value of an uniform to an array of int32 (stored as vec2)
  51647. * @param uniform defines the webGL uniform location where to store the value
  51648. * @param array defines the array of int32 to store
  51649. */
  51650. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51651. /**
  51652. * Set the value of an uniform to an array of int32 (stored as vec3)
  51653. * @param uniform defines the webGL uniform location where to store the value
  51654. * @param array defines the array of int32 to store
  51655. */
  51656. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51657. /**
  51658. * Set the value of an uniform to an array of int32 (stored as vec4)
  51659. * @param uniform defines the webGL uniform location where to store the value
  51660. * @param array defines the array of int32 to store
  51661. */
  51662. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51663. /**
  51664. * Set the value of an uniform to an array of float32
  51665. * @param uniform defines the webGL uniform location where to store the value
  51666. * @param array defines the array of float32 to store
  51667. */
  51668. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51669. /**
  51670. * Set the value of an uniform to an array of float32 (stored as vec2)
  51671. * @param uniform defines the webGL uniform location where to store the value
  51672. * @param array defines the array of float32 to store
  51673. */
  51674. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51675. /**
  51676. * Set the value of an uniform to an array of float32 (stored as vec3)
  51677. * @param uniform defines the webGL uniform location where to store the value
  51678. * @param array defines the array of float32 to store
  51679. */
  51680. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51681. /**
  51682. * Set the value of an uniform to an array of float32 (stored as vec4)
  51683. * @param uniform defines the webGL uniform location where to store the value
  51684. * @param array defines the array of float32 to store
  51685. */
  51686. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51687. /**
  51688. * Set the value of an uniform to an array of number
  51689. * @param uniform defines the webGL uniform location where to store the value
  51690. * @param array defines the array of number to store
  51691. */
  51692. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51693. /**
  51694. * Set the value of an uniform to an array of number (stored as vec2)
  51695. * @param uniform defines the webGL uniform location where to store the value
  51696. * @param array defines the array of number to store
  51697. */
  51698. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51699. /**
  51700. * Set the value of an uniform to an array of number (stored as vec3)
  51701. * @param uniform defines the webGL uniform location where to store the value
  51702. * @param array defines the array of number to store
  51703. */
  51704. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51705. /**
  51706. * Set the value of an uniform to an array of number (stored as vec4)
  51707. * @param uniform defines the webGL uniform location where to store the value
  51708. * @param array defines the array of number to store
  51709. */
  51710. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51711. /**
  51712. * Set the value of an uniform to an array of float32 (stored as matrices)
  51713. * @param uniform defines the webGL uniform location where to store the value
  51714. * @param matrices defines the array of float32 to store
  51715. */
  51716. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51717. /**
  51718. * Set the value of an uniform to a matrix (3x3)
  51719. * @param uniform defines the webGL uniform location where to store the value
  51720. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51721. */
  51722. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51723. /**
  51724. * Set the value of an uniform to a matrix (2x2)
  51725. * @param uniform defines the webGL uniform location where to store the value
  51726. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51727. */
  51728. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51729. /**
  51730. * Set the value of an uniform to a number (float)
  51731. * @param uniform defines the webGL uniform location where to store the value
  51732. * @param value defines the float number to store
  51733. */
  51734. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51735. /**
  51736. * Set the value of an uniform to a vec2
  51737. * @param uniform defines the webGL uniform location where to store the value
  51738. * @param x defines the 1st component of the value
  51739. * @param y defines the 2nd component of the value
  51740. */
  51741. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51742. /**
  51743. * Set the value of an uniform to a vec3
  51744. * @param uniform defines the webGL uniform location where to store the value
  51745. * @param x defines the 1st component of the value
  51746. * @param y defines the 2nd component of the value
  51747. * @param z defines the 3rd component of the value
  51748. */
  51749. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51750. /**
  51751. * Set the value of an uniform to a boolean
  51752. * @param uniform defines the webGL uniform location where to store the value
  51753. * @param bool defines the boolean to store
  51754. */
  51755. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51756. /**
  51757. * Set the value of an uniform to a vec4
  51758. * @param uniform defines the webGL uniform location where to store the value
  51759. * @param x defines the 1st component of the value
  51760. * @param y defines the 2nd component of the value
  51761. * @param z defines the 3rd component of the value
  51762. * @param w defines the 4th component of the value
  51763. */
  51764. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51765. /**
  51766. * Sets the current alpha mode
  51767. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51768. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51769. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51770. */
  51771. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51772. /**
  51773. * Bind webGl buffers directly to the webGL context
  51774. * @param vertexBuffers defines the vertex buffer to bind
  51775. * @param indexBuffer defines the index buffer to bind
  51776. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51777. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51778. * @param effect defines the effect associated with the vertex buffer
  51779. */
  51780. bindBuffers(vertexBuffers: {
  51781. [key: string]: VertexBuffer;
  51782. }, indexBuffer: DataBuffer, effect: Effect): void;
  51783. /**
  51784. * Force the entire cache to be cleared
  51785. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51786. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51787. */
  51788. wipeCaches(bruteForce?: boolean): void;
  51789. /**
  51790. * Send a draw order
  51791. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51792. * @param indexStart defines the starting index
  51793. * @param indexCount defines the number of index to draw
  51794. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51795. */
  51796. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51797. /**
  51798. * Draw a list of indexed primitives
  51799. * @param fillMode defines the primitive to use
  51800. * @param indexStart defines the starting index
  51801. * @param indexCount defines the number of index to draw
  51802. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51803. */
  51804. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51805. /**
  51806. * Draw a list of unindexed primitives
  51807. * @param fillMode defines the primitive to use
  51808. * @param verticesStart defines the index of first vertex to draw
  51809. * @param verticesCount defines the count of vertices to draw
  51810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51811. */
  51812. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51813. /** @hidden */
  51814. _createTexture(): WebGLTexture;
  51815. /** @hidden */
  51816. _releaseTexture(texture: InternalTexture): void;
  51817. /**
  51818. * Usually called from Texture.ts.
  51819. * Passed information to create a WebGLTexture
  51820. * @param urlArg defines a value which contains one of the following:
  51821. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51822. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51823. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51824. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51825. * @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)
  51826. * @param scene needed for loading to the correct scene
  51827. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51828. * @param onLoad optional callback to be called upon successful completion
  51829. * @param onError optional callback to be called upon failure
  51830. * @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
  51831. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51832. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51833. * @param forcedExtension defines the extension to use to pick the right loader
  51834. * @param mimeType defines an optional mime type
  51835. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51836. */
  51837. 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;
  51838. /**
  51839. * Creates a new render target texture
  51840. * @param size defines the size of the texture
  51841. * @param options defines the options used to create the texture
  51842. * @returns a new render target texture stored in an InternalTexture
  51843. */
  51844. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51845. /**
  51846. * Update the sampling mode of a given texture
  51847. * @param samplingMode defines the required sampling mode
  51848. * @param texture defines the texture to update
  51849. */
  51850. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51851. /**
  51852. * Binds the frame buffer to the specified texture.
  51853. * @param texture The texture to render to or null for the default canvas
  51854. * @param faceIndex The face of the texture to render to in case of cube texture
  51855. * @param requiredWidth The width of the target to render to
  51856. * @param requiredHeight The height of the target to render to
  51857. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51858. * @param lodLevel defines le lod level to bind to the frame buffer
  51859. */
  51860. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51861. /**
  51862. * Unbind the current render target texture from the webGL context
  51863. * @param texture defines the render target texture to unbind
  51864. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51865. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51866. */
  51867. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51868. /**
  51869. * Creates a dynamic vertex buffer
  51870. * @param vertices the data for the dynamic vertex buffer
  51871. * @returns the new WebGL dynamic buffer
  51872. */
  51873. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51874. /**
  51875. * Update the content of a dynamic texture
  51876. * @param texture defines the texture to update
  51877. * @param canvas defines the canvas containing the source
  51878. * @param invertY defines if data must be stored with Y axis inverted
  51879. * @param premulAlpha defines if alpha is stored as premultiplied
  51880. * @param format defines the format of the data
  51881. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51882. */
  51883. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51884. /**
  51885. * Gets a boolean indicating if all created effects are ready
  51886. * @returns true if all effects are ready
  51887. */
  51888. areAllEffectsReady(): boolean;
  51889. /**
  51890. * @hidden
  51891. * Get the current error code of the webGL context
  51892. * @returns the error code
  51893. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51894. */
  51895. getError(): number;
  51896. /** @hidden */
  51897. _getUnpackAlignement(): number;
  51898. /** @hidden */
  51899. _unpackFlipY(value: boolean): void;
  51900. /**
  51901. * Update a dynamic index buffer
  51902. * @param indexBuffer defines the target index buffer
  51903. * @param indices defines the data to update
  51904. * @param offset defines the offset in the target index buffer where update should start
  51905. */
  51906. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51907. /**
  51908. * Updates a dynamic vertex buffer.
  51909. * @param vertexBuffer the vertex buffer to update
  51910. * @param vertices the data used to update the vertex buffer
  51911. * @param byteOffset the byte offset of the data (optional)
  51912. * @param byteLength the byte length of the data (optional)
  51913. */
  51914. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51915. /** @hidden */
  51916. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51917. /** @hidden */
  51918. _bindTexture(channel: number, texture: InternalTexture): void;
  51919. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51920. /**
  51921. * 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
  51922. */
  51923. releaseEffects(): void;
  51924. displayLoadingUI(): void;
  51925. hideLoadingUI(): void;
  51926. /** @hidden */
  51927. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51928. /** @hidden */
  51929. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51930. /** @hidden */
  51931. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51932. /** @hidden */
  51933. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51934. }
  51935. }
  51936. declare module BABYLON {
  51937. /**
  51938. * @hidden
  51939. **/
  51940. export class _TimeToken {
  51941. _startTimeQuery: Nullable<WebGLQuery>;
  51942. _endTimeQuery: Nullable<WebGLQuery>;
  51943. _timeElapsedQuery: Nullable<WebGLQuery>;
  51944. _timeElapsedQueryEnded: boolean;
  51945. }
  51946. }
  51947. declare module BABYLON {
  51948. /** @hidden */
  51949. export class _OcclusionDataStorage {
  51950. /** @hidden */
  51951. occlusionInternalRetryCounter: number;
  51952. /** @hidden */
  51953. isOcclusionQueryInProgress: boolean;
  51954. /** @hidden */
  51955. isOccluded: boolean;
  51956. /** @hidden */
  51957. occlusionRetryCount: number;
  51958. /** @hidden */
  51959. occlusionType: number;
  51960. /** @hidden */
  51961. occlusionQueryAlgorithmType: number;
  51962. }
  51963. interface Engine {
  51964. /**
  51965. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51966. * @return the new query
  51967. */
  51968. createQuery(): WebGLQuery;
  51969. /**
  51970. * Delete and release a webGL query
  51971. * @param query defines the query to delete
  51972. * @return the current engine
  51973. */
  51974. deleteQuery(query: WebGLQuery): Engine;
  51975. /**
  51976. * Check if a given query has resolved and got its value
  51977. * @param query defines the query to check
  51978. * @returns true if the query got its value
  51979. */
  51980. isQueryResultAvailable(query: WebGLQuery): boolean;
  51981. /**
  51982. * Gets the value of a given query
  51983. * @param query defines the query to check
  51984. * @returns the value of the query
  51985. */
  51986. getQueryResult(query: WebGLQuery): number;
  51987. /**
  51988. * Initiates an occlusion query
  51989. * @param algorithmType defines the algorithm to use
  51990. * @param query defines the query to use
  51991. * @returns the current engine
  51992. * @see https://doc.babylonjs.com/features/occlusionquery
  51993. */
  51994. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51995. /**
  51996. * Ends an occlusion query
  51997. * @see https://doc.babylonjs.com/features/occlusionquery
  51998. * @param algorithmType defines the algorithm to use
  51999. * @returns the current engine
  52000. */
  52001. endOcclusionQuery(algorithmType: number): Engine;
  52002. /**
  52003. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52004. * Please note that only one query can be issued at a time
  52005. * @returns a time token used to track the time span
  52006. */
  52007. startTimeQuery(): Nullable<_TimeToken>;
  52008. /**
  52009. * Ends a time query
  52010. * @param token defines the token used to measure the time span
  52011. * @returns the time spent (in ns)
  52012. */
  52013. endTimeQuery(token: _TimeToken): int;
  52014. /** @hidden */
  52015. _currentNonTimestampToken: Nullable<_TimeToken>;
  52016. /** @hidden */
  52017. _createTimeQuery(): WebGLQuery;
  52018. /** @hidden */
  52019. _deleteTimeQuery(query: WebGLQuery): void;
  52020. /** @hidden */
  52021. _getGlAlgorithmType(algorithmType: number): number;
  52022. /** @hidden */
  52023. _getTimeQueryResult(query: WebGLQuery): any;
  52024. /** @hidden */
  52025. _getTimeQueryAvailability(query: WebGLQuery): any;
  52026. }
  52027. interface AbstractMesh {
  52028. /**
  52029. * Backing filed
  52030. * @hidden
  52031. */
  52032. __occlusionDataStorage: _OcclusionDataStorage;
  52033. /**
  52034. * Access property
  52035. * @hidden
  52036. */
  52037. _occlusionDataStorage: _OcclusionDataStorage;
  52038. /**
  52039. * 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.
  52040. * The default value is -1 which means don't break the query and wait till the result
  52041. * @see https://doc.babylonjs.com/features/occlusionquery
  52042. */
  52043. occlusionRetryCount: number;
  52044. /**
  52045. * 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:
  52046. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52047. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52048. * * 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.
  52049. * @see https://doc.babylonjs.com/features/occlusionquery
  52050. */
  52051. occlusionType: number;
  52052. /**
  52053. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52054. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52055. * * 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.
  52056. * @see https://doc.babylonjs.com/features/occlusionquery
  52057. */
  52058. occlusionQueryAlgorithmType: number;
  52059. /**
  52060. * 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
  52061. * @see https://doc.babylonjs.com/features/occlusionquery
  52062. */
  52063. isOccluded: boolean;
  52064. /**
  52065. * Flag to check the progress status of the query
  52066. * @see https://doc.babylonjs.com/features/occlusionquery
  52067. */
  52068. isOcclusionQueryInProgress: boolean;
  52069. }
  52070. }
  52071. declare module BABYLON {
  52072. /** @hidden */
  52073. export var _forceTransformFeedbackToBundle: boolean;
  52074. interface Engine {
  52075. /**
  52076. * Creates a webGL transform feedback object
  52077. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52078. * @returns the webGL transform feedback object
  52079. */
  52080. createTransformFeedback(): WebGLTransformFeedback;
  52081. /**
  52082. * Delete a webGL transform feedback object
  52083. * @param value defines the webGL transform feedback object to delete
  52084. */
  52085. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52086. /**
  52087. * Bind a webGL transform feedback object to the webgl context
  52088. * @param value defines the webGL transform feedback object to bind
  52089. */
  52090. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52091. /**
  52092. * Begins a transform feedback operation
  52093. * @param usePoints defines if points or triangles must be used
  52094. */
  52095. beginTransformFeedback(usePoints: boolean): void;
  52096. /**
  52097. * Ends a transform feedback operation
  52098. */
  52099. endTransformFeedback(): void;
  52100. /**
  52101. * Specify the varyings to use with transform feedback
  52102. * @param program defines the associated webGL program
  52103. * @param value defines the list of strings representing the varying names
  52104. */
  52105. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52106. /**
  52107. * Bind a webGL buffer for a transform feedback operation
  52108. * @param value defines the webGL buffer to bind
  52109. */
  52110. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52111. }
  52112. }
  52113. declare module BABYLON {
  52114. /**
  52115. * Class used to define an additional view for the engine
  52116. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52117. */
  52118. export class EngineView {
  52119. /** Defines the canvas where to render the view */
  52120. target: HTMLCanvasElement;
  52121. /** Defines an optional camera used to render the view (will use active camera else) */
  52122. camera?: Camera;
  52123. }
  52124. interface Engine {
  52125. /**
  52126. * Gets or sets the HTML element to use for attaching events
  52127. */
  52128. inputElement: Nullable<HTMLElement>;
  52129. /**
  52130. * Gets the current engine view
  52131. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52132. */
  52133. activeView: Nullable<EngineView>;
  52134. /** Gets or sets the list of views */
  52135. views: EngineView[];
  52136. /**
  52137. * Register a new child canvas
  52138. * @param canvas defines the canvas to register
  52139. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52140. * @returns the associated view
  52141. */
  52142. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52143. /**
  52144. * Remove a registered child canvas
  52145. * @param canvas defines the canvas to remove
  52146. * @returns the current engine
  52147. */
  52148. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52149. }
  52150. }
  52151. declare module BABYLON {
  52152. interface Engine {
  52153. /** @hidden */
  52154. _excludedCompressedTextures: string[];
  52155. /** @hidden */
  52156. _textureFormatInUse: string;
  52157. /**
  52158. * Gets the list of texture formats supported
  52159. */
  52160. readonly texturesSupported: Array<string>;
  52161. /**
  52162. * Gets the texture format in use
  52163. */
  52164. readonly textureFormatInUse: Nullable<string>;
  52165. /**
  52166. * Set the compressed texture extensions or file names to skip.
  52167. *
  52168. * @param skippedFiles defines the list of those texture files you want to skip
  52169. * Example: [".dds", ".env", "myfile.png"]
  52170. */
  52171. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52172. /**
  52173. * Set the compressed texture format to use, based on the formats you have, and the formats
  52174. * supported by the hardware / browser.
  52175. *
  52176. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52177. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52178. * to API arguments needed to compressed textures. This puts the burden on the container
  52179. * generator to house the arcane code for determining these for current & future formats.
  52180. *
  52181. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52182. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52183. *
  52184. * Note: The result of this call is not taken into account when a texture is base64.
  52185. *
  52186. * @param formatsAvailable defines the list of those format families you have created
  52187. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52188. *
  52189. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52190. * @returns The extension selected.
  52191. */
  52192. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52193. }
  52194. }
  52195. declare module BABYLON {
  52196. /**
  52197. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52198. */
  52199. export interface CubeMapInfo {
  52200. /**
  52201. * The pixel array for the front face.
  52202. * This is stored in format, left to right, up to down format.
  52203. */
  52204. front: Nullable<ArrayBufferView>;
  52205. /**
  52206. * The pixel array for the back face.
  52207. * This is stored in format, left to right, up to down format.
  52208. */
  52209. back: Nullable<ArrayBufferView>;
  52210. /**
  52211. * The pixel array for the left face.
  52212. * This is stored in format, left to right, up to down format.
  52213. */
  52214. left: Nullable<ArrayBufferView>;
  52215. /**
  52216. * The pixel array for the right face.
  52217. * This is stored in format, left to right, up to down format.
  52218. */
  52219. right: Nullable<ArrayBufferView>;
  52220. /**
  52221. * The pixel array for the up face.
  52222. * This is stored in format, left to right, up to down format.
  52223. */
  52224. up: Nullable<ArrayBufferView>;
  52225. /**
  52226. * The pixel array for the down face.
  52227. * This is stored in format, left to right, up to down format.
  52228. */
  52229. down: Nullable<ArrayBufferView>;
  52230. /**
  52231. * The size of the cubemap stored.
  52232. *
  52233. * Each faces will be size * size pixels.
  52234. */
  52235. size: number;
  52236. /**
  52237. * The format of the texture.
  52238. *
  52239. * RGBA, RGB.
  52240. */
  52241. format: number;
  52242. /**
  52243. * The type of the texture data.
  52244. *
  52245. * UNSIGNED_INT, FLOAT.
  52246. */
  52247. type: number;
  52248. /**
  52249. * Specifies whether the texture is in gamma space.
  52250. */
  52251. gammaSpace: boolean;
  52252. }
  52253. /**
  52254. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52255. */
  52256. export class PanoramaToCubeMapTools {
  52257. private static FACE_LEFT;
  52258. private static FACE_RIGHT;
  52259. private static FACE_FRONT;
  52260. private static FACE_BACK;
  52261. private static FACE_DOWN;
  52262. private static FACE_UP;
  52263. /**
  52264. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52265. *
  52266. * @param float32Array The source data.
  52267. * @param inputWidth The width of the input panorama.
  52268. * @param inputHeight The height of the input panorama.
  52269. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52270. * @return The cubemap data
  52271. */
  52272. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52273. private static CreateCubemapTexture;
  52274. private static CalcProjectionSpherical;
  52275. }
  52276. }
  52277. declare module BABYLON {
  52278. /**
  52279. * Helper class dealing with the extraction of spherical polynomial dataArray
  52280. * from a cube map.
  52281. */
  52282. export class CubeMapToSphericalPolynomialTools {
  52283. private static FileFaces;
  52284. /**
  52285. * Converts a texture to the according Spherical Polynomial data.
  52286. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52287. *
  52288. * @param texture The texture to extract the information from.
  52289. * @return The Spherical Polynomial data.
  52290. */
  52291. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52292. /**
  52293. * Converts a cubemap to the according Spherical Polynomial data.
  52294. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52295. *
  52296. * @param cubeInfo The Cube map to extract the information from.
  52297. * @return The Spherical Polynomial data.
  52298. */
  52299. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52300. }
  52301. }
  52302. declare module BABYLON {
  52303. interface BaseTexture {
  52304. /**
  52305. * Get the polynomial representation of the texture data.
  52306. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52307. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52308. */
  52309. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52310. }
  52311. }
  52312. declare module BABYLON {
  52313. /** @hidden */
  52314. export var rgbdEncodePixelShader: {
  52315. name: string;
  52316. shader: string;
  52317. };
  52318. }
  52319. declare module BABYLON {
  52320. /** @hidden */
  52321. export var rgbdDecodePixelShader: {
  52322. name: string;
  52323. shader: string;
  52324. };
  52325. }
  52326. declare module BABYLON {
  52327. /**
  52328. * Raw texture data and descriptor sufficient for WebGL texture upload
  52329. */
  52330. export interface EnvironmentTextureInfo {
  52331. /**
  52332. * Version of the environment map
  52333. */
  52334. version: number;
  52335. /**
  52336. * Width of image
  52337. */
  52338. width: number;
  52339. /**
  52340. * Irradiance information stored in the file.
  52341. */
  52342. irradiance: any;
  52343. /**
  52344. * Specular information stored in the file.
  52345. */
  52346. specular: any;
  52347. }
  52348. /**
  52349. * Defines One Image in the file. It requires only the position in the file
  52350. * as well as the length.
  52351. */
  52352. interface BufferImageData {
  52353. /**
  52354. * Length of the image data.
  52355. */
  52356. length: number;
  52357. /**
  52358. * Position of the data from the null terminator delimiting the end of the JSON.
  52359. */
  52360. position: number;
  52361. }
  52362. /**
  52363. * Defines the specular data enclosed in the file.
  52364. * This corresponds to the version 1 of the data.
  52365. */
  52366. export interface EnvironmentTextureSpecularInfoV1 {
  52367. /**
  52368. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52369. */
  52370. specularDataPosition?: number;
  52371. /**
  52372. * This contains all the images data needed to reconstruct the cubemap.
  52373. */
  52374. mipmaps: Array<BufferImageData>;
  52375. /**
  52376. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52377. */
  52378. lodGenerationScale: number;
  52379. }
  52380. /**
  52381. * Sets of helpers addressing the serialization and deserialization of environment texture
  52382. * stored in a BabylonJS env file.
  52383. * Those files are usually stored as .env files.
  52384. */
  52385. export class EnvironmentTextureTools {
  52386. /**
  52387. * Magic number identifying the env file.
  52388. */
  52389. private static _MagicBytes;
  52390. /**
  52391. * Gets the environment info from an env file.
  52392. * @param data The array buffer containing the .env bytes.
  52393. * @returns the environment file info (the json header) if successfully parsed.
  52394. */
  52395. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52396. /**
  52397. * Creates an environment texture from a loaded cube texture.
  52398. * @param texture defines the cube texture to convert in env file
  52399. * @return a promise containing the environment data if succesfull.
  52400. */
  52401. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52402. /**
  52403. * Creates a JSON representation of the spherical data.
  52404. * @param texture defines the texture containing the polynomials
  52405. * @return the JSON representation of the spherical info
  52406. */
  52407. private static _CreateEnvTextureIrradiance;
  52408. /**
  52409. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52410. * @param data the image data
  52411. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52412. * @return the views described by info providing access to the underlying buffer
  52413. */
  52414. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52415. /**
  52416. * Uploads the texture info contained in the env file to the GPU.
  52417. * @param texture defines the internal texture to upload to
  52418. * @param data defines the data to load
  52419. * @param info defines the texture info retrieved through the GetEnvInfo method
  52420. * @returns a promise
  52421. */
  52422. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52423. private static _OnImageReadyAsync;
  52424. /**
  52425. * Uploads the levels of image data to the GPU.
  52426. * @param texture defines the internal texture to upload to
  52427. * @param imageData defines the array buffer views of image data [mipmap][face]
  52428. * @returns a promise
  52429. */
  52430. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52431. /**
  52432. * Uploads spherical polynomials information to the texture.
  52433. * @param texture defines the texture we are trying to upload the information to
  52434. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52435. */
  52436. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52437. /** @hidden */
  52438. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52439. }
  52440. }
  52441. declare module BABYLON {
  52442. /**
  52443. * Class used to inline functions in shader code
  52444. */
  52445. export class ShaderCodeInliner {
  52446. private static readonly _RegexpFindFunctionNameAndType;
  52447. private _sourceCode;
  52448. private _functionDescr;
  52449. private _numMaxIterations;
  52450. /** Gets or sets the token used to mark the functions to inline */
  52451. inlineToken: string;
  52452. /** Gets or sets the debug mode */
  52453. debug: boolean;
  52454. /** Gets the code after the inlining process */
  52455. get code(): string;
  52456. /**
  52457. * Initializes the inliner
  52458. * @param sourceCode shader code source to inline
  52459. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52460. */
  52461. constructor(sourceCode: string, numMaxIterations?: number);
  52462. /**
  52463. * Start the processing of the shader code
  52464. */
  52465. processCode(): void;
  52466. private _collectFunctions;
  52467. private _processInlining;
  52468. private _extractBetweenMarkers;
  52469. private _skipWhitespaces;
  52470. private _removeComments;
  52471. private _replaceFunctionCallsByCode;
  52472. private _findBackward;
  52473. private _escapeRegExp;
  52474. private _replaceNames;
  52475. }
  52476. }
  52477. declare module BABYLON {
  52478. /**
  52479. * Container for accessors for natively-stored mesh data buffers.
  52480. */
  52481. class NativeDataBuffer extends DataBuffer {
  52482. /**
  52483. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52484. */
  52485. nativeIndexBuffer?: any;
  52486. /**
  52487. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52488. */
  52489. nativeVertexBuffer?: any;
  52490. }
  52491. /** @hidden */
  52492. class NativeTexture extends InternalTexture {
  52493. getInternalTexture(): InternalTexture;
  52494. getViewCount(): number;
  52495. }
  52496. /** @hidden */
  52497. export class NativeEngine extends Engine {
  52498. private readonly _native;
  52499. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52500. private readonly INVALID_HANDLE;
  52501. private _boundBuffersVertexArray;
  52502. getHardwareScalingLevel(): number;
  52503. constructor();
  52504. dispose(): void;
  52505. /**
  52506. * Can be used to override the current requestAnimationFrame requester.
  52507. * @hidden
  52508. */
  52509. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52510. /**
  52511. * Override default engine behavior.
  52512. * @param color
  52513. * @param backBuffer
  52514. * @param depth
  52515. * @param stencil
  52516. */
  52517. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52518. /**
  52519. * Gets host document
  52520. * @returns the host document object
  52521. */
  52522. getHostDocument(): Nullable<Document>;
  52523. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52524. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52525. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52526. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52527. [key: string]: VertexBuffer;
  52528. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52529. bindBuffers(vertexBuffers: {
  52530. [key: string]: VertexBuffer;
  52531. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52532. recordVertexArrayObject(vertexBuffers: {
  52533. [key: string]: VertexBuffer;
  52534. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52535. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52536. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52537. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52538. /**
  52539. * Draw a list of indexed primitives
  52540. * @param fillMode defines the primitive to use
  52541. * @param indexStart defines the starting index
  52542. * @param indexCount defines the number of index to draw
  52543. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52544. */
  52545. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52546. /**
  52547. * Draw a list of unindexed primitives
  52548. * @param fillMode defines the primitive to use
  52549. * @param verticesStart defines the index of first vertex to draw
  52550. * @param verticesCount defines the count of vertices to draw
  52551. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52552. */
  52553. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52554. createPipelineContext(): IPipelineContext;
  52555. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52556. /** @hidden */
  52557. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52558. /** @hidden */
  52559. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52560. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52561. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52562. protected _setProgram(program: WebGLProgram): void;
  52563. _releaseEffect(effect: Effect): void;
  52564. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52565. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52566. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52567. bindSamplers(effect: Effect): void;
  52568. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52569. getRenderWidth(useScreen?: boolean): number;
  52570. getRenderHeight(useScreen?: boolean): number;
  52571. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52572. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52573. /**
  52574. * Set the z offset to apply to current rendering
  52575. * @param value defines the offset to apply
  52576. */
  52577. setZOffset(value: number): void;
  52578. /**
  52579. * Gets the current value of the zOffset
  52580. * @returns the current zOffset state
  52581. */
  52582. getZOffset(): number;
  52583. /**
  52584. * Enable or disable depth buffering
  52585. * @param enable defines the state to set
  52586. */
  52587. setDepthBuffer(enable: boolean): void;
  52588. /**
  52589. * Gets a boolean indicating if depth writing is enabled
  52590. * @returns the current depth writing state
  52591. */
  52592. getDepthWrite(): boolean;
  52593. /**
  52594. * Enable or disable depth writing
  52595. * @param enable defines the state to set
  52596. */
  52597. setDepthWrite(enable: boolean): void;
  52598. /**
  52599. * Enable or disable color writing
  52600. * @param enable defines the state to set
  52601. */
  52602. setColorWrite(enable: boolean): void;
  52603. /**
  52604. * Gets a boolean indicating if color writing is enabled
  52605. * @returns the current color writing state
  52606. */
  52607. getColorWrite(): boolean;
  52608. /**
  52609. * Sets alpha constants used by some alpha blending modes
  52610. * @param r defines the red component
  52611. * @param g defines the green component
  52612. * @param b defines the blue component
  52613. * @param a defines the alpha component
  52614. */
  52615. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52616. /**
  52617. * Sets the current alpha mode
  52618. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52619. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52620. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52621. */
  52622. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52623. /**
  52624. * Gets the current alpha mode
  52625. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52626. * @returns the current alpha mode
  52627. */
  52628. getAlphaMode(): number;
  52629. setInt(uniform: WebGLUniformLocation, int: number): void;
  52630. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52631. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52632. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52633. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52634. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52635. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52636. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52637. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52638. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52639. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52640. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52641. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52642. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52643. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52644. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52645. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52646. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52647. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52648. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52649. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52650. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52651. wipeCaches(bruteForce?: boolean): void;
  52652. _createTexture(): WebGLTexture;
  52653. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52654. /**
  52655. * Usually called from Texture.ts.
  52656. * Passed information to create a WebGLTexture
  52657. * @param url defines a value which contains one of the following:
  52658. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52659. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52660. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52661. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52662. * @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)
  52663. * @param scene needed for loading to the correct scene
  52664. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52665. * @param onLoad optional callback to be called upon successful completion
  52666. * @param onError optional callback to be called upon failure
  52667. * @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
  52668. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52669. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52670. * @param forcedExtension defines the extension to use to pick the right loader
  52671. * @param mimeType defines an optional mime type
  52672. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52673. */
  52674. 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;
  52675. /**
  52676. * Creates a cube texture
  52677. * @param rootUrl defines the url where the files to load is located
  52678. * @param scene defines the current scene
  52679. * @param files defines the list of files to load (1 per face)
  52680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52681. * @param onLoad defines an optional callback raised when the texture is loaded
  52682. * @param onError defines an optional callback raised if there is an issue to load the texture
  52683. * @param format defines the format of the data
  52684. * @param forcedExtension defines the extension to use to pick the right loader
  52685. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52686. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52687. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52688. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52689. * @returns the cube texture as an InternalTexture
  52690. */
  52691. 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;
  52692. private _getSamplingFilter;
  52693. private static _GetNativeTextureFormat;
  52694. createRenderTargetTexture(size: number | {
  52695. width: number;
  52696. height: number;
  52697. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52698. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52699. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52700. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52701. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52702. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52703. /**
  52704. * Updates a dynamic vertex buffer.
  52705. * @param vertexBuffer the vertex buffer to update
  52706. * @param data the data used to update the vertex buffer
  52707. * @param byteOffset the byte offset of the data (optional)
  52708. * @param byteLength the byte length of the data (optional)
  52709. */
  52710. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52711. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52712. private _updateAnisotropicLevel;
  52713. private _getAddressMode;
  52714. /** @hidden */
  52715. _bindTexture(channel: number, texture: InternalTexture): void;
  52716. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52717. releaseEffects(): void;
  52718. /** @hidden */
  52719. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52720. /** @hidden */
  52721. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52722. /** @hidden */
  52723. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52724. /** @hidden */
  52725. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52726. }
  52727. }
  52728. declare module BABYLON {
  52729. /**
  52730. * Gather the list of clipboard event types as constants.
  52731. */
  52732. export class ClipboardEventTypes {
  52733. /**
  52734. * The clipboard event is fired when a copy command is active (pressed).
  52735. */
  52736. static readonly COPY: number;
  52737. /**
  52738. * The clipboard event is fired when a cut command is active (pressed).
  52739. */
  52740. static readonly CUT: number;
  52741. /**
  52742. * The clipboard event is fired when a paste command is active (pressed).
  52743. */
  52744. static readonly PASTE: number;
  52745. }
  52746. /**
  52747. * This class is used to store clipboard related info for the onClipboardObservable event.
  52748. */
  52749. export class ClipboardInfo {
  52750. /**
  52751. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52752. */
  52753. type: number;
  52754. /**
  52755. * Defines the related dom event
  52756. */
  52757. event: ClipboardEvent;
  52758. /**
  52759. *Creates an instance of ClipboardInfo.
  52760. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52761. * @param event Defines the related dom event
  52762. */
  52763. constructor(
  52764. /**
  52765. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52766. */
  52767. type: number,
  52768. /**
  52769. * Defines the related dom event
  52770. */
  52771. event: ClipboardEvent);
  52772. /**
  52773. * Get the clipboard event's type from the keycode.
  52774. * @param keyCode Defines the keyCode for the current keyboard event.
  52775. * @return {number}
  52776. */
  52777. static GetTypeFromCharacter(keyCode: number): number;
  52778. }
  52779. }
  52780. declare module BABYLON {
  52781. /**
  52782. * Google Daydream controller
  52783. */
  52784. export class DaydreamController extends WebVRController {
  52785. /**
  52786. * Base Url for the controller model.
  52787. */
  52788. static MODEL_BASE_URL: string;
  52789. /**
  52790. * File name for the controller model.
  52791. */
  52792. static MODEL_FILENAME: string;
  52793. /**
  52794. * Gamepad Id prefix used to identify Daydream Controller.
  52795. */
  52796. static readonly GAMEPAD_ID_PREFIX: string;
  52797. /**
  52798. * Creates a new DaydreamController from a gamepad
  52799. * @param vrGamepad the gamepad that the controller should be created from
  52800. */
  52801. constructor(vrGamepad: any);
  52802. /**
  52803. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52804. * @param scene scene in which to add meshes
  52805. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52806. */
  52807. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52808. /**
  52809. * Called once for each button that changed state since the last frame
  52810. * @param buttonIdx Which button index changed
  52811. * @param state New state of the button
  52812. * @param changes Which properties on the state changed since last frame
  52813. */
  52814. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52815. }
  52816. }
  52817. declare module BABYLON {
  52818. /**
  52819. * Gear VR Controller
  52820. */
  52821. export class GearVRController extends WebVRController {
  52822. /**
  52823. * Base Url for the controller model.
  52824. */
  52825. static MODEL_BASE_URL: string;
  52826. /**
  52827. * File name for the controller model.
  52828. */
  52829. static MODEL_FILENAME: string;
  52830. /**
  52831. * Gamepad Id prefix used to identify this controller.
  52832. */
  52833. static readonly GAMEPAD_ID_PREFIX: string;
  52834. private readonly _buttonIndexToObservableNameMap;
  52835. /**
  52836. * Creates a new GearVRController from a gamepad
  52837. * @param vrGamepad the gamepad that the controller should be created from
  52838. */
  52839. constructor(vrGamepad: any);
  52840. /**
  52841. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52842. * @param scene scene in which to add meshes
  52843. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52844. */
  52845. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52846. /**
  52847. * Called once for each button that changed state since the last frame
  52848. * @param buttonIdx Which button index changed
  52849. * @param state New state of the button
  52850. * @param changes Which properties on the state changed since last frame
  52851. */
  52852. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52853. }
  52854. }
  52855. declare module BABYLON {
  52856. /**
  52857. * Generic Controller
  52858. */
  52859. export class GenericController extends WebVRController {
  52860. /**
  52861. * Base Url for the controller model.
  52862. */
  52863. static readonly MODEL_BASE_URL: string;
  52864. /**
  52865. * File name for the controller model.
  52866. */
  52867. static readonly MODEL_FILENAME: string;
  52868. /**
  52869. * Creates a new GenericController from a gamepad
  52870. * @param vrGamepad the gamepad that the controller should be created from
  52871. */
  52872. constructor(vrGamepad: any);
  52873. /**
  52874. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52875. * @param scene scene in which to add meshes
  52876. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52877. */
  52878. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52879. /**
  52880. * Called once for each button that changed state since the last frame
  52881. * @param buttonIdx Which button index changed
  52882. * @param state New state of the button
  52883. * @param changes Which properties on the state changed since last frame
  52884. */
  52885. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52886. }
  52887. }
  52888. declare module BABYLON {
  52889. /**
  52890. * Oculus Touch Controller
  52891. */
  52892. export class OculusTouchController extends WebVRController {
  52893. /**
  52894. * Base Url for the controller model.
  52895. */
  52896. static MODEL_BASE_URL: string;
  52897. /**
  52898. * File name for the left controller model.
  52899. */
  52900. static MODEL_LEFT_FILENAME: string;
  52901. /**
  52902. * File name for the right controller model.
  52903. */
  52904. static MODEL_RIGHT_FILENAME: string;
  52905. /**
  52906. * Base Url for the Quest controller model.
  52907. */
  52908. static QUEST_MODEL_BASE_URL: string;
  52909. /**
  52910. * @hidden
  52911. * If the controllers are running on a device that needs the updated Quest controller models
  52912. */
  52913. static _IsQuest: boolean;
  52914. /**
  52915. * Fired when the secondary trigger on this controller is modified
  52916. */
  52917. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52918. /**
  52919. * Fired when the thumb rest on this controller is modified
  52920. */
  52921. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52922. /**
  52923. * Creates a new OculusTouchController from a gamepad
  52924. * @param vrGamepad the gamepad that the controller should be created from
  52925. */
  52926. constructor(vrGamepad: any);
  52927. /**
  52928. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52929. * @param scene scene in which to add meshes
  52930. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52931. */
  52932. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52933. /**
  52934. * Fired when the A button on this controller is modified
  52935. */
  52936. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52937. /**
  52938. * Fired when the B button on this controller is modified
  52939. */
  52940. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52941. /**
  52942. * Fired when the X button on this controller is modified
  52943. */
  52944. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52945. /**
  52946. * Fired when the Y button on this controller is modified
  52947. */
  52948. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52949. /**
  52950. * Called once for each button that changed state since the last frame
  52951. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52952. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52953. * 2) secondary trigger (same)
  52954. * 3) A (right) X (left), touch, pressed = value
  52955. * 4) B / Y
  52956. * 5) thumb rest
  52957. * @param buttonIdx Which button index changed
  52958. * @param state New state of the button
  52959. * @param changes Which properties on the state changed since last frame
  52960. */
  52961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52962. }
  52963. }
  52964. declare module BABYLON {
  52965. /**
  52966. * Vive Controller
  52967. */
  52968. export class ViveController extends WebVRController {
  52969. /**
  52970. * Base Url for the controller model.
  52971. */
  52972. static MODEL_BASE_URL: string;
  52973. /**
  52974. * File name for the controller model.
  52975. */
  52976. static MODEL_FILENAME: string;
  52977. /**
  52978. * Creates a new ViveController from a gamepad
  52979. * @param vrGamepad the gamepad that the controller should be created from
  52980. */
  52981. constructor(vrGamepad: any);
  52982. /**
  52983. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52984. * @param scene scene in which to add meshes
  52985. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52986. */
  52987. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52988. /**
  52989. * Fired when the left button on this controller is modified
  52990. */
  52991. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52992. /**
  52993. * Fired when the right button on this controller is modified
  52994. */
  52995. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52996. /**
  52997. * Fired when the menu button on this controller is modified
  52998. */
  52999. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53000. /**
  53001. * Called once for each button that changed state since the last frame
  53002. * Vive mapping:
  53003. * 0: touchpad
  53004. * 1: trigger
  53005. * 2: left AND right buttons
  53006. * 3: menu button
  53007. * @param buttonIdx Which button index changed
  53008. * @param state New state of the button
  53009. * @param changes Which properties on the state changed since last frame
  53010. */
  53011. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53012. }
  53013. }
  53014. declare module BABYLON {
  53015. /**
  53016. * Defines the WindowsMotionController object that the state of the windows motion controller
  53017. */
  53018. export class WindowsMotionController extends WebVRController {
  53019. /**
  53020. * The base url used to load the left and right controller models
  53021. */
  53022. static MODEL_BASE_URL: string;
  53023. /**
  53024. * The name of the left controller model file
  53025. */
  53026. static MODEL_LEFT_FILENAME: string;
  53027. /**
  53028. * The name of the right controller model file
  53029. */
  53030. static MODEL_RIGHT_FILENAME: string;
  53031. /**
  53032. * The controller name prefix for this controller type
  53033. */
  53034. static readonly GAMEPAD_ID_PREFIX: string;
  53035. /**
  53036. * The controller id pattern for this controller type
  53037. */
  53038. private static readonly GAMEPAD_ID_PATTERN;
  53039. private _loadedMeshInfo;
  53040. protected readonly _mapping: {
  53041. buttons: string[];
  53042. buttonMeshNames: {
  53043. trigger: string;
  53044. menu: string;
  53045. grip: string;
  53046. thumbstick: string;
  53047. trackpad: string;
  53048. };
  53049. buttonObservableNames: {
  53050. trigger: string;
  53051. menu: string;
  53052. grip: string;
  53053. thumbstick: string;
  53054. trackpad: string;
  53055. };
  53056. axisMeshNames: string[];
  53057. pointingPoseMeshName: string;
  53058. };
  53059. /**
  53060. * Fired when the trackpad on this controller is clicked
  53061. */
  53062. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53063. /**
  53064. * Fired when the trackpad on this controller is modified
  53065. */
  53066. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53067. /**
  53068. * The current x and y values of this controller's trackpad
  53069. */
  53070. trackpad: StickValues;
  53071. /**
  53072. * Creates a new WindowsMotionController from a gamepad
  53073. * @param vrGamepad the gamepad that the controller should be created from
  53074. */
  53075. constructor(vrGamepad: any);
  53076. /**
  53077. * Fired when the trigger on this controller is modified
  53078. */
  53079. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53080. /**
  53081. * Fired when the menu button on this controller is modified
  53082. */
  53083. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53084. /**
  53085. * Fired when the grip button on this controller is modified
  53086. */
  53087. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53088. /**
  53089. * Fired when the thumbstick button on this controller is modified
  53090. */
  53091. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53092. /**
  53093. * Fired when the touchpad button on this controller is modified
  53094. */
  53095. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53096. /**
  53097. * Fired when the touchpad values on this controller are modified
  53098. */
  53099. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53100. protected _updateTrackpad(): void;
  53101. /**
  53102. * Called once per frame by the engine.
  53103. */
  53104. update(): void;
  53105. /**
  53106. * Called once for each button that changed state since the last frame
  53107. * @param buttonIdx Which button index changed
  53108. * @param state New state of the button
  53109. * @param changes Which properties on the state changed since last frame
  53110. */
  53111. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53112. /**
  53113. * Moves the buttons on the controller mesh based on their current state
  53114. * @param buttonName the name of the button to move
  53115. * @param buttonValue the value of the button which determines the buttons new position
  53116. */
  53117. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53118. /**
  53119. * Moves the axis on the controller mesh based on its current state
  53120. * @param axis the index of the axis
  53121. * @param axisValue the value of the axis which determines the meshes new position
  53122. * @hidden
  53123. */
  53124. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53125. /**
  53126. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53127. * @param scene scene in which to add meshes
  53128. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53129. */
  53130. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53131. /**
  53132. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53133. * can be transformed by button presses and axes values, based on this._mapping.
  53134. *
  53135. * @param scene scene in which the meshes exist
  53136. * @param meshes list of meshes that make up the controller model to process
  53137. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53138. */
  53139. private processModel;
  53140. private createMeshInfo;
  53141. /**
  53142. * Gets the ray of the controller in the direction the controller is pointing
  53143. * @param length the length the resulting ray should be
  53144. * @returns a ray in the direction the controller is pointing
  53145. */
  53146. getForwardRay(length?: number): Ray;
  53147. /**
  53148. * Disposes of the controller
  53149. */
  53150. dispose(): void;
  53151. }
  53152. /**
  53153. * This class represents a new windows motion controller in XR.
  53154. */
  53155. export class XRWindowsMotionController extends WindowsMotionController {
  53156. /**
  53157. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53158. */
  53159. protected readonly _mapping: {
  53160. buttons: string[];
  53161. buttonMeshNames: {
  53162. trigger: string;
  53163. menu: string;
  53164. grip: string;
  53165. thumbstick: string;
  53166. trackpad: string;
  53167. };
  53168. buttonObservableNames: {
  53169. trigger: string;
  53170. menu: string;
  53171. grip: string;
  53172. thumbstick: string;
  53173. trackpad: string;
  53174. };
  53175. axisMeshNames: string[];
  53176. pointingPoseMeshName: string;
  53177. };
  53178. /**
  53179. * Construct a new XR-Based windows motion controller
  53180. *
  53181. * @param gamepadInfo the gamepad object from the browser
  53182. */
  53183. constructor(gamepadInfo: any);
  53184. /**
  53185. * holds the thumbstick values (X,Y)
  53186. */
  53187. thumbstickValues: StickValues;
  53188. /**
  53189. * Fired when the thumbstick on this controller is clicked
  53190. */
  53191. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53192. /**
  53193. * Fired when the thumbstick on this controller is modified
  53194. */
  53195. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53196. /**
  53197. * Fired when the touchpad button on this controller is modified
  53198. */
  53199. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53200. /**
  53201. * Fired when the touchpad values on this controller are modified
  53202. */
  53203. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53204. /**
  53205. * Fired when the thumbstick button on this controller is modified
  53206. * here to prevent breaking changes
  53207. */
  53208. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53209. /**
  53210. * updating the thumbstick(!) and not the trackpad.
  53211. * This is named this way due to the difference between WebVR and XR and to avoid
  53212. * changing the parent class.
  53213. */
  53214. protected _updateTrackpad(): void;
  53215. /**
  53216. * Disposes the class with joy
  53217. */
  53218. dispose(): void;
  53219. }
  53220. }
  53221. declare module BABYLON {
  53222. /**
  53223. * Class containing static functions to help procedurally build meshes
  53224. */
  53225. export class PolyhedronBuilder {
  53226. /**
  53227. * Creates a polyhedron mesh
  53228. * * 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
  53229. * * The parameter `size` (positive float, default 1) sets the polygon size
  53230. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53231. * * 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`
  53232. * * 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
  53233. * * 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)`)
  53234. * * 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
  53235. * * 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
  53236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53237. * * 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
  53238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53239. * @param name defines the name of the mesh
  53240. * @param options defines the options used to create the mesh
  53241. * @param scene defines the hosting scene
  53242. * @returns the polyhedron mesh
  53243. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53244. */
  53245. static CreatePolyhedron(name: string, options: {
  53246. type?: number;
  53247. size?: number;
  53248. sizeX?: number;
  53249. sizeY?: number;
  53250. sizeZ?: number;
  53251. custom?: any;
  53252. faceUV?: Vector4[];
  53253. faceColors?: Color4[];
  53254. flat?: boolean;
  53255. updatable?: boolean;
  53256. sideOrientation?: number;
  53257. frontUVs?: Vector4;
  53258. backUVs?: Vector4;
  53259. }, scene?: Nullable<Scene>): Mesh;
  53260. }
  53261. }
  53262. declare module BABYLON {
  53263. /**
  53264. * Gizmo that enables scaling a mesh along 3 axis
  53265. */
  53266. export class ScaleGizmo extends Gizmo {
  53267. /**
  53268. * Internal gizmo used for interactions on the x axis
  53269. */
  53270. xGizmo: AxisScaleGizmo;
  53271. /**
  53272. * Internal gizmo used for interactions on the y axis
  53273. */
  53274. yGizmo: AxisScaleGizmo;
  53275. /**
  53276. * Internal gizmo used for interactions on the z axis
  53277. */
  53278. zGizmo: AxisScaleGizmo;
  53279. /**
  53280. * Internal gizmo used to scale all axis equally
  53281. */
  53282. uniformScaleGizmo: AxisScaleGizmo;
  53283. private _meshAttached;
  53284. private _nodeAttached;
  53285. private _updateGizmoRotationToMatchAttachedMesh;
  53286. private _snapDistance;
  53287. private _scaleRatio;
  53288. private _uniformScalingMesh;
  53289. private _octahedron;
  53290. private _sensitivity;
  53291. /** Fires an event when any of it's sub gizmos are dragged */
  53292. onDragStartObservable: Observable<unknown>;
  53293. /** Fires an event when any of it's sub gizmos are released from dragging */
  53294. onDragEndObservable: Observable<unknown>;
  53295. get attachedMesh(): Nullable<AbstractMesh>;
  53296. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53297. get attachedNode(): Nullable<Node>;
  53298. set attachedNode(node: Nullable<Node>);
  53299. /**
  53300. * Creates a ScaleGizmo
  53301. * @param gizmoLayer The utility layer the gizmo will be added to
  53302. * @param thickness display gizmo axis thickness
  53303. */
  53304. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53305. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53306. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53307. /**
  53308. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53309. */
  53310. set snapDistance(value: number);
  53311. get snapDistance(): number;
  53312. /**
  53313. * Ratio for the scale of the gizmo (Default: 1)
  53314. */
  53315. set scaleRatio(value: number);
  53316. get scaleRatio(): number;
  53317. /**
  53318. * Sensitivity factor for dragging (Default: 1)
  53319. */
  53320. set sensitivity(value: number);
  53321. get sensitivity(): number;
  53322. /**
  53323. * Disposes of the gizmo
  53324. */
  53325. dispose(): void;
  53326. }
  53327. }
  53328. declare module BABYLON {
  53329. /**
  53330. * Single axis scale gizmo
  53331. */
  53332. export class AxisScaleGizmo extends Gizmo {
  53333. /**
  53334. * Drag behavior responsible for the gizmos dragging interactions
  53335. */
  53336. dragBehavior: PointerDragBehavior;
  53337. private _pointerObserver;
  53338. /**
  53339. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53340. */
  53341. snapDistance: number;
  53342. /**
  53343. * Event that fires each time the gizmo snaps to a new location.
  53344. * * snapDistance is the the change in distance
  53345. */
  53346. onSnapObservable: Observable<{
  53347. snapDistance: number;
  53348. }>;
  53349. /**
  53350. * If the scaling operation should be done on all axis (default: false)
  53351. */
  53352. uniformScaling: boolean;
  53353. /**
  53354. * Custom sensitivity value for the drag strength
  53355. */
  53356. sensitivity: number;
  53357. private _isEnabled;
  53358. private _parent;
  53359. private _arrow;
  53360. private _coloredMaterial;
  53361. private _hoverMaterial;
  53362. /**
  53363. * Creates an AxisScaleGizmo
  53364. * @param gizmoLayer The utility layer the gizmo will be added to
  53365. * @param dragAxis The axis which the gizmo will be able to scale on
  53366. * @param color The color of the gizmo
  53367. * @param thickness display gizmo axis thickness
  53368. */
  53369. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53370. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53371. /**
  53372. * If the gizmo is enabled
  53373. */
  53374. set isEnabled(value: boolean);
  53375. get isEnabled(): boolean;
  53376. /**
  53377. * Disposes of the gizmo
  53378. */
  53379. dispose(): void;
  53380. /**
  53381. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53382. * @param mesh The mesh to replace the default mesh of the gizmo
  53383. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53384. */
  53385. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53386. }
  53387. }
  53388. declare module BABYLON {
  53389. /**
  53390. * Bounding box gizmo
  53391. */
  53392. export class BoundingBoxGizmo extends Gizmo {
  53393. private _lineBoundingBox;
  53394. private _rotateSpheresParent;
  53395. private _scaleBoxesParent;
  53396. private _boundingDimensions;
  53397. private _renderObserver;
  53398. private _pointerObserver;
  53399. private _scaleDragSpeed;
  53400. private _tmpQuaternion;
  53401. private _tmpVector;
  53402. private _tmpRotationMatrix;
  53403. /**
  53404. * 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)
  53405. */
  53406. ignoreChildren: boolean;
  53407. /**
  53408. * 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)
  53409. */
  53410. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53411. /**
  53412. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53413. */
  53414. rotationSphereSize: number;
  53415. /**
  53416. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53417. */
  53418. scaleBoxSize: number;
  53419. /**
  53420. * 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)
  53421. */
  53422. fixedDragMeshScreenSize: boolean;
  53423. /**
  53424. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53425. */
  53426. fixedDragMeshScreenSizeDistanceFactor: number;
  53427. /**
  53428. * Fired when a rotation sphere or scale box is dragged
  53429. */
  53430. onDragStartObservable: Observable<{}>;
  53431. /**
  53432. * Fired when a scale box is dragged
  53433. */
  53434. onScaleBoxDragObservable: Observable<{}>;
  53435. /**
  53436. * Fired when a scale box drag is ended
  53437. */
  53438. onScaleBoxDragEndObservable: Observable<{}>;
  53439. /**
  53440. * Fired when a rotation sphere is dragged
  53441. */
  53442. onRotationSphereDragObservable: Observable<{}>;
  53443. /**
  53444. * Fired when a rotation sphere drag is ended
  53445. */
  53446. onRotationSphereDragEndObservable: Observable<{}>;
  53447. /**
  53448. * 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)
  53449. */
  53450. scalePivot: Nullable<Vector3>;
  53451. /**
  53452. * Mesh used as a pivot to rotate the attached node
  53453. */
  53454. private _anchorMesh;
  53455. private _existingMeshScale;
  53456. private _dragMesh;
  53457. private pointerDragBehavior;
  53458. private coloredMaterial;
  53459. private hoverColoredMaterial;
  53460. /**
  53461. * Sets the color of the bounding box gizmo
  53462. * @param color the color to set
  53463. */
  53464. setColor(color: Color3): void;
  53465. /**
  53466. * Creates an BoundingBoxGizmo
  53467. * @param gizmoLayer The utility layer the gizmo will be added to
  53468. * @param color The color of the gizmo
  53469. */
  53470. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53471. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53472. private _selectNode;
  53473. /**
  53474. * Updates the bounding box information for the Gizmo
  53475. */
  53476. updateBoundingBox(): void;
  53477. private _updateRotationSpheres;
  53478. private _updateScaleBoxes;
  53479. /**
  53480. * Enables rotation on the specified axis and disables rotation on the others
  53481. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53482. */
  53483. setEnabledRotationAxis(axis: string): void;
  53484. /**
  53485. * Enables/disables scaling
  53486. * @param enable if scaling should be enabled
  53487. * @param homogeneousScaling defines if scaling should only be homogeneous
  53488. */
  53489. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53490. private _updateDummy;
  53491. /**
  53492. * Enables a pointer drag behavior on the bounding box of the gizmo
  53493. */
  53494. enableDragBehavior(): void;
  53495. /**
  53496. * Disposes of the gizmo
  53497. */
  53498. dispose(): void;
  53499. /**
  53500. * 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)
  53501. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53502. * @returns the bounding box mesh with the passed in mesh as a child
  53503. */
  53504. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53505. /**
  53506. * CustomMeshes are not supported by this gizmo
  53507. * @param mesh The mesh to replace the default mesh of the gizmo
  53508. */
  53509. setCustomMesh(mesh: Mesh): void;
  53510. }
  53511. }
  53512. declare module BABYLON {
  53513. /**
  53514. * Single plane rotation gizmo
  53515. */
  53516. export class PlaneRotationGizmo extends Gizmo {
  53517. /**
  53518. * Drag behavior responsible for the gizmos dragging interactions
  53519. */
  53520. dragBehavior: PointerDragBehavior;
  53521. private _pointerObserver;
  53522. /**
  53523. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53524. */
  53525. snapDistance: number;
  53526. /**
  53527. * Event that fires each time the gizmo snaps to a new location.
  53528. * * snapDistance is the the change in distance
  53529. */
  53530. onSnapObservable: Observable<{
  53531. snapDistance: number;
  53532. }>;
  53533. private _isEnabled;
  53534. private _parent;
  53535. /**
  53536. * Creates a PlaneRotationGizmo
  53537. * @param gizmoLayer The utility layer the gizmo will be added to
  53538. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53539. * @param color The color of the gizmo
  53540. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53541. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53542. * @param thickness display gizmo axis thickness
  53543. */
  53544. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53545. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53546. /**
  53547. * If the gizmo is enabled
  53548. */
  53549. set isEnabled(value: boolean);
  53550. get isEnabled(): boolean;
  53551. /**
  53552. * Disposes of the gizmo
  53553. */
  53554. dispose(): void;
  53555. }
  53556. }
  53557. declare module BABYLON {
  53558. /**
  53559. * Gizmo that enables rotating a mesh along 3 axis
  53560. */
  53561. export class RotationGizmo extends Gizmo {
  53562. /**
  53563. * Internal gizmo used for interactions on the x axis
  53564. */
  53565. xGizmo: PlaneRotationGizmo;
  53566. /**
  53567. * Internal gizmo used for interactions on the y axis
  53568. */
  53569. yGizmo: PlaneRotationGizmo;
  53570. /**
  53571. * Internal gizmo used for interactions on the z axis
  53572. */
  53573. zGizmo: PlaneRotationGizmo;
  53574. /** Fires an event when any of it's sub gizmos are dragged */
  53575. onDragStartObservable: Observable<unknown>;
  53576. /** Fires an event when any of it's sub gizmos are released from dragging */
  53577. onDragEndObservable: Observable<unknown>;
  53578. private _meshAttached;
  53579. private _nodeAttached;
  53580. get attachedMesh(): Nullable<AbstractMesh>;
  53581. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53582. get attachedNode(): Nullable<Node>;
  53583. set attachedNode(node: Nullable<Node>);
  53584. /**
  53585. * Creates a RotationGizmo
  53586. * @param gizmoLayer The utility layer the gizmo will be added to
  53587. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53588. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53589. * @param thickness display gizmo axis thickness
  53590. */
  53591. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53592. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53593. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53594. /**
  53595. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53596. */
  53597. set snapDistance(value: number);
  53598. get snapDistance(): number;
  53599. /**
  53600. * Ratio for the scale of the gizmo (Default: 1)
  53601. */
  53602. set scaleRatio(value: number);
  53603. get scaleRatio(): number;
  53604. /**
  53605. * Disposes of the gizmo
  53606. */
  53607. dispose(): void;
  53608. /**
  53609. * CustomMeshes are not supported by this gizmo
  53610. * @param mesh The mesh to replace the default mesh of the gizmo
  53611. */
  53612. setCustomMesh(mesh: Mesh): void;
  53613. }
  53614. }
  53615. declare module BABYLON {
  53616. /**
  53617. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53618. */
  53619. export class GizmoManager implements IDisposable {
  53620. private scene;
  53621. /**
  53622. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53623. */
  53624. gizmos: {
  53625. positionGizmo: Nullable<PositionGizmo>;
  53626. rotationGizmo: Nullable<RotationGizmo>;
  53627. scaleGizmo: Nullable<ScaleGizmo>;
  53628. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53629. };
  53630. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53631. clearGizmoOnEmptyPointerEvent: boolean;
  53632. /** Fires an event when the manager is attached to a mesh */
  53633. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53634. /** Fires an event when the manager is attached to a node */
  53635. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53636. private _gizmosEnabled;
  53637. private _pointerObserver;
  53638. private _attachedMesh;
  53639. private _attachedNode;
  53640. private _boundingBoxColor;
  53641. private _defaultUtilityLayer;
  53642. private _defaultKeepDepthUtilityLayer;
  53643. private _thickness;
  53644. /**
  53645. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53646. */
  53647. boundingBoxDragBehavior: SixDofDragBehavior;
  53648. /**
  53649. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53650. */
  53651. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53652. /**
  53653. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53654. */
  53655. attachableNodes: Nullable<Array<Node>>;
  53656. /**
  53657. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53658. */
  53659. usePointerToAttachGizmos: boolean;
  53660. /**
  53661. * Utility layer that the bounding box gizmo belongs to
  53662. */
  53663. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53664. /**
  53665. * Utility layer that all gizmos besides bounding box belong to
  53666. */
  53667. get utilityLayer(): UtilityLayerRenderer;
  53668. /**
  53669. * Instatiates a gizmo manager
  53670. * @param scene the scene to overlay the gizmos on top of
  53671. * @param thickness display gizmo axis thickness
  53672. */
  53673. constructor(scene: Scene, thickness?: number);
  53674. /**
  53675. * Attaches a set of gizmos to the specified mesh
  53676. * @param mesh The mesh the gizmo's should be attached to
  53677. */
  53678. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53679. /**
  53680. * Attaches a set of gizmos to the specified node
  53681. * @param node The node the gizmo's should be attached to
  53682. */
  53683. attachToNode(node: Nullable<Node>): void;
  53684. /**
  53685. * If the position gizmo is enabled
  53686. */
  53687. set positionGizmoEnabled(value: boolean);
  53688. get positionGizmoEnabled(): boolean;
  53689. /**
  53690. * If the rotation gizmo is enabled
  53691. */
  53692. set rotationGizmoEnabled(value: boolean);
  53693. get rotationGizmoEnabled(): boolean;
  53694. /**
  53695. * If the scale gizmo is enabled
  53696. */
  53697. set scaleGizmoEnabled(value: boolean);
  53698. get scaleGizmoEnabled(): boolean;
  53699. /**
  53700. * If the boundingBox gizmo is enabled
  53701. */
  53702. set boundingBoxGizmoEnabled(value: boolean);
  53703. get boundingBoxGizmoEnabled(): boolean;
  53704. /**
  53705. * Disposes of the gizmo manager
  53706. */
  53707. dispose(): void;
  53708. }
  53709. }
  53710. declare module BABYLON {
  53711. /**
  53712. * A directional light is defined by a direction (what a surprise!).
  53713. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53714. * 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.
  53715. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53716. */
  53717. export class DirectionalLight extends ShadowLight {
  53718. private _shadowFrustumSize;
  53719. /**
  53720. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53721. */
  53722. get shadowFrustumSize(): number;
  53723. /**
  53724. * Specifies a fix frustum size for the shadow generation.
  53725. */
  53726. set shadowFrustumSize(value: number);
  53727. private _shadowOrthoScale;
  53728. /**
  53729. * Gets the shadow projection scale against the optimal computed one.
  53730. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53731. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53732. */
  53733. get shadowOrthoScale(): number;
  53734. /**
  53735. * Sets the shadow projection scale against the optimal computed one.
  53736. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53737. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53738. */
  53739. set shadowOrthoScale(value: number);
  53740. /**
  53741. * Automatically compute the projection matrix to best fit (including all the casters)
  53742. * on each frame.
  53743. */
  53744. autoUpdateExtends: boolean;
  53745. /**
  53746. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53747. * on each frame. autoUpdateExtends must be set to true for this to work
  53748. */
  53749. autoCalcShadowZBounds: boolean;
  53750. private _orthoLeft;
  53751. private _orthoRight;
  53752. private _orthoTop;
  53753. private _orthoBottom;
  53754. /**
  53755. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53756. * The directional light is emitted from everywhere in the given direction.
  53757. * It can cast shadows.
  53758. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53759. * @param name The friendly name of the light
  53760. * @param direction The direction of the light
  53761. * @param scene The scene the light belongs to
  53762. */
  53763. constructor(name: string, direction: Vector3, scene: Scene);
  53764. /**
  53765. * Returns the string "DirectionalLight".
  53766. * @return The class name
  53767. */
  53768. getClassName(): string;
  53769. /**
  53770. * Returns the integer 1.
  53771. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53772. */
  53773. getTypeID(): number;
  53774. /**
  53775. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53776. * Returns the DirectionalLight Shadow projection matrix.
  53777. */
  53778. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53779. /**
  53780. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53781. * Returns the DirectionalLight Shadow projection matrix.
  53782. */
  53783. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53784. /**
  53785. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53786. * Returns the DirectionalLight Shadow projection matrix.
  53787. */
  53788. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53789. protected _buildUniformLayout(): void;
  53790. /**
  53791. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53792. * @param effect The effect to update
  53793. * @param lightIndex The index of the light in the effect to update
  53794. * @returns The directional light
  53795. */
  53796. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53797. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53798. /**
  53799. * Gets the minZ used for shadow according to both the scene and the light.
  53800. *
  53801. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53802. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53803. * @param activeCamera The camera we are returning the min for
  53804. * @returns the depth min z
  53805. */
  53806. getDepthMinZ(activeCamera: Camera): number;
  53807. /**
  53808. * Gets the maxZ used for shadow according to both the scene and the light.
  53809. *
  53810. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53811. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53812. * @param activeCamera The camera we are returning the max for
  53813. * @returns the depth max z
  53814. */
  53815. getDepthMaxZ(activeCamera: Camera): number;
  53816. /**
  53817. * Prepares the list of defines specific to the light type.
  53818. * @param defines the list of defines
  53819. * @param lightIndex defines the index of the light for the effect
  53820. */
  53821. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53822. }
  53823. }
  53824. declare module BABYLON {
  53825. /**
  53826. * Class containing static functions to help procedurally build meshes
  53827. */
  53828. export class HemisphereBuilder {
  53829. /**
  53830. * Creates a hemisphere mesh
  53831. * @param name defines the name of the mesh
  53832. * @param options defines the options used to create the mesh
  53833. * @param scene defines the hosting scene
  53834. * @returns the hemisphere mesh
  53835. */
  53836. static CreateHemisphere(name: string, options: {
  53837. segments?: number;
  53838. diameter?: number;
  53839. sideOrientation?: number;
  53840. }, scene: any): Mesh;
  53841. }
  53842. }
  53843. declare module BABYLON {
  53844. /**
  53845. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53846. * These values define a cone of light starting from the position, emitting toward the direction.
  53847. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53848. * and the exponent defines the speed of the decay of the light with distance (reach).
  53849. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53850. */
  53851. export class SpotLight extends ShadowLight {
  53852. private _angle;
  53853. private _innerAngle;
  53854. private _cosHalfAngle;
  53855. private _lightAngleScale;
  53856. private _lightAngleOffset;
  53857. /**
  53858. * Gets the cone angle of the spot light in Radians.
  53859. */
  53860. get angle(): number;
  53861. /**
  53862. * Sets the cone angle of the spot light in Radians.
  53863. */
  53864. set angle(value: number);
  53865. /**
  53866. * Only used in gltf falloff mode, this defines the angle where
  53867. * the directional falloff will start before cutting at angle which could be seen
  53868. * as outer angle.
  53869. */
  53870. get innerAngle(): number;
  53871. /**
  53872. * Only used in gltf falloff mode, this defines the angle where
  53873. * the directional falloff will start before cutting at angle which could be seen
  53874. * as outer angle.
  53875. */
  53876. set innerAngle(value: number);
  53877. private _shadowAngleScale;
  53878. /**
  53879. * Allows scaling the angle of the light for shadow generation only.
  53880. */
  53881. get shadowAngleScale(): number;
  53882. /**
  53883. * Allows scaling the angle of the light for shadow generation only.
  53884. */
  53885. set shadowAngleScale(value: number);
  53886. /**
  53887. * The light decay speed with the distance from the emission spot.
  53888. */
  53889. exponent: number;
  53890. private _projectionTextureMatrix;
  53891. /**
  53892. * Allows reading the projecton texture
  53893. */
  53894. get projectionTextureMatrix(): Matrix;
  53895. protected _projectionTextureLightNear: number;
  53896. /**
  53897. * Gets the near clip of the Spotlight for texture projection.
  53898. */
  53899. get projectionTextureLightNear(): number;
  53900. /**
  53901. * Sets the near clip of the Spotlight for texture projection.
  53902. */
  53903. set projectionTextureLightNear(value: number);
  53904. protected _projectionTextureLightFar: number;
  53905. /**
  53906. * Gets the far clip of the Spotlight for texture projection.
  53907. */
  53908. get projectionTextureLightFar(): number;
  53909. /**
  53910. * Sets the far clip of the Spotlight for texture projection.
  53911. */
  53912. set projectionTextureLightFar(value: number);
  53913. protected _projectionTextureUpDirection: Vector3;
  53914. /**
  53915. * Gets the Up vector of the Spotlight for texture projection.
  53916. */
  53917. get projectionTextureUpDirection(): Vector3;
  53918. /**
  53919. * Sets the Up vector of the Spotlight for texture projection.
  53920. */
  53921. set projectionTextureUpDirection(value: Vector3);
  53922. private _projectionTexture;
  53923. /**
  53924. * Gets the projection texture of the light.
  53925. */
  53926. get projectionTexture(): Nullable<BaseTexture>;
  53927. /**
  53928. * Sets the projection texture of the light.
  53929. */
  53930. set projectionTexture(value: Nullable<BaseTexture>);
  53931. private _projectionTextureViewLightDirty;
  53932. private _projectionTextureProjectionLightDirty;
  53933. private _projectionTextureDirty;
  53934. private _projectionTextureViewTargetVector;
  53935. private _projectionTextureViewLightMatrix;
  53936. private _projectionTextureProjectionLightMatrix;
  53937. private _projectionTextureScalingMatrix;
  53938. /**
  53939. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53940. * It can cast shadows.
  53941. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53942. * @param name The light friendly name
  53943. * @param position The position of the spot light in the scene
  53944. * @param direction The direction of the light in the scene
  53945. * @param angle The cone angle of the light in Radians
  53946. * @param exponent The light decay speed with the distance from the emission spot
  53947. * @param scene The scene the lights belongs to
  53948. */
  53949. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53950. /**
  53951. * Returns the string "SpotLight".
  53952. * @returns the class name
  53953. */
  53954. getClassName(): string;
  53955. /**
  53956. * Returns the integer 2.
  53957. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53958. */
  53959. getTypeID(): number;
  53960. /**
  53961. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53962. */
  53963. protected _setDirection(value: Vector3): void;
  53964. /**
  53965. * Overrides the position setter to recompute the projection texture view light Matrix.
  53966. */
  53967. protected _setPosition(value: Vector3): void;
  53968. /**
  53969. * 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.
  53970. * Returns the SpotLight.
  53971. */
  53972. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53973. protected _computeProjectionTextureViewLightMatrix(): void;
  53974. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53975. /**
  53976. * Main function for light texture projection matrix computing.
  53977. */
  53978. protected _computeProjectionTextureMatrix(): void;
  53979. protected _buildUniformLayout(): void;
  53980. private _computeAngleValues;
  53981. /**
  53982. * Sets the passed Effect "effect" with the Light textures.
  53983. * @param effect The effect to update
  53984. * @param lightIndex The index of the light in the effect to update
  53985. * @returns The light
  53986. */
  53987. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53988. /**
  53989. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53990. * @param effect The effect to update
  53991. * @param lightIndex The index of the light in the effect to update
  53992. * @returns The spot light
  53993. */
  53994. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53995. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53996. /**
  53997. * Disposes the light and the associated resources.
  53998. */
  53999. dispose(): void;
  54000. /**
  54001. * Prepares the list of defines specific to the light type.
  54002. * @param defines the list of defines
  54003. * @param lightIndex defines the index of the light for the effect
  54004. */
  54005. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54006. }
  54007. }
  54008. declare module BABYLON {
  54009. /**
  54010. * Gizmo that enables viewing a light
  54011. */
  54012. export class LightGizmo extends Gizmo {
  54013. private _lightMesh;
  54014. private _material;
  54015. private _cachedPosition;
  54016. private _cachedForward;
  54017. private _attachedMeshParent;
  54018. /**
  54019. * Creates a LightGizmo
  54020. * @param gizmoLayer The utility layer the gizmo will be added to
  54021. */
  54022. constructor(gizmoLayer?: UtilityLayerRenderer);
  54023. private _light;
  54024. /**
  54025. * The light that the gizmo is attached to
  54026. */
  54027. set light(light: Nullable<Light>);
  54028. get light(): Nullable<Light>;
  54029. /**
  54030. * Gets the material used to render the light gizmo
  54031. */
  54032. get material(): StandardMaterial;
  54033. /**
  54034. * @hidden
  54035. * Updates the gizmo to match the attached mesh's position/rotation
  54036. */
  54037. protected _update(): void;
  54038. private static _Scale;
  54039. /**
  54040. * Creates the lines for a light mesh
  54041. */
  54042. private static _CreateLightLines;
  54043. /**
  54044. * Disposes of the light gizmo
  54045. */
  54046. dispose(): void;
  54047. private static _CreateHemisphericLightMesh;
  54048. private static _CreatePointLightMesh;
  54049. private static _CreateSpotLightMesh;
  54050. private static _CreateDirectionalLightMesh;
  54051. }
  54052. }
  54053. declare module BABYLON {
  54054. /**
  54055. * Gizmo that enables viewing a camera
  54056. */
  54057. export class CameraGizmo extends Gizmo {
  54058. private _cameraMesh;
  54059. private _cameraLinesMesh;
  54060. private _material;
  54061. /**
  54062. * Creates a CameraGizmo
  54063. * @param gizmoLayer The utility layer the gizmo will be added to
  54064. */
  54065. constructor(gizmoLayer?: UtilityLayerRenderer);
  54066. private _camera;
  54067. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54068. get displayFrustum(): boolean;
  54069. set displayFrustum(value: boolean);
  54070. /**
  54071. * The camera that the gizmo is attached to
  54072. */
  54073. set camera(camera: Nullable<Camera>);
  54074. get camera(): Nullable<Camera>;
  54075. /**
  54076. * Gets the material used to render the camera gizmo
  54077. */
  54078. get material(): StandardMaterial;
  54079. /**
  54080. * @hidden
  54081. * Updates the gizmo to match the attached mesh's position/rotation
  54082. */
  54083. protected _update(): void;
  54084. private static _Scale;
  54085. private _invProjection;
  54086. /**
  54087. * Disposes of the camera gizmo
  54088. */
  54089. dispose(): void;
  54090. private static _CreateCameraMesh;
  54091. private static _CreateCameraFrustum;
  54092. }
  54093. }
  54094. declare module BABYLON {
  54095. /** @hidden */
  54096. export var backgroundFragmentDeclaration: {
  54097. name: string;
  54098. shader: string;
  54099. };
  54100. }
  54101. declare module BABYLON {
  54102. /** @hidden */
  54103. export var backgroundUboDeclaration: {
  54104. name: string;
  54105. shader: string;
  54106. };
  54107. }
  54108. declare module BABYLON {
  54109. /** @hidden */
  54110. export var backgroundPixelShader: {
  54111. name: string;
  54112. shader: string;
  54113. };
  54114. }
  54115. declare module BABYLON {
  54116. /** @hidden */
  54117. export var backgroundVertexDeclaration: {
  54118. name: string;
  54119. shader: string;
  54120. };
  54121. }
  54122. declare module BABYLON {
  54123. /** @hidden */
  54124. export var backgroundVertexShader: {
  54125. name: string;
  54126. shader: string;
  54127. };
  54128. }
  54129. declare module BABYLON {
  54130. /**
  54131. * Background material used to create an efficient environement around your scene.
  54132. */
  54133. export class BackgroundMaterial extends PushMaterial {
  54134. /**
  54135. * Standard reflectance value at parallel view angle.
  54136. */
  54137. static StandardReflectance0: number;
  54138. /**
  54139. * Standard reflectance value at grazing angle.
  54140. */
  54141. static StandardReflectance90: number;
  54142. protected _primaryColor: Color3;
  54143. /**
  54144. * Key light Color (multiply against the environement texture)
  54145. */
  54146. primaryColor: Color3;
  54147. protected __perceptualColor: Nullable<Color3>;
  54148. /**
  54149. * Experimental Internal Use Only.
  54150. *
  54151. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54152. * This acts as a helper to set the primary color to a more "human friendly" value.
  54153. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54154. * output color as close as possible from the chosen value.
  54155. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54156. * part of lighting setup.)
  54157. */
  54158. get _perceptualColor(): Nullable<Color3>;
  54159. set _perceptualColor(value: Nullable<Color3>);
  54160. protected _primaryColorShadowLevel: float;
  54161. /**
  54162. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54163. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54164. */
  54165. get primaryColorShadowLevel(): float;
  54166. set primaryColorShadowLevel(value: float);
  54167. protected _primaryColorHighlightLevel: float;
  54168. /**
  54169. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54170. * The primary color is used at the level chosen to define what the white area would look.
  54171. */
  54172. get primaryColorHighlightLevel(): float;
  54173. set primaryColorHighlightLevel(value: float);
  54174. protected _reflectionTexture: Nullable<BaseTexture>;
  54175. /**
  54176. * Reflection Texture used in the material.
  54177. * Should be author in a specific way for the best result (refer to the documentation).
  54178. */
  54179. reflectionTexture: Nullable<BaseTexture>;
  54180. protected _reflectionBlur: float;
  54181. /**
  54182. * Reflection Texture level of blur.
  54183. *
  54184. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54185. * texture twice.
  54186. */
  54187. reflectionBlur: float;
  54188. protected _diffuseTexture: Nullable<BaseTexture>;
  54189. /**
  54190. * Diffuse Texture used in the material.
  54191. * Should be author in a specific way for the best result (refer to the documentation).
  54192. */
  54193. diffuseTexture: Nullable<BaseTexture>;
  54194. protected _shadowLights: Nullable<IShadowLight[]>;
  54195. /**
  54196. * Specify the list of lights casting shadow on the material.
  54197. * All scene shadow lights will be included if null.
  54198. */
  54199. shadowLights: Nullable<IShadowLight[]>;
  54200. protected _shadowLevel: float;
  54201. /**
  54202. * Helps adjusting the shadow to a softer level if required.
  54203. * 0 means black shadows and 1 means no shadows.
  54204. */
  54205. shadowLevel: float;
  54206. protected _sceneCenter: Vector3;
  54207. /**
  54208. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54209. * It is usually zero but might be interesting to modify according to your setup.
  54210. */
  54211. sceneCenter: Vector3;
  54212. protected _opacityFresnel: boolean;
  54213. /**
  54214. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54215. * This helps ensuring a nice transition when the camera goes under the ground.
  54216. */
  54217. opacityFresnel: boolean;
  54218. protected _reflectionFresnel: boolean;
  54219. /**
  54220. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54221. * This helps adding a mirror texture on the ground.
  54222. */
  54223. reflectionFresnel: boolean;
  54224. protected _reflectionFalloffDistance: number;
  54225. /**
  54226. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54227. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54228. */
  54229. reflectionFalloffDistance: number;
  54230. protected _reflectionAmount: number;
  54231. /**
  54232. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54233. */
  54234. reflectionAmount: number;
  54235. protected _reflectionReflectance0: number;
  54236. /**
  54237. * This specifies the weight of the reflection at grazing angle.
  54238. */
  54239. reflectionReflectance0: number;
  54240. protected _reflectionReflectance90: number;
  54241. /**
  54242. * This specifies the weight of the reflection at a perpendicular point of view.
  54243. */
  54244. reflectionReflectance90: number;
  54245. /**
  54246. * Sets the reflection reflectance fresnel values according to the default standard
  54247. * empirically know to work well :-)
  54248. */
  54249. set reflectionStandardFresnelWeight(value: number);
  54250. protected _useRGBColor: boolean;
  54251. /**
  54252. * Helps to directly use the maps channels instead of their level.
  54253. */
  54254. useRGBColor: boolean;
  54255. protected _enableNoise: boolean;
  54256. /**
  54257. * This helps reducing the banding effect that could occur on the background.
  54258. */
  54259. enableNoise: boolean;
  54260. /**
  54261. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54262. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54263. * Recommended to be keep at 1.0 except for special cases.
  54264. */
  54265. get fovMultiplier(): number;
  54266. set fovMultiplier(value: number);
  54267. private _fovMultiplier;
  54268. /**
  54269. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54270. */
  54271. useEquirectangularFOV: boolean;
  54272. private _maxSimultaneousLights;
  54273. /**
  54274. * Number of Simultaneous lights allowed on the material.
  54275. */
  54276. maxSimultaneousLights: int;
  54277. private _shadowOnly;
  54278. /**
  54279. * Make the material only render shadows
  54280. */
  54281. shadowOnly: boolean;
  54282. /**
  54283. * Default configuration related to image processing available in the Background Material.
  54284. */
  54285. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54286. /**
  54287. * Keep track of the image processing observer to allow dispose and replace.
  54288. */
  54289. private _imageProcessingObserver;
  54290. /**
  54291. * Attaches a new image processing configuration to the PBR Material.
  54292. * @param configuration (if null the scene configuration will be use)
  54293. */
  54294. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54295. /**
  54296. * Gets the image processing configuration used either in this material.
  54297. */
  54298. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54299. /**
  54300. * Sets the Default image processing configuration used either in the this material.
  54301. *
  54302. * If sets to null, the scene one is in use.
  54303. */
  54304. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54305. /**
  54306. * Gets wether the color curves effect is enabled.
  54307. */
  54308. get cameraColorCurvesEnabled(): boolean;
  54309. /**
  54310. * Sets wether the color curves effect is enabled.
  54311. */
  54312. set cameraColorCurvesEnabled(value: boolean);
  54313. /**
  54314. * Gets wether the color grading effect is enabled.
  54315. */
  54316. get cameraColorGradingEnabled(): boolean;
  54317. /**
  54318. * Gets wether the color grading effect is enabled.
  54319. */
  54320. set cameraColorGradingEnabled(value: boolean);
  54321. /**
  54322. * Gets wether tonemapping is enabled or not.
  54323. */
  54324. get cameraToneMappingEnabled(): boolean;
  54325. /**
  54326. * Sets wether tonemapping is enabled or not
  54327. */
  54328. set cameraToneMappingEnabled(value: boolean);
  54329. /**
  54330. * The camera exposure used on this material.
  54331. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54332. * This corresponds to a photographic exposure.
  54333. */
  54334. get cameraExposure(): float;
  54335. /**
  54336. * The camera exposure used on this material.
  54337. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54338. * This corresponds to a photographic exposure.
  54339. */
  54340. set cameraExposure(value: float);
  54341. /**
  54342. * Gets The camera contrast used on this material.
  54343. */
  54344. get cameraContrast(): float;
  54345. /**
  54346. * Sets The camera contrast used on this material.
  54347. */
  54348. set cameraContrast(value: float);
  54349. /**
  54350. * Gets the Color Grading 2D Lookup Texture.
  54351. */
  54352. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54353. /**
  54354. * Sets the Color Grading 2D Lookup Texture.
  54355. */
  54356. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54357. /**
  54358. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54359. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54360. * 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;
  54361. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54362. */
  54363. get cameraColorCurves(): Nullable<ColorCurves>;
  54364. /**
  54365. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54366. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54367. * 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;
  54368. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54369. */
  54370. set cameraColorCurves(value: Nullable<ColorCurves>);
  54371. /**
  54372. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54373. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54374. */
  54375. switchToBGR: boolean;
  54376. private _renderTargets;
  54377. private _reflectionControls;
  54378. private _white;
  54379. private _primaryShadowColor;
  54380. private _primaryHighlightColor;
  54381. /**
  54382. * Instantiates a Background Material in the given scene
  54383. * @param name The friendly name of the material
  54384. * @param scene The scene to add the material to
  54385. */
  54386. constructor(name: string, scene: Scene);
  54387. /**
  54388. * Gets a boolean indicating that current material needs to register RTT
  54389. */
  54390. get hasRenderTargetTextures(): boolean;
  54391. /**
  54392. * The entire material has been created in order to prevent overdraw.
  54393. * @returns false
  54394. */
  54395. needAlphaTesting(): boolean;
  54396. /**
  54397. * The entire material has been created in order to prevent overdraw.
  54398. * @returns true if blending is enable
  54399. */
  54400. needAlphaBlending(): boolean;
  54401. /**
  54402. * Checks wether the material is ready to be rendered for a given mesh.
  54403. * @param mesh The mesh to render
  54404. * @param subMesh The submesh to check against
  54405. * @param useInstances Specify wether or not the material is used with instances
  54406. * @returns true if all the dependencies are ready (Textures, Effects...)
  54407. */
  54408. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54409. /**
  54410. * Compute the primary color according to the chosen perceptual color.
  54411. */
  54412. private _computePrimaryColorFromPerceptualColor;
  54413. /**
  54414. * Compute the highlights and shadow colors according to their chosen levels.
  54415. */
  54416. private _computePrimaryColors;
  54417. /**
  54418. * Build the uniform buffer used in the material.
  54419. */
  54420. buildUniformLayout(): void;
  54421. /**
  54422. * Unbind the material.
  54423. */
  54424. unbind(): void;
  54425. /**
  54426. * Bind only the world matrix to the material.
  54427. * @param world The world matrix to bind.
  54428. */
  54429. bindOnlyWorldMatrix(world: Matrix): void;
  54430. /**
  54431. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54432. * @param world The world matrix to bind.
  54433. * @param subMesh The submesh to bind for.
  54434. */
  54435. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54436. /**
  54437. * Checks to see if a texture is used in the material.
  54438. * @param texture - Base texture to use.
  54439. * @returns - Boolean specifying if a texture is used in the material.
  54440. */
  54441. hasTexture(texture: BaseTexture): boolean;
  54442. /**
  54443. * Dispose the material.
  54444. * @param forceDisposeEffect Force disposal of the associated effect.
  54445. * @param forceDisposeTextures Force disposal of the associated textures.
  54446. */
  54447. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54448. /**
  54449. * Clones the material.
  54450. * @param name The cloned name.
  54451. * @returns The cloned material.
  54452. */
  54453. clone(name: string): BackgroundMaterial;
  54454. /**
  54455. * Serializes the current material to its JSON representation.
  54456. * @returns The JSON representation.
  54457. */
  54458. serialize(): any;
  54459. /**
  54460. * Gets the class name of the material
  54461. * @returns "BackgroundMaterial"
  54462. */
  54463. getClassName(): string;
  54464. /**
  54465. * Parse a JSON input to create back a background material.
  54466. * @param source The JSON data to parse
  54467. * @param scene The scene to create the parsed material in
  54468. * @param rootUrl The root url of the assets the material depends upon
  54469. * @returns the instantiated BackgroundMaterial.
  54470. */
  54471. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54472. }
  54473. }
  54474. declare module BABYLON {
  54475. /**
  54476. * Represents the different options available during the creation of
  54477. * a Environment helper.
  54478. *
  54479. * This can control the default ground, skybox and image processing setup of your scene.
  54480. */
  54481. export interface IEnvironmentHelperOptions {
  54482. /**
  54483. * Specifies whether or not to create a ground.
  54484. * True by default.
  54485. */
  54486. createGround: boolean;
  54487. /**
  54488. * Specifies the ground size.
  54489. * 15 by default.
  54490. */
  54491. groundSize: number;
  54492. /**
  54493. * The texture used on the ground for the main color.
  54494. * Comes from the BabylonJS CDN by default.
  54495. *
  54496. * Remarks: Can be either a texture or a url.
  54497. */
  54498. groundTexture: string | BaseTexture;
  54499. /**
  54500. * The color mixed in the ground texture by default.
  54501. * BabylonJS clearColor by default.
  54502. */
  54503. groundColor: Color3;
  54504. /**
  54505. * Specifies the ground opacity.
  54506. * 1 by default.
  54507. */
  54508. groundOpacity: number;
  54509. /**
  54510. * Enables the ground to receive shadows.
  54511. * True by default.
  54512. */
  54513. enableGroundShadow: boolean;
  54514. /**
  54515. * Helps preventing the shadow to be fully black on the ground.
  54516. * 0.5 by default.
  54517. */
  54518. groundShadowLevel: number;
  54519. /**
  54520. * Creates a mirror texture attach to the ground.
  54521. * false by default.
  54522. */
  54523. enableGroundMirror: boolean;
  54524. /**
  54525. * Specifies the ground mirror size ratio.
  54526. * 0.3 by default as the default kernel is 64.
  54527. */
  54528. groundMirrorSizeRatio: number;
  54529. /**
  54530. * Specifies the ground mirror blur kernel size.
  54531. * 64 by default.
  54532. */
  54533. groundMirrorBlurKernel: number;
  54534. /**
  54535. * Specifies the ground mirror visibility amount.
  54536. * 1 by default
  54537. */
  54538. groundMirrorAmount: number;
  54539. /**
  54540. * Specifies the ground mirror reflectance weight.
  54541. * This uses the standard weight of the background material to setup the fresnel effect
  54542. * of the mirror.
  54543. * 1 by default.
  54544. */
  54545. groundMirrorFresnelWeight: number;
  54546. /**
  54547. * Specifies the ground mirror Falloff distance.
  54548. * This can helps reducing the size of the reflection.
  54549. * 0 by Default.
  54550. */
  54551. groundMirrorFallOffDistance: number;
  54552. /**
  54553. * Specifies the ground mirror texture type.
  54554. * Unsigned Int by Default.
  54555. */
  54556. groundMirrorTextureType: number;
  54557. /**
  54558. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54559. * the shown objects.
  54560. */
  54561. groundYBias: number;
  54562. /**
  54563. * Specifies whether or not to create a skybox.
  54564. * True by default.
  54565. */
  54566. createSkybox: boolean;
  54567. /**
  54568. * Specifies the skybox size.
  54569. * 20 by default.
  54570. */
  54571. skyboxSize: number;
  54572. /**
  54573. * The texture used on the skybox for the main color.
  54574. * Comes from the BabylonJS CDN by default.
  54575. *
  54576. * Remarks: Can be either a texture or a url.
  54577. */
  54578. skyboxTexture: string | BaseTexture;
  54579. /**
  54580. * The color mixed in the skybox texture by default.
  54581. * BabylonJS clearColor by default.
  54582. */
  54583. skyboxColor: Color3;
  54584. /**
  54585. * The background rotation around the Y axis of the scene.
  54586. * This helps aligning the key lights of your scene with the background.
  54587. * 0 by default.
  54588. */
  54589. backgroundYRotation: number;
  54590. /**
  54591. * Compute automatically the size of the elements to best fit with the scene.
  54592. */
  54593. sizeAuto: boolean;
  54594. /**
  54595. * Default position of the rootMesh if autoSize is not true.
  54596. */
  54597. rootPosition: Vector3;
  54598. /**
  54599. * Sets up the image processing in the scene.
  54600. * true by default.
  54601. */
  54602. setupImageProcessing: boolean;
  54603. /**
  54604. * The texture used as your environment texture in the scene.
  54605. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54606. *
  54607. * Remarks: Can be either a texture or a url.
  54608. */
  54609. environmentTexture: string | BaseTexture;
  54610. /**
  54611. * The value of the exposure to apply to the scene.
  54612. * 0.6 by default if setupImageProcessing is true.
  54613. */
  54614. cameraExposure: number;
  54615. /**
  54616. * The value of the contrast to apply to the scene.
  54617. * 1.6 by default if setupImageProcessing is true.
  54618. */
  54619. cameraContrast: number;
  54620. /**
  54621. * Specifies whether or not tonemapping should be enabled in the scene.
  54622. * true by default if setupImageProcessing is true.
  54623. */
  54624. toneMappingEnabled: boolean;
  54625. }
  54626. /**
  54627. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54628. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54629. * It also helps with the default setup of your imageProcessing configuration.
  54630. */
  54631. export class EnvironmentHelper {
  54632. /**
  54633. * Default ground texture URL.
  54634. */
  54635. private static _groundTextureCDNUrl;
  54636. /**
  54637. * Default skybox texture URL.
  54638. */
  54639. private static _skyboxTextureCDNUrl;
  54640. /**
  54641. * Default environment texture URL.
  54642. */
  54643. private static _environmentTextureCDNUrl;
  54644. /**
  54645. * Creates the default options for the helper.
  54646. */
  54647. private static _getDefaultOptions;
  54648. private _rootMesh;
  54649. /**
  54650. * Gets the root mesh created by the helper.
  54651. */
  54652. get rootMesh(): Mesh;
  54653. private _skybox;
  54654. /**
  54655. * Gets the skybox created by the helper.
  54656. */
  54657. get skybox(): Nullable<Mesh>;
  54658. private _skyboxTexture;
  54659. /**
  54660. * Gets the skybox texture created by the helper.
  54661. */
  54662. get skyboxTexture(): Nullable<BaseTexture>;
  54663. private _skyboxMaterial;
  54664. /**
  54665. * Gets the skybox material created by the helper.
  54666. */
  54667. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54668. private _ground;
  54669. /**
  54670. * Gets the ground mesh created by the helper.
  54671. */
  54672. get ground(): Nullable<Mesh>;
  54673. private _groundTexture;
  54674. /**
  54675. * Gets the ground texture created by the helper.
  54676. */
  54677. get groundTexture(): Nullable<BaseTexture>;
  54678. private _groundMirror;
  54679. /**
  54680. * Gets the ground mirror created by the helper.
  54681. */
  54682. get groundMirror(): Nullable<MirrorTexture>;
  54683. /**
  54684. * Gets the ground mirror render list to helps pushing the meshes
  54685. * you wish in the ground reflection.
  54686. */
  54687. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54688. private _groundMaterial;
  54689. /**
  54690. * Gets the ground material created by the helper.
  54691. */
  54692. get groundMaterial(): Nullable<BackgroundMaterial>;
  54693. /**
  54694. * Stores the creation options.
  54695. */
  54696. private readonly _scene;
  54697. private _options;
  54698. /**
  54699. * This observable will be notified with any error during the creation of the environment,
  54700. * mainly texture creation errors.
  54701. */
  54702. onErrorObservable: Observable<{
  54703. message?: string;
  54704. exception?: any;
  54705. }>;
  54706. /**
  54707. * constructor
  54708. * @param options Defines the options we want to customize the helper
  54709. * @param scene The scene to add the material to
  54710. */
  54711. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54712. /**
  54713. * Updates the background according to the new options
  54714. * @param options
  54715. */
  54716. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54717. /**
  54718. * Sets the primary color of all the available elements.
  54719. * @param color the main color to affect to the ground and the background
  54720. */
  54721. setMainColor(color: Color3): void;
  54722. /**
  54723. * Setup the image processing according to the specified options.
  54724. */
  54725. private _setupImageProcessing;
  54726. /**
  54727. * Setup the environment texture according to the specified options.
  54728. */
  54729. private _setupEnvironmentTexture;
  54730. /**
  54731. * Setup the background according to the specified options.
  54732. */
  54733. private _setupBackground;
  54734. /**
  54735. * Get the scene sizes according to the setup.
  54736. */
  54737. private _getSceneSize;
  54738. /**
  54739. * Setup the ground according to the specified options.
  54740. */
  54741. private _setupGround;
  54742. /**
  54743. * Setup the ground material according to the specified options.
  54744. */
  54745. private _setupGroundMaterial;
  54746. /**
  54747. * Setup the ground diffuse texture according to the specified options.
  54748. */
  54749. private _setupGroundDiffuseTexture;
  54750. /**
  54751. * Setup the ground mirror texture according to the specified options.
  54752. */
  54753. private _setupGroundMirrorTexture;
  54754. /**
  54755. * Setup the ground to receive the mirror texture.
  54756. */
  54757. private _setupMirrorInGroundMaterial;
  54758. /**
  54759. * Setup the skybox according to the specified options.
  54760. */
  54761. private _setupSkybox;
  54762. /**
  54763. * Setup the skybox material according to the specified options.
  54764. */
  54765. private _setupSkyboxMaterial;
  54766. /**
  54767. * Setup the skybox reflection texture according to the specified options.
  54768. */
  54769. private _setupSkyboxReflectionTexture;
  54770. private _errorHandler;
  54771. /**
  54772. * Dispose all the elements created by the Helper.
  54773. */
  54774. dispose(): void;
  54775. }
  54776. }
  54777. declare module BABYLON {
  54778. /**
  54779. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54780. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54781. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54782. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54783. */
  54784. export class PhotoDome extends TransformNode {
  54785. /**
  54786. * Define the image as a Monoscopic panoramic 360 image.
  54787. */
  54788. static readonly MODE_MONOSCOPIC: number;
  54789. /**
  54790. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54791. */
  54792. static readonly MODE_TOPBOTTOM: number;
  54793. /**
  54794. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54795. */
  54796. static readonly MODE_SIDEBYSIDE: number;
  54797. private _useDirectMapping;
  54798. /**
  54799. * The texture being displayed on the sphere
  54800. */
  54801. protected _photoTexture: Texture;
  54802. /**
  54803. * Gets or sets the texture being displayed on the sphere
  54804. */
  54805. get photoTexture(): Texture;
  54806. set photoTexture(value: Texture);
  54807. /**
  54808. * Observable raised when an error occured while loading the 360 image
  54809. */
  54810. onLoadErrorObservable: Observable<string>;
  54811. /**
  54812. * The skybox material
  54813. */
  54814. protected _material: BackgroundMaterial;
  54815. /**
  54816. * The surface used for the skybox
  54817. */
  54818. protected _mesh: Mesh;
  54819. /**
  54820. * Gets the mesh used for the skybox.
  54821. */
  54822. get mesh(): Mesh;
  54823. /**
  54824. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54825. * Also see the options.resolution property.
  54826. */
  54827. get fovMultiplier(): number;
  54828. set fovMultiplier(value: number);
  54829. private _imageMode;
  54830. /**
  54831. * Gets or set the current video mode for the video. It can be:
  54832. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54833. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54834. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54835. */
  54836. get imageMode(): number;
  54837. set imageMode(value: number);
  54838. /**
  54839. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54840. * @param name Element's name, child elements will append suffixes for their own names.
  54841. * @param urlsOfPhoto defines the url of the photo to display
  54842. * @param options defines an object containing optional or exposed sub element properties
  54843. * @param onError defines a callback called when an error occured while loading the texture
  54844. */
  54845. constructor(name: string, urlOfPhoto: string, options: {
  54846. resolution?: number;
  54847. size?: number;
  54848. useDirectMapping?: boolean;
  54849. faceForward?: boolean;
  54850. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54851. private _onBeforeCameraRenderObserver;
  54852. private _changeImageMode;
  54853. /**
  54854. * Releases resources associated with this node.
  54855. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54856. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54857. */
  54858. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54859. }
  54860. }
  54861. declare module BABYLON {
  54862. /**
  54863. * Class used to host RGBD texture specific utilities
  54864. */
  54865. export class RGBDTextureTools {
  54866. /**
  54867. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54868. * @param texture the texture to expand.
  54869. */
  54870. static ExpandRGBDTexture(texture: Texture): void;
  54871. }
  54872. }
  54873. declare module BABYLON {
  54874. /**
  54875. * Class used to host texture specific utilities
  54876. */
  54877. export class BRDFTextureTools {
  54878. /**
  54879. * Prevents texture cache collision
  54880. */
  54881. private static _instanceNumber;
  54882. /**
  54883. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54884. * @param scene defines the hosting scene
  54885. * @returns the environment BRDF texture
  54886. */
  54887. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54888. private static _environmentBRDFBase64Texture;
  54889. }
  54890. }
  54891. declare module BABYLON {
  54892. /**
  54893. * @hidden
  54894. */
  54895. export interface IMaterialClearCoatDefines {
  54896. CLEARCOAT: boolean;
  54897. CLEARCOAT_DEFAULTIOR: boolean;
  54898. CLEARCOAT_TEXTURE: boolean;
  54899. CLEARCOAT_TEXTUREDIRECTUV: number;
  54900. CLEARCOAT_BUMP: boolean;
  54901. CLEARCOAT_BUMPDIRECTUV: number;
  54902. CLEARCOAT_TINT: boolean;
  54903. CLEARCOAT_TINT_TEXTURE: boolean;
  54904. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54905. /** @hidden */
  54906. _areTexturesDirty: boolean;
  54907. }
  54908. /**
  54909. * Define the code related to the clear coat parameters of the pbr material.
  54910. */
  54911. export class PBRClearCoatConfiguration {
  54912. /**
  54913. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54914. * The default fits with a polyurethane material.
  54915. */
  54916. private static readonly _DefaultIndexOfRefraction;
  54917. private _isEnabled;
  54918. /**
  54919. * Defines if the clear coat is enabled in the material.
  54920. */
  54921. isEnabled: boolean;
  54922. /**
  54923. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54924. */
  54925. intensity: number;
  54926. /**
  54927. * Defines the clear coat layer roughness.
  54928. */
  54929. roughness: number;
  54930. private _indexOfRefraction;
  54931. /**
  54932. * Defines the index of refraction of the clear coat.
  54933. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54934. * The default fits with a polyurethane material.
  54935. * Changing the default value is more performance intensive.
  54936. */
  54937. indexOfRefraction: number;
  54938. private _texture;
  54939. /**
  54940. * Stores the clear coat values in a texture.
  54941. */
  54942. texture: Nullable<BaseTexture>;
  54943. private _bumpTexture;
  54944. /**
  54945. * Define the clear coat specific bump texture.
  54946. */
  54947. bumpTexture: Nullable<BaseTexture>;
  54948. private _isTintEnabled;
  54949. /**
  54950. * Defines if the clear coat tint is enabled in the material.
  54951. */
  54952. isTintEnabled: boolean;
  54953. /**
  54954. * Defines the clear coat tint of the material.
  54955. * This is only use if tint is enabled
  54956. */
  54957. tintColor: Color3;
  54958. /**
  54959. * Defines the distance at which the tint color should be found in the
  54960. * clear coat media.
  54961. * This is only use if tint is enabled
  54962. */
  54963. tintColorAtDistance: number;
  54964. /**
  54965. * Defines the clear coat layer thickness.
  54966. * This is only use if tint is enabled
  54967. */
  54968. tintThickness: number;
  54969. private _tintTexture;
  54970. /**
  54971. * Stores the clear tint values in a texture.
  54972. * rgb is tint
  54973. * a is a thickness factor
  54974. */
  54975. tintTexture: Nullable<BaseTexture>;
  54976. /** @hidden */
  54977. private _internalMarkAllSubMeshesAsTexturesDirty;
  54978. /** @hidden */
  54979. _markAllSubMeshesAsTexturesDirty(): void;
  54980. /**
  54981. * Instantiate a new istance of clear coat configuration.
  54982. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54983. */
  54984. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54985. /**
  54986. * Gets wehter the submesh is ready to be used or not.
  54987. * @param defines the list of "defines" to update.
  54988. * @param scene defines the scene the material belongs to.
  54989. * @param engine defines the engine the material belongs to.
  54990. * @param disableBumpMap defines wether the material disables bump or not.
  54991. * @returns - boolean indicating that the submesh is ready or not.
  54992. */
  54993. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54994. /**
  54995. * Checks to see if a texture is used in the material.
  54996. * @param defines the list of "defines" to update.
  54997. * @param scene defines the scene to the material belongs to.
  54998. */
  54999. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55000. /**
  55001. * Binds the material data.
  55002. * @param uniformBuffer defines the Uniform buffer to fill in.
  55003. * @param scene defines the scene the material belongs to.
  55004. * @param engine defines the engine the material belongs to.
  55005. * @param disableBumpMap defines wether the material disables bump or not.
  55006. * @param isFrozen defines wether the material is frozen or not.
  55007. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55008. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55009. */
  55010. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55011. /**
  55012. * Checks to see if a texture is used in the material.
  55013. * @param texture - Base texture to use.
  55014. * @returns - Boolean specifying if a texture is used in the material.
  55015. */
  55016. hasTexture(texture: BaseTexture): boolean;
  55017. /**
  55018. * Returns an array of the actively used textures.
  55019. * @param activeTextures Array of BaseTextures
  55020. */
  55021. getActiveTextures(activeTextures: BaseTexture[]): void;
  55022. /**
  55023. * Returns the animatable textures.
  55024. * @param animatables Array of animatable textures.
  55025. */
  55026. getAnimatables(animatables: IAnimatable[]): void;
  55027. /**
  55028. * Disposes the resources of the material.
  55029. * @param forceDisposeTextures - Forces the disposal of all textures.
  55030. */
  55031. dispose(forceDisposeTextures?: boolean): void;
  55032. /**
  55033. * Get the current class name of the texture useful for serialization or dynamic coding.
  55034. * @returns "PBRClearCoatConfiguration"
  55035. */
  55036. getClassName(): string;
  55037. /**
  55038. * Add fallbacks to the effect fallbacks list.
  55039. * @param defines defines the Base texture to use.
  55040. * @param fallbacks defines the current fallback list.
  55041. * @param currentRank defines the current fallback rank.
  55042. * @returns the new fallback rank.
  55043. */
  55044. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55045. /**
  55046. * Add the required uniforms to the current list.
  55047. * @param uniforms defines the current uniform list.
  55048. */
  55049. static AddUniforms(uniforms: string[]): void;
  55050. /**
  55051. * Add the required samplers to the current list.
  55052. * @param samplers defines the current sampler list.
  55053. */
  55054. static AddSamplers(samplers: string[]): void;
  55055. /**
  55056. * Add the required uniforms to the current buffer.
  55057. * @param uniformBuffer defines the current uniform buffer.
  55058. */
  55059. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55060. /**
  55061. * Makes a duplicate of the current configuration into another one.
  55062. * @param clearCoatConfiguration define the config where to copy the info
  55063. */
  55064. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55065. /**
  55066. * Serializes this clear coat configuration.
  55067. * @returns - An object with the serialized config.
  55068. */
  55069. serialize(): any;
  55070. /**
  55071. * Parses a anisotropy Configuration from a serialized object.
  55072. * @param source - Serialized object.
  55073. * @param scene Defines the scene we are parsing for
  55074. * @param rootUrl Defines the rootUrl to load from
  55075. */
  55076. parse(source: any, scene: Scene, rootUrl: string): void;
  55077. }
  55078. }
  55079. declare module BABYLON {
  55080. /**
  55081. * @hidden
  55082. */
  55083. export interface IMaterialAnisotropicDefines {
  55084. ANISOTROPIC: boolean;
  55085. ANISOTROPIC_TEXTURE: boolean;
  55086. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55087. MAINUV1: boolean;
  55088. _areTexturesDirty: boolean;
  55089. _needUVs: boolean;
  55090. }
  55091. /**
  55092. * Define the code related to the anisotropic parameters of the pbr material.
  55093. */
  55094. export class PBRAnisotropicConfiguration {
  55095. private _isEnabled;
  55096. /**
  55097. * Defines if the anisotropy is enabled in the material.
  55098. */
  55099. isEnabled: boolean;
  55100. /**
  55101. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55102. */
  55103. intensity: number;
  55104. /**
  55105. * Defines if the effect is along the tangents, bitangents or in between.
  55106. * By default, the effect is "strectching" the highlights along the tangents.
  55107. */
  55108. direction: Vector2;
  55109. private _texture;
  55110. /**
  55111. * Stores the anisotropy values in a texture.
  55112. * rg is direction (like normal from -1 to 1)
  55113. * b is a intensity
  55114. */
  55115. texture: Nullable<BaseTexture>;
  55116. /** @hidden */
  55117. private _internalMarkAllSubMeshesAsTexturesDirty;
  55118. /** @hidden */
  55119. _markAllSubMeshesAsTexturesDirty(): void;
  55120. /**
  55121. * Instantiate a new istance of anisotropy configuration.
  55122. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55123. */
  55124. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55125. /**
  55126. * Specifies that the submesh is ready to be used.
  55127. * @param defines the list of "defines" to update.
  55128. * @param scene defines the scene the material belongs to.
  55129. * @returns - boolean indicating that the submesh is ready or not.
  55130. */
  55131. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55132. /**
  55133. * Checks to see if a texture is used in the material.
  55134. * @param defines the list of "defines" to update.
  55135. * @param mesh the mesh we are preparing the defines for.
  55136. * @param scene defines the scene the material belongs to.
  55137. */
  55138. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55139. /**
  55140. * Binds the material data.
  55141. * @param uniformBuffer defines the Uniform buffer to fill in.
  55142. * @param scene defines the scene the material belongs to.
  55143. * @param isFrozen defines wether the material is frozen or not.
  55144. */
  55145. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55146. /**
  55147. * Checks to see if a texture is used in the material.
  55148. * @param texture - Base texture to use.
  55149. * @returns - Boolean specifying if a texture is used in the material.
  55150. */
  55151. hasTexture(texture: BaseTexture): boolean;
  55152. /**
  55153. * Returns an array of the actively used textures.
  55154. * @param activeTextures Array of BaseTextures
  55155. */
  55156. getActiveTextures(activeTextures: BaseTexture[]): void;
  55157. /**
  55158. * Returns the animatable textures.
  55159. * @param animatables Array of animatable textures.
  55160. */
  55161. getAnimatables(animatables: IAnimatable[]): void;
  55162. /**
  55163. * Disposes the resources of the material.
  55164. * @param forceDisposeTextures - Forces the disposal of all textures.
  55165. */
  55166. dispose(forceDisposeTextures?: boolean): void;
  55167. /**
  55168. * Get the current class name of the texture useful for serialization or dynamic coding.
  55169. * @returns "PBRAnisotropicConfiguration"
  55170. */
  55171. getClassName(): string;
  55172. /**
  55173. * Add fallbacks to the effect fallbacks list.
  55174. * @param defines defines the Base texture to use.
  55175. * @param fallbacks defines the current fallback list.
  55176. * @param currentRank defines the current fallback rank.
  55177. * @returns the new fallback rank.
  55178. */
  55179. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55180. /**
  55181. * Add the required uniforms to the current list.
  55182. * @param uniforms defines the current uniform list.
  55183. */
  55184. static AddUniforms(uniforms: string[]): void;
  55185. /**
  55186. * Add the required uniforms to the current buffer.
  55187. * @param uniformBuffer defines the current uniform buffer.
  55188. */
  55189. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55190. /**
  55191. * Add the required samplers to the current list.
  55192. * @param samplers defines the current sampler list.
  55193. */
  55194. static AddSamplers(samplers: string[]): void;
  55195. /**
  55196. * Makes a duplicate of the current configuration into another one.
  55197. * @param anisotropicConfiguration define the config where to copy the info
  55198. */
  55199. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55200. /**
  55201. * Serializes this anisotropy configuration.
  55202. * @returns - An object with the serialized config.
  55203. */
  55204. serialize(): any;
  55205. /**
  55206. * Parses a anisotropy Configuration from a serialized object.
  55207. * @param source - Serialized object.
  55208. * @param scene Defines the scene we are parsing for
  55209. * @param rootUrl Defines the rootUrl to load from
  55210. */
  55211. parse(source: any, scene: Scene, rootUrl: string): void;
  55212. }
  55213. }
  55214. declare module BABYLON {
  55215. /**
  55216. * @hidden
  55217. */
  55218. export interface IMaterialBRDFDefines {
  55219. BRDF_V_HEIGHT_CORRELATED: boolean;
  55220. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55221. SPHERICAL_HARMONICS: boolean;
  55222. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55223. /** @hidden */
  55224. _areMiscDirty: boolean;
  55225. }
  55226. /**
  55227. * Define the code related to the BRDF parameters of the pbr material.
  55228. */
  55229. export class PBRBRDFConfiguration {
  55230. /**
  55231. * Default value used for the energy conservation.
  55232. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55233. */
  55234. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55235. /**
  55236. * Default value used for the Smith Visibility Height Correlated mode.
  55237. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55238. */
  55239. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55240. /**
  55241. * Default value used for the IBL diffuse part.
  55242. * This can help switching back to the polynomials mode globally which is a tiny bit
  55243. * less GPU intensive at the drawback of a lower quality.
  55244. */
  55245. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55246. /**
  55247. * Default value used for activating energy conservation for the specular workflow.
  55248. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55249. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55250. */
  55251. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55252. private _useEnergyConservation;
  55253. /**
  55254. * Defines if the material uses energy conservation.
  55255. */
  55256. useEnergyConservation: boolean;
  55257. private _useSmithVisibilityHeightCorrelated;
  55258. /**
  55259. * LEGACY Mode set to false
  55260. * Defines if the material uses height smith correlated visibility term.
  55261. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55262. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55263. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55264. * Not relying on height correlated will also disable energy conservation.
  55265. */
  55266. useSmithVisibilityHeightCorrelated: boolean;
  55267. private _useSphericalHarmonics;
  55268. /**
  55269. * LEGACY Mode set to false
  55270. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55271. * diffuse part of the IBL.
  55272. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55273. * to the ground truth.
  55274. */
  55275. useSphericalHarmonics: boolean;
  55276. private _useSpecularGlossinessInputEnergyConservation;
  55277. /**
  55278. * Defines if the material uses energy conservation, when the specular workflow is active.
  55279. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55280. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55281. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55282. */
  55283. useSpecularGlossinessInputEnergyConservation: boolean;
  55284. /** @hidden */
  55285. private _internalMarkAllSubMeshesAsMiscDirty;
  55286. /** @hidden */
  55287. _markAllSubMeshesAsMiscDirty(): void;
  55288. /**
  55289. * Instantiate a new istance of clear coat configuration.
  55290. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55291. */
  55292. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55293. /**
  55294. * Checks to see if a texture is used in the material.
  55295. * @param defines the list of "defines" to update.
  55296. */
  55297. prepareDefines(defines: IMaterialBRDFDefines): void;
  55298. /**
  55299. * Get the current class name of the texture useful for serialization or dynamic coding.
  55300. * @returns "PBRClearCoatConfiguration"
  55301. */
  55302. getClassName(): string;
  55303. /**
  55304. * Makes a duplicate of the current configuration into another one.
  55305. * @param brdfConfiguration define the config where to copy the info
  55306. */
  55307. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55308. /**
  55309. * Serializes this BRDF configuration.
  55310. * @returns - An object with the serialized config.
  55311. */
  55312. serialize(): any;
  55313. /**
  55314. * Parses a anisotropy Configuration from a serialized object.
  55315. * @param source - Serialized object.
  55316. * @param scene Defines the scene we are parsing for
  55317. * @param rootUrl Defines the rootUrl to load from
  55318. */
  55319. parse(source: any, scene: Scene, rootUrl: string): void;
  55320. }
  55321. }
  55322. declare module BABYLON {
  55323. /**
  55324. * @hidden
  55325. */
  55326. export interface IMaterialSheenDefines {
  55327. SHEEN: boolean;
  55328. SHEEN_TEXTURE: boolean;
  55329. SHEEN_TEXTUREDIRECTUV: number;
  55330. SHEEN_LINKWITHALBEDO: boolean;
  55331. SHEEN_ROUGHNESS: boolean;
  55332. SHEEN_ALBEDOSCALING: boolean;
  55333. /** @hidden */
  55334. _areTexturesDirty: boolean;
  55335. }
  55336. /**
  55337. * Define the code related to the Sheen parameters of the pbr material.
  55338. */
  55339. export class PBRSheenConfiguration {
  55340. private _isEnabled;
  55341. /**
  55342. * Defines if the material uses sheen.
  55343. */
  55344. isEnabled: boolean;
  55345. private _linkSheenWithAlbedo;
  55346. /**
  55347. * Defines if the sheen is linked to the sheen color.
  55348. */
  55349. linkSheenWithAlbedo: boolean;
  55350. /**
  55351. * Defines the sheen intensity.
  55352. */
  55353. intensity: number;
  55354. /**
  55355. * Defines the sheen color.
  55356. */
  55357. color: Color3;
  55358. private _texture;
  55359. /**
  55360. * Stores the sheen tint values in a texture.
  55361. * rgb is tint
  55362. * a is a intensity or roughness if roughness has been defined
  55363. */
  55364. texture: Nullable<BaseTexture>;
  55365. private _roughness;
  55366. /**
  55367. * Defines the sheen roughness.
  55368. * It is not taken into account if linkSheenWithAlbedo is true.
  55369. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55370. */
  55371. roughness: Nullable<number>;
  55372. private _albedoScaling;
  55373. /**
  55374. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55375. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55376. * making it easier to setup and tweak the effect
  55377. */
  55378. albedoScaling: boolean;
  55379. /** @hidden */
  55380. private _internalMarkAllSubMeshesAsTexturesDirty;
  55381. /** @hidden */
  55382. _markAllSubMeshesAsTexturesDirty(): void;
  55383. /**
  55384. * Instantiate a new istance of clear coat configuration.
  55385. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55386. */
  55387. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55388. /**
  55389. * Specifies that the submesh is ready to be used.
  55390. * @param defines the list of "defines" to update.
  55391. * @param scene defines the scene the material belongs to.
  55392. * @returns - boolean indicating that the submesh is ready or not.
  55393. */
  55394. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55395. /**
  55396. * Checks to see if a texture is used in the material.
  55397. * @param defines the list of "defines" to update.
  55398. * @param scene defines the scene the material belongs to.
  55399. */
  55400. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55401. /**
  55402. * Binds the material data.
  55403. * @param uniformBuffer defines the Uniform buffer to fill in.
  55404. * @param scene defines the scene the material belongs to.
  55405. * @param isFrozen defines wether the material is frozen or not.
  55406. */
  55407. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55408. /**
  55409. * Checks to see if a texture is used in the material.
  55410. * @param texture - Base texture to use.
  55411. * @returns - Boolean specifying if a texture is used in the material.
  55412. */
  55413. hasTexture(texture: BaseTexture): boolean;
  55414. /**
  55415. * Returns an array of the actively used textures.
  55416. * @param activeTextures Array of BaseTextures
  55417. */
  55418. getActiveTextures(activeTextures: BaseTexture[]): void;
  55419. /**
  55420. * Returns the animatable textures.
  55421. * @param animatables Array of animatable textures.
  55422. */
  55423. getAnimatables(animatables: IAnimatable[]): void;
  55424. /**
  55425. * Disposes the resources of the material.
  55426. * @param forceDisposeTextures - Forces the disposal of all textures.
  55427. */
  55428. dispose(forceDisposeTextures?: boolean): void;
  55429. /**
  55430. * Get the current class name of the texture useful for serialization or dynamic coding.
  55431. * @returns "PBRSheenConfiguration"
  55432. */
  55433. getClassName(): string;
  55434. /**
  55435. * Add fallbacks to the effect fallbacks list.
  55436. * @param defines defines the Base texture to use.
  55437. * @param fallbacks defines the current fallback list.
  55438. * @param currentRank defines the current fallback rank.
  55439. * @returns the new fallback rank.
  55440. */
  55441. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55442. /**
  55443. * Add the required uniforms to the current list.
  55444. * @param uniforms defines the current uniform list.
  55445. */
  55446. static AddUniforms(uniforms: string[]): void;
  55447. /**
  55448. * Add the required uniforms to the current buffer.
  55449. * @param uniformBuffer defines the current uniform buffer.
  55450. */
  55451. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55452. /**
  55453. * Add the required samplers to the current list.
  55454. * @param samplers defines the current sampler list.
  55455. */
  55456. static AddSamplers(samplers: string[]): void;
  55457. /**
  55458. * Makes a duplicate of the current configuration into another one.
  55459. * @param sheenConfiguration define the config where to copy the info
  55460. */
  55461. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55462. /**
  55463. * Serializes this BRDF configuration.
  55464. * @returns - An object with the serialized config.
  55465. */
  55466. serialize(): any;
  55467. /**
  55468. * Parses a anisotropy Configuration from a serialized object.
  55469. * @param source - Serialized object.
  55470. * @param scene Defines the scene we are parsing for
  55471. * @param rootUrl Defines the rootUrl to load from
  55472. */
  55473. parse(source: any, scene: Scene, rootUrl: string): void;
  55474. }
  55475. }
  55476. declare module BABYLON {
  55477. /**
  55478. * @hidden
  55479. */
  55480. export interface IMaterialSubSurfaceDefines {
  55481. SUBSURFACE: boolean;
  55482. SS_REFRACTION: boolean;
  55483. SS_TRANSLUCENCY: boolean;
  55484. SS_SCATTERING: boolean;
  55485. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55486. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55487. SS_REFRACTIONMAP_3D: boolean;
  55488. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55489. SS_LODINREFRACTIONALPHA: boolean;
  55490. SS_GAMMAREFRACTION: boolean;
  55491. SS_RGBDREFRACTION: boolean;
  55492. SS_LINEARSPECULARREFRACTION: boolean;
  55493. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55494. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55495. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55496. /** @hidden */
  55497. _areTexturesDirty: boolean;
  55498. }
  55499. /**
  55500. * Define the code related to the sub surface parameters of the pbr material.
  55501. */
  55502. export class PBRSubSurfaceConfiguration {
  55503. private _isRefractionEnabled;
  55504. /**
  55505. * Defines if the refraction is enabled in the material.
  55506. */
  55507. isRefractionEnabled: boolean;
  55508. private _isTranslucencyEnabled;
  55509. /**
  55510. * Defines if the translucency is enabled in the material.
  55511. */
  55512. isTranslucencyEnabled: boolean;
  55513. private _isScatteringEnabled;
  55514. /**
  55515. * Defines if the sub surface scattering is enabled in the material.
  55516. */
  55517. isScatteringEnabled: boolean;
  55518. private _scatteringDiffusionProfileIndex;
  55519. /**
  55520. * Diffusion profile for subsurface scattering.
  55521. * Useful for better scattering in the skins or foliages.
  55522. */
  55523. get scatteringDiffusionProfile(): Nullable<Color3>;
  55524. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55525. /**
  55526. * Defines the refraction intensity of the material.
  55527. * The refraction when enabled replaces the Diffuse part of the material.
  55528. * The intensity helps transitionning between diffuse and refraction.
  55529. */
  55530. refractionIntensity: number;
  55531. /**
  55532. * Defines the translucency intensity of the material.
  55533. * When translucency has been enabled, this defines how much of the "translucency"
  55534. * is addded to the diffuse part of the material.
  55535. */
  55536. translucencyIntensity: number;
  55537. /**
  55538. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55539. */
  55540. useAlbedoToTintRefraction: boolean;
  55541. private _thicknessTexture;
  55542. /**
  55543. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55544. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55545. * 0 would mean minimumThickness
  55546. * 1 would mean maximumThickness
  55547. * The other channels might be use as a mask to vary the different effects intensity.
  55548. */
  55549. thicknessTexture: Nullable<BaseTexture>;
  55550. private _refractionTexture;
  55551. /**
  55552. * Defines the texture to use for refraction.
  55553. */
  55554. refractionTexture: Nullable<BaseTexture>;
  55555. private _indexOfRefraction;
  55556. /**
  55557. * Index of refraction of the material base layer.
  55558. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55559. *
  55560. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55561. *
  55562. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55563. */
  55564. indexOfRefraction: number;
  55565. private _volumeIndexOfRefraction;
  55566. /**
  55567. * Index of refraction of the material's volume.
  55568. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55569. *
  55570. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55571. * the volume will use the same IOR as the surface.
  55572. */
  55573. get volumeIndexOfRefraction(): number;
  55574. set volumeIndexOfRefraction(value: number);
  55575. private _invertRefractionY;
  55576. /**
  55577. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55578. */
  55579. invertRefractionY: boolean;
  55580. private _linkRefractionWithTransparency;
  55581. /**
  55582. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55583. * Materials half opaque for instance using refraction could benefit from this control.
  55584. */
  55585. linkRefractionWithTransparency: boolean;
  55586. /**
  55587. * Defines the minimum thickness stored in the thickness map.
  55588. * If no thickness map is defined, this value will be used to simulate thickness.
  55589. */
  55590. minimumThickness: number;
  55591. /**
  55592. * Defines the maximum thickness stored in the thickness map.
  55593. */
  55594. maximumThickness: number;
  55595. /**
  55596. * Defines the volume tint of the material.
  55597. * This is used for both translucency and scattering.
  55598. */
  55599. tintColor: Color3;
  55600. /**
  55601. * Defines the distance at which the tint color should be found in the media.
  55602. * This is used for refraction only.
  55603. */
  55604. tintColorAtDistance: number;
  55605. /**
  55606. * Defines how far each channel transmit through the media.
  55607. * It is defined as a color to simplify it selection.
  55608. */
  55609. diffusionDistance: Color3;
  55610. private _useMaskFromThicknessTexture;
  55611. /**
  55612. * Stores the intensity of the different subsurface effects in the thickness texture.
  55613. * * the green channel is the translucency intensity.
  55614. * * the blue channel is the scattering intensity.
  55615. * * the alpha channel is the refraction intensity.
  55616. */
  55617. useMaskFromThicknessTexture: boolean;
  55618. private _scene;
  55619. /** @hidden */
  55620. private _internalMarkAllSubMeshesAsTexturesDirty;
  55621. private _internalMarkScenePrePassDirty;
  55622. /** @hidden */
  55623. _markAllSubMeshesAsTexturesDirty(): void;
  55624. /** @hidden */
  55625. _markScenePrePassDirty(): void;
  55626. /**
  55627. * Instantiate a new istance of sub surface configuration.
  55628. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55629. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55630. * @param scene The scene
  55631. */
  55632. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55633. /**
  55634. * Gets wehter the submesh is ready to be used or not.
  55635. * @param defines the list of "defines" to update.
  55636. * @param scene defines the scene the material belongs to.
  55637. * @returns - boolean indicating that the submesh is ready or not.
  55638. */
  55639. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55640. /**
  55641. * Checks to see if a texture is used in the material.
  55642. * @param defines the list of "defines" to update.
  55643. * @param scene defines the scene to the material belongs to.
  55644. */
  55645. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55646. /**
  55647. * Binds the material data.
  55648. * @param uniformBuffer defines the Uniform buffer to fill in.
  55649. * @param scene defines the scene the material belongs to.
  55650. * @param engine defines the engine the material belongs to.
  55651. * @param isFrozen defines whether the material is frozen or not.
  55652. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55653. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55654. */
  55655. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55656. /**
  55657. * Unbinds the material from the mesh.
  55658. * @param activeEffect defines the effect that should be unbound from.
  55659. * @returns true if unbound, otherwise false
  55660. */
  55661. unbind(activeEffect: Effect): boolean;
  55662. /**
  55663. * Returns the texture used for refraction or null if none is used.
  55664. * @param scene defines the scene the material belongs to.
  55665. * @returns - Refraction texture if present. If no refraction texture and refraction
  55666. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55667. */
  55668. private _getRefractionTexture;
  55669. /**
  55670. * Returns true if alpha blending should be disabled.
  55671. */
  55672. get disableAlphaBlending(): boolean;
  55673. /**
  55674. * Fills the list of render target textures.
  55675. * @param renderTargets the list of render targets to update
  55676. */
  55677. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55678. /**
  55679. * Checks to see if a texture is used in the material.
  55680. * @param texture - Base texture to use.
  55681. * @returns - Boolean specifying if a texture is used in the material.
  55682. */
  55683. hasTexture(texture: BaseTexture): boolean;
  55684. /**
  55685. * Gets a boolean indicating that current material needs to register RTT
  55686. * @returns true if this uses a render target otherwise false.
  55687. */
  55688. hasRenderTargetTextures(): boolean;
  55689. /**
  55690. * Returns an array of the actively used textures.
  55691. * @param activeTextures Array of BaseTextures
  55692. */
  55693. getActiveTextures(activeTextures: BaseTexture[]): void;
  55694. /**
  55695. * Returns the animatable textures.
  55696. * @param animatables Array of animatable textures.
  55697. */
  55698. getAnimatables(animatables: IAnimatable[]): void;
  55699. /**
  55700. * Disposes the resources of the material.
  55701. * @param forceDisposeTextures - Forces the disposal of all textures.
  55702. */
  55703. dispose(forceDisposeTextures?: boolean): void;
  55704. /**
  55705. * Get the current class name of the texture useful for serialization or dynamic coding.
  55706. * @returns "PBRSubSurfaceConfiguration"
  55707. */
  55708. getClassName(): string;
  55709. /**
  55710. * Add fallbacks to the effect fallbacks list.
  55711. * @param defines defines the Base texture to use.
  55712. * @param fallbacks defines the current fallback list.
  55713. * @param currentRank defines the current fallback rank.
  55714. * @returns the new fallback rank.
  55715. */
  55716. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55717. /**
  55718. * Add the required uniforms to the current list.
  55719. * @param uniforms defines the current uniform list.
  55720. */
  55721. static AddUniforms(uniforms: string[]): void;
  55722. /**
  55723. * Add the required samplers to the current list.
  55724. * @param samplers defines the current sampler list.
  55725. */
  55726. static AddSamplers(samplers: string[]): void;
  55727. /**
  55728. * Add the required uniforms to the current buffer.
  55729. * @param uniformBuffer defines the current uniform buffer.
  55730. */
  55731. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55732. /**
  55733. * Makes a duplicate of the current configuration into another one.
  55734. * @param configuration define the config where to copy the info
  55735. */
  55736. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55737. /**
  55738. * Serializes this Sub Surface configuration.
  55739. * @returns - An object with the serialized config.
  55740. */
  55741. serialize(): any;
  55742. /**
  55743. * Parses a anisotropy Configuration from a serialized object.
  55744. * @param source - Serialized object.
  55745. * @param scene Defines the scene we are parsing for
  55746. * @param rootUrl Defines the rootUrl to load from
  55747. */
  55748. parse(source: any, scene: Scene, rootUrl: string): void;
  55749. }
  55750. }
  55751. declare module BABYLON {
  55752. /** @hidden */
  55753. export var pbrFragmentDeclaration: {
  55754. name: string;
  55755. shader: string;
  55756. };
  55757. }
  55758. declare module BABYLON {
  55759. /** @hidden */
  55760. export var pbrUboDeclaration: {
  55761. name: string;
  55762. shader: string;
  55763. };
  55764. }
  55765. declare module BABYLON {
  55766. /** @hidden */
  55767. export var pbrFragmentExtraDeclaration: {
  55768. name: string;
  55769. shader: string;
  55770. };
  55771. }
  55772. declare module BABYLON {
  55773. /** @hidden */
  55774. export var pbrFragmentSamplersDeclaration: {
  55775. name: string;
  55776. shader: string;
  55777. };
  55778. }
  55779. declare module BABYLON {
  55780. /** @hidden */
  55781. export var importanceSampling: {
  55782. name: string;
  55783. shader: string;
  55784. };
  55785. }
  55786. declare module BABYLON {
  55787. /** @hidden */
  55788. export var pbrHelperFunctions: {
  55789. name: string;
  55790. shader: string;
  55791. };
  55792. }
  55793. declare module BABYLON {
  55794. /** @hidden */
  55795. export var harmonicsFunctions: {
  55796. name: string;
  55797. shader: string;
  55798. };
  55799. }
  55800. declare module BABYLON {
  55801. /** @hidden */
  55802. export var pbrDirectLightingSetupFunctions: {
  55803. name: string;
  55804. shader: string;
  55805. };
  55806. }
  55807. declare module BABYLON {
  55808. /** @hidden */
  55809. export var pbrDirectLightingFalloffFunctions: {
  55810. name: string;
  55811. shader: string;
  55812. };
  55813. }
  55814. declare module BABYLON {
  55815. /** @hidden */
  55816. export var pbrBRDFFunctions: {
  55817. name: string;
  55818. shader: string;
  55819. };
  55820. }
  55821. declare module BABYLON {
  55822. /** @hidden */
  55823. export var hdrFilteringFunctions: {
  55824. name: string;
  55825. shader: string;
  55826. };
  55827. }
  55828. declare module BABYLON {
  55829. /** @hidden */
  55830. export var pbrDirectLightingFunctions: {
  55831. name: string;
  55832. shader: string;
  55833. };
  55834. }
  55835. declare module BABYLON {
  55836. /** @hidden */
  55837. export var pbrIBLFunctions: {
  55838. name: string;
  55839. shader: string;
  55840. };
  55841. }
  55842. declare module BABYLON {
  55843. /** @hidden */
  55844. export var pbrBlockAlbedoOpacity: {
  55845. name: string;
  55846. shader: string;
  55847. };
  55848. }
  55849. declare module BABYLON {
  55850. /** @hidden */
  55851. export var pbrBlockReflectivity: {
  55852. name: string;
  55853. shader: string;
  55854. };
  55855. }
  55856. declare module BABYLON {
  55857. /** @hidden */
  55858. export var pbrBlockAmbientOcclusion: {
  55859. name: string;
  55860. shader: string;
  55861. };
  55862. }
  55863. declare module BABYLON {
  55864. /** @hidden */
  55865. export var pbrBlockAlphaFresnel: {
  55866. name: string;
  55867. shader: string;
  55868. };
  55869. }
  55870. declare module BABYLON {
  55871. /** @hidden */
  55872. export var pbrBlockAnisotropic: {
  55873. name: string;
  55874. shader: string;
  55875. };
  55876. }
  55877. declare module BABYLON {
  55878. /** @hidden */
  55879. export var pbrBlockReflection: {
  55880. name: string;
  55881. shader: string;
  55882. };
  55883. }
  55884. declare module BABYLON {
  55885. /** @hidden */
  55886. export var pbrBlockSheen: {
  55887. name: string;
  55888. shader: string;
  55889. };
  55890. }
  55891. declare module BABYLON {
  55892. /** @hidden */
  55893. export var pbrBlockClearcoat: {
  55894. name: string;
  55895. shader: string;
  55896. };
  55897. }
  55898. declare module BABYLON {
  55899. /** @hidden */
  55900. export var pbrBlockSubSurface: {
  55901. name: string;
  55902. shader: string;
  55903. };
  55904. }
  55905. declare module BABYLON {
  55906. /** @hidden */
  55907. export var pbrBlockNormalGeometric: {
  55908. name: string;
  55909. shader: string;
  55910. };
  55911. }
  55912. declare module BABYLON {
  55913. /** @hidden */
  55914. export var pbrBlockNormalFinal: {
  55915. name: string;
  55916. shader: string;
  55917. };
  55918. }
  55919. declare module BABYLON {
  55920. /** @hidden */
  55921. export var pbrBlockLightmapInit: {
  55922. name: string;
  55923. shader: string;
  55924. };
  55925. }
  55926. declare module BABYLON {
  55927. /** @hidden */
  55928. export var pbrBlockGeometryInfo: {
  55929. name: string;
  55930. shader: string;
  55931. };
  55932. }
  55933. declare module BABYLON {
  55934. /** @hidden */
  55935. export var pbrBlockReflectance0: {
  55936. name: string;
  55937. shader: string;
  55938. };
  55939. }
  55940. declare module BABYLON {
  55941. /** @hidden */
  55942. export var pbrBlockReflectance: {
  55943. name: string;
  55944. shader: string;
  55945. };
  55946. }
  55947. declare module BABYLON {
  55948. /** @hidden */
  55949. export var pbrBlockDirectLighting: {
  55950. name: string;
  55951. shader: string;
  55952. };
  55953. }
  55954. declare module BABYLON {
  55955. /** @hidden */
  55956. export var pbrBlockFinalLitComponents: {
  55957. name: string;
  55958. shader: string;
  55959. };
  55960. }
  55961. declare module BABYLON {
  55962. /** @hidden */
  55963. export var pbrBlockFinalUnlitComponents: {
  55964. name: string;
  55965. shader: string;
  55966. };
  55967. }
  55968. declare module BABYLON {
  55969. /** @hidden */
  55970. export var pbrBlockFinalColorComposition: {
  55971. name: string;
  55972. shader: string;
  55973. };
  55974. }
  55975. declare module BABYLON {
  55976. /** @hidden */
  55977. export var pbrBlockImageProcessing: {
  55978. name: string;
  55979. shader: string;
  55980. };
  55981. }
  55982. declare module BABYLON {
  55983. /** @hidden */
  55984. export var pbrDebug: {
  55985. name: string;
  55986. shader: string;
  55987. };
  55988. }
  55989. declare module BABYLON {
  55990. /** @hidden */
  55991. export var pbrPixelShader: {
  55992. name: string;
  55993. shader: string;
  55994. };
  55995. }
  55996. declare module BABYLON {
  55997. /** @hidden */
  55998. export var pbrVertexDeclaration: {
  55999. name: string;
  56000. shader: string;
  56001. };
  56002. }
  56003. declare module BABYLON {
  56004. /** @hidden */
  56005. export var pbrVertexShader: {
  56006. name: string;
  56007. shader: string;
  56008. };
  56009. }
  56010. declare module BABYLON {
  56011. /**
  56012. * Manages the defines for the PBR Material.
  56013. * @hidden
  56014. */
  56015. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56016. PBR: boolean;
  56017. NUM_SAMPLES: string;
  56018. REALTIME_FILTERING: boolean;
  56019. MAINUV1: boolean;
  56020. MAINUV2: boolean;
  56021. UV1: boolean;
  56022. UV2: boolean;
  56023. ALBEDO: boolean;
  56024. GAMMAALBEDO: boolean;
  56025. ALBEDODIRECTUV: number;
  56026. VERTEXCOLOR: boolean;
  56027. DETAIL: boolean;
  56028. DETAILDIRECTUV: number;
  56029. DETAIL_NORMALBLENDMETHOD: number;
  56030. AMBIENT: boolean;
  56031. AMBIENTDIRECTUV: number;
  56032. AMBIENTINGRAYSCALE: boolean;
  56033. OPACITY: boolean;
  56034. VERTEXALPHA: boolean;
  56035. OPACITYDIRECTUV: number;
  56036. OPACITYRGB: boolean;
  56037. ALPHATEST: boolean;
  56038. DEPTHPREPASS: boolean;
  56039. ALPHABLEND: boolean;
  56040. ALPHAFROMALBEDO: boolean;
  56041. ALPHATESTVALUE: string;
  56042. SPECULAROVERALPHA: boolean;
  56043. RADIANCEOVERALPHA: boolean;
  56044. ALPHAFRESNEL: boolean;
  56045. LINEARALPHAFRESNEL: boolean;
  56046. PREMULTIPLYALPHA: boolean;
  56047. EMISSIVE: boolean;
  56048. EMISSIVEDIRECTUV: number;
  56049. REFLECTIVITY: boolean;
  56050. REFLECTIVITYDIRECTUV: number;
  56051. SPECULARTERM: boolean;
  56052. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56053. MICROSURFACEAUTOMATIC: boolean;
  56054. LODBASEDMICROSFURACE: boolean;
  56055. MICROSURFACEMAP: boolean;
  56056. MICROSURFACEMAPDIRECTUV: number;
  56057. METALLICWORKFLOW: boolean;
  56058. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56059. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56060. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56061. AOSTOREINMETALMAPRED: boolean;
  56062. METALLIC_REFLECTANCE: boolean;
  56063. METALLIC_REFLECTANCEDIRECTUV: number;
  56064. ENVIRONMENTBRDF: boolean;
  56065. ENVIRONMENTBRDF_RGBD: boolean;
  56066. NORMAL: boolean;
  56067. TANGENT: boolean;
  56068. BUMP: boolean;
  56069. BUMPDIRECTUV: number;
  56070. OBJECTSPACE_NORMALMAP: boolean;
  56071. PARALLAX: boolean;
  56072. PARALLAXOCCLUSION: boolean;
  56073. NORMALXYSCALE: boolean;
  56074. LIGHTMAP: boolean;
  56075. LIGHTMAPDIRECTUV: number;
  56076. USELIGHTMAPASSHADOWMAP: boolean;
  56077. GAMMALIGHTMAP: boolean;
  56078. RGBDLIGHTMAP: boolean;
  56079. REFLECTION: boolean;
  56080. REFLECTIONMAP_3D: boolean;
  56081. REFLECTIONMAP_SPHERICAL: boolean;
  56082. REFLECTIONMAP_PLANAR: boolean;
  56083. REFLECTIONMAP_CUBIC: boolean;
  56084. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56085. REFLECTIONMAP_PROJECTION: boolean;
  56086. REFLECTIONMAP_SKYBOX: boolean;
  56087. REFLECTIONMAP_EXPLICIT: boolean;
  56088. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56089. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56090. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56091. INVERTCUBICMAP: boolean;
  56092. USESPHERICALFROMREFLECTIONMAP: boolean;
  56093. USEIRRADIANCEMAP: boolean;
  56094. SPHERICAL_HARMONICS: boolean;
  56095. USESPHERICALINVERTEX: boolean;
  56096. REFLECTIONMAP_OPPOSITEZ: boolean;
  56097. LODINREFLECTIONALPHA: boolean;
  56098. GAMMAREFLECTION: boolean;
  56099. RGBDREFLECTION: boolean;
  56100. LINEARSPECULARREFLECTION: boolean;
  56101. RADIANCEOCCLUSION: boolean;
  56102. HORIZONOCCLUSION: boolean;
  56103. INSTANCES: boolean;
  56104. THIN_INSTANCES: boolean;
  56105. PREPASS: boolean;
  56106. SCENE_MRT_COUNT: number;
  56107. NUM_BONE_INFLUENCERS: number;
  56108. BonesPerMesh: number;
  56109. BONETEXTURE: boolean;
  56110. NONUNIFORMSCALING: boolean;
  56111. MORPHTARGETS: boolean;
  56112. MORPHTARGETS_NORMAL: boolean;
  56113. MORPHTARGETS_TANGENT: boolean;
  56114. MORPHTARGETS_UV: boolean;
  56115. NUM_MORPH_INFLUENCERS: number;
  56116. IMAGEPROCESSING: boolean;
  56117. VIGNETTE: boolean;
  56118. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56119. VIGNETTEBLENDMODEOPAQUE: boolean;
  56120. TONEMAPPING: boolean;
  56121. TONEMAPPING_ACES: boolean;
  56122. CONTRAST: boolean;
  56123. COLORCURVES: boolean;
  56124. COLORGRADING: boolean;
  56125. COLORGRADING3D: boolean;
  56126. SAMPLER3DGREENDEPTH: boolean;
  56127. SAMPLER3DBGRMAP: boolean;
  56128. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56129. EXPOSURE: boolean;
  56130. MULTIVIEW: boolean;
  56131. USEPHYSICALLIGHTFALLOFF: boolean;
  56132. USEGLTFLIGHTFALLOFF: boolean;
  56133. TWOSIDEDLIGHTING: boolean;
  56134. SHADOWFLOAT: boolean;
  56135. CLIPPLANE: boolean;
  56136. CLIPPLANE2: boolean;
  56137. CLIPPLANE3: boolean;
  56138. CLIPPLANE4: boolean;
  56139. CLIPPLANE5: boolean;
  56140. CLIPPLANE6: boolean;
  56141. POINTSIZE: boolean;
  56142. FOG: boolean;
  56143. LOGARITHMICDEPTH: boolean;
  56144. FORCENORMALFORWARD: boolean;
  56145. SPECULARAA: boolean;
  56146. CLEARCOAT: boolean;
  56147. CLEARCOAT_DEFAULTIOR: boolean;
  56148. CLEARCOAT_TEXTURE: boolean;
  56149. CLEARCOAT_TEXTUREDIRECTUV: number;
  56150. CLEARCOAT_BUMP: boolean;
  56151. CLEARCOAT_BUMPDIRECTUV: number;
  56152. CLEARCOAT_TINT: boolean;
  56153. CLEARCOAT_TINT_TEXTURE: boolean;
  56154. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56155. ANISOTROPIC: boolean;
  56156. ANISOTROPIC_TEXTURE: boolean;
  56157. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56158. BRDF_V_HEIGHT_CORRELATED: boolean;
  56159. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56160. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56161. SHEEN: boolean;
  56162. SHEEN_TEXTURE: boolean;
  56163. SHEEN_TEXTUREDIRECTUV: number;
  56164. SHEEN_LINKWITHALBEDO: boolean;
  56165. SHEEN_ROUGHNESS: boolean;
  56166. SHEEN_ALBEDOSCALING: boolean;
  56167. SUBSURFACE: boolean;
  56168. SS_REFRACTION: boolean;
  56169. SS_TRANSLUCENCY: boolean;
  56170. SS_SCATTERING: boolean;
  56171. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56172. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56173. SS_REFRACTIONMAP_3D: boolean;
  56174. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56175. SS_LODINREFRACTIONALPHA: boolean;
  56176. SS_GAMMAREFRACTION: boolean;
  56177. SS_RGBDREFRACTION: boolean;
  56178. SS_LINEARSPECULARREFRACTION: boolean;
  56179. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56180. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56181. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56182. UNLIT: boolean;
  56183. DEBUGMODE: number;
  56184. /**
  56185. * Initializes the PBR Material defines.
  56186. */
  56187. constructor();
  56188. /**
  56189. * Resets the PBR Material defines.
  56190. */
  56191. reset(): void;
  56192. }
  56193. /**
  56194. * The Physically based material base class of BJS.
  56195. *
  56196. * This offers the main features of a standard PBR material.
  56197. * For more information, please refer to the documentation :
  56198. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56199. */
  56200. export abstract class PBRBaseMaterial extends PushMaterial {
  56201. /**
  56202. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56203. */
  56204. static readonly PBRMATERIAL_OPAQUE: number;
  56205. /**
  56206. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56207. */
  56208. static readonly PBRMATERIAL_ALPHATEST: number;
  56209. /**
  56210. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56211. */
  56212. static readonly PBRMATERIAL_ALPHABLEND: number;
  56213. /**
  56214. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56215. * They are also discarded below the alpha cutoff threshold to improve performances.
  56216. */
  56217. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56218. /**
  56219. * Defines the default value of how much AO map is occluding the analytical lights
  56220. * (point spot...).
  56221. */
  56222. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56223. /**
  56224. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56225. */
  56226. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56227. /**
  56228. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56229. * to enhance interoperability with other engines.
  56230. */
  56231. static readonly LIGHTFALLOFF_GLTF: number;
  56232. /**
  56233. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56234. * to enhance interoperability with other materials.
  56235. */
  56236. static readonly LIGHTFALLOFF_STANDARD: number;
  56237. /**
  56238. * Intensity of the direct lights e.g. the four lights available in your scene.
  56239. * This impacts both the direct diffuse and specular highlights.
  56240. */
  56241. protected _directIntensity: number;
  56242. /**
  56243. * Intensity of the emissive part of the material.
  56244. * This helps controlling the emissive effect without modifying the emissive color.
  56245. */
  56246. protected _emissiveIntensity: number;
  56247. /**
  56248. * Intensity of the environment e.g. how much the environment will light the object
  56249. * either through harmonics for rough material or through the refelction for shiny ones.
  56250. */
  56251. protected _environmentIntensity: number;
  56252. /**
  56253. * This is a special control allowing the reduction of the specular highlights coming from the
  56254. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56255. */
  56256. protected _specularIntensity: number;
  56257. /**
  56258. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56259. */
  56260. private _lightingInfos;
  56261. /**
  56262. * Debug Control allowing disabling the bump map on this material.
  56263. */
  56264. protected _disableBumpMap: boolean;
  56265. /**
  56266. * AKA Diffuse Texture in standard nomenclature.
  56267. */
  56268. protected _albedoTexture: Nullable<BaseTexture>;
  56269. /**
  56270. * AKA Occlusion Texture in other nomenclature.
  56271. */
  56272. protected _ambientTexture: Nullable<BaseTexture>;
  56273. /**
  56274. * AKA Occlusion Texture Intensity in other nomenclature.
  56275. */
  56276. protected _ambientTextureStrength: number;
  56277. /**
  56278. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56279. * 1 means it completely occludes it
  56280. * 0 mean it has no impact
  56281. */
  56282. protected _ambientTextureImpactOnAnalyticalLights: number;
  56283. /**
  56284. * Stores the alpha values in a texture.
  56285. */
  56286. protected _opacityTexture: Nullable<BaseTexture>;
  56287. /**
  56288. * Stores the reflection values in a texture.
  56289. */
  56290. protected _reflectionTexture: Nullable<BaseTexture>;
  56291. /**
  56292. * Stores the emissive values in a texture.
  56293. */
  56294. protected _emissiveTexture: Nullable<BaseTexture>;
  56295. /**
  56296. * AKA Specular texture in other nomenclature.
  56297. */
  56298. protected _reflectivityTexture: Nullable<BaseTexture>;
  56299. /**
  56300. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56301. */
  56302. protected _metallicTexture: Nullable<BaseTexture>;
  56303. /**
  56304. * Specifies the metallic scalar of the metallic/roughness workflow.
  56305. * Can also be used to scale the metalness values of the metallic texture.
  56306. */
  56307. protected _metallic: Nullable<number>;
  56308. /**
  56309. * Specifies the roughness scalar of the metallic/roughness workflow.
  56310. * Can also be used to scale the roughness values of the metallic texture.
  56311. */
  56312. protected _roughness: Nullable<number>;
  56313. /**
  56314. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56315. * By default the indexOfrefraction is used to compute F0;
  56316. *
  56317. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56318. *
  56319. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56320. * F90 = metallicReflectanceColor;
  56321. */
  56322. protected _metallicF0Factor: number;
  56323. /**
  56324. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56325. * By default the F90 is always 1;
  56326. *
  56327. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56328. *
  56329. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56330. * F90 = metallicReflectanceColor;
  56331. */
  56332. protected _metallicReflectanceColor: Color3;
  56333. /**
  56334. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56335. * This is multiply against the scalar values defined in the material.
  56336. */
  56337. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56338. /**
  56339. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56340. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56341. */
  56342. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56343. /**
  56344. * Stores surface normal data used to displace a mesh in a texture.
  56345. */
  56346. protected _bumpTexture: Nullable<BaseTexture>;
  56347. /**
  56348. * Stores the pre-calculated light information of a mesh in a texture.
  56349. */
  56350. protected _lightmapTexture: Nullable<BaseTexture>;
  56351. /**
  56352. * The color of a material in ambient lighting.
  56353. */
  56354. protected _ambientColor: Color3;
  56355. /**
  56356. * AKA Diffuse Color in other nomenclature.
  56357. */
  56358. protected _albedoColor: Color3;
  56359. /**
  56360. * AKA Specular Color in other nomenclature.
  56361. */
  56362. protected _reflectivityColor: Color3;
  56363. /**
  56364. * The color applied when light is reflected from a material.
  56365. */
  56366. protected _reflectionColor: Color3;
  56367. /**
  56368. * The color applied when light is emitted from a material.
  56369. */
  56370. protected _emissiveColor: Color3;
  56371. /**
  56372. * AKA Glossiness in other nomenclature.
  56373. */
  56374. protected _microSurface: number;
  56375. /**
  56376. * Specifies that the material will use the light map as a show map.
  56377. */
  56378. protected _useLightmapAsShadowmap: boolean;
  56379. /**
  56380. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56381. * makes the reflect vector face the model (under horizon).
  56382. */
  56383. protected _useHorizonOcclusion: boolean;
  56384. /**
  56385. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56386. * too much the area relying on ambient texture to define their ambient occlusion.
  56387. */
  56388. protected _useRadianceOcclusion: boolean;
  56389. /**
  56390. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56391. */
  56392. protected _useAlphaFromAlbedoTexture: boolean;
  56393. /**
  56394. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56395. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56396. */
  56397. protected _useSpecularOverAlpha: boolean;
  56398. /**
  56399. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56400. */
  56401. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56402. /**
  56403. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56404. */
  56405. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56406. /**
  56407. * Specifies if the metallic texture contains the roughness information in its green channel.
  56408. */
  56409. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56410. /**
  56411. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56412. */
  56413. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56414. /**
  56415. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56416. */
  56417. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56418. /**
  56419. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56420. */
  56421. protected _useAmbientInGrayScale: boolean;
  56422. /**
  56423. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56424. * The material will try to infer what glossiness each pixel should be.
  56425. */
  56426. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56427. /**
  56428. * Defines the falloff type used in this material.
  56429. * It by default is Physical.
  56430. */
  56431. protected _lightFalloff: number;
  56432. /**
  56433. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56434. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56435. */
  56436. protected _useRadianceOverAlpha: boolean;
  56437. /**
  56438. * Allows using an object space normal map (instead of tangent space).
  56439. */
  56440. protected _useObjectSpaceNormalMap: boolean;
  56441. /**
  56442. * Allows using the bump map in parallax mode.
  56443. */
  56444. protected _useParallax: boolean;
  56445. /**
  56446. * Allows using the bump map in parallax occlusion mode.
  56447. */
  56448. protected _useParallaxOcclusion: boolean;
  56449. /**
  56450. * Controls the scale bias of the parallax mode.
  56451. */
  56452. protected _parallaxScaleBias: number;
  56453. /**
  56454. * If sets to true, disables all the lights affecting the material.
  56455. */
  56456. protected _disableLighting: boolean;
  56457. /**
  56458. * Number of Simultaneous lights allowed on the material.
  56459. */
  56460. protected _maxSimultaneousLights: number;
  56461. /**
  56462. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56463. */
  56464. protected _invertNormalMapX: boolean;
  56465. /**
  56466. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56467. */
  56468. protected _invertNormalMapY: boolean;
  56469. /**
  56470. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56471. */
  56472. protected _twoSidedLighting: boolean;
  56473. /**
  56474. * Defines the alpha limits in alpha test mode.
  56475. */
  56476. protected _alphaCutOff: number;
  56477. /**
  56478. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56479. */
  56480. protected _forceAlphaTest: boolean;
  56481. /**
  56482. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56483. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56484. */
  56485. protected _useAlphaFresnel: boolean;
  56486. /**
  56487. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56488. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56489. */
  56490. protected _useLinearAlphaFresnel: boolean;
  56491. /**
  56492. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56493. * from cos thetav and roughness:
  56494. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56495. */
  56496. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56497. /**
  56498. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56499. */
  56500. protected _forceIrradianceInFragment: boolean;
  56501. private _realTimeFiltering;
  56502. /**
  56503. * Enables realtime filtering on the texture.
  56504. */
  56505. get realTimeFiltering(): boolean;
  56506. set realTimeFiltering(b: boolean);
  56507. private _realTimeFilteringQuality;
  56508. /**
  56509. * Quality switch for realtime filtering
  56510. */
  56511. get realTimeFilteringQuality(): number;
  56512. set realTimeFilteringQuality(n: number);
  56513. /**
  56514. * Can this material render to several textures at once
  56515. */
  56516. get canRenderToMRT(): boolean;
  56517. /**
  56518. * Force normal to face away from face.
  56519. */
  56520. protected _forceNormalForward: boolean;
  56521. /**
  56522. * Enables specular anti aliasing in the PBR shader.
  56523. * It will both interacts on the Geometry for analytical and IBL lighting.
  56524. * It also prefilter the roughness map based on the bump values.
  56525. */
  56526. protected _enableSpecularAntiAliasing: boolean;
  56527. /**
  56528. * Default configuration related to image processing available in the PBR Material.
  56529. */
  56530. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56531. /**
  56532. * Keep track of the image processing observer to allow dispose and replace.
  56533. */
  56534. private _imageProcessingObserver;
  56535. /**
  56536. * Attaches a new image processing configuration to the PBR Material.
  56537. * @param configuration
  56538. */
  56539. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56540. /**
  56541. * Stores the available render targets.
  56542. */
  56543. private _renderTargets;
  56544. /**
  56545. * Sets the global ambient color for the material used in lighting calculations.
  56546. */
  56547. private _globalAmbientColor;
  56548. /**
  56549. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56550. */
  56551. private _useLogarithmicDepth;
  56552. /**
  56553. * If set to true, no lighting calculations will be applied.
  56554. */
  56555. private _unlit;
  56556. private _debugMode;
  56557. /**
  56558. * @hidden
  56559. * This is reserved for the inspector.
  56560. * Defines the material debug mode.
  56561. * It helps seeing only some components of the material while troubleshooting.
  56562. */
  56563. debugMode: number;
  56564. /**
  56565. * @hidden
  56566. * This is reserved for the inspector.
  56567. * Specify from where on screen the debug mode should start.
  56568. * The value goes from -1 (full screen) to 1 (not visible)
  56569. * It helps with side by side comparison against the final render
  56570. * This defaults to -1
  56571. */
  56572. private debugLimit;
  56573. /**
  56574. * @hidden
  56575. * This is reserved for the inspector.
  56576. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56577. * You can use the factor to better multiply the final value.
  56578. */
  56579. private debugFactor;
  56580. /**
  56581. * Defines the clear coat layer parameters for the material.
  56582. */
  56583. readonly clearCoat: PBRClearCoatConfiguration;
  56584. /**
  56585. * Defines the anisotropic parameters for the material.
  56586. */
  56587. readonly anisotropy: PBRAnisotropicConfiguration;
  56588. /**
  56589. * Defines the BRDF parameters for the material.
  56590. */
  56591. readonly brdf: PBRBRDFConfiguration;
  56592. /**
  56593. * Defines the Sheen parameters for the material.
  56594. */
  56595. readonly sheen: PBRSheenConfiguration;
  56596. /**
  56597. * Defines the SubSurface parameters for the material.
  56598. */
  56599. readonly subSurface: PBRSubSurfaceConfiguration;
  56600. /**
  56601. * Defines the detail map parameters for the material.
  56602. */
  56603. readonly detailMap: DetailMapConfiguration;
  56604. protected _rebuildInParallel: boolean;
  56605. /**
  56606. * Instantiates a new PBRMaterial instance.
  56607. *
  56608. * @param name The material name
  56609. * @param scene The scene the material will be use in.
  56610. */
  56611. constructor(name: string, scene: Scene);
  56612. /**
  56613. * Gets a boolean indicating that current material needs to register RTT
  56614. */
  56615. get hasRenderTargetTextures(): boolean;
  56616. /**
  56617. * Gets the name of the material class.
  56618. */
  56619. getClassName(): string;
  56620. /**
  56621. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56622. */
  56623. get useLogarithmicDepth(): boolean;
  56624. /**
  56625. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56626. */
  56627. set useLogarithmicDepth(value: boolean);
  56628. /**
  56629. * Returns true if alpha blending should be disabled.
  56630. */
  56631. protected get _disableAlphaBlending(): boolean;
  56632. /**
  56633. * Specifies whether or not this material should be rendered in alpha blend mode.
  56634. */
  56635. needAlphaBlending(): boolean;
  56636. /**
  56637. * Specifies whether or not this material should be rendered in alpha test mode.
  56638. */
  56639. needAlphaTesting(): boolean;
  56640. /**
  56641. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56642. */
  56643. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56644. /**
  56645. * Gets the texture used for the alpha test.
  56646. */
  56647. getAlphaTestTexture(): Nullable<BaseTexture>;
  56648. /**
  56649. * Specifies that the submesh is ready to be used.
  56650. * @param mesh - BJS mesh.
  56651. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56652. * @param useInstances - Specifies that instances should be used.
  56653. * @returns - boolean indicating that the submesh is ready or not.
  56654. */
  56655. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56656. /**
  56657. * Specifies if the material uses metallic roughness workflow.
  56658. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56659. */
  56660. isMetallicWorkflow(): boolean;
  56661. private _prepareEffect;
  56662. private _prepareDefines;
  56663. /**
  56664. * Force shader compilation
  56665. */
  56666. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56667. /**
  56668. * Initializes the uniform buffer layout for the shader.
  56669. */
  56670. buildUniformLayout(): void;
  56671. /**
  56672. * Unbinds the material from the mesh
  56673. */
  56674. unbind(): void;
  56675. /**
  56676. * Binds the submesh data.
  56677. * @param world - The world matrix.
  56678. * @param mesh - The BJS mesh.
  56679. * @param subMesh - A submesh of the BJS mesh.
  56680. */
  56681. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56682. /**
  56683. * Returns the animatable textures.
  56684. * @returns - Array of animatable textures.
  56685. */
  56686. getAnimatables(): IAnimatable[];
  56687. /**
  56688. * Returns the texture used for reflections.
  56689. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56690. */
  56691. private _getReflectionTexture;
  56692. /**
  56693. * Returns an array of the actively used textures.
  56694. * @returns - Array of BaseTextures
  56695. */
  56696. getActiveTextures(): BaseTexture[];
  56697. /**
  56698. * Checks to see if a texture is used in the material.
  56699. * @param texture - Base texture to use.
  56700. * @returns - Boolean specifying if a texture is used in the material.
  56701. */
  56702. hasTexture(texture: BaseTexture): boolean;
  56703. /**
  56704. * Sets the required values to the prepass renderer.
  56705. * @param prePassRenderer defines the prepass renderer to setup
  56706. */
  56707. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56708. /**
  56709. * Disposes the resources of the material.
  56710. * @param forceDisposeEffect - Forces the disposal of effects.
  56711. * @param forceDisposeTextures - Forces the disposal of all textures.
  56712. */
  56713. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56714. }
  56715. }
  56716. declare module BABYLON {
  56717. /**
  56718. * The Physically based material of BJS.
  56719. *
  56720. * This offers the main features of a standard PBR material.
  56721. * For more information, please refer to the documentation :
  56722. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56723. */
  56724. export class PBRMaterial extends PBRBaseMaterial {
  56725. /**
  56726. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56727. */
  56728. static readonly PBRMATERIAL_OPAQUE: number;
  56729. /**
  56730. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56731. */
  56732. static readonly PBRMATERIAL_ALPHATEST: number;
  56733. /**
  56734. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56735. */
  56736. static readonly PBRMATERIAL_ALPHABLEND: number;
  56737. /**
  56738. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56739. * They are also discarded below the alpha cutoff threshold to improve performances.
  56740. */
  56741. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56742. /**
  56743. * Defines the default value of how much AO map is occluding the analytical lights
  56744. * (point spot...).
  56745. */
  56746. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56747. /**
  56748. * Intensity of the direct lights e.g. the four lights available in your scene.
  56749. * This impacts both the direct diffuse and specular highlights.
  56750. */
  56751. directIntensity: number;
  56752. /**
  56753. * Intensity of the emissive part of the material.
  56754. * This helps controlling the emissive effect without modifying the emissive color.
  56755. */
  56756. emissiveIntensity: number;
  56757. /**
  56758. * Intensity of the environment e.g. how much the environment will light the object
  56759. * either through harmonics for rough material or through the refelction for shiny ones.
  56760. */
  56761. environmentIntensity: number;
  56762. /**
  56763. * This is a special control allowing the reduction of the specular highlights coming from the
  56764. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56765. */
  56766. specularIntensity: number;
  56767. /**
  56768. * Debug Control allowing disabling the bump map on this material.
  56769. */
  56770. disableBumpMap: boolean;
  56771. /**
  56772. * AKA Diffuse Texture in standard nomenclature.
  56773. */
  56774. albedoTexture: BaseTexture;
  56775. /**
  56776. * AKA Occlusion Texture in other nomenclature.
  56777. */
  56778. ambientTexture: BaseTexture;
  56779. /**
  56780. * AKA Occlusion Texture Intensity in other nomenclature.
  56781. */
  56782. ambientTextureStrength: number;
  56783. /**
  56784. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56785. * 1 means it completely occludes it
  56786. * 0 mean it has no impact
  56787. */
  56788. ambientTextureImpactOnAnalyticalLights: number;
  56789. /**
  56790. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56791. */
  56792. opacityTexture: BaseTexture;
  56793. /**
  56794. * Stores the reflection values in a texture.
  56795. */
  56796. reflectionTexture: Nullable<BaseTexture>;
  56797. /**
  56798. * Stores the emissive values in a texture.
  56799. */
  56800. emissiveTexture: BaseTexture;
  56801. /**
  56802. * AKA Specular texture in other nomenclature.
  56803. */
  56804. reflectivityTexture: BaseTexture;
  56805. /**
  56806. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56807. */
  56808. metallicTexture: BaseTexture;
  56809. /**
  56810. * Specifies the metallic scalar of the metallic/roughness workflow.
  56811. * Can also be used to scale the metalness values of the metallic texture.
  56812. */
  56813. metallic: Nullable<number>;
  56814. /**
  56815. * Specifies the roughness scalar of the metallic/roughness workflow.
  56816. * Can also be used to scale the roughness values of the metallic texture.
  56817. */
  56818. roughness: Nullable<number>;
  56819. /**
  56820. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56821. * By default the indexOfrefraction is used to compute F0;
  56822. *
  56823. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56824. *
  56825. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56826. * F90 = metallicReflectanceColor;
  56827. */
  56828. metallicF0Factor: number;
  56829. /**
  56830. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56831. * By default the F90 is always 1;
  56832. *
  56833. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56834. *
  56835. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56836. * F90 = metallicReflectanceColor;
  56837. */
  56838. metallicReflectanceColor: Color3;
  56839. /**
  56840. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56841. * This is multiply against the scalar values defined in the material.
  56842. */
  56843. metallicReflectanceTexture: Nullable<BaseTexture>;
  56844. /**
  56845. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56846. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56847. */
  56848. microSurfaceTexture: BaseTexture;
  56849. /**
  56850. * Stores surface normal data used to displace a mesh in a texture.
  56851. */
  56852. bumpTexture: BaseTexture;
  56853. /**
  56854. * Stores the pre-calculated light information of a mesh in a texture.
  56855. */
  56856. lightmapTexture: BaseTexture;
  56857. /**
  56858. * Stores the refracted light information in a texture.
  56859. */
  56860. get refractionTexture(): Nullable<BaseTexture>;
  56861. set refractionTexture(value: Nullable<BaseTexture>);
  56862. /**
  56863. * The color of a material in ambient lighting.
  56864. */
  56865. ambientColor: Color3;
  56866. /**
  56867. * AKA Diffuse Color in other nomenclature.
  56868. */
  56869. albedoColor: Color3;
  56870. /**
  56871. * AKA Specular Color in other nomenclature.
  56872. */
  56873. reflectivityColor: Color3;
  56874. /**
  56875. * The color reflected from the material.
  56876. */
  56877. reflectionColor: Color3;
  56878. /**
  56879. * The color emitted from the material.
  56880. */
  56881. emissiveColor: Color3;
  56882. /**
  56883. * AKA Glossiness in other nomenclature.
  56884. */
  56885. microSurface: number;
  56886. /**
  56887. * Index of refraction of the material base layer.
  56888. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56889. *
  56890. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56891. *
  56892. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56893. */
  56894. get indexOfRefraction(): number;
  56895. set indexOfRefraction(value: number);
  56896. /**
  56897. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56898. */
  56899. get invertRefractionY(): boolean;
  56900. set invertRefractionY(value: boolean);
  56901. /**
  56902. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56903. * Materials half opaque for instance using refraction could benefit from this control.
  56904. */
  56905. get linkRefractionWithTransparency(): boolean;
  56906. set linkRefractionWithTransparency(value: boolean);
  56907. /**
  56908. * If true, the light map contains occlusion information instead of lighting info.
  56909. */
  56910. useLightmapAsShadowmap: boolean;
  56911. /**
  56912. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56913. */
  56914. useAlphaFromAlbedoTexture: boolean;
  56915. /**
  56916. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56917. */
  56918. forceAlphaTest: boolean;
  56919. /**
  56920. * Defines the alpha limits in alpha test mode.
  56921. */
  56922. alphaCutOff: number;
  56923. /**
  56924. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56925. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56926. */
  56927. useSpecularOverAlpha: boolean;
  56928. /**
  56929. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56930. */
  56931. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56932. /**
  56933. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56934. */
  56935. useRoughnessFromMetallicTextureAlpha: boolean;
  56936. /**
  56937. * Specifies if the metallic texture contains the roughness information in its green channel.
  56938. */
  56939. useRoughnessFromMetallicTextureGreen: boolean;
  56940. /**
  56941. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56942. */
  56943. useMetallnessFromMetallicTextureBlue: boolean;
  56944. /**
  56945. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56946. */
  56947. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56948. /**
  56949. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56950. */
  56951. useAmbientInGrayScale: boolean;
  56952. /**
  56953. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56954. * The material will try to infer what glossiness each pixel should be.
  56955. */
  56956. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56957. /**
  56958. * BJS is using an harcoded light falloff based on a manually sets up range.
  56959. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56960. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56961. */
  56962. get usePhysicalLightFalloff(): boolean;
  56963. /**
  56964. * BJS is using an harcoded light falloff based on a manually sets up range.
  56965. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56966. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56967. */
  56968. set usePhysicalLightFalloff(value: boolean);
  56969. /**
  56970. * In order to support the falloff compatibility with gltf, a special mode has been added
  56971. * to reproduce the gltf light falloff.
  56972. */
  56973. get useGLTFLightFalloff(): boolean;
  56974. /**
  56975. * In order to support the falloff compatibility with gltf, a special mode has been added
  56976. * to reproduce the gltf light falloff.
  56977. */
  56978. set useGLTFLightFalloff(value: boolean);
  56979. /**
  56980. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56981. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56982. */
  56983. useRadianceOverAlpha: boolean;
  56984. /**
  56985. * Allows using an object space normal map (instead of tangent space).
  56986. */
  56987. useObjectSpaceNormalMap: boolean;
  56988. /**
  56989. * Allows using the bump map in parallax mode.
  56990. */
  56991. useParallax: boolean;
  56992. /**
  56993. * Allows using the bump map in parallax occlusion mode.
  56994. */
  56995. useParallaxOcclusion: boolean;
  56996. /**
  56997. * Controls the scale bias of the parallax mode.
  56998. */
  56999. parallaxScaleBias: number;
  57000. /**
  57001. * If sets to true, disables all the lights affecting the material.
  57002. */
  57003. disableLighting: boolean;
  57004. /**
  57005. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57006. */
  57007. forceIrradianceInFragment: boolean;
  57008. /**
  57009. * Number of Simultaneous lights allowed on the material.
  57010. */
  57011. maxSimultaneousLights: number;
  57012. /**
  57013. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57014. */
  57015. invertNormalMapX: boolean;
  57016. /**
  57017. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57018. */
  57019. invertNormalMapY: boolean;
  57020. /**
  57021. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57022. */
  57023. twoSidedLighting: boolean;
  57024. /**
  57025. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57026. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57027. */
  57028. useAlphaFresnel: boolean;
  57029. /**
  57030. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57031. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57032. */
  57033. useLinearAlphaFresnel: boolean;
  57034. /**
  57035. * Let user defines the brdf lookup texture used for IBL.
  57036. * A default 8bit version is embedded but you could point at :
  57037. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57038. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57039. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57040. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57041. */
  57042. environmentBRDFTexture: Nullable<BaseTexture>;
  57043. /**
  57044. * Force normal to face away from face.
  57045. */
  57046. forceNormalForward: boolean;
  57047. /**
  57048. * Enables specular anti aliasing in the PBR shader.
  57049. * It will both interacts on the Geometry for analytical and IBL lighting.
  57050. * It also prefilter the roughness map based on the bump values.
  57051. */
  57052. enableSpecularAntiAliasing: boolean;
  57053. /**
  57054. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57055. * makes the reflect vector face the model (under horizon).
  57056. */
  57057. useHorizonOcclusion: boolean;
  57058. /**
  57059. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57060. * too much the area relying on ambient texture to define their ambient occlusion.
  57061. */
  57062. useRadianceOcclusion: boolean;
  57063. /**
  57064. * If set to true, no lighting calculations will be applied.
  57065. */
  57066. unlit: boolean;
  57067. /**
  57068. * Gets the image processing configuration used either in this material.
  57069. */
  57070. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57071. /**
  57072. * Sets the Default image processing configuration used either in the this material.
  57073. *
  57074. * If sets to null, the scene one is in use.
  57075. */
  57076. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57077. /**
  57078. * Gets wether the color curves effect is enabled.
  57079. */
  57080. get cameraColorCurvesEnabled(): boolean;
  57081. /**
  57082. * Sets wether the color curves effect is enabled.
  57083. */
  57084. set cameraColorCurvesEnabled(value: boolean);
  57085. /**
  57086. * Gets wether the color grading effect is enabled.
  57087. */
  57088. get cameraColorGradingEnabled(): boolean;
  57089. /**
  57090. * Gets wether the color grading effect is enabled.
  57091. */
  57092. set cameraColorGradingEnabled(value: boolean);
  57093. /**
  57094. * Gets wether tonemapping is enabled or not.
  57095. */
  57096. get cameraToneMappingEnabled(): boolean;
  57097. /**
  57098. * Sets wether tonemapping is enabled or not
  57099. */
  57100. set cameraToneMappingEnabled(value: boolean);
  57101. /**
  57102. * The camera exposure used on this material.
  57103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57104. * This corresponds to a photographic exposure.
  57105. */
  57106. get cameraExposure(): number;
  57107. /**
  57108. * The camera exposure used on this material.
  57109. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57110. * This corresponds to a photographic exposure.
  57111. */
  57112. set cameraExposure(value: number);
  57113. /**
  57114. * Gets The camera contrast used on this material.
  57115. */
  57116. get cameraContrast(): number;
  57117. /**
  57118. * Sets The camera contrast used on this material.
  57119. */
  57120. set cameraContrast(value: number);
  57121. /**
  57122. * Gets the Color Grading 2D Lookup Texture.
  57123. */
  57124. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57125. /**
  57126. * Sets the Color Grading 2D Lookup Texture.
  57127. */
  57128. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57129. /**
  57130. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57131. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57132. * 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;
  57133. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57134. */
  57135. get cameraColorCurves(): Nullable<ColorCurves>;
  57136. /**
  57137. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57138. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57139. * 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;
  57140. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57141. */
  57142. set cameraColorCurves(value: Nullable<ColorCurves>);
  57143. /**
  57144. * Instantiates a new PBRMaterial instance.
  57145. *
  57146. * @param name The material name
  57147. * @param scene The scene the material will be use in.
  57148. */
  57149. constructor(name: string, scene: Scene);
  57150. /**
  57151. * Returns the name of this material class.
  57152. */
  57153. getClassName(): string;
  57154. /**
  57155. * Makes a duplicate of the current material.
  57156. * @param name - name to use for the new material.
  57157. */
  57158. clone(name: string): PBRMaterial;
  57159. /**
  57160. * Serializes this PBR Material.
  57161. * @returns - An object with the serialized material.
  57162. */
  57163. serialize(): any;
  57164. /**
  57165. * Parses a PBR Material from a serialized object.
  57166. * @param source - Serialized object.
  57167. * @param scene - BJS scene instance.
  57168. * @param rootUrl - url for the scene object
  57169. * @returns - PBRMaterial
  57170. */
  57171. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57172. }
  57173. }
  57174. declare module BABYLON {
  57175. /**
  57176. * Direct draw surface info
  57177. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57178. */
  57179. export interface DDSInfo {
  57180. /**
  57181. * Width of the texture
  57182. */
  57183. width: number;
  57184. /**
  57185. * Width of the texture
  57186. */
  57187. height: number;
  57188. /**
  57189. * Number of Mipmaps for the texture
  57190. * @see https://en.wikipedia.org/wiki/Mipmap
  57191. */
  57192. mipmapCount: number;
  57193. /**
  57194. * If the textures format is a known fourCC format
  57195. * @see https://www.fourcc.org/
  57196. */
  57197. isFourCC: boolean;
  57198. /**
  57199. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57200. */
  57201. isRGB: boolean;
  57202. /**
  57203. * If the texture is a lumincance format
  57204. */
  57205. isLuminance: boolean;
  57206. /**
  57207. * If this is a cube texture
  57208. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57209. */
  57210. isCube: boolean;
  57211. /**
  57212. * If the texture is a compressed format eg. FOURCC_DXT1
  57213. */
  57214. isCompressed: boolean;
  57215. /**
  57216. * The dxgiFormat of the texture
  57217. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57218. */
  57219. dxgiFormat: number;
  57220. /**
  57221. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57222. */
  57223. textureType: number;
  57224. /**
  57225. * Sphericle polynomial created for the dds texture
  57226. */
  57227. sphericalPolynomial?: SphericalPolynomial;
  57228. }
  57229. /**
  57230. * Class used to provide DDS decompression tools
  57231. */
  57232. export class DDSTools {
  57233. /**
  57234. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57235. */
  57236. static StoreLODInAlphaChannel: boolean;
  57237. /**
  57238. * Gets DDS information from an array buffer
  57239. * @param data defines the array buffer view to read data from
  57240. * @returns the DDS information
  57241. */
  57242. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57243. private static _FloatView;
  57244. private static _Int32View;
  57245. private static _ToHalfFloat;
  57246. private static _FromHalfFloat;
  57247. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57248. private static _GetHalfFloatRGBAArrayBuffer;
  57249. private static _GetFloatRGBAArrayBuffer;
  57250. private static _GetFloatAsUIntRGBAArrayBuffer;
  57251. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57252. private static _GetRGBAArrayBuffer;
  57253. private static _ExtractLongWordOrder;
  57254. private static _GetRGBArrayBuffer;
  57255. private static _GetLuminanceArrayBuffer;
  57256. /**
  57257. * Uploads DDS Levels to a Babylon Texture
  57258. * @hidden
  57259. */
  57260. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57261. }
  57262. interface ThinEngine {
  57263. /**
  57264. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57265. * @param rootUrl defines the url where the file to load is located
  57266. * @param scene defines the current scene
  57267. * @param lodScale defines scale to apply to the mip map selection
  57268. * @param lodOffset defines offset to apply to the mip map selection
  57269. * @param onLoad defines an optional callback raised when the texture is loaded
  57270. * @param onError defines an optional callback raised if there is an issue to load the texture
  57271. * @param format defines the format of the data
  57272. * @param forcedExtension defines the extension to use to pick the right loader
  57273. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57274. * @returns the cube texture as an InternalTexture
  57275. */
  57276. 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;
  57277. }
  57278. }
  57279. declare module BABYLON {
  57280. /**
  57281. * Implementation of the DDS Texture Loader.
  57282. * @hidden
  57283. */
  57284. export class _DDSTextureLoader implements IInternalTextureLoader {
  57285. /**
  57286. * Defines wether the loader supports cascade loading the different faces.
  57287. */
  57288. readonly supportCascades: boolean;
  57289. /**
  57290. * This returns if the loader support the current file information.
  57291. * @param extension defines the file extension of the file being loaded
  57292. * @returns true if the loader can load the specified file
  57293. */
  57294. canLoad(extension: string): boolean;
  57295. /**
  57296. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57297. * @param data contains the texture data
  57298. * @param texture defines the BabylonJS internal texture
  57299. * @param createPolynomials will be true if polynomials have been requested
  57300. * @param onLoad defines the callback to trigger once the texture is ready
  57301. * @param onError defines the callback to trigger in case of error
  57302. */
  57303. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57304. /**
  57305. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57306. * @param data contains the texture data
  57307. * @param texture defines the BabylonJS internal texture
  57308. * @param callback defines the method to call once ready to upload
  57309. */
  57310. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57311. }
  57312. }
  57313. declare module BABYLON {
  57314. /**
  57315. * Implementation of the ENV Texture Loader.
  57316. * @hidden
  57317. */
  57318. export class _ENVTextureLoader implements IInternalTextureLoader {
  57319. /**
  57320. * Defines wether the loader supports cascade loading the different faces.
  57321. */
  57322. readonly supportCascades: boolean;
  57323. /**
  57324. * This returns if the loader support the current file information.
  57325. * @param extension defines the file extension of the file being loaded
  57326. * @returns true if the loader can load the specified file
  57327. */
  57328. canLoad(extension: string): boolean;
  57329. /**
  57330. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57331. * @param data contains the texture data
  57332. * @param texture defines the BabylonJS internal texture
  57333. * @param createPolynomials will be true if polynomials have been requested
  57334. * @param onLoad defines the callback to trigger once the texture is ready
  57335. * @param onError defines the callback to trigger in case of error
  57336. */
  57337. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57338. /**
  57339. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57340. * @param data contains the texture data
  57341. * @param texture defines the BabylonJS internal texture
  57342. * @param callback defines the method to call once ready to upload
  57343. */
  57344. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57345. }
  57346. }
  57347. declare module BABYLON {
  57348. /**
  57349. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57350. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57351. */
  57352. export class KhronosTextureContainer {
  57353. /** contents of the KTX container file */
  57354. data: ArrayBufferView;
  57355. private static HEADER_LEN;
  57356. private static COMPRESSED_2D;
  57357. private static COMPRESSED_3D;
  57358. private static TEX_2D;
  57359. private static TEX_3D;
  57360. /**
  57361. * Gets the openGL type
  57362. */
  57363. glType: number;
  57364. /**
  57365. * Gets the openGL type size
  57366. */
  57367. glTypeSize: number;
  57368. /**
  57369. * Gets the openGL format
  57370. */
  57371. glFormat: number;
  57372. /**
  57373. * Gets the openGL internal format
  57374. */
  57375. glInternalFormat: number;
  57376. /**
  57377. * Gets the base internal format
  57378. */
  57379. glBaseInternalFormat: number;
  57380. /**
  57381. * Gets image width in pixel
  57382. */
  57383. pixelWidth: number;
  57384. /**
  57385. * Gets image height in pixel
  57386. */
  57387. pixelHeight: number;
  57388. /**
  57389. * Gets image depth in pixels
  57390. */
  57391. pixelDepth: number;
  57392. /**
  57393. * Gets the number of array elements
  57394. */
  57395. numberOfArrayElements: number;
  57396. /**
  57397. * Gets the number of faces
  57398. */
  57399. numberOfFaces: number;
  57400. /**
  57401. * Gets the number of mipmap levels
  57402. */
  57403. numberOfMipmapLevels: number;
  57404. /**
  57405. * Gets the bytes of key value data
  57406. */
  57407. bytesOfKeyValueData: number;
  57408. /**
  57409. * Gets the load type
  57410. */
  57411. loadType: number;
  57412. /**
  57413. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57414. */
  57415. isInvalid: boolean;
  57416. /**
  57417. * Creates a new KhronosTextureContainer
  57418. * @param data contents of the KTX container file
  57419. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57420. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57421. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57422. */
  57423. constructor(
  57424. /** contents of the KTX container file */
  57425. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57426. /**
  57427. * Uploads KTX content to a Babylon Texture.
  57428. * It is assumed that the texture has already been created & is currently bound
  57429. * @hidden
  57430. */
  57431. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57432. private _upload2DCompressedLevels;
  57433. /**
  57434. * Checks if the given data starts with a KTX file identifier.
  57435. * @param data the data to check
  57436. * @returns true if the data is a KTX file or false otherwise
  57437. */
  57438. static IsValid(data: ArrayBufferView): boolean;
  57439. }
  57440. }
  57441. declare module BABYLON {
  57442. /**
  57443. * Class for loading KTX2 files
  57444. * !!! Experimental Extension Subject to Changes !!!
  57445. * @hidden
  57446. */
  57447. export class KhronosTextureContainer2 {
  57448. private static _ModulePromise;
  57449. private static _TranscodeFormat;
  57450. constructor(engine: ThinEngine);
  57451. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57452. private _determineTranscodeFormat;
  57453. /**
  57454. * Checks if the given data starts with a KTX2 file identifier.
  57455. * @param data the data to check
  57456. * @returns true if the data is a KTX2 file or false otherwise
  57457. */
  57458. static IsValid(data: ArrayBufferView): boolean;
  57459. }
  57460. }
  57461. declare module BABYLON {
  57462. /**
  57463. * Implementation of the KTX Texture Loader.
  57464. * @hidden
  57465. */
  57466. export class _KTXTextureLoader implements IInternalTextureLoader {
  57467. /**
  57468. * Defines wether the loader supports cascade loading the different faces.
  57469. */
  57470. readonly supportCascades: boolean;
  57471. /**
  57472. * This returns if the loader support the current file information.
  57473. * @param extension defines the file extension of the file being loaded
  57474. * @param mimeType defines the optional mime type of the file being loaded
  57475. * @returns true if the loader can load the specified file
  57476. */
  57477. canLoad(extension: string, mimeType?: string): boolean;
  57478. /**
  57479. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57480. * @param data contains the texture data
  57481. * @param texture defines the BabylonJS internal texture
  57482. * @param createPolynomials will be true if polynomials have been requested
  57483. * @param onLoad defines the callback to trigger once the texture is ready
  57484. * @param onError defines the callback to trigger in case of error
  57485. */
  57486. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57487. /**
  57488. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57489. * @param data contains the texture data
  57490. * @param texture defines the BabylonJS internal texture
  57491. * @param callback defines the method to call once ready to upload
  57492. */
  57493. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57494. }
  57495. }
  57496. declare module BABYLON {
  57497. /** @hidden */
  57498. export var _forceSceneHelpersToBundle: boolean;
  57499. interface Scene {
  57500. /**
  57501. * Creates a default light for the scene.
  57502. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57503. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57504. */
  57505. createDefaultLight(replace?: boolean): void;
  57506. /**
  57507. * Creates a default camera for the scene.
  57508. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57509. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57510. * @param replace has default false, when true replaces the active camera in the scene
  57511. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57512. */
  57513. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57514. /**
  57515. * Creates a default camera and a default light.
  57516. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57517. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57518. * @param replace has the default false, when true replaces the active camera/light in the scene
  57519. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57520. */
  57521. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57522. /**
  57523. * Creates a new sky box
  57524. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57525. * @param environmentTexture defines the texture to use as environment texture
  57526. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57527. * @param scale defines the overall scale of the skybox
  57528. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57529. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57530. * @returns a new mesh holding the sky box
  57531. */
  57532. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57533. /**
  57534. * Creates a new environment
  57535. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57536. * @param options defines the options you can use to configure the environment
  57537. * @returns the new EnvironmentHelper
  57538. */
  57539. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57540. /**
  57541. * Creates a new VREXperienceHelper
  57542. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57543. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57544. * @returns a new VREXperienceHelper
  57545. */
  57546. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57547. /**
  57548. * Creates a new WebXRDefaultExperience
  57549. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57550. * @param options experience options
  57551. * @returns a promise for a new WebXRDefaultExperience
  57552. */
  57553. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57554. }
  57555. }
  57556. declare module BABYLON {
  57557. /**
  57558. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57559. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57560. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57561. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57562. */
  57563. export class VideoDome extends TransformNode {
  57564. /**
  57565. * Define the video source as a Monoscopic panoramic 360 video.
  57566. */
  57567. static readonly MODE_MONOSCOPIC: number;
  57568. /**
  57569. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57570. */
  57571. static readonly MODE_TOPBOTTOM: number;
  57572. /**
  57573. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57574. */
  57575. static readonly MODE_SIDEBYSIDE: number;
  57576. private _halfDome;
  57577. private _useDirectMapping;
  57578. /**
  57579. * The video texture being displayed on the sphere
  57580. */
  57581. protected _videoTexture: VideoTexture;
  57582. /**
  57583. * Gets the video texture being displayed on the sphere
  57584. */
  57585. get videoTexture(): VideoTexture;
  57586. /**
  57587. * The skybox material
  57588. */
  57589. protected _material: BackgroundMaterial;
  57590. /**
  57591. * The surface used for the video dome
  57592. */
  57593. protected _mesh: Mesh;
  57594. /**
  57595. * Gets the mesh used for the video dome.
  57596. */
  57597. get mesh(): Mesh;
  57598. /**
  57599. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57600. */
  57601. private _halfDomeMask;
  57602. /**
  57603. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57604. * Also see the options.resolution property.
  57605. */
  57606. get fovMultiplier(): number;
  57607. set fovMultiplier(value: number);
  57608. private _videoMode;
  57609. /**
  57610. * Gets or set the current video mode for the video. It can be:
  57611. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57612. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57613. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57614. */
  57615. get videoMode(): number;
  57616. set videoMode(value: number);
  57617. /**
  57618. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57619. *
  57620. */
  57621. get halfDome(): boolean;
  57622. /**
  57623. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57624. */
  57625. set halfDome(enabled: boolean);
  57626. /**
  57627. * Oberserver used in Stereoscopic VR Mode.
  57628. */
  57629. private _onBeforeCameraRenderObserver;
  57630. /**
  57631. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57632. * @param name Element's name, child elements will append suffixes for their own names.
  57633. * @param urlsOrVideo defines the url(s) or the video element to use
  57634. * @param options An object containing optional or exposed sub element properties
  57635. */
  57636. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57637. resolution?: number;
  57638. clickToPlay?: boolean;
  57639. autoPlay?: boolean;
  57640. loop?: boolean;
  57641. size?: number;
  57642. poster?: string;
  57643. faceForward?: boolean;
  57644. useDirectMapping?: boolean;
  57645. halfDomeMode?: boolean;
  57646. }, scene: Scene);
  57647. private _changeVideoMode;
  57648. /**
  57649. * Releases resources associated with this node.
  57650. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57651. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57652. */
  57653. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57654. }
  57655. }
  57656. declare module BABYLON {
  57657. /**
  57658. * This class can be used to get instrumentation data from a Babylon engine
  57659. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57660. */
  57661. export class EngineInstrumentation implements IDisposable {
  57662. /**
  57663. * Define the instrumented engine.
  57664. */
  57665. engine: Engine;
  57666. private _captureGPUFrameTime;
  57667. private _gpuFrameTimeToken;
  57668. private _gpuFrameTime;
  57669. private _captureShaderCompilationTime;
  57670. private _shaderCompilationTime;
  57671. private _onBeginFrameObserver;
  57672. private _onEndFrameObserver;
  57673. private _onBeforeShaderCompilationObserver;
  57674. private _onAfterShaderCompilationObserver;
  57675. /**
  57676. * Gets the perf counter used for GPU frame time
  57677. */
  57678. get gpuFrameTimeCounter(): PerfCounter;
  57679. /**
  57680. * Gets the GPU frame time capture status
  57681. */
  57682. get captureGPUFrameTime(): boolean;
  57683. /**
  57684. * Enable or disable the GPU frame time capture
  57685. */
  57686. set captureGPUFrameTime(value: boolean);
  57687. /**
  57688. * Gets the perf counter used for shader compilation time
  57689. */
  57690. get shaderCompilationTimeCounter(): PerfCounter;
  57691. /**
  57692. * Gets the shader compilation time capture status
  57693. */
  57694. get captureShaderCompilationTime(): boolean;
  57695. /**
  57696. * Enable or disable the shader compilation time capture
  57697. */
  57698. set captureShaderCompilationTime(value: boolean);
  57699. /**
  57700. * Instantiates a new engine instrumentation.
  57701. * This class can be used to get instrumentation data from a Babylon engine
  57702. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57703. * @param engine Defines the engine to instrument
  57704. */
  57705. constructor(
  57706. /**
  57707. * Define the instrumented engine.
  57708. */
  57709. engine: Engine);
  57710. /**
  57711. * Dispose and release associated resources.
  57712. */
  57713. dispose(): void;
  57714. }
  57715. }
  57716. declare module BABYLON {
  57717. /**
  57718. * This class can be used to get instrumentation data from a Babylon engine
  57719. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57720. */
  57721. export class SceneInstrumentation implements IDisposable {
  57722. /**
  57723. * Defines the scene to instrument
  57724. */
  57725. scene: Scene;
  57726. private _captureActiveMeshesEvaluationTime;
  57727. private _activeMeshesEvaluationTime;
  57728. private _captureRenderTargetsRenderTime;
  57729. private _renderTargetsRenderTime;
  57730. private _captureFrameTime;
  57731. private _frameTime;
  57732. private _captureRenderTime;
  57733. private _renderTime;
  57734. private _captureInterFrameTime;
  57735. private _interFrameTime;
  57736. private _captureParticlesRenderTime;
  57737. private _particlesRenderTime;
  57738. private _captureSpritesRenderTime;
  57739. private _spritesRenderTime;
  57740. private _capturePhysicsTime;
  57741. private _physicsTime;
  57742. private _captureAnimationsTime;
  57743. private _animationsTime;
  57744. private _captureCameraRenderTime;
  57745. private _cameraRenderTime;
  57746. private _onBeforeActiveMeshesEvaluationObserver;
  57747. private _onAfterActiveMeshesEvaluationObserver;
  57748. private _onBeforeRenderTargetsRenderObserver;
  57749. private _onAfterRenderTargetsRenderObserver;
  57750. private _onAfterRenderObserver;
  57751. private _onBeforeDrawPhaseObserver;
  57752. private _onAfterDrawPhaseObserver;
  57753. private _onBeforeAnimationsObserver;
  57754. private _onBeforeParticlesRenderingObserver;
  57755. private _onAfterParticlesRenderingObserver;
  57756. private _onBeforeSpritesRenderingObserver;
  57757. private _onAfterSpritesRenderingObserver;
  57758. private _onBeforePhysicsObserver;
  57759. private _onAfterPhysicsObserver;
  57760. private _onAfterAnimationsObserver;
  57761. private _onBeforeCameraRenderObserver;
  57762. private _onAfterCameraRenderObserver;
  57763. /**
  57764. * Gets the perf counter used for active meshes evaluation time
  57765. */
  57766. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57767. /**
  57768. * Gets the active meshes evaluation time capture status
  57769. */
  57770. get captureActiveMeshesEvaluationTime(): boolean;
  57771. /**
  57772. * Enable or disable the active meshes evaluation time capture
  57773. */
  57774. set captureActiveMeshesEvaluationTime(value: boolean);
  57775. /**
  57776. * Gets the perf counter used for render targets render time
  57777. */
  57778. get renderTargetsRenderTimeCounter(): PerfCounter;
  57779. /**
  57780. * Gets the render targets render time capture status
  57781. */
  57782. get captureRenderTargetsRenderTime(): boolean;
  57783. /**
  57784. * Enable or disable the render targets render time capture
  57785. */
  57786. set captureRenderTargetsRenderTime(value: boolean);
  57787. /**
  57788. * Gets the perf counter used for particles render time
  57789. */
  57790. get particlesRenderTimeCounter(): PerfCounter;
  57791. /**
  57792. * Gets the particles render time capture status
  57793. */
  57794. get captureParticlesRenderTime(): boolean;
  57795. /**
  57796. * Enable or disable the particles render time capture
  57797. */
  57798. set captureParticlesRenderTime(value: boolean);
  57799. /**
  57800. * Gets the perf counter used for sprites render time
  57801. */
  57802. get spritesRenderTimeCounter(): PerfCounter;
  57803. /**
  57804. * Gets the sprites render time capture status
  57805. */
  57806. get captureSpritesRenderTime(): boolean;
  57807. /**
  57808. * Enable or disable the sprites render time capture
  57809. */
  57810. set captureSpritesRenderTime(value: boolean);
  57811. /**
  57812. * Gets the perf counter used for physics time
  57813. */
  57814. get physicsTimeCounter(): PerfCounter;
  57815. /**
  57816. * Gets the physics time capture status
  57817. */
  57818. get capturePhysicsTime(): boolean;
  57819. /**
  57820. * Enable or disable the physics time capture
  57821. */
  57822. set capturePhysicsTime(value: boolean);
  57823. /**
  57824. * Gets the perf counter used for animations time
  57825. */
  57826. get animationsTimeCounter(): PerfCounter;
  57827. /**
  57828. * Gets the animations time capture status
  57829. */
  57830. get captureAnimationsTime(): boolean;
  57831. /**
  57832. * Enable or disable the animations time capture
  57833. */
  57834. set captureAnimationsTime(value: boolean);
  57835. /**
  57836. * Gets the perf counter used for frame time capture
  57837. */
  57838. get frameTimeCounter(): PerfCounter;
  57839. /**
  57840. * Gets the frame time capture status
  57841. */
  57842. get captureFrameTime(): boolean;
  57843. /**
  57844. * Enable or disable the frame time capture
  57845. */
  57846. set captureFrameTime(value: boolean);
  57847. /**
  57848. * Gets the perf counter used for inter-frames time capture
  57849. */
  57850. get interFrameTimeCounter(): PerfCounter;
  57851. /**
  57852. * Gets the inter-frames time capture status
  57853. */
  57854. get captureInterFrameTime(): boolean;
  57855. /**
  57856. * Enable or disable the inter-frames time capture
  57857. */
  57858. set captureInterFrameTime(value: boolean);
  57859. /**
  57860. * Gets the perf counter used for render time capture
  57861. */
  57862. get renderTimeCounter(): PerfCounter;
  57863. /**
  57864. * Gets the render time capture status
  57865. */
  57866. get captureRenderTime(): boolean;
  57867. /**
  57868. * Enable or disable the render time capture
  57869. */
  57870. set captureRenderTime(value: boolean);
  57871. /**
  57872. * Gets the perf counter used for camera render time capture
  57873. */
  57874. get cameraRenderTimeCounter(): PerfCounter;
  57875. /**
  57876. * Gets the camera render time capture status
  57877. */
  57878. get captureCameraRenderTime(): boolean;
  57879. /**
  57880. * Enable or disable the camera render time capture
  57881. */
  57882. set captureCameraRenderTime(value: boolean);
  57883. /**
  57884. * Gets the perf counter used for draw calls
  57885. */
  57886. get drawCallsCounter(): PerfCounter;
  57887. /**
  57888. * Instantiates a new scene instrumentation.
  57889. * This class can be used to get instrumentation data from a Babylon engine
  57890. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57891. * @param scene Defines the scene to instrument
  57892. */
  57893. constructor(
  57894. /**
  57895. * Defines the scene to instrument
  57896. */
  57897. scene: Scene);
  57898. /**
  57899. * Dispose and release associated resources.
  57900. */
  57901. dispose(): void;
  57902. }
  57903. }
  57904. declare module BABYLON {
  57905. /** @hidden */
  57906. export var glowMapGenerationPixelShader: {
  57907. name: string;
  57908. shader: string;
  57909. };
  57910. }
  57911. declare module BABYLON {
  57912. /** @hidden */
  57913. export var glowMapGenerationVertexShader: {
  57914. name: string;
  57915. shader: string;
  57916. };
  57917. }
  57918. declare module BABYLON {
  57919. /**
  57920. * Effect layer options. This helps customizing the behaviour
  57921. * of the effect layer.
  57922. */
  57923. export interface IEffectLayerOptions {
  57924. /**
  57925. * Multiplication factor apply to the canvas size to compute the render target size
  57926. * used to generated the objects (the smaller the faster).
  57927. */
  57928. mainTextureRatio: number;
  57929. /**
  57930. * Enforces a fixed size texture to ensure effect stability across devices.
  57931. */
  57932. mainTextureFixedSize?: number;
  57933. /**
  57934. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57935. */
  57936. alphaBlendingMode: number;
  57937. /**
  57938. * The camera attached to the layer.
  57939. */
  57940. camera: Nullable<Camera>;
  57941. /**
  57942. * The rendering group to draw the layer in.
  57943. */
  57944. renderingGroupId: number;
  57945. }
  57946. /**
  57947. * The effect layer Helps adding post process effect blended with the main pass.
  57948. *
  57949. * This can be for instance use to generate glow or higlight effects on the scene.
  57950. *
  57951. * The effect layer class can not be used directly and is intented to inherited from to be
  57952. * customized per effects.
  57953. */
  57954. export abstract class EffectLayer {
  57955. private _vertexBuffers;
  57956. private _indexBuffer;
  57957. private _cachedDefines;
  57958. private _effectLayerMapGenerationEffect;
  57959. private _effectLayerOptions;
  57960. private _mergeEffect;
  57961. protected _scene: Scene;
  57962. protected _engine: Engine;
  57963. protected _maxSize: number;
  57964. protected _mainTextureDesiredSize: ISize;
  57965. protected _mainTexture: RenderTargetTexture;
  57966. protected _shouldRender: boolean;
  57967. protected _postProcesses: PostProcess[];
  57968. protected _textures: BaseTexture[];
  57969. protected _emissiveTextureAndColor: {
  57970. texture: Nullable<BaseTexture>;
  57971. color: Color4;
  57972. };
  57973. /**
  57974. * The name of the layer
  57975. */
  57976. name: string;
  57977. /**
  57978. * The clear color of the texture used to generate the glow map.
  57979. */
  57980. neutralColor: Color4;
  57981. /**
  57982. * Specifies whether the highlight layer is enabled or not.
  57983. */
  57984. isEnabled: boolean;
  57985. /**
  57986. * Gets the camera attached to the layer.
  57987. */
  57988. get camera(): Nullable<Camera>;
  57989. /**
  57990. * Gets the rendering group id the layer should render in.
  57991. */
  57992. get renderingGroupId(): number;
  57993. set renderingGroupId(renderingGroupId: number);
  57994. /**
  57995. * An event triggered when the effect layer has been disposed.
  57996. */
  57997. onDisposeObservable: Observable<EffectLayer>;
  57998. /**
  57999. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58000. */
  58001. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58002. /**
  58003. * An event triggered when the generated texture is being merged in the scene.
  58004. */
  58005. onBeforeComposeObservable: Observable<EffectLayer>;
  58006. /**
  58007. * An event triggered when the mesh is rendered into the effect render target.
  58008. */
  58009. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58010. /**
  58011. * An event triggered after the mesh has been rendered into the effect render target.
  58012. */
  58013. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58014. /**
  58015. * An event triggered when the generated texture has been merged in the scene.
  58016. */
  58017. onAfterComposeObservable: Observable<EffectLayer>;
  58018. /**
  58019. * An event triggered when the efffect layer changes its size.
  58020. */
  58021. onSizeChangedObservable: Observable<EffectLayer>;
  58022. /** @hidden */
  58023. static _SceneComponentInitialization: (scene: Scene) => void;
  58024. /**
  58025. * Instantiates a new effect Layer and references it in the scene.
  58026. * @param name The name of the layer
  58027. * @param scene The scene to use the layer in
  58028. */
  58029. constructor(
  58030. /** The Friendly of the effect in the scene */
  58031. name: string, scene: Scene);
  58032. /**
  58033. * Get the effect name of the layer.
  58034. * @return The effect name
  58035. */
  58036. abstract getEffectName(): string;
  58037. /**
  58038. * Checks for the readiness of the element composing the layer.
  58039. * @param subMesh the mesh to check for
  58040. * @param useInstances specify whether or not to use instances to render the mesh
  58041. * @return true if ready otherwise, false
  58042. */
  58043. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58044. /**
  58045. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58046. * @returns true if the effect requires stencil during the main canvas render pass.
  58047. */
  58048. abstract needStencil(): boolean;
  58049. /**
  58050. * Create the merge effect. This is the shader use to blit the information back
  58051. * to the main canvas at the end of the scene rendering.
  58052. * @returns The effect containing the shader used to merge the effect on the main canvas
  58053. */
  58054. protected abstract _createMergeEffect(): Effect;
  58055. /**
  58056. * Creates the render target textures and post processes used in the effect layer.
  58057. */
  58058. protected abstract _createTextureAndPostProcesses(): void;
  58059. /**
  58060. * Implementation specific of rendering the generating effect on the main canvas.
  58061. * @param effect The effect used to render through
  58062. */
  58063. protected abstract _internalRender(effect: Effect): void;
  58064. /**
  58065. * Sets the required values for both the emissive texture and and the main color.
  58066. */
  58067. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58068. /**
  58069. * Free any resources and references associated to a mesh.
  58070. * Internal use
  58071. * @param mesh The mesh to free.
  58072. */
  58073. abstract _disposeMesh(mesh: Mesh): void;
  58074. /**
  58075. * Serializes this layer (Glow or Highlight for example)
  58076. * @returns a serialized layer object
  58077. */
  58078. abstract serialize?(): any;
  58079. /**
  58080. * Initializes the effect layer with the required options.
  58081. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58082. */
  58083. protected _init(options: Partial<IEffectLayerOptions>): void;
  58084. /**
  58085. * Generates the index buffer of the full screen quad blending to the main canvas.
  58086. */
  58087. private _generateIndexBuffer;
  58088. /**
  58089. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58090. */
  58091. private _generateVertexBuffer;
  58092. /**
  58093. * Sets the main texture desired size which is the closest power of two
  58094. * of the engine canvas size.
  58095. */
  58096. private _setMainTextureSize;
  58097. /**
  58098. * Creates the main texture for the effect layer.
  58099. */
  58100. protected _createMainTexture(): void;
  58101. /**
  58102. * Adds specific effects defines.
  58103. * @param defines The defines to add specifics to.
  58104. */
  58105. protected _addCustomEffectDefines(defines: string[]): void;
  58106. /**
  58107. * Checks for the readiness of the element composing the layer.
  58108. * @param subMesh the mesh to check for
  58109. * @param useInstances specify whether or not to use instances to render the mesh
  58110. * @param emissiveTexture the associated emissive texture used to generate the glow
  58111. * @return true if ready otherwise, false
  58112. */
  58113. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58114. /**
  58115. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58116. */
  58117. render(): void;
  58118. /**
  58119. * Determine if a given mesh will be used in the current effect.
  58120. * @param mesh mesh to test
  58121. * @returns true if the mesh will be used
  58122. */
  58123. hasMesh(mesh: AbstractMesh): boolean;
  58124. /**
  58125. * Returns true if the layer contains information to display, otherwise false.
  58126. * @returns true if the glow layer should be rendered
  58127. */
  58128. shouldRender(): boolean;
  58129. /**
  58130. * Returns true if the mesh should render, otherwise false.
  58131. * @param mesh The mesh to render
  58132. * @returns true if it should render otherwise false
  58133. */
  58134. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58135. /**
  58136. * Returns true if the mesh can be rendered, otherwise false.
  58137. * @param mesh The mesh to render
  58138. * @param material The material used on the mesh
  58139. * @returns true if it can be rendered otherwise false
  58140. */
  58141. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58142. /**
  58143. * Returns true if the mesh should render, otherwise false.
  58144. * @param mesh The mesh to render
  58145. * @returns true if it should render otherwise false
  58146. */
  58147. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58148. /**
  58149. * Renders the submesh passed in parameter to the generation map.
  58150. */
  58151. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58152. /**
  58153. * Defines whether the current material of the mesh should be use to render the effect.
  58154. * @param mesh defines the current mesh to render
  58155. */
  58156. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58157. /**
  58158. * Rebuild the required buffers.
  58159. * @hidden Internal use only.
  58160. */
  58161. _rebuild(): void;
  58162. /**
  58163. * Dispose only the render target textures and post process.
  58164. */
  58165. private _disposeTextureAndPostProcesses;
  58166. /**
  58167. * Dispose the highlight layer and free resources.
  58168. */
  58169. dispose(): void;
  58170. /**
  58171. * Gets the class name of the effect layer
  58172. * @returns the string with the class name of the effect layer
  58173. */
  58174. getClassName(): string;
  58175. /**
  58176. * Creates an effect layer from parsed effect layer data
  58177. * @param parsedEffectLayer defines effect layer data
  58178. * @param scene defines the current scene
  58179. * @param rootUrl defines the root URL containing the effect layer information
  58180. * @returns a parsed effect Layer
  58181. */
  58182. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58183. }
  58184. }
  58185. declare module BABYLON {
  58186. interface AbstractScene {
  58187. /**
  58188. * The list of effect layers (highlights/glow) added to the scene
  58189. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58190. * @see https://doc.babylonjs.com/how_to/glow_layer
  58191. */
  58192. effectLayers: Array<EffectLayer>;
  58193. /**
  58194. * Removes the given effect layer from this scene.
  58195. * @param toRemove defines the effect layer to remove
  58196. * @returns the index of the removed effect layer
  58197. */
  58198. removeEffectLayer(toRemove: EffectLayer): number;
  58199. /**
  58200. * Adds the given effect layer to this scene
  58201. * @param newEffectLayer defines the effect layer to add
  58202. */
  58203. addEffectLayer(newEffectLayer: EffectLayer): void;
  58204. }
  58205. /**
  58206. * Defines the layer scene component responsible to manage any effect layers
  58207. * in a given scene.
  58208. */
  58209. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58210. /**
  58211. * The component name helpfull to identify the component in the list of scene components.
  58212. */
  58213. readonly name: string;
  58214. /**
  58215. * The scene the component belongs to.
  58216. */
  58217. scene: Scene;
  58218. private _engine;
  58219. private _renderEffects;
  58220. private _needStencil;
  58221. private _previousStencilState;
  58222. /**
  58223. * Creates a new instance of the component for the given scene
  58224. * @param scene Defines the scene to register the component in
  58225. */
  58226. constructor(scene: Scene);
  58227. /**
  58228. * Registers the component in a given scene
  58229. */
  58230. register(): void;
  58231. /**
  58232. * Rebuilds the elements related to this component in case of
  58233. * context lost for instance.
  58234. */
  58235. rebuild(): void;
  58236. /**
  58237. * Serializes the component data to the specified json object
  58238. * @param serializationObject The object to serialize to
  58239. */
  58240. serialize(serializationObject: any): void;
  58241. /**
  58242. * Adds all the elements from the container to the scene
  58243. * @param container the container holding the elements
  58244. */
  58245. addFromContainer(container: AbstractScene): void;
  58246. /**
  58247. * Removes all the elements in the container from the scene
  58248. * @param container contains the elements to remove
  58249. * @param dispose if the removed element should be disposed (default: false)
  58250. */
  58251. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58252. /**
  58253. * Disposes the component and the associated ressources.
  58254. */
  58255. dispose(): void;
  58256. private _isReadyForMesh;
  58257. private _renderMainTexture;
  58258. private _setStencil;
  58259. private _setStencilBack;
  58260. private _draw;
  58261. private _drawCamera;
  58262. private _drawRenderingGroup;
  58263. }
  58264. }
  58265. declare module BABYLON {
  58266. /** @hidden */
  58267. export var glowMapMergePixelShader: {
  58268. name: string;
  58269. shader: string;
  58270. };
  58271. }
  58272. declare module BABYLON {
  58273. /** @hidden */
  58274. export var glowMapMergeVertexShader: {
  58275. name: string;
  58276. shader: string;
  58277. };
  58278. }
  58279. declare module BABYLON {
  58280. interface AbstractScene {
  58281. /**
  58282. * Return a the first highlight layer of the scene with a given name.
  58283. * @param name The name of the highlight layer to look for.
  58284. * @return The highlight layer if found otherwise null.
  58285. */
  58286. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58287. }
  58288. /**
  58289. * Glow layer options. This helps customizing the behaviour
  58290. * of the glow layer.
  58291. */
  58292. export interface IGlowLayerOptions {
  58293. /**
  58294. * Multiplication factor apply to the canvas size to compute the render target size
  58295. * used to generated the glowing objects (the smaller the faster).
  58296. */
  58297. mainTextureRatio: number;
  58298. /**
  58299. * Enforces a fixed size texture to ensure resize independant blur.
  58300. */
  58301. mainTextureFixedSize?: number;
  58302. /**
  58303. * How big is the kernel of the blur texture.
  58304. */
  58305. blurKernelSize: number;
  58306. /**
  58307. * The camera attached to the layer.
  58308. */
  58309. camera: Nullable<Camera>;
  58310. /**
  58311. * Enable MSAA by chosing the number of samples.
  58312. */
  58313. mainTextureSamples?: number;
  58314. /**
  58315. * The rendering group to draw the layer in.
  58316. */
  58317. renderingGroupId: number;
  58318. }
  58319. /**
  58320. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58321. *
  58322. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58323. *
  58324. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58325. */
  58326. export class GlowLayer extends EffectLayer {
  58327. /**
  58328. * Effect Name of the layer.
  58329. */
  58330. static readonly EffectName: string;
  58331. /**
  58332. * The default blur kernel size used for the glow.
  58333. */
  58334. static DefaultBlurKernelSize: number;
  58335. /**
  58336. * The default texture size ratio used for the glow.
  58337. */
  58338. static DefaultTextureRatio: number;
  58339. /**
  58340. * Sets the kernel size of the blur.
  58341. */
  58342. set blurKernelSize(value: number);
  58343. /**
  58344. * Gets the kernel size of the blur.
  58345. */
  58346. get blurKernelSize(): number;
  58347. /**
  58348. * Sets the glow intensity.
  58349. */
  58350. set intensity(value: number);
  58351. /**
  58352. * Gets the glow intensity.
  58353. */
  58354. get intensity(): number;
  58355. private _options;
  58356. private _intensity;
  58357. private _horizontalBlurPostprocess1;
  58358. private _verticalBlurPostprocess1;
  58359. private _horizontalBlurPostprocess2;
  58360. private _verticalBlurPostprocess2;
  58361. private _blurTexture1;
  58362. private _blurTexture2;
  58363. private _postProcesses1;
  58364. private _postProcesses2;
  58365. private _includedOnlyMeshes;
  58366. private _excludedMeshes;
  58367. private _meshesUsingTheirOwnMaterials;
  58368. /**
  58369. * Callback used to let the user override the color selection on a per mesh basis
  58370. */
  58371. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58372. /**
  58373. * Callback used to let the user override the texture selection on a per mesh basis
  58374. */
  58375. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58376. /**
  58377. * Instantiates a new glow Layer and references it to the scene.
  58378. * @param name The name of the layer
  58379. * @param scene The scene to use the layer in
  58380. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58381. */
  58382. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58383. /**
  58384. * Get the effect name of the layer.
  58385. * @return The effect name
  58386. */
  58387. getEffectName(): string;
  58388. /**
  58389. * Create the merge effect. This is the shader use to blit the information back
  58390. * to the main canvas at the end of the scene rendering.
  58391. */
  58392. protected _createMergeEffect(): Effect;
  58393. /**
  58394. * Creates the render target textures and post processes used in the glow layer.
  58395. */
  58396. protected _createTextureAndPostProcesses(): void;
  58397. /**
  58398. * Checks for the readiness of the element composing the layer.
  58399. * @param subMesh the mesh to check for
  58400. * @param useInstances specify wether or not to use instances to render the mesh
  58401. * @param emissiveTexture the associated emissive texture used to generate the glow
  58402. * @return true if ready otherwise, false
  58403. */
  58404. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58405. /**
  58406. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58407. */
  58408. needStencil(): boolean;
  58409. /**
  58410. * Returns true if the mesh can be rendered, otherwise false.
  58411. * @param mesh The mesh to render
  58412. * @param material The material used on the mesh
  58413. * @returns true if it can be rendered otherwise false
  58414. */
  58415. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58416. /**
  58417. * Implementation specific of rendering the generating effect on the main canvas.
  58418. * @param effect The effect used to render through
  58419. */
  58420. protected _internalRender(effect: Effect): void;
  58421. /**
  58422. * Sets the required values for both the emissive texture and and the main color.
  58423. */
  58424. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58425. /**
  58426. * Returns true if the mesh should render, otherwise false.
  58427. * @param mesh The mesh to render
  58428. * @returns true if it should render otherwise false
  58429. */
  58430. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58431. /**
  58432. * Adds specific effects defines.
  58433. * @param defines The defines to add specifics to.
  58434. */
  58435. protected _addCustomEffectDefines(defines: string[]): void;
  58436. /**
  58437. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58438. * @param mesh The mesh to exclude from the glow layer
  58439. */
  58440. addExcludedMesh(mesh: Mesh): void;
  58441. /**
  58442. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58443. * @param mesh The mesh to remove
  58444. */
  58445. removeExcludedMesh(mesh: Mesh): void;
  58446. /**
  58447. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58448. * @param mesh The mesh to include in the glow layer
  58449. */
  58450. addIncludedOnlyMesh(mesh: Mesh): void;
  58451. /**
  58452. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58453. * @param mesh The mesh to remove
  58454. */
  58455. removeIncludedOnlyMesh(mesh: Mesh): void;
  58456. /**
  58457. * Determine if a given mesh will be used in the glow layer
  58458. * @param mesh The mesh to test
  58459. * @returns true if the mesh will be highlighted by the current glow layer
  58460. */
  58461. hasMesh(mesh: AbstractMesh): boolean;
  58462. /**
  58463. * Defines whether the current material of the mesh should be use to render the effect.
  58464. * @param mesh defines the current mesh to render
  58465. */
  58466. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58467. /**
  58468. * Add a mesh to be rendered through its own material and not with emissive only.
  58469. * @param mesh The mesh for which we need to use its material
  58470. */
  58471. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58472. /**
  58473. * Remove a mesh from being rendered through its own material and not with emissive only.
  58474. * @param mesh The mesh for which we need to not use its material
  58475. */
  58476. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58477. /**
  58478. * Free any resources and references associated to a mesh.
  58479. * Internal use
  58480. * @param mesh The mesh to free.
  58481. * @hidden
  58482. */
  58483. _disposeMesh(mesh: Mesh): void;
  58484. /**
  58485. * Gets the class name of the effect layer
  58486. * @returns the string with the class name of the effect layer
  58487. */
  58488. getClassName(): string;
  58489. /**
  58490. * Serializes this glow layer
  58491. * @returns a serialized glow layer object
  58492. */
  58493. serialize(): any;
  58494. /**
  58495. * Creates a Glow Layer from parsed glow layer data
  58496. * @param parsedGlowLayer defines glow layer data
  58497. * @param scene defines the current scene
  58498. * @param rootUrl defines the root URL containing the glow layer information
  58499. * @returns a parsed Glow Layer
  58500. */
  58501. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58502. }
  58503. }
  58504. declare module BABYLON {
  58505. /** @hidden */
  58506. export var glowBlurPostProcessPixelShader: {
  58507. name: string;
  58508. shader: string;
  58509. };
  58510. }
  58511. declare module BABYLON {
  58512. interface AbstractScene {
  58513. /**
  58514. * Return a the first highlight layer of the scene with a given name.
  58515. * @param name The name of the highlight layer to look for.
  58516. * @return The highlight layer if found otherwise null.
  58517. */
  58518. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58519. }
  58520. /**
  58521. * Highlight layer options. This helps customizing the behaviour
  58522. * of the highlight layer.
  58523. */
  58524. export interface IHighlightLayerOptions {
  58525. /**
  58526. * Multiplication factor apply to the canvas size to compute the render target size
  58527. * used to generated the glowing objects (the smaller the faster).
  58528. */
  58529. mainTextureRatio: number;
  58530. /**
  58531. * Enforces a fixed size texture to ensure resize independant blur.
  58532. */
  58533. mainTextureFixedSize?: number;
  58534. /**
  58535. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58536. * of the picture to blur (the smaller the faster).
  58537. */
  58538. blurTextureSizeRatio: number;
  58539. /**
  58540. * How big in texel of the blur texture is the vertical blur.
  58541. */
  58542. blurVerticalSize: number;
  58543. /**
  58544. * How big in texel of the blur texture is the horizontal blur.
  58545. */
  58546. blurHorizontalSize: number;
  58547. /**
  58548. * Alpha blending mode used to apply the blur. Default is combine.
  58549. */
  58550. alphaBlendingMode: number;
  58551. /**
  58552. * The camera attached to the layer.
  58553. */
  58554. camera: Nullable<Camera>;
  58555. /**
  58556. * Should we display highlight as a solid stroke?
  58557. */
  58558. isStroke?: boolean;
  58559. /**
  58560. * The rendering group to draw the layer in.
  58561. */
  58562. renderingGroupId: number;
  58563. }
  58564. /**
  58565. * The highlight layer Helps adding a glow effect around a mesh.
  58566. *
  58567. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58568. * glowy meshes to your scene.
  58569. *
  58570. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58571. */
  58572. export class HighlightLayer extends EffectLayer {
  58573. name: string;
  58574. /**
  58575. * Effect Name of the highlight layer.
  58576. */
  58577. static readonly EffectName: string;
  58578. /**
  58579. * The neutral color used during the preparation of the glow effect.
  58580. * This is black by default as the blend operation is a blend operation.
  58581. */
  58582. static NeutralColor: Color4;
  58583. /**
  58584. * Stencil value used for glowing meshes.
  58585. */
  58586. static GlowingMeshStencilReference: number;
  58587. /**
  58588. * Stencil value used for the other meshes in the scene.
  58589. */
  58590. static NormalMeshStencilReference: number;
  58591. /**
  58592. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58593. */
  58594. innerGlow: boolean;
  58595. /**
  58596. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58597. */
  58598. outerGlow: boolean;
  58599. /**
  58600. * Specifies the horizontal size of the blur.
  58601. */
  58602. set blurHorizontalSize(value: number);
  58603. /**
  58604. * Specifies the vertical size of the blur.
  58605. */
  58606. set blurVerticalSize(value: number);
  58607. /**
  58608. * Gets the horizontal size of the blur.
  58609. */
  58610. get blurHorizontalSize(): number;
  58611. /**
  58612. * Gets the vertical size of the blur.
  58613. */
  58614. get blurVerticalSize(): number;
  58615. /**
  58616. * An event triggered when the highlight layer is being blurred.
  58617. */
  58618. onBeforeBlurObservable: Observable<HighlightLayer>;
  58619. /**
  58620. * An event triggered when the highlight layer has been blurred.
  58621. */
  58622. onAfterBlurObservable: Observable<HighlightLayer>;
  58623. private _instanceGlowingMeshStencilReference;
  58624. private _options;
  58625. private _downSamplePostprocess;
  58626. private _horizontalBlurPostprocess;
  58627. private _verticalBlurPostprocess;
  58628. private _blurTexture;
  58629. private _meshes;
  58630. private _excludedMeshes;
  58631. /**
  58632. * Instantiates a new highlight Layer and references it to the scene..
  58633. * @param name The name of the layer
  58634. * @param scene The scene to use the layer in
  58635. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58636. */
  58637. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58638. /**
  58639. * Get the effect name of the layer.
  58640. * @return The effect name
  58641. */
  58642. getEffectName(): string;
  58643. /**
  58644. * Create the merge effect. This is the shader use to blit the information back
  58645. * to the main canvas at the end of the scene rendering.
  58646. */
  58647. protected _createMergeEffect(): Effect;
  58648. /**
  58649. * Creates the render target textures and post processes used in the highlight layer.
  58650. */
  58651. protected _createTextureAndPostProcesses(): void;
  58652. /**
  58653. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58654. */
  58655. needStencil(): boolean;
  58656. /**
  58657. * Checks for the readiness of the element composing the layer.
  58658. * @param subMesh the mesh to check for
  58659. * @param useInstances specify wether or not to use instances to render the mesh
  58660. * @param emissiveTexture the associated emissive texture used to generate the glow
  58661. * @return true if ready otherwise, false
  58662. */
  58663. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58664. /**
  58665. * Implementation specific of rendering the generating effect on the main canvas.
  58666. * @param effect The effect used to render through
  58667. */
  58668. protected _internalRender(effect: Effect): void;
  58669. /**
  58670. * Returns true if the layer contains information to display, otherwise false.
  58671. */
  58672. shouldRender(): boolean;
  58673. /**
  58674. * Returns true if the mesh should render, otherwise false.
  58675. * @param mesh The mesh to render
  58676. * @returns true if it should render otherwise false
  58677. */
  58678. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58679. /**
  58680. * Returns true if the mesh can be rendered, otherwise false.
  58681. * @param mesh The mesh to render
  58682. * @param material The material used on the mesh
  58683. * @returns true if it can be rendered otherwise false
  58684. */
  58685. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58686. /**
  58687. * Adds specific effects defines.
  58688. * @param defines The defines to add specifics to.
  58689. */
  58690. protected _addCustomEffectDefines(defines: string[]): void;
  58691. /**
  58692. * Sets the required values for both the emissive texture and and the main color.
  58693. */
  58694. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58695. /**
  58696. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58697. * @param mesh The mesh to exclude from the highlight layer
  58698. */
  58699. addExcludedMesh(mesh: Mesh): void;
  58700. /**
  58701. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58702. * @param mesh The mesh to highlight
  58703. */
  58704. removeExcludedMesh(mesh: Mesh): void;
  58705. /**
  58706. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58707. * @param mesh mesh to test
  58708. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58709. */
  58710. hasMesh(mesh: AbstractMesh): boolean;
  58711. /**
  58712. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58713. * @param mesh The mesh to highlight
  58714. * @param color The color of the highlight
  58715. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58716. */
  58717. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58718. /**
  58719. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58720. * @param mesh The mesh to highlight
  58721. */
  58722. removeMesh(mesh: Mesh): void;
  58723. /**
  58724. * Remove all the meshes currently referenced in the highlight layer
  58725. */
  58726. removeAllMeshes(): void;
  58727. /**
  58728. * Force the stencil to the normal expected value for none glowing parts
  58729. */
  58730. private _defaultStencilReference;
  58731. /**
  58732. * Free any resources and references associated to a mesh.
  58733. * Internal use
  58734. * @param mesh The mesh to free.
  58735. * @hidden
  58736. */
  58737. _disposeMesh(mesh: Mesh): void;
  58738. /**
  58739. * Dispose the highlight layer and free resources.
  58740. */
  58741. dispose(): void;
  58742. /**
  58743. * Gets the class name of the effect layer
  58744. * @returns the string with the class name of the effect layer
  58745. */
  58746. getClassName(): string;
  58747. /**
  58748. * Serializes this Highlight layer
  58749. * @returns a serialized Highlight layer object
  58750. */
  58751. serialize(): any;
  58752. /**
  58753. * Creates a Highlight layer from parsed Highlight layer data
  58754. * @param parsedHightlightLayer defines the Highlight layer data
  58755. * @param scene defines the current scene
  58756. * @param rootUrl defines the root URL containing the Highlight layer information
  58757. * @returns a parsed Highlight layer
  58758. */
  58759. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58760. }
  58761. }
  58762. declare module BABYLON {
  58763. interface AbstractScene {
  58764. /**
  58765. * The list of layers (background and foreground) of the scene
  58766. */
  58767. layers: Array<Layer>;
  58768. }
  58769. /**
  58770. * Defines the layer scene component responsible to manage any layers
  58771. * in a given scene.
  58772. */
  58773. export class LayerSceneComponent implements ISceneComponent {
  58774. /**
  58775. * The component name helpfull to identify the component in the list of scene components.
  58776. */
  58777. readonly name: string;
  58778. /**
  58779. * The scene the component belongs to.
  58780. */
  58781. scene: Scene;
  58782. private _engine;
  58783. /**
  58784. * Creates a new instance of the component for the given scene
  58785. * @param scene Defines the scene to register the component in
  58786. */
  58787. constructor(scene: Scene);
  58788. /**
  58789. * Registers the component in a given scene
  58790. */
  58791. register(): void;
  58792. /**
  58793. * Rebuilds the elements related to this component in case of
  58794. * context lost for instance.
  58795. */
  58796. rebuild(): void;
  58797. /**
  58798. * Disposes the component and the associated ressources.
  58799. */
  58800. dispose(): void;
  58801. private _draw;
  58802. private _drawCameraPredicate;
  58803. private _drawCameraBackground;
  58804. private _drawCameraForeground;
  58805. private _drawRenderTargetPredicate;
  58806. private _drawRenderTargetBackground;
  58807. private _drawRenderTargetForeground;
  58808. /**
  58809. * Adds all the elements from the container to the scene
  58810. * @param container the container holding the elements
  58811. */
  58812. addFromContainer(container: AbstractScene): void;
  58813. /**
  58814. * Removes all the elements in the container from the scene
  58815. * @param container contains the elements to remove
  58816. * @param dispose if the removed element should be disposed (default: false)
  58817. */
  58818. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58819. }
  58820. }
  58821. declare module BABYLON {
  58822. /** @hidden */
  58823. export var layerPixelShader: {
  58824. name: string;
  58825. shader: string;
  58826. };
  58827. }
  58828. declare module BABYLON {
  58829. /** @hidden */
  58830. export var layerVertexShader: {
  58831. name: string;
  58832. shader: string;
  58833. };
  58834. }
  58835. declare module BABYLON {
  58836. /**
  58837. * This represents a full screen 2d layer.
  58838. * This can be useful to display a picture in the background of your scene for instance.
  58839. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58840. */
  58841. export class Layer {
  58842. /**
  58843. * Define the name of the layer.
  58844. */
  58845. name: string;
  58846. /**
  58847. * Define the texture the layer should display.
  58848. */
  58849. texture: Nullable<Texture>;
  58850. /**
  58851. * Is the layer in background or foreground.
  58852. */
  58853. isBackground: boolean;
  58854. /**
  58855. * Define the color of the layer (instead of texture).
  58856. */
  58857. color: Color4;
  58858. /**
  58859. * Define the scale of the layer in order to zoom in out of the texture.
  58860. */
  58861. scale: Vector2;
  58862. /**
  58863. * Define an offset for the layer in order to shift the texture.
  58864. */
  58865. offset: Vector2;
  58866. /**
  58867. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58868. */
  58869. alphaBlendingMode: number;
  58870. /**
  58871. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58872. * Alpha test will not mix with the background color in case of transparency.
  58873. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58874. */
  58875. alphaTest: boolean;
  58876. /**
  58877. * Define a mask to restrict the layer to only some of the scene cameras.
  58878. */
  58879. layerMask: number;
  58880. /**
  58881. * Define the list of render target the layer is visible into.
  58882. */
  58883. renderTargetTextures: RenderTargetTexture[];
  58884. /**
  58885. * Define if the layer is only used in renderTarget or if it also
  58886. * renders in the main frame buffer of the canvas.
  58887. */
  58888. renderOnlyInRenderTargetTextures: boolean;
  58889. private _scene;
  58890. private _vertexBuffers;
  58891. private _indexBuffer;
  58892. private _effect;
  58893. private _previousDefines;
  58894. /**
  58895. * An event triggered when the layer is disposed.
  58896. */
  58897. onDisposeObservable: Observable<Layer>;
  58898. private _onDisposeObserver;
  58899. /**
  58900. * Back compatibility with callback before the onDisposeObservable existed.
  58901. * The set callback will be triggered when the layer has been disposed.
  58902. */
  58903. set onDispose(callback: () => void);
  58904. /**
  58905. * An event triggered before rendering the scene
  58906. */
  58907. onBeforeRenderObservable: Observable<Layer>;
  58908. private _onBeforeRenderObserver;
  58909. /**
  58910. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58911. * The set callback will be triggered just before rendering the layer.
  58912. */
  58913. set onBeforeRender(callback: () => void);
  58914. /**
  58915. * An event triggered after rendering the scene
  58916. */
  58917. onAfterRenderObservable: Observable<Layer>;
  58918. private _onAfterRenderObserver;
  58919. /**
  58920. * Back compatibility with callback before the onAfterRenderObservable existed.
  58921. * The set callback will be triggered just after rendering the layer.
  58922. */
  58923. set onAfterRender(callback: () => void);
  58924. /**
  58925. * Instantiates a new layer.
  58926. * This represents a full screen 2d layer.
  58927. * This can be useful to display a picture in the background of your scene for instance.
  58928. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58929. * @param name Define the name of the layer in the scene
  58930. * @param imgUrl Define the url of the texture to display in the layer
  58931. * @param scene Define the scene the layer belongs to
  58932. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58933. * @param color Defines a color for the layer
  58934. */
  58935. constructor(
  58936. /**
  58937. * Define the name of the layer.
  58938. */
  58939. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58940. private _createIndexBuffer;
  58941. /** @hidden */
  58942. _rebuild(): void;
  58943. /**
  58944. * Renders the layer in the scene.
  58945. */
  58946. render(): void;
  58947. /**
  58948. * Disposes and releases the associated ressources.
  58949. */
  58950. dispose(): void;
  58951. }
  58952. }
  58953. declare module BABYLON {
  58954. /** @hidden */
  58955. export var lensFlarePixelShader: {
  58956. name: string;
  58957. shader: string;
  58958. };
  58959. }
  58960. declare module BABYLON {
  58961. /** @hidden */
  58962. export var lensFlareVertexShader: {
  58963. name: string;
  58964. shader: string;
  58965. };
  58966. }
  58967. declare module BABYLON {
  58968. /**
  58969. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58970. * It is usually composed of several `lensFlare`.
  58971. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58972. */
  58973. export class LensFlareSystem {
  58974. /**
  58975. * Define the name of the lens flare system
  58976. */
  58977. name: string;
  58978. /**
  58979. * List of lens flares used in this system.
  58980. */
  58981. lensFlares: LensFlare[];
  58982. /**
  58983. * Define a limit from the border the lens flare can be visible.
  58984. */
  58985. borderLimit: number;
  58986. /**
  58987. * Define a viewport border we do not want to see the lens flare in.
  58988. */
  58989. viewportBorder: number;
  58990. /**
  58991. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58992. */
  58993. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58994. /**
  58995. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58996. */
  58997. layerMask: number;
  58998. /**
  58999. * Define the id of the lens flare system in the scene.
  59000. * (equal to name by default)
  59001. */
  59002. id: string;
  59003. private _scene;
  59004. private _emitter;
  59005. private _vertexBuffers;
  59006. private _indexBuffer;
  59007. private _effect;
  59008. private _positionX;
  59009. private _positionY;
  59010. private _isEnabled;
  59011. /** @hidden */
  59012. static _SceneComponentInitialization: (scene: Scene) => void;
  59013. /**
  59014. * Instantiates a lens flare system.
  59015. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59016. * It is usually composed of several `lensFlare`.
  59017. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59018. * @param name Define the name of the lens flare system in the scene
  59019. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59020. * @param scene Define the scene the lens flare system belongs to
  59021. */
  59022. constructor(
  59023. /**
  59024. * Define the name of the lens flare system
  59025. */
  59026. name: string, emitter: any, scene: Scene);
  59027. /**
  59028. * Define if the lens flare system is enabled.
  59029. */
  59030. get isEnabled(): boolean;
  59031. set isEnabled(value: boolean);
  59032. /**
  59033. * Get the scene the effects belongs to.
  59034. * @returns the scene holding the lens flare system
  59035. */
  59036. getScene(): Scene;
  59037. /**
  59038. * Get the emitter of the lens flare system.
  59039. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59040. * @returns the emitter of the lens flare system
  59041. */
  59042. getEmitter(): any;
  59043. /**
  59044. * Set the emitter of the lens flare system.
  59045. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59046. * @param newEmitter Define the new emitter of the system
  59047. */
  59048. setEmitter(newEmitter: any): void;
  59049. /**
  59050. * Get the lens flare system emitter position.
  59051. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59052. * @returns the position
  59053. */
  59054. getEmitterPosition(): Vector3;
  59055. /**
  59056. * @hidden
  59057. */
  59058. computeEffectivePosition(globalViewport: Viewport): boolean;
  59059. /** @hidden */
  59060. _isVisible(): boolean;
  59061. /**
  59062. * @hidden
  59063. */
  59064. render(): boolean;
  59065. /**
  59066. * Dispose and release the lens flare with its associated resources.
  59067. */
  59068. dispose(): void;
  59069. /**
  59070. * Parse a lens flare system from a JSON repressentation
  59071. * @param parsedLensFlareSystem Define the JSON to parse
  59072. * @param scene Define the scene the parsed system should be instantiated in
  59073. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59074. * @returns the parsed system
  59075. */
  59076. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59077. /**
  59078. * Serialize the current Lens Flare System into a JSON representation.
  59079. * @returns the serialized JSON
  59080. */
  59081. serialize(): any;
  59082. }
  59083. }
  59084. declare module BABYLON {
  59085. /**
  59086. * This represents one of the lens effect in a `lensFlareSystem`.
  59087. * It controls one of the indiviual texture used in the effect.
  59088. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59089. */
  59090. export class LensFlare {
  59091. /**
  59092. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59093. */
  59094. size: number;
  59095. /**
  59096. * 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.
  59097. */
  59098. position: number;
  59099. /**
  59100. * Define the lens color.
  59101. */
  59102. color: Color3;
  59103. /**
  59104. * Define the lens texture.
  59105. */
  59106. texture: Nullable<Texture>;
  59107. /**
  59108. * Define the alpha mode to render this particular lens.
  59109. */
  59110. alphaMode: number;
  59111. private _system;
  59112. /**
  59113. * Creates a new Lens Flare.
  59114. * This represents one of the lens effect in a `lensFlareSystem`.
  59115. * It controls one of the indiviual texture used in the effect.
  59116. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59117. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59118. * @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.
  59119. * @param color Define the lens color
  59120. * @param imgUrl Define the lens texture url
  59121. * @param system Define the `lensFlareSystem` this flare is part of
  59122. * @returns The newly created Lens Flare
  59123. */
  59124. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59125. /**
  59126. * Instantiates a new Lens Flare.
  59127. * This represents one of the lens effect in a `lensFlareSystem`.
  59128. * It controls one of the indiviual texture used in the effect.
  59129. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59130. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59131. * @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.
  59132. * @param color Define the lens color
  59133. * @param imgUrl Define the lens texture url
  59134. * @param system Define the `lensFlareSystem` this flare is part of
  59135. */
  59136. constructor(
  59137. /**
  59138. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59139. */
  59140. size: number,
  59141. /**
  59142. * 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.
  59143. */
  59144. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59145. /**
  59146. * Dispose and release the lens flare with its associated resources.
  59147. */
  59148. dispose(): void;
  59149. }
  59150. }
  59151. declare module BABYLON {
  59152. interface AbstractScene {
  59153. /**
  59154. * The list of lens flare system added to the scene
  59155. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59156. */
  59157. lensFlareSystems: Array<LensFlareSystem>;
  59158. /**
  59159. * Removes the given lens flare system from this scene.
  59160. * @param toRemove The lens flare system to remove
  59161. * @returns The index of the removed lens flare system
  59162. */
  59163. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59164. /**
  59165. * Adds the given lens flare system to this scene
  59166. * @param newLensFlareSystem The lens flare system to add
  59167. */
  59168. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59169. /**
  59170. * Gets a lens flare system using its name
  59171. * @param name defines the name to look for
  59172. * @returns the lens flare system or null if not found
  59173. */
  59174. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59175. /**
  59176. * Gets a lens flare system using its id
  59177. * @param id defines the id to look for
  59178. * @returns the lens flare system or null if not found
  59179. */
  59180. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59181. }
  59182. /**
  59183. * Defines the lens flare scene component responsible to manage any lens flares
  59184. * in a given scene.
  59185. */
  59186. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59187. /**
  59188. * The component name helpfull to identify the component in the list of scene components.
  59189. */
  59190. readonly name: string;
  59191. /**
  59192. * The scene the component belongs to.
  59193. */
  59194. scene: Scene;
  59195. /**
  59196. * Creates a new instance of the component for the given scene
  59197. * @param scene Defines the scene to register the component in
  59198. */
  59199. constructor(scene: Scene);
  59200. /**
  59201. * Registers the component in a given scene
  59202. */
  59203. register(): void;
  59204. /**
  59205. * Rebuilds the elements related to this component in case of
  59206. * context lost for instance.
  59207. */
  59208. rebuild(): void;
  59209. /**
  59210. * Adds all the elements from the container to the scene
  59211. * @param container the container holding the elements
  59212. */
  59213. addFromContainer(container: AbstractScene): void;
  59214. /**
  59215. * Removes all the elements in the container from the scene
  59216. * @param container contains the elements to remove
  59217. * @param dispose if the removed element should be disposed (default: false)
  59218. */
  59219. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59220. /**
  59221. * Serializes the component data to the specified json object
  59222. * @param serializationObject The object to serialize to
  59223. */
  59224. serialize(serializationObject: any): void;
  59225. /**
  59226. * Disposes the component and the associated ressources.
  59227. */
  59228. dispose(): void;
  59229. private _draw;
  59230. }
  59231. }
  59232. declare module BABYLON {
  59233. /** @hidden */
  59234. export var depthPixelShader: {
  59235. name: string;
  59236. shader: string;
  59237. };
  59238. }
  59239. declare module BABYLON {
  59240. /** @hidden */
  59241. export var depthVertexShader: {
  59242. name: string;
  59243. shader: string;
  59244. };
  59245. }
  59246. declare module BABYLON {
  59247. /**
  59248. * This represents a depth renderer in Babylon.
  59249. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59250. */
  59251. export class DepthRenderer {
  59252. private _scene;
  59253. private _depthMap;
  59254. private _effect;
  59255. private readonly _storeNonLinearDepth;
  59256. private readonly _clearColor;
  59257. /** Get if the depth renderer is using packed depth or not */
  59258. readonly isPacked: boolean;
  59259. private _cachedDefines;
  59260. private _camera;
  59261. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59262. enabled: boolean;
  59263. /**
  59264. * Specifiess that the depth renderer will only be used within
  59265. * the camera it is created for.
  59266. * This can help forcing its rendering during the camera processing.
  59267. */
  59268. useOnlyInActiveCamera: boolean;
  59269. /** @hidden */
  59270. static _SceneComponentInitialization: (scene: Scene) => void;
  59271. /**
  59272. * Instantiates a depth renderer
  59273. * @param scene The scene the renderer belongs to
  59274. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59275. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59276. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59277. */
  59278. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59279. /**
  59280. * Creates the depth rendering effect and checks if the effect is ready.
  59281. * @param subMesh The submesh to be used to render the depth map of
  59282. * @param useInstances If multiple world instances should be used
  59283. * @returns if the depth renderer is ready to render the depth map
  59284. */
  59285. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59286. /**
  59287. * Gets the texture which the depth map will be written to.
  59288. * @returns The depth map texture
  59289. */
  59290. getDepthMap(): RenderTargetTexture;
  59291. /**
  59292. * Disposes of the depth renderer.
  59293. */
  59294. dispose(): void;
  59295. }
  59296. }
  59297. declare module BABYLON {
  59298. /** @hidden */
  59299. export var minmaxReduxPixelShader: {
  59300. name: string;
  59301. shader: string;
  59302. };
  59303. }
  59304. declare module BABYLON {
  59305. /**
  59306. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59307. * and maximum values from all values of the texture.
  59308. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59309. * The source values are read from the red channel of the texture.
  59310. */
  59311. export class MinMaxReducer {
  59312. /**
  59313. * Observable triggered when the computation has been performed
  59314. */
  59315. onAfterReductionPerformed: Observable<{
  59316. min: number;
  59317. max: number;
  59318. }>;
  59319. protected _camera: Camera;
  59320. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59321. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59322. protected _postProcessManager: PostProcessManager;
  59323. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59324. protected _forceFullscreenViewport: boolean;
  59325. /**
  59326. * Creates a min/max reducer
  59327. * @param camera The camera to use for the post processes
  59328. */
  59329. constructor(camera: Camera);
  59330. /**
  59331. * Gets the texture used to read the values from.
  59332. */
  59333. get sourceTexture(): Nullable<RenderTargetTexture>;
  59334. /**
  59335. * Sets the source texture to read the values from.
  59336. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59337. * because in such textures '1' value must not be taken into account to compute the maximum
  59338. * as this value is used to clear the texture.
  59339. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59340. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59341. * @param depthRedux Indicates if the texture is a depth texture or not
  59342. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59343. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59344. */
  59345. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59346. /**
  59347. * Defines the refresh rate of the computation.
  59348. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59349. */
  59350. get refreshRate(): number;
  59351. set refreshRate(value: number);
  59352. protected _activated: boolean;
  59353. /**
  59354. * Gets the activation status of the reducer
  59355. */
  59356. get activated(): boolean;
  59357. /**
  59358. * Activates the reduction computation.
  59359. * When activated, the observers registered in onAfterReductionPerformed are
  59360. * called after the compuation is performed
  59361. */
  59362. activate(): void;
  59363. /**
  59364. * Deactivates the reduction computation.
  59365. */
  59366. deactivate(): void;
  59367. /**
  59368. * Disposes the min/max reducer
  59369. * @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.
  59370. */
  59371. dispose(disposeAll?: boolean): void;
  59372. }
  59373. }
  59374. declare module BABYLON {
  59375. /**
  59376. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59377. */
  59378. export class DepthReducer extends MinMaxReducer {
  59379. private _depthRenderer;
  59380. private _depthRendererId;
  59381. /**
  59382. * Gets the depth renderer used for the computation.
  59383. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59384. */
  59385. get depthRenderer(): Nullable<DepthRenderer>;
  59386. /**
  59387. * Creates a depth reducer
  59388. * @param camera The camera used to render the depth texture
  59389. */
  59390. constructor(camera: Camera);
  59391. /**
  59392. * Sets the depth renderer to use to generate the depth map
  59393. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59394. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59395. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59396. */
  59397. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59398. /** @hidden */
  59399. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59400. /**
  59401. * Activates the reduction computation.
  59402. * When activated, the observers registered in onAfterReductionPerformed are
  59403. * called after the compuation is performed
  59404. */
  59405. activate(): void;
  59406. /**
  59407. * Deactivates the reduction computation.
  59408. */
  59409. deactivate(): void;
  59410. /**
  59411. * Disposes the depth reducer
  59412. * @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.
  59413. */
  59414. dispose(disposeAll?: boolean): void;
  59415. }
  59416. }
  59417. declare module BABYLON {
  59418. /**
  59419. * A CSM implementation allowing casting shadows on large scenes.
  59420. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59421. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59422. */
  59423. export class CascadedShadowGenerator extends ShadowGenerator {
  59424. private static readonly frustumCornersNDCSpace;
  59425. /**
  59426. * Name of the CSM class
  59427. */
  59428. static CLASSNAME: string;
  59429. /**
  59430. * Defines the default number of cascades used by the CSM.
  59431. */
  59432. static readonly DEFAULT_CASCADES_COUNT: number;
  59433. /**
  59434. * Defines the minimum number of cascades used by the CSM.
  59435. */
  59436. static readonly MIN_CASCADES_COUNT: number;
  59437. /**
  59438. * Defines the maximum number of cascades used by the CSM.
  59439. */
  59440. static readonly MAX_CASCADES_COUNT: number;
  59441. protected _validateFilter(filter: number): number;
  59442. /**
  59443. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59444. */
  59445. penumbraDarkness: number;
  59446. private _numCascades;
  59447. /**
  59448. * Gets or set the number of cascades used by the CSM.
  59449. */
  59450. get numCascades(): number;
  59451. set numCascades(value: number);
  59452. /**
  59453. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59454. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59455. */
  59456. stabilizeCascades: boolean;
  59457. private _freezeShadowCastersBoundingInfo;
  59458. private _freezeShadowCastersBoundingInfoObservable;
  59459. /**
  59460. * Enables or disables the shadow casters bounding info computation.
  59461. * If your shadow casters don't move, you can disable this feature.
  59462. * If it is enabled, the bounding box computation is done every frame.
  59463. */
  59464. get freezeShadowCastersBoundingInfo(): boolean;
  59465. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59466. private _scbiMin;
  59467. private _scbiMax;
  59468. protected _computeShadowCastersBoundingInfo(): void;
  59469. protected _shadowCastersBoundingInfo: BoundingInfo;
  59470. /**
  59471. * Gets or sets the shadow casters bounding info.
  59472. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59473. * so that the system won't overwrite the bounds you provide
  59474. */
  59475. get shadowCastersBoundingInfo(): BoundingInfo;
  59476. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59477. protected _breaksAreDirty: boolean;
  59478. protected _minDistance: number;
  59479. protected _maxDistance: number;
  59480. /**
  59481. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59482. *
  59483. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59484. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59485. * @param min minimal distance for the breaks (default to 0.)
  59486. * @param max maximal distance for the breaks (default to 1.)
  59487. */
  59488. setMinMaxDistance(min: number, max: number): void;
  59489. /** Gets the minimal distance used in the cascade break computation */
  59490. get minDistance(): number;
  59491. /** Gets the maximal distance used in the cascade break computation */
  59492. get maxDistance(): number;
  59493. /**
  59494. * Gets the class name of that object
  59495. * @returns "CascadedShadowGenerator"
  59496. */
  59497. getClassName(): string;
  59498. private _cascadeMinExtents;
  59499. private _cascadeMaxExtents;
  59500. /**
  59501. * Gets a cascade minimum extents
  59502. * @param cascadeIndex index of the cascade
  59503. * @returns the minimum cascade extents
  59504. */
  59505. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59506. /**
  59507. * Gets a cascade maximum extents
  59508. * @param cascadeIndex index of the cascade
  59509. * @returns the maximum cascade extents
  59510. */
  59511. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59512. private _cascades;
  59513. private _currentLayer;
  59514. private _viewSpaceFrustumsZ;
  59515. private _viewMatrices;
  59516. private _projectionMatrices;
  59517. private _transformMatrices;
  59518. private _transformMatricesAsArray;
  59519. private _frustumLengths;
  59520. private _lightSizeUVCorrection;
  59521. private _depthCorrection;
  59522. private _frustumCornersWorldSpace;
  59523. private _frustumCenter;
  59524. private _shadowCameraPos;
  59525. private _shadowMaxZ;
  59526. /**
  59527. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59528. * It defaults to camera.maxZ
  59529. */
  59530. get shadowMaxZ(): number;
  59531. /**
  59532. * Sets the shadow max z distance.
  59533. */
  59534. set shadowMaxZ(value: number);
  59535. protected _debug: boolean;
  59536. /**
  59537. * Gets or sets the debug flag.
  59538. * When enabled, the cascades are materialized by different colors on the screen.
  59539. */
  59540. get debug(): boolean;
  59541. set debug(dbg: boolean);
  59542. private _depthClamp;
  59543. /**
  59544. * Gets or sets the depth clamping value.
  59545. *
  59546. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59547. * to account for the shadow casters far away.
  59548. *
  59549. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59550. */
  59551. get depthClamp(): boolean;
  59552. set depthClamp(value: boolean);
  59553. private _cascadeBlendPercentage;
  59554. /**
  59555. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59556. * It defaults to 0.1 (10% blending).
  59557. */
  59558. get cascadeBlendPercentage(): number;
  59559. set cascadeBlendPercentage(value: number);
  59560. private _lambda;
  59561. /**
  59562. * Gets or set the lambda parameter.
  59563. * This parameter is used to split the camera frustum and create the cascades.
  59564. * 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.
  59565. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59566. */
  59567. get lambda(): number;
  59568. set lambda(value: number);
  59569. /**
  59570. * Gets the view matrix corresponding to a given cascade
  59571. * @param cascadeNum cascade to retrieve the view matrix from
  59572. * @returns the cascade view matrix
  59573. */
  59574. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59575. /**
  59576. * Gets the projection matrix corresponding to a given cascade
  59577. * @param cascadeNum cascade to retrieve the projection matrix from
  59578. * @returns the cascade projection matrix
  59579. */
  59580. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59581. /**
  59582. * Gets the transformation matrix corresponding to a given cascade
  59583. * @param cascadeNum cascade to retrieve the transformation matrix from
  59584. * @returns the cascade transformation matrix
  59585. */
  59586. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59587. private _depthRenderer;
  59588. /**
  59589. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59590. *
  59591. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59592. *
  59593. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59594. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59595. * @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
  59596. */
  59597. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59598. private _depthReducer;
  59599. private _autoCalcDepthBounds;
  59600. /**
  59601. * Gets or sets the autoCalcDepthBounds property.
  59602. *
  59603. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59604. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59605. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59606. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59607. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59608. */
  59609. get autoCalcDepthBounds(): boolean;
  59610. set autoCalcDepthBounds(value: boolean);
  59611. /**
  59612. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59613. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59614. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59615. * for setting the refresh rate on the renderer yourself!
  59616. */
  59617. get autoCalcDepthBoundsRefreshRate(): number;
  59618. set autoCalcDepthBoundsRefreshRate(value: number);
  59619. /**
  59620. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59621. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59622. * you change the camera near/far planes!
  59623. */
  59624. splitFrustum(): void;
  59625. private _splitFrustum;
  59626. private _computeMatrices;
  59627. private _computeFrustumInWorldSpace;
  59628. private _computeCascadeFrustum;
  59629. /**
  59630. * Support test.
  59631. */
  59632. static get IsSupported(): boolean;
  59633. /** @hidden */
  59634. static _SceneComponentInitialization: (scene: Scene) => void;
  59635. /**
  59636. * Creates a Cascaded Shadow Generator object.
  59637. * A ShadowGenerator is the required tool to use the shadows.
  59638. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59639. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59640. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59641. * @param light The directional light object generating the shadows.
  59642. * @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.
  59643. */
  59644. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59645. protected _initializeGenerator(): void;
  59646. protected _createTargetRenderTexture(): void;
  59647. protected _initializeShadowMap(): void;
  59648. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59649. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59650. /**
  59651. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59652. * @param defines Defines of the material we want to update
  59653. * @param lightIndex Index of the light in the enabled light list of the material
  59654. */
  59655. prepareDefines(defines: any, lightIndex: number): void;
  59656. /**
  59657. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59658. * defined in the generator but impacting the effect).
  59659. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59660. * @param effect The effect we are binfing the information for
  59661. */
  59662. bindShadowLight(lightIndex: string, effect: Effect): void;
  59663. /**
  59664. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59665. * (eq to view projection * shadow projection matrices)
  59666. * @returns The transform matrix used to create the shadow map
  59667. */
  59668. getTransformMatrix(): Matrix;
  59669. /**
  59670. * Disposes the ShadowGenerator.
  59671. * Returns nothing.
  59672. */
  59673. dispose(): void;
  59674. /**
  59675. * Serializes the shadow generator setup to a json object.
  59676. * @returns The serialized JSON object
  59677. */
  59678. serialize(): any;
  59679. /**
  59680. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59681. * @param parsedShadowGenerator The JSON object to parse
  59682. * @param scene The scene to create the shadow map for
  59683. * @returns The parsed shadow generator
  59684. */
  59685. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59686. }
  59687. }
  59688. declare module BABYLON {
  59689. /**
  59690. * Defines the shadow generator component responsible to manage any shadow generators
  59691. * in a given scene.
  59692. */
  59693. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59694. /**
  59695. * The component name helpfull to identify the component in the list of scene components.
  59696. */
  59697. readonly name: string;
  59698. /**
  59699. * The scene the component belongs to.
  59700. */
  59701. scene: Scene;
  59702. /**
  59703. * Creates a new instance of the component for the given scene
  59704. * @param scene Defines the scene to register the component in
  59705. */
  59706. constructor(scene: Scene);
  59707. /**
  59708. * Registers the component in a given scene
  59709. */
  59710. register(): void;
  59711. /**
  59712. * Rebuilds the elements related to this component in case of
  59713. * context lost for instance.
  59714. */
  59715. rebuild(): void;
  59716. /**
  59717. * Serializes the component data to the specified json object
  59718. * @param serializationObject The object to serialize to
  59719. */
  59720. serialize(serializationObject: any): void;
  59721. /**
  59722. * Adds all the elements from the container to the scene
  59723. * @param container the container holding the elements
  59724. */
  59725. addFromContainer(container: AbstractScene): void;
  59726. /**
  59727. * Removes all the elements in the container from the scene
  59728. * @param container contains the elements to remove
  59729. * @param dispose if the removed element should be disposed (default: false)
  59730. */
  59731. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59732. /**
  59733. * Rebuilds the elements related to this component in case of
  59734. * context lost for instance.
  59735. */
  59736. dispose(): void;
  59737. private _gatherRenderTargets;
  59738. }
  59739. }
  59740. declare module BABYLON {
  59741. /**
  59742. * A point light is a light defined by an unique point in world space.
  59743. * The light is emitted in every direction from this point.
  59744. * A good example of a point light is a standard light bulb.
  59745. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59746. */
  59747. export class PointLight extends ShadowLight {
  59748. private _shadowAngle;
  59749. /**
  59750. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59751. * This specifies what angle the shadow will use to be created.
  59752. *
  59753. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59754. */
  59755. get shadowAngle(): number;
  59756. /**
  59757. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59758. * This specifies what angle the shadow will use to be created.
  59759. *
  59760. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59761. */
  59762. set shadowAngle(value: number);
  59763. /**
  59764. * Gets the direction if it has been set.
  59765. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59766. */
  59767. get direction(): Vector3;
  59768. /**
  59769. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59770. */
  59771. set direction(value: Vector3);
  59772. /**
  59773. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59774. * A PointLight emits the light in every direction.
  59775. * It can cast shadows.
  59776. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59777. * ```javascript
  59778. * var pointLight = new PointLight("pl", camera.position, scene);
  59779. * ```
  59780. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59781. * @param name The light friendly name
  59782. * @param position The position of the point light in the scene
  59783. * @param scene The scene the lights belongs to
  59784. */
  59785. constructor(name: string, position: Vector3, scene: Scene);
  59786. /**
  59787. * Returns the string "PointLight"
  59788. * @returns the class name
  59789. */
  59790. getClassName(): string;
  59791. /**
  59792. * Returns the integer 0.
  59793. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59794. */
  59795. getTypeID(): number;
  59796. /**
  59797. * Specifies wether or not the shadowmap should be a cube texture.
  59798. * @returns true if the shadowmap needs to be a cube texture.
  59799. */
  59800. needCube(): boolean;
  59801. /**
  59802. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59803. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59804. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59805. */
  59806. getShadowDirection(faceIndex?: number): Vector3;
  59807. /**
  59808. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59809. * - fov = PI / 2
  59810. * - aspect ratio : 1.0
  59811. * - z-near and far equal to the active camera minZ and maxZ.
  59812. * Returns the PointLight.
  59813. */
  59814. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59815. protected _buildUniformLayout(): void;
  59816. /**
  59817. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59818. * @param effect The effect to update
  59819. * @param lightIndex The index of the light in the effect to update
  59820. * @returns The point light
  59821. */
  59822. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59823. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59824. /**
  59825. * Prepares the list of defines specific to the light type.
  59826. * @param defines the list of defines
  59827. * @param lightIndex defines the index of the light for the effect
  59828. */
  59829. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59830. }
  59831. }
  59832. declare module BABYLON {
  59833. /**
  59834. * Header information of HDR texture files.
  59835. */
  59836. export interface HDRInfo {
  59837. /**
  59838. * The height of the texture in pixels.
  59839. */
  59840. height: number;
  59841. /**
  59842. * The width of the texture in pixels.
  59843. */
  59844. width: number;
  59845. /**
  59846. * The index of the beginning of the data in the binary file.
  59847. */
  59848. dataPosition: number;
  59849. }
  59850. /**
  59851. * This groups tools to convert HDR texture to native colors array.
  59852. */
  59853. export class HDRTools {
  59854. private static Ldexp;
  59855. private static Rgbe2float;
  59856. private static readStringLine;
  59857. /**
  59858. * Reads header information from an RGBE texture stored in a native array.
  59859. * More information on this format are available here:
  59860. * https://en.wikipedia.org/wiki/RGBE_image_format
  59861. *
  59862. * @param uint8array The binary file stored in native array.
  59863. * @return The header information.
  59864. */
  59865. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59866. /**
  59867. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59868. * This RGBE texture needs to store the information as a panorama.
  59869. *
  59870. * More information on this format are available here:
  59871. * https://en.wikipedia.org/wiki/RGBE_image_format
  59872. *
  59873. * @param buffer The binary file stored in an array buffer.
  59874. * @param size The expected size of the extracted cubemap.
  59875. * @return The Cube Map information.
  59876. */
  59877. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59878. /**
  59879. * Returns the pixels data extracted from an RGBE texture.
  59880. * This pixels will be stored left to right up to down in the R G B order in one array.
  59881. *
  59882. * More information on this format are available here:
  59883. * https://en.wikipedia.org/wiki/RGBE_image_format
  59884. *
  59885. * @param uint8array The binary file stored in an array buffer.
  59886. * @param hdrInfo The header information of the file.
  59887. * @return The pixels data in RGB right to left up to down order.
  59888. */
  59889. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59890. private static RGBE_ReadPixels_RLE;
  59891. private static RGBE_ReadPixels_NOT_RLE;
  59892. }
  59893. }
  59894. declare module BABYLON {
  59895. /**
  59896. * Effect Render Options
  59897. */
  59898. export interface IEffectRendererOptions {
  59899. /**
  59900. * Defines the vertices positions.
  59901. */
  59902. positions?: number[];
  59903. /**
  59904. * Defines the indices.
  59905. */
  59906. indices?: number[];
  59907. }
  59908. /**
  59909. * Helper class to render one or more effects.
  59910. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59911. */
  59912. export class EffectRenderer {
  59913. private engine;
  59914. private static _DefaultOptions;
  59915. private _vertexBuffers;
  59916. private _indexBuffer;
  59917. private _fullscreenViewport;
  59918. /**
  59919. * Creates an effect renderer
  59920. * @param engine the engine to use for rendering
  59921. * @param options defines the options of the effect renderer
  59922. */
  59923. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59924. /**
  59925. * Sets the current viewport in normalized coordinates 0-1
  59926. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59927. */
  59928. setViewport(viewport?: Viewport): void;
  59929. /**
  59930. * Binds the embedded attributes buffer to the effect.
  59931. * @param effect Defines the effect to bind the attributes for
  59932. */
  59933. bindBuffers(effect: Effect): void;
  59934. /**
  59935. * Sets the current effect wrapper to use during draw.
  59936. * The effect needs to be ready before calling this api.
  59937. * This also sets the default full screen position attribute.
  59938. * @param effectWrapper Defines the effect to draw with
  59939. */
  59940. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59941. /**
  59942. * Restores engine states
  59943. */
  59944. restoreStates(): void;
  59945. /**
  59946. * Draws a full screen quad.
  59947. */
  59948. draw(): void;
  59949. private isRenderTargetTexture;
  59950. /**
  59951. * renders one or more effects to a specified texture
  59952. * @param effectWrapper the effect to renderer
  59953. * @param outputTexture texture to draw to, if null it will render to the screen.
  59954. */
  59955. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59956. /**
  59957. * Disposes of the effect renderer
  59958. */
  59959. dispose(): void;
  59960. }
  59961. /**
  59962. * Options to create an EffectWrapper
  59963. */
  59964. interface EffectWrapperCreationOptions {
  59965. /**
  59966. * Engine to use to create the effect
  59967. */
  59968. engine: ThinEngine;
  59969. /**
  59970. * Fragment shader for the effect
  59971. */
  59972. fragmentShader: string;
  59973. /**
  59974. * Use the shader store instead of direct source code
  59975. */
  59976. useShaderStore?: boolean;
  59977. /**
  59978. * Vertex shader for the effect
  59979. */
  59980. vertexShader?: string;
  59981. /**
  59982. * Attributes to use in the shader
  59983. */
  59984. attributeNames?: Array<string>;
  59985. /**
  59986. * Uniforms to use in the shader
  59987. */
  59988. uniformNames?: Array<string>;
  59989. /**
  59990. * Texture sampler names to use in the shader
  59991. */
  59992. samplerNames?: Array<string>;
  59993. /**
  59994. * Defines to use in the shader
  59995. */
  59996. defines?: Array<string>;
  59997. /**
  59998. * Callback when effect is compiled
  59999. */
  60000. onCompiled?: Nullable<(effect: Effect) => void>;
  60001. /**
  60002. * The friendly name of the effect displayed in Spector.
  60003. */
  60004. name?: string;
  60005. }
  60006. /**
  60007. * Wraps an effect to be used for rendering
  60008. */
  60009. export class EffectWrapper {
  60010. /**
  60011. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60012. */
  60013. onApplyObservable: Observable<{}>;
  60014. /**
  60015. * The underlying effect
  60016. */
  60017. effect: Effect;
  60018. /**
  60019. * Creates an effect to be renderer
  60020. * @param creationOptions options to create the effect
  60021. */
  60022. constructor(creationOptions: EffectWrapperCreationOptions);
  60023. /**
  60024. * Disposes of the effect wrapper
  60025. */
  60026. dispose(): void;
  60027. }
  60028. }
  60029. declare module BABYLON {
  60030. /** @hidden */
  60031. export var hdrFilteringVertexShader: {
  60032. name: string;
  60033. shader: string;
  60034. };
  60035. }
  60036. declare module BABYLON {
  60037. /** @hidden */
  60038. export var hdrFilteringPixelShader: {
  60039. name: string;
  60040. shader: string;
  60041. };
  60042. }
  60043. declare module BABYLON {
  60044. /**
  60045. * Options for texture filtering
  60046. */
  60047. interface IHDRFilteringOptions {
  60048. /**
  60049. * Scales pixel intensity for the input HDR map.
  60050. */
  60051. hdrScale?: number;
  60052. /**
  60053. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60054. */
  60055. quality?: number;
  60056. }
  60057. /**
  60058. * Filters HDR maps to get correct renderings of PBR reflections
  60059. */
  60060. export class HDRFiltering {
  60061. private _engine;
  60062. private _effectRenderer;
  60063. private _effectWrapper;
  60064. private _lodGenerationOffset;
  60065. private _lodGenerationScale;
  60066. /**
  60067. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60068. * you care about baking speed.
  60069. */
  60070. quality: number;
  60071. /**
  60072. * Scales pixel intensity for the input HDR map.
  60073. */
  60074. hdrScale: number;
  60075. /**
  60076. * Instantiates HDR filter for reflection maps
  60077. *
  60078. * @param engine Thin engine
  60079. * @param options Options
  60080. */
  60081. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60082. private _createRenderTarget;
  60083. private _prefilterInternal;
  60084. private _createEffect;
  60085. /**
  60086. * Get a value indicating if the filter is ready to be used
  60087. * @param texture Texture to filter
  60088. * @returns true if the filter is ready
  60089. */
  60090. isReady(texture: BaseTexture): boolean;
  60091. /**
  60092. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60093. * Prefiltering will be invoked at the end of next rendering pass.
  60094. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60095. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60096. * @param texture Texture to filter
  60097. * @param onFinished Callback when filtering is done
  60098. * @return Promise called when prefiltering is done
  60099. */
  60100. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60101. }
  60102. }
  60103. declare module BABYLON {
  60104. /**
  60105. * This represents a texture coming from an HDR input.
  60106. *
  60107. * The only supported format is currently panorama picture stored in RGBE format.
  60108. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60109. */
  60110. export class HDRCubeTexture extends BaseTexture {
  60111. private static _facesMapping;
  60112. private _generateHarmonics;
  60113. private _noMipmap;
  60114. private _prefilterOnLoad;
  60115. private _textureMatrix;
  60116. private _size;
  60117. private _onLoad;
  60118. private _onError;
  60119. /**
  60120. * The texture URL.
  60121. */
  60122. url: string;
  60123. /**
  60124. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  60125. */
  60126. coordinatesMode: number;
  60127. protected _isBlocking: boolean;
  60128. /**
  60129. * Sets wether or not the texture is blocking during loading.
  60130. */
  60131. set isBlocking(value: boolean);
  60132. /**
  60133. * Gets wether or not the texture is blocking during loading.
  60134. */
  60135. get isBlocking(): boolean;
  60136. protected _rotationY: number;
  60137. /**
  60138. * Sets texture matrix rotation angle around Y axis in radians.
  60139. */
  60140. set rotationY(value: number);
  60141. /**
  60142. * Gets texture matrix rotation angle around Y axis radians.
  60143. */
  60144. get rotationY(): number;
  60145. /**
  60146. * Gets or sets the center of the bounding box associated with the cube texture
  60147. * It must define where the camera used to render the texture was set
  60148. */
  60149. boundingBoxPosition: Vector3;
  60150. private _boundingBoxSize;
  60151. /**
  60152. * Gets or sets the size of the bounding box associated with the cube texture
  60153. * When defined, the cubemap will switch to local mode
  60154. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60155. * @example https://www.babylonjs-playground.com/#RNASML
  60156. */
  60157. set boundingBoxSize(value: Vector3);
  60158. get boundingBoxSize(): Vector3;
  60159. /**
  60160. * Instantiates an HDRTexture from the following parameters.
  60161. *
  60162. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60163. * @param sceneOrEngine The scene or engine the texture will be used in
  60164. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60165. * @param noMipmap Forces to not generate the mipmap if true
  60166. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60167. * @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)
  60168. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60169. */
  60170. 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>);
  60171. /**
  60172. * Get the current class name of the texture useful for serialization or dynamic coding.
  60173. * @returns "HDRCubeTexture"
  60174. */
  60175. getClassName(): string;
  60176. /**
  60177. * Occurs when the file is raw .hdr file.
  60178. */
  60179. private loadTexture;
  60180. clone(): HDRCubeTexture;
  60181. delayLoad(): void;
  60182. /**
  60183. * Get the texture reflection matrix used to rotate/transform the reflection.
  60184. * @returns the reflection matrix
  60185. */
  60186. getReflectionTextureMatrix(): Matrix;
  60187. /**
  60188. * Set the texture reflection matrix used to rotate/transform the reflection.
  60189. * @param value Define the reflection matrix to set
  60190. */
  60191. setReflectionTextureMatrix(value: Matrix): void;
  60192. /**
  60193. * Parses a JSON representation of an HDR Texture in order to create the texture
  60194. * @param parsedTexture Define the JSON representation
  60195. * @param scene Define the scene the texture should be created in
  60196. * @param rootUrl Define the root url in case we need to load relative dependencies
  60197. * @returns the newly created texture after parsing
  60198. */
  60199. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60200. serialize(): any;
  60201. }
  60202. }
  60203. declare module BABYLON {
  60204. /**
  60205. * Class used to control physics engine
  60206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60207. */
  60208. export class PhysicsEngine implements IPhysicsEngine {
  60209. private _physicsPlugin;
  60210. /**
  60211. * Global value used to control the smallest number supported by the simulation
  60212. */
  60213. static Epsilon: number;
  60214. private _impostors;
  60215. private _joints;
  60216. private _subTimeStep;
  60217. /**
  60218. * Gets the gravity vector used by the simulation
  60219. */
  60220. gravity: Vector3;
  60221. /**
  60222. * Factory used to create the default physics plugin.
  60223. * @returns The default physics plugin
  60224. */
  60225. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60226. /**
  60227. * Creates a new Physics Engine
  60228. * @param gravity defines the gravity vector used by the simulation
  60229. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60230. */
  60231. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60232. /**
  60233. * Sets the gravity vector used by the simulation
  60234. * @param gravity defines the gravity vector to use
  60235. */
  60236. setGravity(gravity: Vector3): void;
  60237. /**
  60238. * Set the time step of the physics engine.
  60239. * Default is 1/60.
  60240. * To slow it down, enter 1/600 for example.
  60241. * To speed it up, 1/30
  60242. * @param newTimeStep defines the new timestep to apply to this world.
  60243. */
  60244. setTimeStep(newTimeStep?: number): void;
  60245. /**
  60246. * Get the time step of the physics engine.
  60247. * @returns the current time step
  60248. */
  60249. getTimeStep(): number;
  60250. /**
  60251. * Set the sub time step of the physics engine.
  60252. * Default is 0 meaning there is no sub steps
  60253. * To increase physics resolution precision, set a small value (like 1 ms)
  60254. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60255. */
  60256. setSubTimeStep(subTimeStep?: number): void;
  60257. /**
  60258. * Get the sub time step of the physics engine.
  60259. * @returns the current sub time step
  60260. */
  60261. getSubTimeStep(): number;
  60262. /**
  60263. * Release all resources
  60264. */
  60265. dispose(): void;
  60266. /**
  60267. * Gets the name of the current physics plugin
  60268. * @returns the name of the plugin
  60269. */
  60270. getPhysicsPluginName(): string;
  60271. /**
  60272. * Adding a new impostor for the impostor tracking.
  60273. * This will be done by the impostor itself.
  60274. * @param impostor the impostor to add
  60275. */
  60276. addImpostor(impostor: PhysicsImpostor): void;
  60277. /**
  60278. * Remove an impostor from the engine.
  60279. * This impostor and its mesh will not longer be updated by the physics engine.
  60280. * @param impostor the impostor to remove
  60281. */
  60282. removeImpostor(impostor: PhysicsImpostor): void;
  60283. /**
  60284. * Add a joint to the physics engine
  60285. * @param mainImpostor defines the main impostor to which the joint is added.
  60286. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60287. * @param joint defines the joint that will connect both impostors.
  60288. */
  60289. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60290. /**
  60291. * Removes a joint from the simulation
  60292. * @param mainImpostor defines the impostor used with the joint
  60293. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60294. * @param joint defines the joint to remove
  60295. */
  60296. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60297. /**
  60298. * Called by the scene. No need to call it.
  60299. * @param delta defines the timespam between frames
  60300. */
  60301. _step(delta: number): void;
  60302. /**
  60303. * Gets the current plugin used to run the simulation
  60304. * @returns current plugin
  60305. */
  60306. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60307. /**
  60308. * Gets the list of physic impostors
  60309. * @returns an array of PhysicsImpostor
  60310. */
  60311. getImpostors(): Array<PhysicsImpostor>;
  60312. /**
  60313. * Gets the impostor for a physics enabled object
  60314. * @param object defines the object impersonated by the impostor
  60315. * @returns the PhysicsImpostor or null if not found
  60316. */
  60317. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60318. /**
  60319. * Gets the impostor for a physics body object
  60320. * @param body defines physics body used by the impostor
  60321. * @returns the PhysicsImpostor or null if not found
  60322. */
  60323. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60324. /**
  60325. * Does a raycast in the physics world
  60326. * @param from when should the ray start?
  60327. * @param to when should the ray end?
  60328. * @returns PhysicsRaycastResult
  60329. */
  60330. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60331. }
  60332. }
  60333. declare module BABYLON {
  60334. /** @hidden */
  60335. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60336. private _useDeltaForWorldStep;
  60337. world: any;
  60338. name: string;
  60339. private _physicsMaterials;
  60340. private _fixedTimeStep;
  60341. private _cannonRaycastResult;
  60342. private _raycastResult;
  60343. private _physicsBodysToRemoveAfterStep;
  60344. private _firstFrame;
  60345. BJSCANNON: any;
  60346. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60347. setGravity(gravity: Vector3): void;
  60348. setTimeStep(timeStep: number): void;
  60349. getTimeStep(): number;
  60350. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60351. private _removeMarkedPhysicsBodiesFromWorld;
  60352. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60353. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60354. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60355. private _processChildMeshes;
  60356. removePhysicsBody(impostor: PhysicsImpostor): void;
  60357. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60358. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60359. private _addMaterial;
  60360. private _checkWithEpsilon;
  60361. private _createShape;
  60362. private _createHeightmap;
  60363. private _minus90X;
  60364. private _plus90X;
  60365. private _tmpPosition;
  60366. private _tmpDeltaPosition;
  60367. private _tmpUnityRotation;
  60368. private _updatePhysicsBodyTransformation;
  60369. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60370. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60371. isSupported(): boolean;
  60372. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60373. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60374. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60375. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60376. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60377. getBodyMass(impostor: PhysicsImpostor): number;
  60378. getBodyFriction(impostor: PhysicsImpostor): number;
  60379. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60380. getBodyRestitution(impostor: PhysicsImpostor): number;
  60381. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60382. sleepBody(impostor: PhysicsImpostor): void;
  60383. wakeUpBody(impostor: PhysicsImpostor): void;
  60384. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60385. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60386. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60387. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60388. getRadius(impostor: PhysicsImpostor): number;
  60389. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60390. dispose(): void;
  60391. private _extendNamespace;
  60392. /**
  60393. * Does a raycast in the physics world
  60394. * @param from when should the ray start?
  60395. * @param to when should the ray end?
  60396. * @returns PhysicsRaycastResult
  60397. */
  60398. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60399. }
  60400. }
  60401. declare module BABYLON {
  60402. /** @hidden */
  60403. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60404. private _useDeltaForWorldStep;
  60405. world: any;
  60406. name: string;
  60407. BJSOIMO: any;
  60408. private _raycastResult;
  60409. private _fixedTimeStep;
  60410. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60411. setGravity(gravity: Vector3): void;
  60412. setTimeStep(timeStep: number): void;
  60413. getTimeStep(): number;
  60414. private _tmpImpostorsArray;
  60415. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60416. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60418. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60419. private _tmpPositionVector;
  60420. removePhysicsBody(impostor: PhysicsImpostor): void;
  60421. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60422. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60423. isSupported(): boolean;
  60424. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60425. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60426. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60427. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60428. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60429. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60430. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60431. getBodyMass(impostor: PhysicsImpostor): number;
  60432. getBodyFriction(impostor: PhysicsImpostor): number;
  60433. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60434. getBodyRestitution(impostor: PhysicsImpostor): number;
  60435. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60436. sleepBody(impostor: PhysicsImpostor): void;
  60437. wakeUpBody(impostor: PhysicsImpostor): void;
  60438. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60439. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60440. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60441. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60442. getRadius(impostor: PhysicsImpostor): number;
  60443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60444. dispose(): void;
  60445. /**
  60446. * Does a raycast in the physics world
  60447. * @param from when should the ray start?
  60448. * @param to when should the ray end?
  60449. * @returns PhysicsRaycastResult
  60450. */
  60451. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60452. }
  60453. }
  60454. declare module BABYLON {
  60455. /**
  60456. * AmmoJS Physics plugin
  60457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60458. * @see https://github.com/kripken/ammo.js/
  60459. */
  60460. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60461. private _useDeltaForWorldStep;
  60462. /**
  60463. * Reference to the Ammo library
  60464. */
  60465. bjsAMMO: any;
  60466. /**
  60467. * Created ammoJS world which physics bodies are added to
  60468. */
  60469. world: any;
  60470. /**
  60471. * Name of the plugin
  60472. */
  60473. name: string;
  60474. private _timeStep;
  60475. private _fixedTimeStep;
  60476. private _maxSteps;
  60477. private _tmpQuaternion;
  60478. private _tmpAmmoTransform;
  60479. private _tmpAmmoQuaternion;
  60480. private _tmpAmmoConcreteContactResultCallback;
  60481. private _collisionConfiguration;
  60482. private _dispatcher;
  60483. private _overlappingPairCache;
  60484. private _solver;
  60485. private _softBodySolver;
  60486. private _tmpAmmoVectorA;
  60487. private _tmpAmmoVectorB;
  60488. private _tmpAmmoVectorC;
  60489. private _tmpAmmoVectorD;
  60490. private _tmpContactCallbackResult;
  60491. private _tmpAmmoVectorRCA;
  60492. private _tmpAmmoVectorRCB;
  60493. private _raycastResult;
  60494. private static readonly DISABLE_COLLISION_FLAG;
  60495. private static readonly KINEMATIC_FLAG;
  60496. private static readonly DISABLE_DEACTIVATION_FLAG;
  60497. /**
  60498. * Initializes the ammoJS plugin
  60499. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60500. * @param ammoInjection can be used to inject your own ammo reference
  60501. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60502. */
  60503. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60504. /**
  60505. * Sets the gravity of the physics world (m/(s^2))
  60506. * @param gravity Gravity to set
  60507. */
  60508. setGravity(gravity: Vector3): void;
  60509. /**
  60510. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60511. * @param timeStep timestep to use in seconds
  60512. */
  60513. setTimeStep(timeStep: number): void;
  60514. /**
  60515. * 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)
  60516. * @param fixedTimeStep fixedTimeStep to use in seconds
  60517. */
  60518. setFixedTimeStep(fixedTimeStep: number): void;
  60519. /**
  60520. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60521. * @param maxSteps the maximum number of steps by the physics engine per frame
  60522. */
  60523. setMaxSteps(maxSteps: number): void;
  60524. /**
  60525. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60526. * @returns the current timestep in seconds
  60527. */
  60528. getTimeStep(): number;
  60529. /**
  60530. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60531. */
  60532. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60533. private _isImpostorInContact;
  60534. private _isImpostorPairInContact;
  60535. private _stepSimulation;
  60536. /**
  60537. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60538. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60539. * After the step the babylon meshes are set to the position of the physics imposters
  60540. * @param delta amount of time to step forward
  60541. * @param impostors array of imposters to update before/after the step
  60542. */
  60543. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60544. /**
  60545. * Update babylon mesh to match physics world object
  60546. * @param impostor imposter to match
  60547. */
  60548. private _afterSoftStep;
  60549. /**
  60550. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60551. * @param impostor imposter to match
  60552. */
  60553. private _ropeStep;
  60554. /**
  60555. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60556. * @param impostor imposter to match
  60557. */
  60558. private _softbodyOrClothStep;
  60559. private _tmpMatrix;
  60560. /**
  60561. * Applies an impulse on the imposter
  60562. * @param impostor imposter to apply impulse to
  60563. * @param force amount of force to be applied to the imposter
  60564. * @param contactPoint the location to apply the impulse on the imposter
  60565. */
  60566. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60567. /**
  60568. * Applies a force on the imposter
  60569. * @param impostor imposter to apply force
  60570. * @param force amount of force to be applied to the imposter
  60571. * @param contactPoint the location to apply the force on the imposter
  60572. */
  60573. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60574. /**
  60575. * Creates a physics body using the plugin
  60576. * @param impostor the imposter to create the physics body on
  60577. */
  60578. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60579. /**
  60580. * Removes the physics body from the imposter and disposes of the body's memory
  60581. * @param impostor imposter to remove the physics body from
  60582. */
  60583. removePhysicsBody(impostor: PhysicsImpostor): void;
  60584. /**
  60585. * Generates a joint
  60586. * @param impostorJoint the imposter joint to create the joint with
  60587. */
  60588. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60589. /**
  60590. * Removes a joint
  60591. * @param impostorJoint the imposter joint to remove the joint from
  60592. */
  60593. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60594. private _addMeshVerts;
  60595. /**
  60596. * Initialise the soft body vertices to match its object's (mesh) vertices
  60597. * Softbody vertices (nodes) are in world space and to match this
  60598. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60599. * @param impostor to create the softbody for
  60600. */
  60601. private _softVertexData;
  60602. /**
  60603. * Create an impostor's soft body
  60604. * @param impostor to create the softbody for
  60605. */
  60606. private _createSoftbody;
  60607. /**
  60608. * Create cloth for an impostor
  60609. * @param impostor to create the softbody for
  60610. */
  60611. private _createCloth;
  60612. /**
  60613. * Create rope for an impostor
  60614. * @param impostor to create the softbody for
  60615. */
  60616. private _createRope;
  60617. /**
  60618. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60619. * @param impostor to create the custom physics shape for
  60620. */
  60621. private _createCustom;
  60622. private _addHullVerts;
  60623. private _createShape;
  60624. /**
  60625. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60626. * @param impostor imposter containing the physics body and babylon object
  60627. */
  60628. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60629. /**
  60630. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60631. * @param impostor imposter containing the physics body and babylon object
  60632. * @param newPosition new position
  60633. * @param newRotation new rotation
  60634. */
  60635. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60636. /**
  60637. * If this plugin is supported
  60638. * @returns true if its supported
  60639. */
  60640. isSupported(): boolean;
  60641. /**
  60642. * Sets the linear velocity of the physics body
  60643. * @param impostor imposter to set the velocity on
  60644. * @param velocity velocity to set
  60645. */
  60646. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60647. /**
  60648. * Sets the angular velocity of the physics body
  60649. * @param impostor imposter to set the velocity on
  60650. * @param velocity velocity to set
  60651. */
  60652. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60653. /**
  60654. * gets the linear velocity
  60655. * @param impostor imposter to get linear velocity from
  60656. * @returns linear velocity
  60657. */
  60658. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60659. /**
  60660. * gets the angular velocity
  60661. * @param impostor imposter to get angular velocity from
  60662. * @returns angular velocity
  60663. */
  60664. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60665. /**
  60666. * Sets the mass of physics body
  60667. * @param impostor imposter to set the mass on
  60668. * @param mass mass to set
  60669. */
  60670. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60671. /**
  60672. * Gets the mass of the physics body
  60673. * @param impostor imposter to get the mass from
  60674. * @returns mass
  60675. */
  60676. getBodyMass(impostor: PhysicsImpostor): number;
  60677. /**
  60678. * Gets friction of the impostor
  60679. * @param impostor impostor to get friction from
  60680. * @returns friction value
  60681. */
  60682. getBodyFriction(impostor: PhysicsImpostor): number;
  60683. /**
  60684. * Sets friction of the impostor
  60685. * @param impostor impostor to set friction on
  60686. * @param friction friction value
  60687. */
  60688. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60689. /**
  60690. * Gets restitution of the impostor
  60691. * @param impostor impostor to get restitution from
  60692. * @returns restitution value
  60693. */
  60694. getBodyRestitution(impostor: PhysicsImpostor): number;
  60695. /**
  60696. * Sets resitution of the impostor
  60697. * @param impostor impostor to set resitution on
  60698. * @param restitution resitution value
  60699. */
  60700. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60701. /**
  60702. * Gets pressure inside the impostor
  60703. * @param impostor impostor to get pressure from
  60704. * @returns pressure value
  60705. */
  60706. getBodyPressure(impostor: PhysicsImpostor): number;
  60707. /**
  60708. * Sets pressure inside a soft body impostor
  60709. * Cloth and rope must remain 0 pressure
  60710. * @param impostor impostor to set pressure on
  60711. * @param pressure pressure value
  60712. */
  60713. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60714. /**
  60715. * Gets stiffness of the impostor
  60716. * @param impostor impostor to get stiffness from
  60717. * @returns pressure value
  60718. */
  60719. getBodyStiffness(impostor: PhysicsImpostor): number;
  60720. /**
  60721. * Sets stiffness of the impostor
  60722. * @param impostor impostor to set stiffness on
  60723. * @param stiffness stiffness value from 0 to 1
  60724. */
  60725. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60726. /**
  60727. * Gets velocityIterations of the impostor
  60728. * @param impostor impostor to get velocity iterations from
  60729. * @returns velocityIterations value
  60730. */
  60731. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60732. /**
  60733. * Sets velocityIterations of the impostor
  60734. * @param impostor impostor to set velocity iterations on
  60735. * @param velocityIterations velocityIterations value
  60736. */
  60737. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60738. /**
  60739. * Gets positionIterations of the impostor
  60740. * @param impostor impostor to get position iterations from
  60741. * @returns positionIterations value
  60742. */
  60743. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60744. /**
  60745. * Sets positionIterations of the impostor
  60746. * @param impostor impostor to set position on
  60747. * @param positionIterations positionIterations value
  60748. */
  60749. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60750. /**
  60751. * Append an anchor to a cloth object
  60752. * @param impostor is the cloth impostor to add anchor to
  60753. * @param otherImpostor is the rigid impostor to anchor to
  60754. * @param width ratio across width from 0 to 1
  60755. * @param height ratio up height from 0 to 1
  60756. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60757. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60758. */
  60759. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60760. /**
  60761. * Append an hook to a rope object
  60762. * @param impostor is the rope impostor to add hook to
  60763. * @param otherImpostor is the rigid impostor to hook to
  60764. * @param length ratio along the rope from 0 to 1
  60765. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60766. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60767. */
  60768. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60769. /**
  60770. * Sleeps the physics body and stops it from being active
  60771. * @param impostor impostor to sleep
  60772. */
  60773. sleepBody(impostor: PhysicsImpostor): void;
  60774. /**
  60775. * Activates the physics body
  60776. * @param impostor impostor to activate
  60777. */
  60778. wakeUpBody(impostor: PhysicsImpostor): void;
  60779. /**
  60780. * Updates the distance parameters of the joint
  60781. * @param joint joint to update
  60782. * @param maxDistance maximum distance of the joint
  60783. * @param minDistance minimum distance of the joint
  60784. */
  60785. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60786. /**
  60787. * Sets a motor on the joint
  60788. * @param joint joint to set motor on
  60789. * @param speed speed of the motor
  60790. * @param maxForce maximum force of the motor
  60791. * @param motorIndex index of the motor
  60792. */
  60793. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60794. /**
  60795. * Sets the motors limit
  60796. * @param joint joint to set limit on
  60797. * @param upperLimit upper limit
  60798. * @param lowerLimit lower limit
  60799. */
  60800. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60801. /**
  60802. * Syncs the position and rotation of a mesh with the impostor
  60803. * @param mesh mesh to sync
  60804. * @param impostor impostor to update the mesh with
  60805. */
  60806. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60807. /**
  60808. * Gets the radius of the impostor
  60809. * @param impostor impostor to get radius from
  60810. * @returns the radius
  60811. */
  60812. getRadius(impostor: PhysicsImpostor): number;
  60813. /**
  60814. * Gets the box size of the impostor
  60815. * @param impostor impostor to get box size from
  60816. * @param result the resulting box size
  60817. */
  60818. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60819. /**
  60820. * Disposes of the impostor
  60821. */
  60822. dispose(): void;
  60823. /**
  60824. * Does a raycast in the physics world
  60825. * @param from when should the ray start?
  60826. * @param to when should the ray end?
  60827. * @returns PhysicsRaycastResult
  60828. */
  60829. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60830. }
  60831. }
  60832. declare module BABYLON {
  60833. interface AbstractScene {
  60834. /**
  60835. * The list of reflection probes added to the scene
  60836. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60837. */
  60838. reflectionProbes: Array<ReflectionProbe>;
  60839. /**
  60840. * Removes the given reflection probe from this scene.
  60841. * @param toRemove The reflection probe to remove
  60842. * @returns The index of the removed reflection probe
  60843. */
  60844. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60845. /**
  60846. * Adds the given reflection probe to this scene.
  60847. * @param newReflectionProbe The reflection probe to add
  60848. */
  60849. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60850. }
  60851. /**
  60852. * Class used to generate realtime reflection / refraction cube textures
  60853. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60854. */
  60855. export class ReflectionProbe {
  60856. /** defines the name of the probe */
  60857. name: string;
  60858. private _scene;
  60859. private _renderTargetTexture;
  60860. private _projectionMatrix;
  60861. private _viewMatrix;
  60862. private _target;
  60863. private _add;
  60864. private _attachedMesh;
  60865. private _invertYAxis;
  60866. /** Gets or sets probe position (center of the cube map) */
  60867. position: Vector3;
  60868. /**
  60869. * Creates a new reflection probe
  60870. * @param name defines the name of the probe
  60871. * @param size defines the texture resolution (for each face)
  60872. * @param scene defines the hosting scene
  60873. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60874. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60875. */
  60876. constructor(
  60877. /** defines the name of the probe */
  60878. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60879. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60880. get samples(): number;
  60881. set samples(value: number);
  60882. /** Gets or sets the refresh rate to use (on every frame by default) */
  60883. get refreshRate(): number;
  60884. set refreshRate(value: number);
  60885. /**
  60886. * Gets the hosting scene
  60887. * @returns a Scene
  60888. */
  60889. getScene(): Scene;
  60890. /** Gets the internal CubeTexture used to render to */
  60891. get cubeTexture(): RenderTargetTexture;
  60892. /** Gets the list of meshes to render */
  60893. get renderList(): Nullable<AbstractMesh[]>;
  60894. /**
  60895. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60896. * @param mesh defines the mesh to attach to
  60897. */
  60898. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60899. /**
  60900. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60901. * @param renderingGroupId The rendering group id corresponding to its index
  60902. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60903. */
  60904. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60905. /**
  60906. * Clean all associated resources
  60907. */
  60908. dispose(): void;
  60909. /**
  60910. * Converts the reflection probe information to a readable string for debug purpose.
  60911. * @param fullDetails Supports for multiple levels of logging within scene loading
  60912. * @returns the human readable reflection probe info
  60913. */
  60914. toString(fullDetails?: boolean): string;
  60915. /**
  60916. * Get the class name of the relfection probe.
  60917. * @returns "ReflectionProbe"
  60918. */
  60919. getClassName(): string;
  60920. /**
  60921. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60922. * @returns The JSON representation of the texture
  60923. */
  60924. serialize(): any;
  60925. /**
  60926. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60927. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60928. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60929. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60930. * @returns The parsed reflection probe if successful
  60931. */
  60932. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60933. }
  60934. }
  60935. declare module BABYLON {
  60936. /** @hidden */
  60937. export var _BabylonLoaderRegistered: boolean;
  60938. /**
  60939. * Helps setting up some configuration for the babylon file loader.
  60940. */
  60941. export class BabylonFileLoaderConfiguration {
  60942. /**
  60943. * The loader does not allow injecting custom physix engine into the plugins.
  60944. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60945. * So you could set this variable to your engine import to make it work.
  60946. */
  60947. static LoaderInjectedPhysicsEngine: any;
  60948. }
  60949. }
  60950. declare module BABYLON {
  60951. /**
  60952. * The Physically based simple base material of BJS.
  60953. *
  60954. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60955. * It is used as the base class for both the specGloss and metalRough conventions.
  60956. */
  60957. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60958. /**
  60959. * Number of Simultaneous lights allowed on the material.
  60960. */
  60961. maxSimultaneousLights: number;
  60962. /**
  60963. * If sets to true, disables all the lights affecting the material.
  60964. */
  60965. disableLighting: boolean;
  60966. /**
  60967. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60968. */
  60969. environmentTexture: BaseTexture;
  60970. /**
  60971. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60972. */
  60973. invertNormalMapX: boolean;
  60974. /**
  60975. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60976. */
  60977. invertNormalMapY: boolean;
  60978. /**
  60979. * Normal map used in the model.
  60980. */
  60981. normalTexture: BaseTexture;
  60982. /**
  60983. * Emissivie color used to self-illuminate the model.
  60984. */
  60985. emissiveColor: Color3;
  60986. /**
  60987. * Emissivie texture used to self-illuminate the model.
  60988. */
  60989. emissiveTexture: BaseTexture;
  60990. /**
  60991. * Occlusion Channel Strenght.
  60992. */
  60993. occlusionStrength: number;
  60994. /**
  60995. * Occlusion Texture of the material (adding extra occlusion effects).
  60996. */
  60997. occlusionTexture: BaseTexture;
  60998. /**
  60999. * Defines the alpha limits in alpha test mode.
  61000. */
  61001. alphaCutOff: number;
  61002. /**
  61003. * Gets the current double sided mode.
  61004. */
  61005. get doubleSided(): boolean;
  61006. /**
  61007. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61008. */
  61009. set doubleSided(value: boolean);
  61010. /**
  61011. * Stores the pre-calculated light information of a mesh in a texture.
  61012. */
  61013. lightmapTexture: BaseTexture;
  61014. /**
  61015. * If true, the light map contains occlusion information instead of lighting info.
  61016. */
  61017. useLightmapAsShadowmap: boolean;
  61018. /**
  61019. * Instantiates a new PBRMaterial instance.
  61020. *
  61021. * @param name The material name
  61022. * @param scene The scene the material will be use in.
  61023. */
  61024. constructor(name: string, scene: Scene);
  61025. getClassName(): string;
  61026. }
  61027. }
  61028. declare module BABYLON {
  61029. /**
  61030. * The PBR material of BJS following the metal roughness convention.
  61031. *
  61032. * This fits to the PBR convention in the GLTF definition:
  61033. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61034. */
  61035. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61036. /**
  61037. * The base color has two different interpretations depending on the value of metalness.
  61038. * When the material is a metal, the base color is the specific measured reflectance value
  61039. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61040. * of the material.
  61041. */
  61042. baseColor: Color3;
  61043. /**
  61044. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61045. * well as opacity information in the alpha channel.
  61046. */
  61047. baseTexture: BaseTexture;
  61048. /**
  61049. * Specifies the metallic scalar value of the material.
  61050. * Can also be used to scale the metalness values of the metallic texture.
  61051. */
  61052. metallic: number;
  61053. /**
  61054. * Specifies the roughness scalar value of the material.
  61055. * Can also be used to scale the roughness values of the metallic texture.
  61056. */
  61057. roughness: number;
  61058. /**
  61059. * Texture containing both the metallic value in the B channel and the
  61060. * roughness value in the G channel to keep better precision.
  61061. */
  61062. metallicRoughnessTexture: BaseTexture;
  61063. /**
  61064. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61065. *
  61066. * @param name The material name
  61067. * @param scene The scene the material will be use in.
  61068. */
  61069. constructor(name: string, scene: Scene);
  61070. /**
  61071. * Return the currrent class name of the material.
  61072. */
  61073. getClassName(): string;
  61074. /**
  61075. * Makes a duplicate of the current material.
  61076. * @param name - name to use for the new material.
  61077. */
  61078. clone(name: string): PBRMetallicRoughnessMaterial;
  61079. /**
  61080. * Serialize the material to a parsable JSON object.
  61081. */
  61082. serialize(): any;
  61083. /**
  61084. * Parses a JSON object correponding to the serialize function.
  61085. */
  61086. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61087. }
  61088. }
  61089. declare module BABYLON {
  61090. /**
  61091. * The PBR material of BJS following the specular glossiness convention.
  61092. *
  61093. * This fits to the PBR convention in the GLTF definition:
  61094. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61095. */
  61096. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61097. /**
  61098. * Specifies the diffuse color of the material.
  61099. */
  61100. diffuseColor: Color3;
  61101. /**
  61102. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61103. * channel.
  61104. */
  61105. diffuseTexture: BaseTexture;
  61106. /**
  61107. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61108. */
  61109. specularColor: Color3;
  61110. /**
  61111. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61112. */
  61113. glossiness: number;
  61114. /**
  61115. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61116. */
  61117. specularGlossinessTexture: BaseTexture;
  61118. /**
  61119. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61120. *
  61121. * @param name The material name
  61122. * @param scene The scene the material will be use in.
  61123. */
  61124. constructor(name: string, scene: Scene);
  61125. /**
  61126. * Return the currrent class name of the material.
  61127. */
  61128. getClassName(): string;
  61129. /**
  61130. * Makes a duplicate of the current material.
  61131. * @param name - name to use for the new material.
  61132. */
  61133. clone(name: string): PBRSpecularGlossinessMaterial;
  61134. /**
  61135. * Serialize the material to a parsable JSON object.
  61136. */
  61137. serialize(): any;
  61138. /**
  61139. * Parses a JSON object correponding to the serialize function.
  61140. */
  61141. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61142. }
  61143. }
  61144. declare module BABYLON {
  61145. /**
  61146. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61147. * It can help converting any input color in a desired output one. This can then be used to create effects
  61148. * from sepia, black and white to sixties or futuristic rendering...
  61149. *
  61150. * The only supported format is currently 3dl.
  61151. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61152. */
  61153. export class ColorGradingTexture extends BaseTexture {
  61154. /**
  61155. * The texture URL.
  61156. */
  61157. url: string;
  61158. /**
  61159. * Empty line regex stored for GC.
  61160. */
  61161. private static _noneEmptyLineRegex;
  61162. private _textureMatrix;
  61163. private _onLoad;
  61164. /**
  61165. * Instantiates a ColorGradingTexture from the following parameters.
  61166. *
  61167. * @param url The location of the color gradind data (currently only supporting 3dl)
  61168. * @param sceneOrEngine The scene or engine the texture will be used in
  61169. * @param onLoad defines a callback triggered when the texture has been loaded
  61170. */
  61171. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61172. /**
  61173. * Fires the onload event from the constructor if requested.
  61174. */
  61175. private _triggerOnLoad;
  61176. /**
  61177. * Returns the texture matrix used in most of the material.
  61178. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61179. */
  61180. getTextureMatrix(): Matrix;
  61181. /**
  61182. * Occurs when the file being loaded is a .3dl LUT file.
  61183. */
  61184. private load3dlTexture;
  61185. /**
  61186. * Starts the loading process of the texture.
  61187. */
  61188. private loadTexture;
  61189. /**
  61190. * Clones the color gradind texture.
  61191. */
  61192. clone(): ColorGradingTexture;
  61193. /**
  61194. * Called during delayed load for textures.
  61195. */
  61196. delayLoad(): void;
  61197. /**
  61198. * Parses a color grading texture serialized by Babylon.
  61199. * @param parsedTexture The texture information being parsedTexture
  61200. * @param scene The scene to load the texture in
  61201. * @param rootUrl The root url of the data assets to load
  61202. * @return A color gradind texture
  61203. */
  61204. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61205. /**
  61206. * Serializes the LUT texture to json format.
  61207. */
  61208. serialize(): any;
  61209. }
  61210. }
  61211. declare module BABYLON {
  61212. /**
  61213. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61214. */
  61215. export class EquiRectangularCubeTexture extends BaseTexture {
  61216. /** The six faces of the cube. */
  61217. private static _FacesMapping;
  61218. private _noMipmap;
  61219. private _onLoad;
  61220. private _onError;
  61221. /** The size of the cubemap. */
  61222. private _size;
  61223. /** The buffer of the image. */
  61224. private _buffer;
  61225. /** The width of the input image. */
  61226. private _width;
  61227. /** The height of the input image. */
  61228. private _height;
  61229. /** The URL to the image. */
  61230. url: string;
  61231. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  61232. coordinatesMode: number;
  61233. /**
  61234. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61235. * @param url The location of the image
  61236. * @param scene The scene the texture will be used in
  61237. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61238. * @param noMipmap Forces to not generate the mipmap if true
  61239. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61240. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61241. * @param onLoad — defines a callback called when texture is loaded
  61242. * @param onError — defines a callback called if there is an error
  61243. */
  61244. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61245. /**
  61246. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61247. */
  61248. private loadImage;
  61249. /**
  61250. * Convert the image buffer into a cubemap and create a CubeTexture.
  61251. */
  61252. private loadTexture;
  61253. /**
  61254. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61255. * @param buffer The ArrayBuffer that should be converted.
  61256. * @returns The buffer as Float32Array.
  61257. */
  61258. private getFloat32ArrayFromArrayBuffer;
  61259. /**
  61260. * Get the current class name of the texture useful for serialization or dynamic coding.
  61261. * @returns "EquiRectangularCubeTexture"
  61262. */
  61263. getClassName(): string;
  61264. /**
  61265. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61266. * @returns A clone of the current EquiRectangularCubeTexture.
  61267. */
  61268. clone(): EquiRectangularCubeTexture;
  61269. }
  61270. }
  61271. declare module BABYLON {
  61272. /**
  61273. * Defines the options related to the creation of an HtmlElementTexture
  61274. */
  61275. export interface IHtmlElementTextureOptions {
  61276. /**
  61277. * Defines wether mip maps should be created or not.
  61278. */
  61279. generateMipMaps?: boolean;
  61280. /**
  61281. * Defines the sampling mode of the texture.
  61282. */
  61283. samplingMode?: number;
  61284. /**
  61285. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61286. */
  61287. engine: Nullable<ThinEngine>;
  61288. /**
  61289. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61290. */
  61291. scene: Nullable<Scene>;
  61292. }
  61293. /**
  61294. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61295. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61296. * is automatically managed.
  61297. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61298. * in your application.
  61299. *
  61300. * As the update is not automatic, you need to call them manually.
  61301. */
  61302. export class HtmlElementTexture extends BaseTexture {
  61303. /**
  61304. * The texture URL.
  61305. */
  61306. element: HTMLVideoElement | HTMLCanvasElement;
  61307. private static readonly DefaultOptions;
  61308. private _textureMatrix;
  61309. private _isVideo;
  61310. private _generateMipMaps;
  61311. private _samplingMode;
  61312. /**
  61313. * Instantiates a HtmlElementTexture from the following parameters.
  61314. *
  61315. * @param name Defines the name of the texture
  61316. * @param element Defines the video or canvas the texture is filled with
  61317. * @param options Defines the other none mandatory texture creation options
  61318. */
  61319. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61320. private _createInternalTexture;
  61321. /**
  61322. * Returns the texture matrix used in most of the material.
  61323. */
  61324. getTextureMatrix(): Matrix;
  61325. /**
  61326. * Updates the content of the texture.
  61327. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61328. */
  61329. update(invertY?: Nullable<boolean>): void;
  61330. }
  61331. }
  61332. declare module BABYLON {
  61333. /**
  61334. * Based on jsTGALoader - Javascript loader for TGA file
  61335. * By Vincent Thibault
  61336. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61337. */
  61338. export class TGATools {
  61339. private static _TYPE_INDEXED;
  61340. private static _TYPE_RGB;
  61341. private static _TYPE_GREY;
  61342. private static _TYPE_RLE_INDEXED;
  61343. private static _TYPE_RLE_RGB;
  61344. private static _TYPE_RLE_GREY;
  61345. private static _ORIGIN_MASK;
  61346. private static _ORIGIN_SHIFT;
  61347. private static _ORIGIN_BL;
  61348. private static _ORIGIN_BR;
  61349. private static _ORIGIN_UL;
  61350. private static _ORIGIN_UR;
  61351. /**
  61352. * Gets the header of a TGA file
  61353. * @param data defines the TGA data
  61354. * @returns the header
  61355. */
  61356. static GetTGAHeader(data: Uint8Array): any;
  61357. /**
  61358. * Uploads TGA content to a Babylon Texture
  61359. * @hidden
  61360. */
  61361. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61362. /** @hidden */
  61363. 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;
  61364. /** @hidden */
  61365. 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;
  61366. /** @hidden */
  61367. 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;
  61368. /** @hidden */
  61369. 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;
  61370. /** @hidden */
  61371. 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;
  61372. /** @hidden */
  61373. 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;
  61374. }
  61375. }
  61376. declare module BABYLON {
  61377. /**
  61378. * Implementation of the TGA Texture Loader.
  61379. * @hidden
  61380. */
  61381. export class _TGATextureLoader implements IInternalTextureLoader {
  61382. /**
  61383. * Defines wether the loader supports cascade loading the different faces.
  61384. */
  61385. readonly supportCascades: boolean;
  61386. /**
  61387. * This returns if the loader support the current file information.
  61388. * @param extension defines the file extension of the file being loaded
  61389. * @returns true if the loader can load the specified file
  61390. */
  61391. canLoad(extension: string): boolean;
  61392. /**
  61393. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61394. * @param data contains the texture data
  61395. * @param texture defines the BabylonJS internal texture
  61396. * @param createPolynomials will be true if polynomials have been requested
  61397. * @param onLoad defines the callback to trigger once the texture is ready
  61398. * @param onError defines the callback to trigger in case of error
  61399. */
  61400. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61401. /**
  61402. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61403. * @param data contains the texture data
  61404. * @param texture defines the BabylonJS internal texture
  61405. * @param callback defines the method to call once ready to upload
  61406. */
  61407. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61408. }
  61409. }
  61410. declare module BABYLON {
  61411. /**
  61412. * Info about the .basis files
  61413. */
  61414. class BasisFileInfo {
  61415. /**
  61416. * If the file has alpha
  61417. */
  61418. hasAlpha: boolean;
  61419. /**
  61420. * Info about each image of the basis file
  61421. */
  61422. images: Array<{
  61423. levels: Array<{
  61424. width: number;
  61425. height: number;
  61426. transcodedPixels: ArrayBufferView;
  61427. }>;
  61428. }>;
  61429. }
  61430. /**
  61431. * Result of transcoding a basis file
  61432. */
  61433. class TranscodeResult {
  61434. /**
  61435. * Info about the .basis file
  61436. */
  61437. fileInfo: BasisFileInfo;
  61438. /**
  61439. * Format to use when loading the file
  61440. */
  61441. format: number;
  61442. }
  61443. /**
  61444. * Configuration options for the Basis transcoder
  61445. */
  61446. export class BasisTranscodeConfiguration {
  61447. /**
  61448. * Supported compression formats used to determine the supported output format of the transcoder
  61449. */
  61450. supportedCompressionFormats?: {
  61451. /**
  61452. * etc1 compression format
  61453. */
  61454. etc1?: boolean;
  61455. /**
  61456. * s3tc compression format
  61457. */
  61458. s3tc?: boolean;
  61459. /**
  61460. * pvrtc compression format
  61461. */
  61462. pvrtc?: boolean;
  61463. /**
  61464. * etc2 compression format
  61465. */
  61466. etc2?: boolean;
  61467. };
  61468. /**
  61469. * If mipmap levels should be loaded for transcoded images (Default: true)
  61470. */
  61471. loadMipmapLevels?: boolean;
  61472. /**
  61473. * Index of a single image to load (Default: all images)
  61474. */
  61475. loadSingleImage?: number;
  61476. }
  61477. /**
  61478. * Used to load .Basis files
  61479. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61480. */
  61481. export class BasisTools {
  61482. private static _IgnoreSupportedFormats;
  61483. /**
  61484. * URL to use when loading the basis transcoder
  61485. */
  61486. static JSModuleURL: string;
  61487. /**
  61488. * URL to use when loading the wasm module for the transcoder
  61489. */
  61490. static WasmModuleURL: string;
  61491. /**
  61492. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61493. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61494. * @returns internal format corresponding to the Basis format
  61495. */
  61496. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61497. private static _WorkerPromise;
  61498. private static _Worker;
  61499. private static _actionId;
  61500. private static _CreateWorkerAsync;
  61501. /**
  61502. * Transcodes a loaded image file to compressed pixel data
  61503. * @param data image data to transcode
  61504. * @param config configuration options for the transcoding
  61505. * @returns a promise resulting in the transcoded image
  61506. */
  61507. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61508. /**
  61509. * Loads a texture from the transcode result
  61510. * @param texture texture load to
  61511. * @param transcodeResult the result of transcoding the basis file to load from
  61512. */
  61513. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61514. }
  61515. }
  61516. declare module BABYLON {
  61517. /**
  61518. * Loader for .basis file format
  61519. */
  61520. export class _BasisTextureLoader implements IInternalTextureLoader {
  61521. /**
  61522. * Defines whether the loader supports cascade loading the different faces.
  61523. */
  61524. readonly supportCascades: boolean;
  61525. /**
  61526. * This returns if the loader support the current file information.
  61527. * @param extension defines the file extension of the file being loaded
  61528. * @returns true if the loader can load the specified file
  61529. */
  61530. canLoad(extension: string): boolean;
  61531. /**
  61532. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61533. * @param data contains the texture data
  61534. * @param texture defines the BabylonJS internal texture
  61535. * @param createPolynomials will be true if polynomials have been requested
  61536. * @param onLoad defines the callback to trigger once the texture is ready
  61537. * @param onError defines the callback to trigger in case of error
  61538. */
  61539. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61540. /**
  61541. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61542. * @param data contains the texture data
  61543. * @param texture defines the BabylonJS internal texture
  61544. * @param callback defines the method to call once ready to upload
  61545. */
  61546. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61547. }
  61548. }
  61549. declare module BABYLON {
  61550. /**
  61551. * Defines the basic options interface of a TexturePacker Frame
  61552. */
  61553. export interface ITexturePackerFrame {
  61554. /**
  61555. * The frame ID
  61556. */
  61557. id: number;
  61558. /**
  61559. * The frames Scale
  61560. */
  61561. scale: Vector2;
  61562. /**
  61563. * The Frames offset
  61564. */
  61565. offset: Vector2;
  61566. }
  61567. /**
  61568. * This is a support class for frame Data on texture packer sets.
  61569. */
  61570. export class TexturePackerFrame implements ITexturePackerFrame {
  61571. /**
  61572. * The frame ID
  61573. */
  61574. id: number;
  61575. /**
  61576. * The frames Scale
  61577. */
  61578. scale: Vector2;
  61579. /**
  61580. * The Frames offset
  61581. */
  61582. offset: Vector2;
  61583. /**
  61584. * Initializes a texture package frame.
  61585. * @param id The numerical frame identifier
  61586. * @param scale Scalar Vector2 for UV frame
  61587. * @param offset Vector2 for the frame position in UV units.
  61588. * @returns TexturePackerFrame
  61589. */
  61590. constructor(id: number, scale: Vector2, offset: Vector2);
  61591. }
  61592. }
  61593. declare module BABYLON {
  61594. /**
  61595. * Defines the basic options interface of a TexturePacker
  61596. */
  61597. export interface ITexturePackerOptions {
  61598. /**
  61599. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61600. */
  61601. map?: string[];
  61602. /**
  61603. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61604. */
  61605. uvsIn?: string;
  61606. /**
  61607. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61608. */
  61609. uvsOut?: string;
  61610. /**
  61611. * number representing the layout style. Defaults to LAYOUT_STRIP
  61612. */
  61613. layout?: number;
  61614. /**
  61615. * number of columns if using custom column count layout(2). This defaults to 4.
  61616. */
  61617. colnum?: number;
  61618. /**
  61619. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61620. */
  61621. updateInputMeshes?: boolean;
  61622. /**
  61623. * boolean flag to dispose all the source textures. Defaults to true.
  61624. */
  61625. disposeSources?: boolean;
  61626. /**
  61627. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61628. */
  61629. fillBlanks?: boolean;
  61630. /**
  61631. * string value representing the context fill style color. Defaults to 'black'.
  61632. */
  61633. customFillColor?: string;
  61634. /**
  61635. * Width and Height Value of each Frame in the TexturePacker Sets
  61636. */
  61637. frameSize?: number;
  61638. /**
  61639. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61640. */
  61641. paddingRatio?: number;
  61642. /**
  61643. * Number that declares the fill method for the padding gutter.
  61644. */
  61645. paddingMode?: number;
  61646. /**
  61647. * If in SUBUV_COLOR padding mode what color to use.
  61648. */
  61649. paddingColor?: Color3 | Color4;
  61650. }
  61651. /**
  61652. * Defines the basic interface of a TexturePacker JSON File
  61653. */
  61654. export interface ITexturePackerJSON {
  61655. /**
  61656. * The frame ID
  61657. */
  61658. name: string;
  61659. /**
  61660. * The base64 channel data
  61661. */
  61662. sets: any;
  61663. /**
  61664. * The options of the Packer
  61665. */
  61666. options: ITexturePackerOptions;
  61667. /**
  61668. * The frame data of the Packer
  61669. */
  61670. frames: Array<number>;
  61671. }
  61672. /**
  61673. * This is a support class that generates a series of packed texture sets.
  61674. * @see https://doc.babylonjs.com/babylon101/materials
  61675. */
  61676. export class TexturePacker {
  61677. /** Packer Layout Constant 0 */
  61678. static readonly LAYOUT_STRIP: number;
  61679. /** Packer Layout Constant 1 */
  61680. static readonly LAYOUT_POWER2: number;
  61681. /** Packer Layout Constant 2 */
  61682. static readonly LAYOUT_COLNUM: number;
  61683. /** Packer Layout Constant 0 */
  61684. static readonly SUBUV_WRAP: number;
  61685. /** Packer Layout Constant 1 */
  61686. static readonly SUBUV_EXTEND: number;
  61687. /** Packer Layout Constant 2 */
  61688. static readonly SUBUV_COLOR: number;
  61689. /** The Name of the Texture Package */
  61690. name: string;
  61691. /** The scene scope of the TexturePacker */
  61692. scene: Scene;
  61693. /** The Meshes to target */
  61694. meshes: AbstractMesh[];
  61695. /** Arguments passed with the Constructor */
  61696. options: ITexturePackerOptions;
  61697. /** The promise that is started upon initialization */
  61698. promise: Nullable<Promise<TexturePacker | string>>;
  61699. /** The Container object for the channel sets that are generated */
  61700. sets: object;
  61701. /** The Container array for the frames that are generated */
  61702. frames: TexturePackerFrame[];
  61703. /** The expected number of textures the system is parsing. */
  61704. private _expecting;
  61705. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61706. private _paddingValue;
  61707. /**
  61708. * Initializes a texture package series from an array of meshes or a single mesh.
  61709. * @param name The name of the package
  61710. * @param meshes The target meshes to compose the package from
  61711. * @param options The arguments that texture packer should follow while building.
  61712. * @param scene The scene which the textures are scoped to.
  61713. * @returns TexturePacker
  61714. */
  61715. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61716. /**
  61717. * Starts the package process
  61718. * @param resolve The promises resolution function
  61719. * @returns TexturePacker
  61720. */
  61721. private _createFrames;
  61722. /**
  61723. * Calculates the Size of the Channel Sets
  61724. * @returns Vector2
  61725. */
  61726. private _calculateSize;
  61727. /**
  61728. * Calculates the UV data for the frames.
  61729. * @param baseSize the base frameSize
  61730. * @param padding the base frame padding
  61731. * @param dtSize size of the Dynamic Texture for that channel
  61732. * @param dtUnits is 1/dtSize
  61733. * @param update flag to update the input meshes
  61734. */
  61735. private _calculateMeshUVFrames;
  61736. /**
  61737. * Calculates the frames Offset.
  61738. * @param index of the frame
  61739. * @returns Vector2
  61740. */
  61741. private _getFrameOffset;
  61742. /**
  61743. * Updates a Mesh to the frame data
  61744. * @param mesh that is the target
  61745. * @param frameID or the frame index
  61746. */
  61747. private _updateMeshUV;
  61748. /**
  61749. * Updates a Meshes materials to use the texture packer channels
  61750. * @param m is the mesh to target
  61751. * @param force all channels on the packer to be set.
  61752. */
  61753. private _updateTextureReferences;
  61754. /**
  61755. * Public method to set a Mesh to a frame
  61756. * @param m that is the target
  61757. * @param frameID or the frame index
  61758. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61759. */
  61760. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61761. /**
  61762. * Starts the async promise to compile the texture packer.
  61763. * @returns Promise<void>
  61764. */
  61765. processAsync(): Promise<void>;
  61766. /**
  61767. * Disposes all textures associated with this packer
  61768. */
  61769. dispose(): void;
  61770. /**
  61771. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61772. * @param imageType is the image type to use.
  61773. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61774. */
  61775. download(imageType?: string, quality?: number): void;
  61776. /**
  61777. * Public method to load a texturePacker JSON file.
  61778. * @param data of the JSON file in string format.
  61779. */
  61780. updateFromJSON(data: string): void;
  61781. }
  61782. }
  61783. declare module BABYLON {
  61784. /**
  61785. * 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.
  61786. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61787. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61788. */
  61789. export class CustomProceduralTexture extends ProceduralTexture {
  61790. private _animate;
  61791. private _time;
  61792. private _config;
  61793. private _texturePath;
  61794. /**
  61795. * Instantiates a new Custom Procedural Texture.
  61796. * 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.
  61797. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61798. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61799. * @param name Define the name of the texture
  61800. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61801. * @param size Define the size of the texture to create
  61802. * @param scene Define the scene the texture belongs to
  61803. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61804. * @param generateMipMaps Define if the texture should creates mip maps or not
  61805. */
  61806. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61807. private _loadJson;
  61808. /**
  61809. * Is the texture ready to be used ? (rendered at least once)
  61810. * @returns true if ready, otherwise, false.
  61811. */
  61812. isReady(): boolean;
  61813. /**
  61814. * Render the texture to its associated render target.
  61815. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61816. */
  61817. render(useCameraPostProcess?: boolean): void;
  61818. /**
  61819. * Update the list of dependant textures samplers in the shader.
  61820. */
  61821. updateTextures(): void;
  61822. /**
  61823. * Update the uniform values of the procedural texture in the shader.
  61824. */
  61825. updateShaderUniforms(): void;
  61826. /**
  61827. * Define if the texture animates or not.
  61828. */
  61829. get animate(): boolean;
  61830. set animate(value: boolean);
  61831. }
  61832. }
  61833. declare module BABYLON {
  61834. /** @hidden */
  61835. export var noisePixelShader: {
  61836. name: string;
  61837. shader: string;
  61838. };
  61839. }
  61840. declare module BABYLON {
  61841. /**
  61842. * Class used to generate noise procedural textures
  61843. */
  61844. export class NoiseProceduralTexture extends ProceduralTexture {
  61845. private _time;
  61846. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61847. brightness: number;
  61848. /** Defines the number of octaves to process */
  61849. octaves: number;
  61850. /** Defines the level of persistence (0.8 by default) */
  61851. persistence: number;
  61852. /** Gets or sets animation speed factor (default is 1) */
  61853. animationSpeedFactor: number;
  61854. /**
  61855. * Creates a new NoiseProceduralTexture
  61856. * @param name defines the name fo the texture
  61857. * @param size defines the size of the texture (default is 256)
  61858. * @param scene defines the hosting scene
  61859. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61860. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61861. */
  61862. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61863. private _updateShaderUniforms;
  61864. protected _getDefines(): string;
  61865. /** Generate the current state of the procedural texture */
  61866. render(useCameraPostProcess?: boolean): void;
  61867. /**
  61868. * Serializes this noise procedural texture
  61869. * @returns a serialized noise procedural texture object
  61870. */
  61871. serialize(): any;
  61872. /**
  61873. * Clone the texture.
  61874. * @returns the cloned texture
  61875. */
  61876. clone(): NoiseProceduralTexture;
  61877. /**
  61878. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61879. * @param parsedTexture defines parsed texture data
  61880. * @param scene defines the current scene
  61881. * @param rootUrl defines the root URL containing noise procedural texture information
  61882. * @returns a parsed NoiseProceduralTexture
  61883. */
  61884. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61885. }
  61886. }
  61887. declare module BABYLON {
  61888. /**
  61889. * Raw cube texture where the raw buffers are passed in
  61890. */
  61891. export class RawCubeTexture extends CubeTexture {
  61892. /**
  61893. * Creates a cube texture where the raw buffers are passed in.
  61894. * @param scene defines the scene the texture is attached to
  61895. * @param data defines the array of data to use to create each face
  61896. * @param size defines the size of the textures
  61897. * @param format defines the format of the data
  61898. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61899. * @param generateMipMaps defines if the engine should generate the mip levels
  61900. * @param invertY defines if data must be stored with Y axis inverted
  61901. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61902. * @param compression defines the compression used (null by default)
  61903. */
  61904. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61905. /**
  61906. * Updates the raw cube texture.
  61907. * @param data defines the data to store
  61908. * @param format defines the data format
  61909. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61910. * @param invertY defines if data must be stored with Y axis inverted
  61911. * @param compression defines the compression used (null by default)
  61912. * @param level defines which level of the texture to update
  61913. */
  61914. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61915. /**
  61916. * Updates a raw cube texture with RGBD encoded data.
  61917. * @param data defines the array of data [mipmap][face] to use to create each face
  61918. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61919. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61920. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61921. * @returns a promsie that resolves when the operation is complete
  61922. */
  61923. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61924. /**
  61925. * Clones the raw cube texture.
  61926. * @return a new cube texture
  61927. */
  61928. clone(): CubeTexture;
  61929. /** @hidden */
  61930. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61931. }
  61932. }
  61933. declare module BABYLON {
  61934. /**
  61935. * Class used to store 2D array textures containing user data
  61936. */
  61937. export class RawTexture2DArray extends Texture {
  61938. /** Gets or sets the texture format to use */
  61939. format: number;
  61940. /**
  61941. * Create a new RawTexture2DArray
  61942. * @param data defines the data of the texture
  61943. * @param width defines the width of the texture
  61944. * @param height defines the height of the texture
  61945. * @param depth defines the number of layers of the texture
  61946. * @param format defines the texture format to use
  61947. * @param scene defines the hosting scene
  61948. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61949. * @param invertY defines if texture must be stored with Y axis inverted
  61950. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61951. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61952. */
  61953. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61954. /** Gets or sets the texture format to use */
  61955. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61956. /**
  61957. * Update the texture with new data
  61958. * @param data defines the data to store in the texture
  61959. */
  61960. update(data: ArrayBufferView): void;
  61961. }
  61962. }
  61963. declare module BABYLON {
  61964. /**
  61965. * Class used to store 3D textures containing user data
  61966. */
  61967. export class RawTexture3D extends Texture {
  61968. /** Gets or sets the texture format to use */
  61969. format: number;
  61970. /**
  61971. * Create a new RawTexture3D
  61972. * @param data defines the data of the texture
  61973. * @param width defines the width of the texture
  61974. * @param height defines the height of the texture
  61975. * @param depth defines the depth of the texture
  61976. * @param format defines the texture format to use
  61977. * @param scene defines the hosting scene
  61978. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61979. * @param invertY defines if texture must be stored with Y axis inverted
  61980. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61981. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61982. */
  61983. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61984. /** Gets or sets the texture format to use */
  61985. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61986. /**
  61987. * Update the texture with new data
  61988. * @param data defines the data to store in the texture
  61989. */
  61990. update(data: ArrayBufferView): void;
  61991. }
  61992. }
  61993. declare module BABYLON {
  61994. /**
  61995. * Creates a refraction texture used by refraction channel of the standard material.
  61996. * It is like a mirror but to see through a material.
  61997. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61998. */
  61999. export class RefractionTexture extends RenderTargetTexture {
  62000. /**
  62001. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62002. * 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.
  62003. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62004. */
  62005. refractionPlane: Plane;
  62006. /**
  62007. * Define how deep under the surface we should see.
  62008. */
  62009. depth: number;
  62010. /**
  62011. * Creates a refraction texture used by refraction channel of the standard material.
  62012. * It is like a mirror but to see through a material.
  62013. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62014. * @param name Define the texture name
  62015. * @param size Define the size of the underlying texture
  62016. * @param scene Define the scene the refraction belongs to
  62017. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62018. */
  62019. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62020. /**
  62021. * Clone the refraction texture.
  62022. * @returns the cloned texture
  62023. */
  62024. clone(): RefractionTexture;
  62025. /**
  62026. * Serialize the texture to a JSON representation you could use in Parse later on
  62027. * @returns the serialized JSON representation
  62028. */
  62029. serialize(): any;
  62030. }
  62031. }
  62032. declare module BABYLON {
  62033. /**
  62034. * Block used to add support for vertex skinning (bones)
  62035. */
  62036. export class BonesBlock extends NodeMaterialBlock {
  62037. /**
  62038. * Creates a new BonesBlock
  62039. * @param name defines the block name
  62040. */
  62041. constructor(name: string);
  62042. /**
  62043. * Initialize the block and prepare the context for build
  62044. * @param state defines the state that will be used for the build
  62045. */
  62046. initialize(state: NodeMaterialBuildState): void;
  62047. /**
  62048. * Gets the current class name
  62049. * @returns the class name
  62050. */
  62051. getClassName(): string;
  62052. /**
  62053. * Gets the matrix indices input component
  62054. */
  62055. get matricesIndices(): NodeMaterialConnectionPoint;
  62056. /**
  62057. * Gets the matrix weights input component
  62058. */
  62059. get matricesWeights(): NodeMaterialConnectionPoint;
  62060. /**
  62061. * Gets the extra matrix indices input component
  62062. */
  62063. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62064. /**
  62065. * Gets the extra matrix weights input component
  62066. */
  62067. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62068. /**
  62069. * Gets the world input component
  62070. */
  62071. get world(): NodeMaterialConnectionPoint;
  62072. /**
  62073. * Gets the output component
  62074. */
  62075. get output(): NodeMaterialConnectionPoint;
  62076. autoConfigure(material: NodeMaterial): void;
  62077. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62078. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62079. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62080. protected _buildBlock(state: NodeMaterialBuildState): this;
  62081. }
  62082. }
  62083. declare module BABYLON {
  62084. /**
  62085. * Block used to add support for instances
  62086. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62087. */
  62088. export class InstancesBlock extends NodeMaterialBlock {
  62089. /**
  62090. * Creates a new InstancesBlock
  62091. * @param name defines the block name
  62092. */
  62093. constructor(name: string);
  62094. /**
  62095. * Gets the current class name
  62096. * @returns the class name
  62097. */
  62098. getClassName(): string;
  62099. /**
  62100. * Gets the first world row input component
  62101. */
  62102. get world0(): NodeMaterialConnectionPoint;
  62103. /**
  62104. * Gets the second world row input component
  62105. */
  62106. get world1(): NodeMaterialConnectionPoint;
  62107. /**
  62108. * Gets the third world row input component
  62109. */
  62110. get world2(): NodeMaterialConnectionPoint;
  62111. /**
  62112. * Gets the forth world row input component
  62113. */
  62114. get world3(): NodeMaterialConnectionPoint;
  62115. /**
  62116. * Gets the world input component
  62117. */
  62118. get world(): NodeMaterialConnectionPoint;
  62119. /**
  62120. * Gets the output component
  62121. */
  62122. get output(): NodeMaterialConnectionPoint;
  62123. /**
  62124. * Gets the isntanceID component
  62125. */
  62126. get instanceID(): NodeMaterialConnectionPoint;
  62127. autoConfigure(material: NodeMaterial): void;
  62128. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62129. protected _buildBlock(state: NodeMaterialBuildState): this;
  62130. }
  62131. }
  62132. declare module BABYLON {
  62133. /**
  62134. * Block used to add morph targets support to vertex shader
  62135. */
  62136. export class MorphTargetsBlock extends NodeMaterialBlock {
  62137. private _repeatableContentAnchor;
  62138. /**
  62139. * Create a new MorphTargetsBlock
  62140. * @param name defines the block name
  62141. */
  62142. constructor(name: string);
  62143. /**
  62144. * Gets the current class name
  62145. * @returns the class name
  62146. */
  62147. getClassName(): string;
  62148. /**
  62149. * Gets the position input component
  62150. */
  62151. get position(): NodeMaterialConnectionPoint;
  62152. /**
  62153. * Gets the normal input component
  62154. */
  62155. get normal(): NodeMaterialConnectionPoint;
  62156. /**
  62157. * Gets the tangent input component
  62158. */
  62159. get tangent(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the tangent input component
  62162. */
  62163. get uv(): NodeMaterialConnectionPoint;
  62164. /**
  62165. * Gets the position output component
  62166. */
  62167. get positionOutput(): NodeMaterialConnectionPoint;
  62168. /**
  62169. * Gets the normal output component
  62170. */
  62171. get normalOutput(): NodeMaterialConnectionPoint;
  62172. /**
  62173. * Gets the tangent output component
  62174. */
  62175. get tangentOutput(): NodeMaterialConnectionPoint;
  62176. /**
  62177. * Gets the tangent output component
  62178. */
  62179. get uvOutput(): NodeMaterialConnectionPoint;
  62180. initialize(state: NodeMaterialBuildState): void;
  62181. autoConfigure(material: NodeMaterial): void;
  62182. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62183. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62184. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62185. protected _buildBlock(state: NodeMaterialBuildState): this;
  62186. }
  62187. }
  62188. declare module BABYLON {
  62189. /**
  62190. * Block used to get data information from a light
  62191. */
  62192. export class LightInformationBlock extends NodeMaterialBlock {
  62193. private _lightDataUniformName;
  62194. private _lightColorUniformName;
  62195. private _lightTypeDefineName;
  62196. /**
  62197. * Gets or sets the light associated with this block
  62198. */
  62199. light: Nullable<Light>;
  62200. /**
  62201. * Creates a new LightInformationBlock
  62202. * @param name defines the block name
  62203. */
  62204. constructor(name: string);
  62205. /**
  62206. * Gets the current class name
  62207. * @returns the class name
  62208. */
  62209. getClassName(): string;
  62210. /**
  62211. * Gets the world position input component
  62212. */
  62213. get worldPosition(): NodeMaterialConnectionPoint;
  62214. /**
  62215. * Gets the direction output component
  62216. */
  62217. get direction(): NodeMaterialConnectionPoint;
  62218. /**
  62219. * Gets the direction output component
  62220. */
  62221. get color(): NodeMaterialConnectionPoint;
  62222. /**
  62223. * Gets the direction output component
  62224. */
  62225. get intensity(): NodeMaterialConnectionPoint;
  62226. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62227. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62228. protected _buildBlock(state: NodeMaterialBuildState): this;
  62229. serialize(): any;
  62230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62231. }
  62232. }
  62233. declare module BABYLON {
  62234. /**
  62235. * Block used to add image processing support to fragment shader
  62236. */
  62237. export class ImageProcessingBlock extends NodeMaterialBlock {
  62238. /**
  62239. * Create a new ImageProcessingBlock
  62240. * @param name defines the block name
  62241. */
  62242. constructor(name: string);
  62243. /**
  62244. * Gets the current class name
  62245. * @returns the class name
  62246. */
  62247. getClassName(): string;
  62248. /**
  62249. * Gets the color input component
  62250. */
  62251. get color(): NodeMaterialConnectionPoint;
  62252. /**
  62253. * Gets the output component
  62254. */
  62255. get output(): NodeMaterialConnectionPoint;
  62256. /**
  62257. * Initialize the block and prepare the context for build
  62258. * @param state defines the state that will be used for the build
  62259. */
  62260. initialize(state: NodeMaterialBuildState): void;
  62261. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62263. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62264. protected _buildBlock(state: NodeMaterialBuildState): this;
  62265. }
  62266. }
  62267. declare module BABYLON {
  62268. /**
  62269. * Block used to pertub normals based on a normal map
  62270. */
  62271. export class PerturbNormalBlock extends NodeMaterialBlock {
  62272. private _tangentSpaceParameterName;
  62273. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62274. invertX: boolean;
  62275. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62276. invertY: boolean;
  62277. /**
  62278. * Create a new PerturbNormalBlock
  62279. * @param name defines the block name
  62280. */
  62281. constructor(name: string);
  62282. /**
  62283. * Gets the current class name
  62284. * @returns the class name
  62285. */
  62286. getClassName(): string;
  62287. /**
  62288. * Gets the world position input component
  62289. */
  62290. get worldPosition(): NodeMaterialConnectionPoint;
  62291. /**
  62292. * Gets the world normal input component
  62293. */
  62294. get worldNormal(): NodeMaterialConnectionPoint;
  62295. /**
  62296. * Gets the world tangent input component
  62297. */
  62298. get worldTangent(): NodeMaterialConnectionPoint;
  62299. /**
  62300. * Gets the uv input component
  62301. */
  62302. get uv(): NodeMaterialConnectionPoint;
  62303. /**
  62304. * Gets the normal map color input component
  62305. */
  62306. get normalMapColor(): NodeMaterialConnectionPoint;
  62307. /**
  62308. * Gets the strength input component
  62309. */
  62310. get strength(): NodeMaterialConnectionPoint;
  62311. /**
  62312. * Gets the output component
  62313. */
  62314. get output(): NodeMaterialConnectionPoint;
  62315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62316. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62317. autoConfigure(material: NodeMaterial): void;
  62318. protected _buildBlock(state: NodeMaterialBuildState): this;
  62319. protected _dumpPropertiesCode(): string;
  62320. serialize(): any;
  62321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62322. }
  62323. }
  62324. declare module BABYLON {
  62325. /**
  62326. * Block used to discard a pixel if a value is smaller than a cutoff
  62327. */
  62328. export class DiscardBlock extends NodeMaterialBlock {
  62329. /**
  62330. * Create a new DiscardBlock
  62331. * @param name defines the block name
  62332. */
  62333. constructor(name: string);
  62334. /**
  62335. * Gets the current class name
  62336. * @returns the class name
  62337. */
  62338. getClassName(): string;
  62339. /**
  62340. * Gets the color input component
  62341. */
  62342. get value(): NodeMaterialConnectionPoint;
  62343. /**
  62344. * Gets the cutoff input component
  62345. */
  62346. get cutoff(): NodeMaterialConnectionPoint;
  62347. protected _buildBlock(state: NodeMaterialBuildState): this;
  62348. }
  62349. }
  62350. declare module BABYLON {
  62351. /**
  62352. * Block used to test if the fragment shader is front facing
  62353. */
  62354. export class FrontFacingBlock extends NodeMaterialBlock {
  62355. /**
  62356. * Creates a new FrontFacingBlock
  62357. * @param name defines the block name
  62358. */
  62359. constructor(name: string);
  62360. /**
  62361. * Gets the current class name
  62362. * @returns the class name
  62363. */
  62364. getClassName(): string;
  62365. /**
  62366. * Gets the output component
  62367. */
  62368. get output(): NodeMaterialConnectionPoint;
  62369. protected _buildBlock(state: NodeMaterialBuildState): this;
  62370. }
  62371. }
  62372. declare module BABYLON {
  62373. /**
  62374. * Block used to get the derivative value on x and y of a given input
  62375. */
  62376. export class DerivativeBlock extends NodeMaterialBlock {
  62377. /**
  62378. * Create a new DerivativeBlock
  62379. * @param name defines the block name
  62380. */
  62381. constructor(name: string);
  62382. /**
  62383. * Gets the current class name
  62384. * @returns the class name
  62385. */
  62386. getClassName(): string;
  62387. /**
  62388. * Gets the input component
  62389. */
  62390. get input(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the derivative output on x
  62393. */
  62394. get dx(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the derivative output on y
  62397. */
  62398. get dy(): NodeMaterialConnectionPoint;
  62399. protected _buildBlock(state: NodeMaterialBuildState): this;
  62400. }
  62401. }
  62402. declare module BABYLON {
  62403. /**
  62404. * Block used to make gl_FragCoord available
  62405. */
  62406. export class FragCoordBlock extends NodeMaterialBlock {
  62407. /**
  62408. * Creates a new FragCoordBlock
  62409. * @param name defines the block name
  62410. */
  62411. constructor(name: string);
  62412. /**
  62413. * Gets the current class name
  62414. * @returns the class name
  62415. */
  62416. getClassName(): string;
  62417. /**
  62418. * Gets the xy component
  62419. */
  62420. get xy(): NodeMaterialConnectionPoint;
  62421. /**
  62422. * Gets the xyz component
  62423. */
  62424. get xyz(): NodeMaterialConnectionPoint;
  62425. /**
  62426. * Gets the xyzw component
  62427. */
  62428. get xyzw(): NodeMaterialConnectionPoint;
  62429. /**
  62430. * Gets the x component
  62431. */
  62432. get x(): NodeMaterialConnectionPoint;
  62433. /**
  62434. * Gets the y component
  62435. */
  62436. get y(): NodeMaterialConnectionPoint;
  62437. /**
  62438. * Gets the z component
  62439. */
  62440. get z(): NodeMaterialConnectionPoint;
  62441. /**
  62442. * Gets the w component
  62443. */
  62444. get output(): NodeMaterialConnectionPoint;
  62445. protected writeOutputs(state: NodeMaterialBuildState): string;
  62446. protected _buildBlock(state: NodeMaterialBuildState): this;
  62447. }
  62448. }
  62449. declare module BABYLON {
  62450. /**
  62451. * Block used to get the screen sizes
  62452. */
  62453. export class ScreenSizeBlock extends NodeMaterialBlock {
  62454. private _varName;
  62455. private _scene;
  62456. /**
  62457. * Creates a new ScreenSizeBlock
  62458. * @param name defines the block name
  62459. */
  62460. constructor(name: string);
  62461. /**
  62462. * Gets the current class name
  62463. * @returns the class name
  62464. */
  62465. getClassName(): string;
  62466. /**
  62467. * Gets the xy component
  62468. */
  62469. get xy(): NodeMaterialConnectionPoint;
  62470. /**
  62471. * Gets the x component
  62472. */
  62473. get x(): NodeMaterialConnectionPoint;
  62474. /**
  62475. * Gets the y component
  62476. */
  62477. get y(): NodeMaterialConnectionPoint;
  62478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62479. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62480. protected _buildBlock(state: NodeMaterialBuildState): this;
  62481. }
  62482. }
  62483. declare module BABYLON {
  62484. /**
  62485. * Block used to add support for scene fog
  62486. */
  62487. export class FogBlock extends NodeMaterialBlock {
  62488. private _fogDistanceName;
  62489. private _fogParameters;
  62490. /**
  62491. * Create a new FogBlock
  62492. * @param name defines the block name
  62493. */
  62494. constructor(name: string);
  62495. /**
  62496. * Gets the current class name
  62497. * @returns the class name
  62498. */
  62499. getClassName(): string;
  62500. /**
  62501. * Gets the world position input component
  62502. */
  62503. get worldPosition(): NodeMaterialConnectionPoint;
  62504. /**
  62505. * Gets the view input component
  62506. */
  62507. get view(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the color input component
  62510. */
  62511. get input(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the fog color input component
  62514. */
  62515. get fogColor(): NodeMaterialConnectionPoint;
  62516. /**
  62517. * Gets the output component
  62518. */
  62519. get output(): NodeMaterialConnectionPoint;
  62520. autoConfigure(material: NodeMaterial): void;
  62521. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62522. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62523. protected _buildBlock(state: NodeMaterialBuildState): this;
  62524. }
  62525. }
  62526. declare module BABYLON {
  62527. /**
  62528. * Block used to add light in the fragment shader
  62529. */
  62530. export class LightBlock extends NodeMaterialBlock {
  62531. private _lightId;
  62532. /**
  62533. * Gets or sets the light associated with this block
  62534. */
  62535. light: Nullable<Light>;
  62536. /**
  62537. * Create a new LightBlock
  62538. * @param name defines the block name
  62539. */
  62540. constructor(name: string);
  62541. /**
  62542. * Gets the current class name
  62543. * @returns the class name
  62544. */
  62545. getClassName(): string;
  62546. /**
  62547. * Gets the world position input component
  62548. */
  62549. get worldPosition(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the world normal input component
  62552. */
  62553. get worldNormal(): NodeMaterialConnectionPoint;
  62554. /**
  62555. * Gets the camera (or eye) position component
  62556. */
  62557. get cameraPosition(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Gets the glossiness component
  62560. */
  62561. get glossiness(): NodeMaterialConnectionPoint;
  62562. /**
  62563. * Gets the glossinness power component
  62564. */
  62565. get glossPower(): NodeMaterialConnectionPoint;
  62566. /**
  62567. * Gets the diffuse color component
  62568. */
  62569. get diffuseColor(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the specular color component
  62572. */
  62573. get specularColor(): NodeMaterialConnectionPoint;
  62574. /**
  62575. * Gets the diffuse output component
  62576. */
  62577. get diffuseOutput(): NodeMaterialConnectionPoint;
  62578. /**
  62579. * Gets the specular output component
  62580. */
  62581. get specularOutput(): NodeMaterialConnectionPoint;
  62582. /**
  62583. * Gets the shadow output component
  62584. */
  62585. get shadow(): NodeMaterialConnectionPoint;
  62586. autoConfigure(material: NodeMaterial): void;
  62587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62588. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62590. private _injectVertexCode;
  62591. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62592. serialize(): any;
  62593. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62594. }
  62595. }
  62596. declare module BABYLON {
  62597. /**
  62598. * Block used to read a reflection texture from a sampler
  62599. */
  62600. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62601. /**
  62602. * Create a new ReflectionTextureBlock
  62603. * @param name defines the block name
  62604. */
  62605. constructor(name: string);
  62606. /**
  62607. * Gets the current class name
  62608. * @returns the class name
  62609. */
  62610. getClassName(): string;
  62611. /**
  62612. * Gets the world position input component
  62613. */
  62614. get position(): NodeMaterialConnectionPoint;
  62615. /**
  62616. * Gets the world position input component
  62617. */
  62618. get worldPosition(): NodeMaterialConnectionPoint;
  62619. /**
  62620. * Gets the world normal input component
  62621. */
  62622. get worldNormal(): NodeMaterialConnectionPoint;
  62623. /**
  62624. * Gets the world input component
  62625. */
  62626. get world(): NodeMaterialConnectionPoint;
  62627. /**
  62628. * Gets the camera (or eye) position component
  62629. */
  62630. get cameraPosition(): NodeMaterialConnectionPoint;
  62631. /**
  62632. * Gets the view input component
  62633. */
  62634. get view(): NodeMaterialConnectionPoint;
  62635. /**
  62636. * Gets the rgb output component
  62637. */
  62638. get rgb(): NodeMaterialConnectionPoint;
  62639. /**
  62640. * Gets the rgba output component
  62641. */
  62642. get rgba(): NodeMaterialConnectionPoint;
  62643. /**
  62644. * Gets the r output component
  62645. */
  62646. get r(): NodeMaterialConnectionPoint;
  62647. /**
  62648. * Gets the g output component
  62649. */
  62650. get g(): NodeMaterialConnectionPoint;
  62651. /**
  62652. * Gets the b output component
  62653. */
  62654. get b(): NodeMaterialConnectionPoint;
  62655. /**
  62656. * Gets the a output component
  62657. */
  62658. get a(): NodeMaterialConnectionPoint;
  62659. autoConfigure(material: NodeMaterial): void;
  62660. protected _buildBlock(state: NodeMaterialBuildState): this;
  62661. }
  62662. }
  62663. declare module BABYLON {
  62664. /**
  62665. * Block used to add 2 vectors
  62666. */
  62667. export class AddBlock extends NodeMaterialBlock {
  62668. /**
  62669. * Creates a new AddBlock
  62670. * @param name defines the block name
  62671. */
  62672. constructor(name: string);
  62673. /**
  62674. * Gets the current class name
  62675. * @returns the class name
  62676. */
  62677. getClassName(): string;
  62678. /**
  62679. * Gets the left operand input component
  62680. */
  62681. get left(): NodeMaterialConnectionPoint;
  62682. /**
  62683. * Gets the right operand input component
  62684. */
  62685. get right(): NodeMaterialConnectionPoint;
  62686. /**
  62687. * Gets the output component
  62688. */
  62689. get output(): NodeMaterialConnectionPoint;
  62690. protected _buildBlock(state: NodeMaterialBuildState): this;
  62691. }
  62692. }
  62693. declare module BABYLON {
  62694. /**
  62695. * Block used to scale a vector by a float
  62696. */
  62697. export class ScaleBlock extends NodeMaterialBlock {
  62698. /**
  62699. * Creates a new ScaleBlock
  62700. * @param name defines the block name
  62701. */
  62702. constructor(name: string);
  62703. /**
  62704. * Gets the current class name
  62705. * @returns the class name
  62706. */
  62707. getClassName(): string;
  62708. /**
  62709. * Gets the input component
  62710. */
  62711. get input(): NodeMaterialConnectionPoint;
  62712. /**
  62713. * Gets the factor input component
  62714. */
  62715. get factor(): NodeMaterialConnectionPoint;
  62716. /**
  62717. * Gets the output component
  62718. */
  62719. get output(): NodeMaterialConnectionPoint;
  62720. protected _buildBlock(state: NodeMaterialBuildState): this;
  62721. }
  62722. }
  62723. declare module BABYLON {
  62724. /**
  62725. * Block used to clamp a float
  62726. */
  62727. export class ClampBlock extends NodeMaterialBlock {
  62728. /** Gets or sets the minimum range */
  62729. minimum: number;
  62730. /** Gets or sets the maximum range */
  62731. maximum: number;
  62732. /**
  62733. * Creates a new ClampBlock
  62734. * @param name defines the block name
  62735. */
  62736. constructor(name: string);
  62737. /**
  62738. * Gets the current class name
  62739. * @returns the class name
  62740. */
  62741. getClassName(): string;
  62742. /**
  62743. * Gets the value input component
  62744. */
  62745. get value(): NodeMaterialConnectionPoint;
  62746. /**
  62747. * Gets the output component
  62748. */
  62749. get output(): NodeMaterialConnectionPoint;
  62750. protected _buildBlock(state: NodeMaterialBuildState): this;
  62751. protected _dumpPropertiesCode(): string;
  62752. serialize(): any;
  62753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62754. }
  62755. }
  62756. declare module BABYLON {
  62757. /**
  62758. * Block used to apply a cross product between 2 vectors
  62759. */
  62760. export class CrossBlock extends NodeMaterialBlock {
  62761. /**
  62762. * Creates a new CrossBlock
  62763. * @param name defines the block name
  62764. */
  62765. constructor(name: string);
  62766. /**
  62767. * Gets the current class name
  62768. * @returns the class name
  62769. */
  62770. getClassName(): string;
  62771. /**
  62772. * Gets the left operand input component
  62773. */
  62774. get left(): NodeMaterialConnectionPoint;
  62775. /**
  62776. * Gets the right operand input component
  62777. */
  62778. get right(): NodeMaterialConnectionPoint;
  62779. /**
  62780. * Gets the output component
  62781. */
  62782. get output(): NodeMaterialConnectionPoint;
  62783. protected _buildBlock(state: NodeMaterialBuildState): this;
  62784. }
  62785. }
  62786. declare module BABYLON {
  62787. /**
  62788. * Block used to apply a dot product between 2 vectors
  62789. */
  62790. export class DotBlock extends NodeMaterialBlock {
  62791. /**
  62792. * Creates a new DotBlock
  62793. * @param name defines the block name
  62794. */
  62795. constructor(name: string);
  62796. /**
  62797. * Gets the current class name
  62798. * @returns the class name
  62799. */
  62800. getClassName(): string;
  62801. /**
  62802. * Gets the left operand input component
  62803. */
  62804. get left(): NodeMaterialConnectionPoint;
  62805. /**
  62806. * Gets the right operand input component
  62807. */
  62808. get right(): NodeMaterialConnectionPoint;
  62809. /**
  62810. * Gets the output component
  62811. */
  62812. get output(): NodeMaterialConnectionPoint;
  62813. protected _buildBlock(state: NodeMaterialBuildState): this;
  62814. }
  62815. }
  62816. declare module BABYLON {
  62817. /**
  62818. * Block used to normalize a vector
  62819. */
  62820. export class NormalizeBlock extends NodeMaterialBlock {
  62821. /**
  62822. * Creates a new NormalizeBlock
  62823. * @param name defines the block name
  62824. */
  62825. constructor(name: string);
  62826. /**
  62827. * Gets the current class name
  62828. * @returns the class name
  62829. */
  62830. getClassName(): string;
  62831. /**
  62832. * Gets the input component
  62833. */
  62834. get input(): NodeMaterialConnectionPoint;
  62835. /**
  62836. * Gets the output component
  62837. */
  62838. get output(): NodeMaterialConnectionPoint;
  62839. protected _buildBlock(state: NodeMaterialBuildState): this;
  62840. }
  62841. }
  62842. declare module BABYLON {
  62843. /**
  62844. * Operations supported by the Trigonometry block
  62845. */
  62846. export enum TrigonometryBlockOperations {
  62847. /** Cos */
  62848. Cos = 0,
  62849. /** Sin */
  62850. Sin = 1,
  62851. /** Abs */
  62852. Abs = 2,
  62853. /** Exp */
  62854. Exp = 3,
  62855. /** Exp2 */
  62856. Exp2 = 4,
  62857. /** Round */
  62858. Round = 5,
  62859. /** Floor */
  62860. Floor = 6,
  62861. /** Ceiling */
  62862. Ceiling = 7,
  62863. /** Square root */
  62864. Sqrt = 8,
  62865. /** Log */
  62866. Log = 9,
  62867. /** Tangent */
  62868. Tan = 10,
  62869. /** Arc tangent */
  62870. ArcTan = 11,
  62871. /** Arc cosinus */
  62872. ArcCos = 12,
  62873. /** Arc sinus */
  62874. ArcSin = 13,
  62875. /** Fraction */
  62876. Fract = 14,
  62877. /** Sign */
  62878. Sign = 15,
  62879. /** To radians (from degrees) */
  62880. Radians = 16,
  62881. /** To degrees (from radians) */
  62882. Degrees = 17
  62883. }
  62884. /**
  62885. * Block used to apply trigonometry operation to floats
  62886. */
  62887. export class TrigonometryBlock extends NodeMaterialBlock {
  62888. /**
  62889. * Gets or sets the operation applied by the block
  62890. */
  62891. operation: TrigonometryBlockOperations;
  62892. /**
  62893. * Creates a new TrigonometryBlock
  62894. * @param name defines the block name
  62895. */
  62896. constructor(name: string);
  62897. /**
  62898. * Gets the current class name
  62899. * @returns the class name
  62900. */
  62901. getClassName(): string;
  62902. /**
  62903. * Gets the input component
  62904. */
  62905. get input(): NodeMaterialConnectionPoint;
  62906. /**
  62907. * Gets the output component
  62908. */
  62909. get output(): NodeMaterialConnectionPoint;
  62910. protected _buildBlock(state: NodeMaterialBuildState): this;
  62911. serialize(): any;
  62912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62913. protected _dumpPropertiesCode(): string;
  62914. }
  62915. }
  62916. declare module BABYLON {
  62917. /**
  62918. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62919. */
  62920. export class ColorMergerBlock extends NodeMaterialBlock {
  62921. /**
  62922. * Create a new ColorMergerBlock
  62923. * @param name defines the block name
  62924. */
  62925. constructor(name: string);
  62926. /**
  62927. * Gets the current class name
  62928. * @returns the class name
  62929. */
  62930. getClassName(): string;
  62931. /**
  62932. * Gets the rgb component (input)
  62933. */
  62934. get rgbIn(): NodeMaterialConnectionPoint;
  62935. /**
  62936. * Gets the r component (input)
  62937. */
  62938. get r(): NodeMaterialConnectionPoint;
  62939. /**
  62940. * Gets the g component (input)
  62941. */
  62942. get g(): NodeMaterialConnectionPoint;
  62943. /**
  62944. * Gets the b component (input)
  62945. */
  62946. get b(): NodeMaterialConnectionPoint;
  62947. /**
  62948. * Gets the a component (input)
  62949. */
  62950. get a(): NodeMaterialConnectionPoint;
  62951. /**
  62952. * Gets the rgba component (output)
  62953. */
  62954. get rgba(): NodeMaterialConnectionPoint;
  62955. /**
  62956. * Gets the rgb component (output)
  62957. */
  62958. get rgbOut(): NodeMaterialConnectionPoint;
  62959. /**
  62960. * Gets the rgb component (output)
  62961. * @deprecated Please use rgbOut instead.
  62962. */
  62963. get rgb(): NodeMaterialConnectionPoint;
  62964. protected _buildBlock(state: NodeMaterialBuildState): this;
  62965. }
  62966. }
  62967. declare module BABYLON {
  62968. /**
  62969. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62970. */
  62971. export class VectorSplitterBlock extends NodeMaterialBlock {
  62972. /**
  62973. * Create a new VectorSplitterBlock
  62974. * @param name defines the block name
  62975. */
  62976. constructor(name: string);
  62977. /**
  62978. * Gets the current class name
  62979. * @returns the class name
  62980. */
  62981. getClassName(): string;
  62982. /**
  62983. * Gets the xyzw component (input)
  62984. */
  62985. get xyzw(): NodeMaterialConnectionPoint;
  62986. /**
  62987. * Gets the xyz component (input)
  62988. */
  62989. get xyzIn(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the xy component (input)
  62992. */
  62993. get xyIn(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the xyz component (output)
  62996. */
  62997. get xyzOut(): NodeMaterialConnectionPoint;
  62998. /**
  62999. * Gets the xy component (output)
  63000. */
  63001. get xyOut(): NodeMaterialConnectionPoint;
  63002. /**
  63003. * Gets the x component (output)
  63004. */
  63005. get x(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the y component (output)
  63008. */
  63009. get y(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the z component (output)
  63012. */
  63013. get z(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the w component (output)
  63016. */
  63017. get w(): NodeMaterialConnectionPoint;
  63018. protected _inputRename(name: string): string;
  63019. protected _outputRename(name: string): string;
  63020. protected _buildBlock(state: NodeMaterialBuildState): this;
  63021. }
  63022. }
  63023. declare module BABYLON {
  63024. /**
  63025. * Block used to lerp between 2 values
  63026. */
  63027. export class LerpBlock extends NodeMaterialBlock {
  63028. /**
  63029. * Creates a new LerpBlock
  63030. * @param name defines the block name
  63031. */
  63032. constructor(name: string);
  63033. /**
  63034. * Gets the current class name
  63035. * @returns the class name
  63036. */
  63037. getClassName(): string;
  63038. /**
  63039. * Gets the left operand input component
  63040. */
  63041. get left(): NodeMaterialConnectionPoint;
  63042. /**
  63043. * Gets the right operand input component
  63044. */
  63045. get right(): NodeMaterialConnectionPoint;
  63046. /**
  63047. * Gets the gradient operand input component
  63048. */
  63049. get gradient(): NodeMaterialConnectionPoint;
  63050. /**
  63051. * Gets the output component
  63052. */
  63053. get output(): NodeMaterialConnectionPoint;
  63054. protected _buildBlock(state: NodeMaterialBuildState): this;
  63055. }
  63056. }
  63057. declare module BABYLON {
  63058. /**
  63059. * Block used to divide 2 vectors
  63060. */
  63061. export class DivideBlock extends NodeMaterialBlock {
  63062. /**
  63063. * Creates a new DivideBlock
  63064. * @param name defines the block name
  63065. */
  63066. constructor(name: string);
  63067. /**
  63068. * Gets the current class name
  63069. * @returns the class name
  63070. */
  63071. getClassName(): string;
  63072. /**
  63073. * Gets the left operand input component
  63074. */
  63075. get left(): NodeMaterialConnectionPoint;
  63076. /**
  63077. * Gets the right operand input component
  63078. */
  63079. get right(): NodeMaterialConnectionPoint;
  63080. /**
  63081. * Gets the output component
  63082. */
  63083. get output(): NodeMaterialConnectionPoint;
  63084. protected _buildBlock(state: NodeMaterialBuildState): this;
  63085. }
  63086. }
  63087. declare module BABYLON {
  63088. /**
  63089. * Block used to subtract 2 vectors
  63090. */
  63091. export class SubtractBlock extends NodeMaterialBlock {
  63092. /**
  63093. * Creates a new SubtractBlock
  63094. * @param name defines the block name
  63095. */
  63096. constructor(name: string);
  63097. /**
  63098. * Gets the current class name
  63099. * @returns the class name
  63100. */
  63101. getClassName(): string;
  63102. /**
  63103. * Gets the left operand input component
  63104. */
  63105. get left(): NodeMaterialConnectionPoint;
  63106. /**
  63107. * Gets the right operand input component
  63108. */
  63109. get right(): NodeMaterialConnectionPoint;
  63110. /**
  63111. * Gets the output component
  63112. */
  63113. get output(): NodeMaterialConnectionPoint;
  63114. protected _buildBlock(state: NodeMaterialBuildState): this;
  63115. }
  63116. }
  63117. declare module BABYLON {
  63118. /**
  63119. * Block used to step a value
  63120. */
  63121. export class StepBlock extends NodeMaterialBlock {
  63122. /**
  63123. * Creates a new StepBlock
  63124. * @param name defines the block name
  63125. */
  63126. constructor(name: string);
  63127. /**
  63128. * Gets the current class name
  63129. * @returns the class name
  63130. */
  63131. getClassName(): string;
  63132. /**
  63133. * Gets the value operand input component
  63134. */
  63135. get value(): NodeMaterialConnectionPoint;
  63136. /**
  63137. * Gets the edge operand input component
  63138. */
  63139. get edge(): NodeMaterialConnectionPoint;
  63140. /**
  63141. * Gets the output component
  63142. */
  63143. get output(): NodeMaterialConnectionPoint;
  63144. protected _buildBlock(state: NodeMaterialBuildState): this;
  63145. }
  63146. }
  63147. declare module BABYLON {
  63148. /**
  63149. * Block used to get the opposite (1 - x) of a value
  63150. */
  63151. export class OneMinusBlock extends NodeMaterialBlock {
  63152. /**
  63153. * Creates a new OneMinusBlock
  63154. * @param name defines the block name
  63155. */
  63156. constructor(name: string);
  63157. /**
  63158. * Gets the current class name
  63159. * @returns the class name
  63160. */
  63161. getClassName(): string;
  63162. /**
  63163. * Gets the input component
  63164. */
  63165. get input(): NodeMaterialConnectionPoint;
  63166. /**
  63167. * Gets the output component
  63168. */
  63169. get output(): NodeMaterialConnectionPoint;
  63170. protected _buildBlock(state: NodeMaterialBuildState): this;
  63171. }
  63172. }
  63173. declare module BABYLON {
  63174. /**
  63175. * Block used to get the view direction
  63176. */
  63177. export class ViewDirectionBlock extends NodeMaterialBlock {
  63178. /**
  63179. * Creates a new ViewDirectionBlock
  63180. * @param name defines the block name
  63181. */
  63182. constructor(name: string);
  63183. /**
  63184. * Gets the current class name
  63185. * @returns the class name
  63186. */
  63187. getClassName(): string;
  63188. /**
  63189. * Gets the world position component
  63190. */
  63191. get worldPosition(): NodeMaterialConnectionPoint;
  63192. /**
  63193. * Gets the camera position component
  63194. */
  63195. get cameraPosition(): NodeMaterialConnectionPoint;
  63196. /**
  63197. * Gets the output component
  63198. */
  63199. get output(): NodeMaterialConnectionPoint;
  63200. autoConfigure(material: NodeMaterial): void;
  63201. protected _buildBlock(state: NodeMaterialBuildState): this;
  63202. }
  63203. }
  63204. declare module BABYLON {
  63205. /**
  63206. * Block used to compute fresnel value
  63207. */
  63208. export class FresnelBlock extends NodeMaterialBlock {
  63209. /**
  63210. * Create a new FresnelBlock
  63211. * @param name defines the block name
  63212. */
  63213. constructor(name: string);
  63214. /**
  63215. * Gets the current class name
  63216. * @returns the class name
  63217. */
  63218. getClassName(): string;
  63219. /**
  63220. * Gets the world normal input component
  63221. */
  63222. get worldNormal(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the view direction input component
  63225. */
  63226. get viewDirection(): NodeMaterialConnectionPoint;
  63227. /**
  63228. * Gets the bias input component
  63229. */
  63230. get bias(): NodeMaterialConnectionPoint;
  63231. /**
  63232. * Gets the camera (or eye) position component
  63233. */
  63234. get power(): NodeMaterialConnectionPoint;
  63235. /**
  63236. * Gets the fresnel output component
  63237. */
  63238. get fresnel(): NodeMaterialConnectionPoint;
  63239. autoConfigure(material: NodeMaterial): void;
  63240. protected _buildBlock(state: NodeMaterialBuildState): this;
  63241. }
  63242. }
  63243. declare module BABYLON {
  63244. /**
  63245. * Block used to get the max of 2 values
  63246. */
  63247. export class MaxBlock extends NodeMaterialBlock {
  63248. /**
  63249. * Creates a new MaxBlock
  63250. * @param name defines the block name
  63251. */
  63252. constructor(name: string);
  63253. /**
  63254. * Gets the current class name
  63255. * @returns the class name
  63256. */
  63257. getClassName(): string;
  63258. /**
  63259. * Gets the left operand input component
  63260. */
  63261. get left(): NodeMaterialConnectionPoint;
  63262. /**
  63263. * Gets the right operand input component
  63264. */
  63265. get right(): NodeMaterialConnectionPoint;
  63266. /**
  63267. * Gets the output component
  63268. */
  63269. get output(): NodeMaterialConnectionPoint;
  63270. protected _buildBlock(state: NodeMaterialBuildState): this;
  63271. }
  63272. }
  63273. declare module BABYLON {
  63274. /**
  63275. * Block used to get the min of 2 values
  63276. */
  63277. export class MinBlock extends NodeMaterialBlock {
  63278. /**
  63279. * Creates a new MinBlock
  63280. * @param name defines the block name
  63281. */
  63282. constructor(name: string);
  63283. /**
  63284. * Gets the current class name
  63285. * @returns the class name
  63286. */
  63287. getClassName(): string;
  63288. /**
  63289. * Gets the left operand input component
  63290. */
  63291. get left(): NodeMaterialConnectionPoint;
  63292. /**
  63293. * Gets the right operand input component
  63294. */
  63295. get right(): NodeMaterialConnectionPoint;
  63296. /**
  63297. * Gets the output component
  63298. */
  63299. get output(): NodeMaterialConnectionPoint;
  63300. protected _buildBlock(state: NodeMaterialBuildState): this;
  63301. }
  63302. }
  63303. declare module BABYLON {
  63304. /**
  63305. * Block used to get the distance between 2 values
  63306. */
  63307. export class DistanceBlock extends NodeMaterialBlock {
  63308. /**
  63309. * Creates a new DistanceBlock
  63310. * @param name defines the block name
  63311. */
  63312. constructor(name: string);
  63313. /**
  63314. * Gets the current class name
  63315. * @returns the class name
  63316. */
  63317. getClassName(): string;
  63318. /**
  63319. * Gets the left operand input component
  63320. */
  63321. get left(): NodeMaterialConnectionPoint;
  63322. /**
  63323. * Gets the right operand input component
  63324. */
  63325. get right(): NodeMaterialConnectionPoint;
  63326. /**
  63327. * Gets the output component
  63328. */
  63329. get output(): NodeMaterialConnectionPoint;
  63330. protected _buildBlock(state: NodeMaterialBuildState): this;
  63331. }
  63332. }
  63333. declare module BABYLON {
  63334. /**
  63335. * Block used to get the length of a vector
  63336. */
  63337. export class LengthBlock extends NodeMaterialBlock {
  63338. /**
  63339. * Creates a new LengthBlock
  63340. * @param name defines the block name
  63341. */
  63342. constructor(name: string);
  63343. /**
  63344. * Gets the current class name
  63345. * @returns the class name
  63346. */
  63347. getClassName(): string;
  63348. /**
  63349. * Gets the value input component
  63350. */
  63351. get value(): NodeMaterialConnectionPoint;
  63352. /**
  63353. * Gets the output component
  63354. */
  63355. get output(): NodeMaterialConnectionPoint;
  63356. protected _buildBlock(state: NodeMaterialBuildState): this;
  63357. }
  63358. }
  63359. declare module BABYLON {
  63360. /**
  63361. * Block used to get negative version of a value (i.e. x * -1)
  63362. */
  63363. export class NegateBlock extends NodeMaterialBlock {
  63364. /**
  63365. * Creates a new NegateBlock
  63366. * @param name defines the block name
  63367. */
  63368. constructor(name: string);
  63369. /**
  63370. * Gets the current class name
  63371. * @returns the class name
  63372. */
  63373. getClassName(): string;
  63374. /**
  63375. * Gets the value input component
  63376. */
  63377. get value(): NodeMaterialConnectionPoint;
  63378. /**
  63379. * Gets the output component
  63380. */
  63381. get output(): NodeMaterialConnectionPoint;
  63382. protected _buildBlock(state: NodeMaterialBuildState): this;
  63383. }
  63384. }
  63385. declare module BABYLON {
  63386. /**
  63387. * Block used to get the value of the first parameter raised to the power of the second
  63388. */
  63389. export class PowBlock extends NodeMaterialBlock {
  63390. /**
  63391. * Creates a new PowBlock
  63392. * @param name defines the block name
  63393. */
  63394. constructor(name: string);
  63395. /**
  63396. * Gets the current class name
  63397. * @returns the class name
  63398. */
  63399. getClassName(): string;
  63400. /**
  63401. * Gets the value operand input component
  63402. */
  63403. get value(): NodeMaterialConnectionPoint;
  63404. /**
  63405. * Gets the power operand input component
  63406. */
  63407. get power(): NodeMaterialConnectionPoint;
  63408. /**
  63409. * Gets the output component
  63410. */
  63411. get output(): NodeMaterialConnectionPoint;
  63412. protected _buildBlock(state: NodeMaterialBuildState): this;
  63413. }
  63414. }
  63415. declare module BABYLON {
  63416. /**
  63417. * Block used to get a random number
  63418. */
  63419. export class RandomNumberBlock extends NodeMaterialBlock {
  63420. /**
  63421. * Creates a new RandomNumberBlock
  63422. * @param name defines the block name
  63423. */
  63424. constructor(name: string);
  63425. /**
  63426. * Gets the current class name
  63427. * @returns the class name
  63428. */
  63429. getClassName(): string;
  63430. /**
  63431. * Gets the seed input component
  63432. */
  63433. get seed(): NodeMaterialConnectionPoint;
  63434. /**
  63435. * Gets the output component
  63436. */
  63437. get output(): NodeMaterialConnectionPoint;
  63438. protected _buildBlock(state: NodeMaterialBuildState): this;
  63439. }
  63440. }
  63441. declare module BABYLON {
  63442. /**
  63443. * Block used to compute arc tangent of 2 values
  63444. */
  63445. export class ArcTan2Block extends NodeMaterialBlock {
  63446. /**
  63447. * Creates a new ArcTan2Block
  63448. * @param name defines the block name
  63449. */
  63450. constructor(name: string);
  63451. /**
  63452. * Gets the current class name
  63453. * @returns the class name
  63454. */
  63455. getClassName(): string;
  63456. /**
  63457. * Gets the x operand input component
  63458. */
  63459. get x(): NodeMaterialConnectionPoint;
  63460. /**
  63461. * Gets the y operand input component
  63462. */
  63463. get y(): NodeMaterialConnectionPoint;
  63464. /**
  63465. * Gets the output component
  63466. */
  63467. get output(): NodeMaterialConnectionPoint;
  63468. protected _buildBlock(state: NodeMaterialBuildState): this;
  63469. }
  63470. }
  63471. declare module BABYLON {
  63472. /**
  63473. * Block used to smooth step a value
  63474. */
  63475. export class SmoothStepBlock extends NodeMaterialBlock {
  63476. /**
  63477. * Creates a new SmoothStepBlock
  63478. * @param name defines the block name
  63479. */
  63480. constructor(name: string);
  63481. /**
  63482. * Gets the current class name
  63483. * @returns the class name
  63484. */
  63485. getClassName(): string;
  63486. /**
  63487. * Gets the value operand input component
  63488. */
  63489. get value(): NodeMaterialConnectionPoint;
  63490. /**
  63491. * Gets the first edge operand input component
  63492. */
  63493. get edge0(): NodeMaterialConnectionPoint;
  63494. /**
  63495. * Gets the second edge operand input component
  63496. */
  63497. get edge1(): NodeMaterialConnectionPoint;
  63498. /**
  63499. * Gets the output component
  63500. */
  63501. get output(): NodeMaterialConnectionPoint;
  63502. protected _buildBlock(state: NodeMaterialBuildState): this;
  63503. }
  63504. }
  63505. declare module BABYLON {
  63506. /**
  63507. * Block used to get the reciprocal (1 / x) of a value
  63508. */
  63509. export class ReciprocalBlock extends NodeMaterialBlock {
  63510. /**
  63511. * Creates a new ReciprocalBlock
  63512. * @param name defines the block name
  63513. */
  63514. constructor(name: string);
  63515. /**
  63516. * Gets the current class name
  63517. * @returns the class name
  63518. */
  63519. getClassName(): string;
  63520. /**
  63521. * Gets the input component
  63522. */
  63523. get input(): NodeMaterialConnectionPoint;
  63524. /**
  63525. * Gets the output component
  63526. */
  63527. get output(): NodeMaterialConnectionPoint;
  63528. protected _buildBlock(state: NodeMaterialBuildState): this;
  63529. }
  63530. }
  63531. declare module BABYLON {
  63532. /**
  63533. * Block used to replace a color by another one
  63534. */
  63535. export class ReplaceColorBlock extends NodeMaterialBlock {
  63536. /**
  63537. * Creates a new ReplaceColorBlock
  63538. * @param name defines the block name
  63539. */
  63540. constructor(name: string);
  63541. /**
  63542. * Gets the current class name
  63543. * @returns the class name
  63544. */
  63545. getClassName(): string;
  63546. /**
  63547. * Gets the value input component
  63548. */
  63549. get value(): NodeMaterialConnectionPoint;
  63550. /**
  63551. * Gets the reference input component
  63552. */
  63553. get reference(): NodeMaterialConnectionPoint;
  63554. /**
  63555. * Gets the distance input component
  63556. */
  63557. get distance(): NodeMaterialConnectionPoint;
  63558. /**
  63559. * Gets the replacement input component
  63560. */
  63561. get replacement(): NodeMaterialConnectionPoint;
  63562. /**
  63563. * Gets the output component
  63564. */
  63565. get output(): NodeMaterialConnectionPoint;
  63566. protected _buildBlock(state: NodeMaterialBuildState): this;
  63567. }
  63568. }
  63569. declare module BABYLON {
  63570. /**
  63571. * Block used to posterize a value
  63572. * @see https://en.wikipedia.org/wiki/Posterization
  63573. */
  63574. export class PosterizeBlock extends NodeMaterialBlock {
  63575. /**
  63576. * Creates a new PosterizeBlock
  63577. * @param name defines the block name
  63578. */
  63579. constructor(name: string);
  63580. /**
  63581. * Gets the current class name
  63582. * @returns the class name
  63583. */
  63584. getClassName(): string;
  63585. /**
  63586. * Gets the value input component
  63587. */
  63588. get value(): NodeMaterialConnectionPoint;
  63589. /**
  63590. * Gets the steps input component
  63591. */
  63592. get steps(): NodeMaterialConnectionPoint;
  63593. /**
  63594. * Gets the output component
  63595. */
  63596. get output(): NodeMaterialConnectionPoint;
  63597. protected _buildBlock(state: NodeMaterialBuildState): this;
  63598. }
  63599. }
  63600. declare module BABYLON {
  63601. /**
  63602. * Operations supported by the Wave block
  63603. */
  63604. export enum WaveBlockKind {
  63605. /** SawTooth */
  63606. SawTooth = 0,
  63607. /** Square */
  63608. Square = 1,
  63609. /** Triangle */
  63610. Triangle = 2
  63611. }
  63612. /**
  63613. * Block used to apply wave operation to floats
  63614. */
  63615. export class WaveBlock extends NodeMaterialBlock {
  63616. /**
  63617. * Gets or sets the kibnd of wave to be applied by the block
  63618. */
  63619. kind: WaveBlockKind;
  63620. /**
  63621. * Creates a new WaveBlock
  63622. * @param name defines the block name
  63623. */
  63624. constructor(name: string);
  63625. /**
  63626. * Gets the current class name
  63627. * @returns the class name
  63628. */
  63629. getClassName(): string;
  63630. /**
  63631. * Gets the input component
  63632. */
  63633. get input(): NodeMaterialConnectionPoint;
  63634. /**
  63635. * Gets the output component
  63636. */
  63637. get output(): NodeMaterialConnectionPoint;
  63638. protected _buildBlock(state: NodeMaterialBuildState): this;
  63639. serialize(): any;
  63640. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63641. }
  63642. }
  63643. declare module BABYLON {
  63644. /**
  63645. * Class used to store a color step for the GradientBlock
  63646. */
  63647. export class GradientBlockColorStep {
  63648. /**
  63649. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63650. */
  63651. step: number;
  63652. /**
  63653. * Gets or sets the color associated with this step
  63654. */
  63655. color: Color3;
  63656. /**
  63657. * Creates a new GradientBlockColorStep
  63658. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63659. * @param color defines the color associated with this step
  63660. */
  63661. constructor(
  63662. /**
  63663. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63664. */
  63665. step: number,
  63666. /**
  63667. * Gets or sets the color associated with this step
  63668. */
  63669. color: Color3);
  63670. }
  63671. /**
  63672. * Block used to return a color from a gradient based on an input value between 0 and 1
  63673. */
  63674. export class GradientBlock extends NodeMaterialBlock {
  63675. /**
  63676. * Gets or sets the list of color steps
  63677. */
  63678. colorSteps: GradientBlockColorStep[];
  63679. /**
  63680. * Creates a new GradientBlock
  63681. * @param name defines the block name
  63682. */
  63683. constructor(name: string);
  63684. /**
  63685. * Gets the current class name
  63686. * @returns the class name
  63687. */
  63688. getClassName(): string;
  63689. /**
  63690. * Gets the gradient input component
  63691. */
  63692. get gradient(): NodeMaterialConnectionPoint;
  63693. /**
  63694. * Gets the output component
  63695. */
  63696. get output(): NodeMaterialConnectionPoint;
  63697. private _writeColorConstant;
  63698. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63699. serialize(): any;
  63700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63701. protected _dumpPropertiesCode(): string;
  63702. }
  63703. }
  63704. declare module BABYLON {
  63705. /**
  63706. * Block used to normalize lerp between 2 values
  63707. */
  63708. export class NLerpBlock extends NodeMaterialBlock {
  63709. /**
  63710. * Creates a new NLerpBlock
  63711. * @param name defines the block name
  63712. */
  63713. constructor(name: string);
  63714. /**
  63715. * Gets the current class name
  63716. * @returns the class name
  63717. */
  63718. getClassName(): string;
  63719. /**
  63720. * Gets the left operand input component
  63721. */
  63722. get left(): NodeMaterialConnectionPoint;
  63723. /**
  63724. * Gets the right operand input component
  63725. */
  63726. get right(): NodeMaterialConnectionPoint;
  63727. /**
  63728. * Gets the gradient operand input component
  63729. */
  63730. get gradient(): NodeMaterialConnectionPoint;
  63731. /**
  63732. * Gets the output component
  63733. */
  63734. get output(): NodeMaterialConnectionPoint;
  63735. protected _buildBlock(state: NodeMaterialBuildState): this;
  63736. }
  63737. }
  63738. declare module BABYLON {
  63739. /**
  63740. * block used to Generate a Worley Noise 3D Noise Pattern
  63741. */
  63742. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63743. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63744. manhattanDistance: boolean;
  63745. /**
  63746. * Creates a new WorleyNoise3DBlock
  63747. * @param name defines the block name
  63748. */
  63749. constructor(name: string);
  63750. /**
  63751. * Gets the current class name
  63752. * @returns the class name
  63753. */
  63754. getClassName(): string;
  63755. /**
  63756. * Gets the seed input component
  63757. */
  63758. get seed(): NodeMaterialConnectionPoint;
  63759. /**
  63760. * Gets the jitter input component
  63761. */
  63762. get jitter(): NodeMaterialConnectionPoint;
  63763. /**
  63764. * Gets the output component
  63765. */
  63766. get output(): NodeMaterialConnectionPoint;
  63767. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63768. /**
  63769. * Exposes the properties to the UI?
  63770. */
  63771. protected _dumpPropertiesCode(): string;
  63772. /**
  63773. * Exposes the properties to the Seralize?
  63774. */
  63775. serialize(): any;
  63776. /**
  63777. * Exposes the properties to the deseralize?
  63778. */
  63779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63780. }
  63781. }
  63782. declare module BABYLON {
  63783. /**
  63784. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63785. */
  63786. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63787. /**
  63788. * Creates a new SimplexPerlin3DBlock
  63789. * @param name defines the block name
  63790. */
  63791. constructor(name: string);
  63792. /**
  63793. * Gets the current class name
  63794. * @returns the class name
  63795. */
  63796. getClassName(): string;
  63797. /**
  63798. * Gets the seed operand input component
  63799. */
  63800. get seed(): NodeMaterialConnectionPoint;
  63801. /**
  63802. * Gets the output component
  63803. */
  63804. get output(): NodeMaterialConnectionPoint;
  63805. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63806. }
  63807. }
  63808. declare module BABYLON {
  63809. /**
  63810. * Block used to blend normals
  63811. */
  63812. export class NormalBlendBlock extends NodeMaterialBlock {
  63813. /**
  63814. * Creates a new NormalBlendBlock
  63815. * @param name defines the block name
  63816. */
  63817. constructor(name: string);
  63818. /**
  63819. * Gets the current class name
  63820. * @returns the class name
  63821. */
  63822. getClassName(): string;
  63823. /**
  63824. * Gets the first input component
  63825. */
  63826. get normalMap0(): NodeMaterialConnectionPoint;
  63827. /**
  63828. * Gets the second input component
  63829. */
  63830. get normalMap1(): NodeMaterialConnectionPoint;
  63831. /**
  63832. * Gets the output component
  63833. */
  63834. get output(): NodeMaterialConnectionPoint;
  63835. protected _buildBlock(state: NodeMaterialBuildState): this;
  63836. }
  63837. }
  63838. declare module BABYLON {
  63839. /**
  63840. * Block used to rotate a 2d vector by a given angle
  63841. */
  63842. export class Rotate2dBlock extends NodeMaterialBlock {
  63843. /**
  63844. * Creates a new Rotate2dBlock
  63845. * @param name defines the block name
  63846. */
  63847. constructor(name: string);
  63848. /**
  63849. * Gets the current class name
  63850. * @returns the class name
  63851. */
  63852. getClassName(): string;
  63853. /**
  63854. * Gets the input vector
  63855. */
  63856. get input(): NodeMaterialConnectionPoint;
  63857. /**
  63858. * Gets the input angle
  63859. */
  63860. get angle(): NodeMaterialConnectionPoint;
  63861. /**
  63862. * Gets the output component
  63863. */
  63864. get output(): NodeMaterialConnectionPoint;
  63865. autoConfigure(material: NodeMaterial): void;
  63866. protected _buildBlock(state: NodeMaterialBuildState): this;
  63867. }
  63868. }
  63869. declare module BABYLON {
  63870. /**
  63871. * Block used to get the reflected vector from a direction and a normal
  63872. */
  63873. export class ReflectBlock extends NodeMaterialBlock {
  63874. /**
  63875. * Creates a new ReflectBlock
  63876. * @param name defines the block name
  63877. */
  63878. constructor(name: string);
  63879. /**
  63880. * Gets the current class name
  63881. * @returns the class name
  63882. */
  63883. getClassName(): string;
  63884. /**
  63885. * Gets the incident component
  63886. */
  63887. get incident(): NodeMaterialConnectionPoint;
  63888. /**
  63889. * Gets the normal component
  63890. */
  63891. get normal(): NodeMaterialConnectionPoint;
  63892. /**
  63893. * Gets the output component
  63894. */
  63895. get output(): NodeMaterialConnectionPoint;
  63896. protected _buildBlock(state: NodeMaterialBuildState): this;
  63897. }
  63898. }
  63899. declare module BABYLON {
  63900. /**
  63901. * Block used to get the refracted vector from a direction and a normal
  63902. */
  63903. export class RefractBlock extends NodeMaterialBlock {
  63904. /**
  63905. * Creates a new RefractBlock
  63906. * @param name defines the block name
  63907. */
  63908. constructor(name: string);
  63909. /**
  63910. * Gets the current class name
  63911. * @returns the class name
  63912. */
  63913. getClassName(): string;
  63914. /**
  63915. * Gets the incident component
  63916. */
  63917. get incident(): NodeMaterialConnectionPoint;
  63918. /**
  63919. * Gets the normal component
  63920. */
  63921. get normal(): NodeMaterialConnectionPoint;
  63922. /**
  63923. * Gets the index of refraction component
  63924. */
  63925. get ior(): NodeMaterialConnectionPoint;
  63926. /**
  63927. * Gets the output component
  63928. */
  63929. get output(): NodeMaterialConnectionPoint;
  63930. protected _buildBlock(state: NodeMaterialBuildState): this;
  63931. }
  63932. }
  63933. declare module BABYLON {
  63934. /**
  63935. * Block used to desaturate a color
  63936. */
  63937. export class DesaturateBlock extends NodeMaterialBlock {
  63938. /**
  63939. * Creates a new DesaturateBlock
  63940. * @param name defines the block name
  63941. */
  63942. constructor(name: string);
  63943. /**
  63944. * Gets the current class name
  63945. * @returns the class name
  63946. */
  63947. getClassName(): string;
  63948. /**
  63949. * Gets the color operand input component
  63950. */
  63951. get color(): NodeMaterialConnectionPoint;
  63952. /**
  63953. * Gets the level operand input component
  63954. */
  63955. get level(): NodeMaterialConnectionPoint;
  63956. /**
  63957. * Gets the output component
  63958. */
  63959. get output(): NodeMaterialConnectionPoint;
  63960. protected _buildBlock(state: NodeMaterialBuildState): this;
  63961. }
  63962. }
  63963. declare module BABYLON {
  63964. /**
  63965. * Block used to implement the ambient occlusion module of the PBR material
  63966. */
  63967. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63968. /**
  63969. * Create a new AmbientOcclusionBlock
  63970. * @param name defines the block name
  63971. */
  63972. constructor(name: string);
  63973. /**
  63974. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63975. */
  63976. useAmbientInGrayScale: boolean;
  63977. /**
  63978. * Initialize the block and prepare the context for build
  63979. * @param state defines the state that will be used for the build
  63980. */
  63981. initialize(state: NodeMaterialBuildState): void;
  63982. /**
  63983. * Gets the current class name
  63984. * @returns the class name
  63985. */
  63986. getClassName(): string;
  63987. /**
  63988. * Gets the texture input component
  63989. */
  63990. get texture(): NodeMaterialConnectionPoint;
  63991. /**
  63992. * Gets the texture intensity component
  63993. */
  63994. get intensity(): NodeMaterialConnectionPoint;
  63995. /**
  63996. * Gets the direct light intensity input component
  63997. */
  63998. get directLightIntensity(): NodeMaterialConnectionPoint;
  63999. /**
  64000. * Gets the ambient occlusion object output component
  64001. */
  64002. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64003. /**
  64004. * Gets the main code of the block (fragment side)
  64005. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64006. * @returns the shader code
  64007. */
  64008. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64010. protected _buildBlock(state: NodeMaterialBuildState): this;
  64011. protected _dumpPropertiesCode(): string;
  64012. serialize(): any;
  64013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64014. }
  64015. }
  64016. declare module BABYLON {
  64017. /**
  64018. * Block used to implement the reflection module of the PBR material
  64019. */
  64020. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64021. /** @hidden */
  64022. _defineLODReflectionAlpha: string;
  64023. /** @hidden */
  64024. _defineLinearSpecularReflection: string;
  64025. private _vEnvironmentIrradianceName;
  64026. /** @hidden */
  64027. _vReflectionMicrosurfaceInfosName: string;
  64028. /** @hidden */
  64029. _vReflectionInfosName: string;
  64030. /** @hidden */
  64031. _vReflectionFilteringInfoName: string;
  64032. private _scene;
  64033. /**
  64034. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64035. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64036. * It's less burden on the user side in the editor part.
  64037. */
  64038. /** @hidden */
  64039. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64040. /** @hidden */
  64041. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64042. /** @hidden */
  64043. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64044. /**
  64045. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64046. * diffuse part of the IBL.
  64047. */
  64048. useSphericalHarmonics: boolean;
  64049. /**
  64050. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64051. */
  64052. forceIrradianceInFragment: boolean;
  64053. /**
  64054. * Create a new ReflectionBlock
  64055. * @param name defines the block name
  64056. */
  64057. constructor(name: string);
  64058. /**
  64059. * Gets the current class name
  64060. * @returns the class name
  64061. */
  64062. getClassName(): string;
  64063. /**
  64064. * Gets the position input component
  64065. */
  64066. get position(): NodeMaterialConnectionPoint;
  64067. /**
  64068. * Gets the world position input component
  64069. */
  64070. get worldPosition(): NodeMaterialConnectionPoint;
  64071. /**
  64072. * Gets the world normal input component
  64073. */
  64074. get worldNormal(): NodeMaterialConnectionPoint;
  64075. /**
  64076. * Gets the world input component
  64077. */
  64078. get world(): NodeMaterialConnectionPoint;
  64079. /**
  64080. * Gets the camera (or eye) position component
  64081. */
  64082. get cameraPosition(): NodeMaterialConnectionPoint;
  64083. /**
  64084. * Gets the view input component
  64085. */
  64086. get view(): NodeMaterialConnectionPoint;
  64087. /**
  64088. * Gets the color input component
  64089. */
  64090. get color(): NodeMaterialConnectionPoint;
  64091. /**
  64092. * Gets the reflection object output component
  64093. */
  64094. get reflection(): NodeMaterialConnectionPoint;
  64095. /**
  64096. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64097. */
  64098. get hasTexture(): boolean;
  64099. /**
  64100. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64101. */
  64102. get reflectionColor(): string;
  64103. protected _getTexture(): Nullable<BaseTexture>;
  64104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64105. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64106. /**
  64107. * Gets the code to inject in the vertex shader
  64108. * @param state current state of the node material building
  64109. * @returns the shader code
  64110. */
  64111. handleVertexSide(state: NodeMaterialBuildState): string;
  64112. /**
  64113. * Gets the main code of the block (fragment side)
  64114. * @param state current state of the node material building
  64115. * @param normalVarName name of the existing variable corresponding to the normal
  64116. * @returns the shader code
  64117. */
  64118. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64119. protected _buildBlock(state: NodeMaterialBuildState): this;
  64120. protected _dumpPropertiesCode(): string;
  64121. serialize(): any;
  64122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64123. }
  64124. }
  64125. declare module BABYLON {
  64126. /**
  64127. * Block used to implement the sheen module of the PBR material
  64128. */
  64129. export class SheenBlock extends NodeMaterialBlock {
  64130. /**
  64131. * Create a new SheenBlock
  64132. * @param name defines the block name
  64133. */
  64134. constructor(name: string);
  64135. /**
  64136. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64137. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64138. * making it easier to setup and tweak the effect
  64139. */
  64140. albedoScaling: boolean;
  64141. /**
  64142. * Defines if the sheen is linked to the sheen color.
  64143. */
  64144. linkSheenWithAlbedo: boolean;
  64145. /**
  64146. * Initialize the block and prepare the context for build
  64147. * @param state defines the state that will be used for the build
  64148. */
  64149. initialize(state: NodeMaterialBuildState): void;
  64150. /**
  64151. * Gets the current class name
  64152. * @returns the class name
  64153. */
  64154. getClassName(): string;
  64155. /**
  64156. * Gets the intensity input component
  64157. */
  64158. get intensity(): NodeMaterialConnectionPoint;
  64159. /**
  64160. * Gets the color input component
  64161. */
  64162. get color(): NodeMaterialConnectionPoint;
  64163. /**
  64164. * Gets the roughness input component
  64165. */
  64166. get roughness(): NodeMaterialConnectionPoint;
  64167. /**
  64168. * Gets the sheen object output component
  64169. */
  64170. get sheen(): NodeMaterialConnectionPoint;
  64171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64172. /**
  64173. * Gets the main code of the block (fragment side)
  64174. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64175. * @returns the shader code
  64176. */
  64177. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64178. protected _buildBlock(state: NodeMaterialBuildState): this;
  64179. protected _dumpPropertiesCode(): string;
  64180. serialize(): any;
  64181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64182. }
  64183. }
  64184. declare module BABYLON {
  64185. /**
  64186. * Block used to implement the reflectivity module of the PBR material
  64187. */
  64188. export class ReflectivityBlock extends NodeMaterialBlock {
  64189. private _metallicReflectanceColor;
  64190. private _metallicF0Factor;
  64191. /** @hidden */
  64192. _vMetallicReflectanceFactorsName: string;
  64193. /**
  64194. * The property below is set by the main PBR block prior to calling methods of this class.
  64195. */
  64196. /** @hidden */
  64197. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64198. /**
  64199. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64200. */
  64201. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64202. /**
  64203. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64204. */
  64205. useMetallnessFromMetallicTextureBlue: boolean;
  64206. /**
  64207. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64208. */
  64209. useRoughnessFromMetallicTextureAlpha: boolean;
  64210. /**
  64211. * Specifies if the metallic texture contains the roughness information in its green channel.
  64212. */
  64213. useRoughnessFromMetallicTextureGreen: boolean;
  64214. /**
  64215. * Create a new ReflectivityBlock
  64216. * @param name defines the block name
  64217. */
  64218. constructor(name: string);
  64219. /**
  64220. * Initialize the block and prepare the context for build
  64221. * @param state defines the state that will be used for the build
  64222. */
  64223. initialize(state: NodeMaterialBuildState): void;
  64224. /**
  64225. * Gets the current class name
  64226. * @returns the class name
  64227. */
  64228. getClassName(): string;
  64229. /**
  64230. * Gets the metallic input component
  64231. */
  64232. get metallic(): NodeMaterialConnectionPoint;
  64233. /**
  64234. * Gets the roughness input component
  64235. */
  64236. get roughness(): NodeMaterialConnectionPoint;
  64237. /**
  64238. * Gets the texture input component
  64239. */
  64240. get texture(): NodeMaterialConnectionPoint;
  64241. /**
  64242. * Gets the reflectivity object output component
  64243. */
  64244. get reflectivity(): NodeMaterialConnectionPoint;
  64245. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64246. /**
  64247. * Gets the main code of the block (fragment side)
  64248. * @param state current state of the node material building
  64249. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64250. * @returns the shader code
  64251. */
  64252. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64253. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64254. protected _buildBlock(state: NodeMaterialBuildState): this;
  64255. protected _dumpPropertiesCode(): string;
  64256. serialize(): any;
  64257. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64258. }
  64259. }
  64260. declare module BABYLON {
  64261. /**
  64262. * Block used to implement the anisotropy module of the PBR material
  64263. */
  64264. export class AnisotropyBlock extends NodeMaterialBlock {
  64265. /**
  64266. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64267. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64268. * It's less burden on the user side in the editor part.
  64269. */
  64270. /** @hidden */
  64271. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64272. /** @hidden */
  64273. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64274. /**
  64275. * Create a new AnisotropyBlock
  64276. * @param name defines the block name
  64277. */
  64278. constructor(name: string);
  64279. /**
  64280. * Initialize the block and prepare the context for build
  64281. * @param state defines the state that will be used for the build
  64282. */
  64283. initialize(state: NodeMaterialBuildState): void;
  64284. /**
  64285. * Gets the current class name
  64286. * @returns the class name
  64287. */
  64288. getClassName(): string;
  64289. /**
  64290. * Gets the intensity input component
  64291. */
  64292. get intensity(): NodeMaterialConnectionPoint;
  64293. /**
  64294. * Gets the direction input component
  64295. */
  64296. get direction(): NodeMaterialConnectionPoint;
  64297. /**
  64298. * Gets the texture input component
  64299. */
  64300. get texture(): NodeMaterialConnectionPoint;
  64301. /**
  64302. * Gets the uv input component
  64303. */
  64304. get uv(): NodeMaterialConnectionPoint;
  64305. /**
  64306. * Gets the worldTangent input component
  64307. */
  64308. get worldTangent(): NodeMaterialConnectionPoint;
  64309. /**
  64310. * Gets the anisotropy object output component
  64311. */
  64312. get anisotropy(): NodeMaterialConnectionPoint;
  64313. private _generateTBNSpace;
  64314. /**
  64315. * Gets the main code of the block (fragment side)
  64316. * @param state current state of the node material building
  64317. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64318. * @returns the shader code
  64319. */
  64320. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64322. protected _buildBlock(state: NodeMaterialBuildState): this;
  64323. }
  64324. }
  64325. declare module BABYLON {
  64326. /**
  64327. * Block used to implement the clear coat module of the PBR material
  64328. */
  64329. export class ClearCoatBlock extends NodeMaterialBlock {
  64330. private _scene;
  64331. /**
  64332. * Create a new ClearCoatBlock
  64333. * @param name defines the block name
  64334. */
  64335. constructor(name: string);
  64336. /**
  64337. * Initialize the block and prepare the context for build
  64338. * @param state defines the state that will be used for the build
  64339. */
  64340. initialize(state: NodeMaterialBuildState): void;
  64341. /**
  64342. * Gets the current class name
  64343. * @returns the class name
  64344. */
  64345. getClassName(): string;
  64346. /**
  64347. * Gets the intensity input component
  64348. */
  64349. get intensity(): NodeMaterialConnectionPoint;
  64350. /**
  64351. * Gets the roughness input component
  64352. */
  64353. get roughness(): NodeMaterialConnectionPoint;
  64354. /**
  64355. * Gets the ior input component
  64356. */
  64357. get ior(): NodeMaterialConnectionPoint;
  64358. /**
  64359. * Gets the texture input component
  64360. */
  64361. get texture(): NodeMaterialConnectionPoint;
  64362. /**
  64363. * Gets the bump texture input component
  64364. */
  64365. get bumpTexture(): NodeMaterialConnectionPoint;
  64366. /**
  64367. * Gets the uv input component
  64368. */
  64369. get uv(): NodeMaterialConnectionPoint;
  64370. /**
  64371. * Gets the tint color input component
  64372. */
  64373. get tintColor(): NodeMaterialConnectionPoint;
  64374. /**
  64375. * Gets the tint "at distance" input component
  64376. */
  64377. get tintAtDistance(): NodeMaterialConnectionPoint;
  64378. /**
  64379. * Gets the tint thickness input component
  64380. */
  64381. get tintThickness(): NodeMaterialConnectionPoint;
  64382. /**
  64383. * Gets the world tangent input component
  64384. */
  64385. get worldTangent(): NodeMaterialConnectionPoint;
  64386. /**
  64387. * Gets the clear coat object output component
  64388. */
  64389. get clearcoat(): NodeMaterialConnectionPoint;
  64390. autoConfigure(material: NodeMaterial): void;
  64391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64392. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64393. private _generateTBNSpace;
  64394. /**
  64395. * Gets the main code of the block (fragment side)
  64396. * @param state current state of the node material building
  64397. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64398. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64399. * @param worldPosVarName name of the variable holding the world position
  64400. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64401. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64402. * @param worldNormalVarName name of the variable holding the world normal
  64403. * @returns the shader code
  64404. */
  64405. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64406. protected _buildBlock(state: NodeMaterialBuildState): this;
  64407. }
  64408. }
  64409. declare module BABYLON {
  64410. /**
  64411. * Block used to implement the sub surface module of the PBR material
  64412. */
  64413. export class SubSurfaceBlock extends NodeMaterialBlock {
  64414. /**
  64415. * Create a new SubSurfaceBlock
  64416. * @param name defines the block name
  64417. */
  64418. constructor(name: string);
  64419. /**
  64420. * Stores the intensity of the different subsurface effects in the thickness texture.
  64421. * * the green channel is the translucency intensity.
  64422. * * the blue channel is the scattering intensity.
  64423. * * the alpha channel is the refraction intensity.
  64424. */
  64425. useMaskFromThicknessTexture: boolean;
  64426. /**
  64427. * Initialize the block and prepare the context for build
  64428. * @param state defines the state that will be used for the build
  64429. */
  64430. initialize(state: NodeMaterialBuildState): void;
  64431. /**
  64432. * Gets the current class name
  64433. * @returns the class name
  64434. */
  64435. getClassName(): string;
  64436. /**
  64437. * Gets the min thickness input component
  64438. */
  64439. get minThickness(): NodeMaterialConnectionPoint;
  64440. /**
  64441. * Gets the max thickness input component
  64442. */
  64443. get maxThickness(): NodeMaterialConnectionPoint;
  64444. /**
  64445. * Gets the thickness texture component
  64446. */
  64447. get thicknessTexture(): NodeMaterialConnectionPoint;
  64448. /**
  64449. * Gets the tint color input component
  64450. */
  64451. get tintColor(): NodeMaterialConnectionPoint;
  64452. /**
  64453. * Gets the translucency intensity input component
  64454. */
  64455. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64456. /**
  64457. * Gets the translucency diffusion distance input component
  64458. */
  64459. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64460. /**
  64461. * Gets the refraction object parameters
  64462. */
  64463. get refraction(): NodeMaterialConnectionPoint;
  64464. /**
  64465. * Gets the sub surface object output component
  64466. */
  64467. get subsurface(): NodeMaterialConnectionPoint;
  64468. autoConfigure(material: NodeMaterial): void;
  64469. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64470. /**
  64471. * Gets the main code of the block (fragment side)
  64472. * @param state current state of the node material building
  64473. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64474. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64475. * @param worldPosVarName name of the variable holding the world position
  64476. * @returns the shader code
  64477. */
  64478. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64479. protected _buildBlock(state: NodeMaterialBuildState): this;
  64480. }
  64481. }
  64482. declare module BABYLON {
  64483. /**
  64484. * Block used to implement the PBR metallic/roughness model
  64485. */
  64486. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64487. /**
  64488. * Gets or sets the light associated with this block
  64489. */
  64490. light: Nullable<Light>;
  64491. private _lightId;
  64492. private _scene;
  64493. private _environmentBRDFTexture;
  64494. private _environmentBrdfSamplerName;
  64495. private _vNormalWName;
  64496. private _invertNormalName;
  64497. /**
  64498. * Create a new ReflectionBlock
  64499. * @param name defines the block name
  64500. */
  64501. constructor(name: string);
  64502. /**
  64503. * Intensity of the direct lights e.g. the four lights available in your scene.
  64504. * This impacts both the direct diffuse and specular highlights.
  64505. */
  64506. directIntensity: number;
  64507. /**
  64508. * Intensity of the environment e.g. how much the environment will light the object
  64509. * either through harmonics for rough material or through the refelction for shiny ones.
  64510. */
  64511. environmentIntensity: number;
  64512. /**
  64513. * This is a special control allowing the reduction of the specular highlights coming from the
  64514. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64515. */
  64516. specularIntensity: number;
  64517. /**
  64518. * Defines the falloff type used in this material.
  64519. * It by default is Physical.
  64520. */
  64521. lightFalloff: number;
  64522. /**
  64523. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64524. */
  64525. useAlphaFromAlbedoTexture: boolean;
  64526. /**
  64527. * Specifies that alpha test should be used
  64528. */
  64529. useAlphaTest: boolean;
  64530. /**
  64531. * Defines the alpha limits in alpha test mode.
  64532. */
  64533. alphaTestCutoff: number;
  64534. /**
  64535. * Specifies that alpha blending should be used
  64536. */
  64537. useAlphaBlending: boolean;
  64538. /**
  64539. * Defines if the alpha value should be determined via the rgb values.
  64540. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64541. */
  64542. opacityRGB: boolean;
  64543. /**
  64544. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64545. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64546. */
  64547. useRadianceOverAlpha: boolean;
  64548. /**
  64549. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64550. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64551. */
  64552. useSpecularOverAlpha: boolean;
  64553. /**
  64554. * Enables specular anti aliasing in the PBR shader.
  64555. * It will both interacts on the Geometry for analytical and IBL lighting.
  64556. * It also prefilter the roughness map based on the bump values.
  64557. */
  64558. enableSpecularAntiAliasing: boolean;
  64559. /**
  64560. * Enables realtime filtering on the texture.
  64561. */
  64562. realTimeFiltering: boolean;
  64563. /**
  64564. * Quality switch for realtime filtering
  64565. */
  64566. realTimeFilteringQuality: number;
  64567. /**
  64568. * Defines if the material uses energy conservation.
  64569. */
  64570. useEnergyConservation: boolean;
  64571. /**
  64572. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64573. * too much the area relying on ambient texture to define their ambient occlusion.
  64574. */
  64575. useRadianceOcclusion: boolean;
  64576. /**
  64577. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64578. * makes the reflect vector face the model (under horizon).
  64579. */
  64580. useHorizonOcclusion: boolean;
  64581. /**
  64582. * If set to true, no lighting calculations will be applied.
  64583. */
  64584. unlit: boolean;
  64585. /**
  64586. * Force normal to face away from face.
  64587. */
  64588. forceNormalForward: boolean;
  64589. /**
  64590. * Defines the material debug mode.
  64591. * It helps seeing only some components of the material while troubleshooting.
  64592. */
  64593. debugMode: number;
  64594. /**
  64595. * Specify from where on screen the debug mode should start.
  64596. * The value goes from -1 (full screen) to 1 (not visible)
  64597. * It helps with side by side comparison against the final render
  64598. * This defaults to 0
  64599. */
  64600. debugLimit: number;
  64601. /**
  64602. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64603. * You can use the factor to better multiply the final value.
  64604. */
  64605. debugFactor: number;
  64606. /**
  64607. * Initialize the block and prepare the context for build
  64608. * @param state defines the state that will be used for the build
  64609. */
  64610. initialize(state: NodeMaterialBuildState): void;
  64611. /**
  64612. * Gets the current class name
  64613. * @returns the class name
  64614. */
  64615. getClassName(): string;
  64616. /**
  64617. * Gets the world position input component
  64618. */
  64619. get worldPosition(): NodeMaterialConnectionPoint;
  64620. /**
  64621. * Gets the world normal input component
  64622. */
  64623. get worldNormal(): NodeMaterialConnectionPoint;
  64624. /**
  64625. * Gets the perturbed normal input component
  64626. */
  64627. get perturbedNormal(): NodeMaterialConnectionPoint;
  64628. /**
  64629. * Gets the camera position input component
  64630. */
  64631. get cameraPosition(): NodeMaterialConnectionPoint;
  64632. /**
  64633. * Gets the base color input component
  64634. */
  64635. get baseColor(): NodeMaterialConnectionPoint;
  64636. /**
  64637. * Gets the opacity texture input component
  64638. */
  64639. get opacityTexture(): NodeMaterialConnectionPoint;
  64640. /**
  64641. * Gets the ambient color input component
  64642. */
  64643. get ambientColor(): NodeMaterialConnectionPoint;
  64644. /**
  64645. * Gets the reflectivity object parameters
  64646. */
  64647. get reflectivity(): NodeMaterialConnectionPoint;
  64648. /**
  64649. * Gets the ambient occlusion object parameters
  64650. */
  64651. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64652. /**
  64653. * Gets the reflection object parameters
  64654. */
  64655. get reflection(): NodeMaterialConnectionPoint;
  64656. /**
  64657. * Gets the sheen object parameters
  64658. */
  64659. get sheen(): NodeMaterialConnectionPoint;
  64660. /**
  64661. * Gets the clear coat object parameters
  64662. */
  64663. get clearcoat(): NodeMaterialConnectionPoint;
  64664. /**
  64665. * Gets the sub surface object parameters
  64666. */
  64667. get subsurface(): NodeMaterialConnectionPoint;
  64668. /**
  64669. * Gets the anisotropy object parameters
  64670. */
  64671. get anisotropy(): NodeMaterialConnectionPoint;
  64672. /**
  64673. * Gets the ambient output component
  64674. */
  64675. get ambient(): NodeMaterialConnectionPoint;
  64676. /**
  64677. * Gets the diffuse output component
  64678. */
  64679. get diffuse(): NodeMaterialConnectionPoint;
  64680. /**
  64681. * Gets the specular output component
  64682. */
  64683. get specular(): NodeMaterialConnectionPoint;
  64684. /**
  64685. * Gets the sheen output component
  64686. */
  64687. get sheenDir(): NodeMaterialConnectionPoint;
  64688. /**
  64689. * Gets the clear coat output component
  64690. */
  64691. get clearcoatDir(): NodeMaterialConnectionPoint;
  64692. /**
  64693. * Gets the indirect diffuse output component
  64694. */
  64695. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64696. /**
  64697. * Gets the indirect specular output component
  64698. */
  64699. get specularIndirect(): NodeMaterialConnectionPoint;
  64700. /**
  64701. * Gets the indirect sheen output component
  64702. */
  64703. get sheenIndirect(): NodeMaterialConnectionPoint;
  64704. /**
  64705. * Gets the indirect clear coat output component
  64706. */
  64707. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64708. /**
  64709. * Gets the refraction output component
  64710. */
  64711. get refraction(): NodeMaterialConnectionPoint;
  64712. /**
  64713. * Gets the global lighting output component
  64714. */
  64715. get lighting(): NodeMaterialConnectionPoint;
  64716. /**
  64717. * Gets the shadow output component
  64718. */
  64719. get shadow(): NodeMaterialConnectionPoint;
  64720. /**
  64721. * Gets the alpha output component
  64722. */
  64723. get alpha(): NodeMaterialConnectionPoint;
  64724. autoConfigure(material: NodeMaterial): void;
  64725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64726. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64727. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64728. private _injectVertexCode;
  64729. /**
  64730. * Gets the code corresponding to the albedo/opacity module
  64731. * @returns the shader code
  64732. */
  64733. getAlbedoOpacityCode(): string;
  64734. protected _buildBlock(state: NodeMaterialBuildState): this;
  64735. protected _dumpPropertiesCode(): string;
  64736. serialize(): any;
  64737. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64738. }
  64739. }
  64740. declare module BABYLON {
  64741. /**
  64742. * Block used to compute value of one parameter modulo another
  64743. */
  64744. export class ModBlock extends NodeMaterialBlock {
  64745. /**
  64746. * Creates a new ModBlock
  64747. * @param name defines the block name
  64748. */
  64749. constructor(name: string);
  64750. /**
  64751. * Gets the current class name
  64752. * @returns the class name
  64753. */
  64754. getClassName(): string;
  64755. /**
  64756. * Gets the left operand input component
  64757. */
  64758. get left(): NodeMaterialConnectionPoint;
  64759. /**
  64760. * Gets the right operand input component
  64761. */
  64762. get right(): NodeMaterialConnectionPoint;
  64763. /**
  64764. * Gets the output component
  64765. */
  64766. get output(): NodeMaterialConnectionPoint;
  64767. protected _buildBlock(state: NodeMaterialBuildState): this;
  64768. }
  64769. }
  64770. declare module BABYLON {
  64771. /**
  64772. * Helper class to push actions to a pool of workers.
  64773. */
  64774. export class WorkerPool implements IDisposable {
  64775. private _workerInfos;
  64776. private _pendingActions;
  64777. /**
  64778. * Constructor
  64779. * @param workers Array of workers to use for actions
  64780. */
  64781. constructor(workers: Array<Worker>);
  64782. /**
  64783. * Terminates all workers and clears any pending actions.
  64784. */
  64785. dispose(): void;
  64786. /**
  64787. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64788. * pended until a worker has completed its action.
  64789. * @param action The action to perform. Call onComplete when the action is complete.
  64790. */
  64791. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64792. private _execute;
  64793. }
  64794. }
  64795. declare module BABYLON {
  64796. /**
  64797. * Configuration for Draco compression
  64798. */
  64799. export interface IDracoCompressionConfiguration {
  64800. /**
  64801. * Configuration for the decoder.
  64802. */
  64803. decoder: {
  64804. /**
  64805. * The url to the WebAssembly module.
  64806. */
  64807. wasmUrl?: string;
  64808. /**
  64809. * The url to the WebAssembly binary.
  64810. */
  64811. wasmBinaryUrl?: string;
  64812. /**
  64813. * The url to the fallback JavaScript module.
  64814. */
  64815. fallbackUrl?: string;
  64816. };
  64817. }
  64818. /**
  64819. * Draco compression (https://google.github.io/draco/)
  64820. *
  64821. * This class wraps the Draco module.
  64822. *
  64823. * **Encoder**
  64824. *
  64825. * The encoder is not currently implemented.
  64826. *
  64827. * **Decoder**
  64828. *
  64829. * 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.
  64830. *
  64831. * To update the configuration, use the following code:
  64832. * ```javascript
  64833. * DracoCompression.Configuration = {
  64834. * decoder: {
  64835. * wasmUrl: "<url to the WebAssembly library>",
  64836. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64837. * fallbackUrl: "<url to the fallback JavaScript library>",
  64838. * }
  64839. * };
  64840. * ```
  64841. *
  64842. * 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.
  64843. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64844. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64845. *
  64846. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64847. * ```javascript
  64848. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64849. * ```
  64850. *
  64851. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64852. */
  64853. export class DracoCompression implements IDisposable {
  64854. private _workerPoolPromise?;
  64855. private _decoderModulePromise?;
  64856. /**
  64857. * The configuration. Defaults to the following urls:
  64858. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64859. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64860. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64861. */
  64862. static Configuration: IDracoCompressionConfiguration;
  64863. /**
  64864. * Returns true if the decoder configuration is available.
  64865. */
  64866. static get DecoderAvailable(): boolean;
  64867. /**
  64868. * Default number of workers to create when creating the draco compression object.
  64869. */
  64870. static DefaultNumWorkers: number;
  64871. private static GetDefaultNumWorkers;
  64872. private static _Default;
  64873. /**
  64874. * Default instance for the draco compression object.
  64875. */
  64876. static get Default(): DracoCompression;
  64877. /**
  64878. * Constructor
  64879. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64880. */
  64881. constructor(numWorkers?: number);
  64882. /**
  64883. * Stop all async operations and release resources.
  64884. */
  64885. dispose(): void;
  64886. /**
  64887. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64888. * @returns a promise that resolves when ready
  64889. */
  64890. whenReadyAsync(): Promise<void>;
  64891. /**
  64892. * Decode Draco compressed mesh data to vertex data.
  64893. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64894. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64895. * @returns A promise that resolves with the decoded vertex data
  64896. */
  64897. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64898. [kind: string]: number;
  64899. }): Promise<VertexData>;
  64900. }
  64901. }
  64902. declare module BABYLON {
  64903. /**
  64904. * Class for building Constructive Solid Geometry
  64905. */
  64906. export class CSG {
  64907. private polygons;
  64908. /**
  64909. * The world matrix
  64910. */
  64911. matrix: Matrix;
  64912. /**
  64913. * Stores the position
  64914. */
  64915. position: Vector3;
  64916. /**
  64917. * Stores the rotation
  64918. */
  64919. rotation: Vector3;
  64920. /**
  64921. * Stores the rotation quaternion
  64922. */
  64923. rotationQuaternion: Nullable<Quaternion>;
  64924. /**
  64925. * Stores the scaling vector
  64926. */
  64927. scaling: Vector3;
  64928. /**
  64929. * Convert the Mesh to CSG
  64930. * @param mesh The Mesh to convert to CSG
  64931. * @returns A new CSG from the Mesh
  64932. */
  64933. static FromMesh(mesh: Mesh): CSG;
  64934. /**
  64935. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64936. * @param polygons Polygons used to construct a CSG solid
  64937. */
  64938. private static FromPolygons;
  64939. /**
  64940. * Clones, or makes a deep copy, of the CSG
  64941. * @returns A new CSG
  64942. */
  64943. clone(): CSG;
  64944. /**
  64945. * Unions this CSG with another CSG
  64946. * @param csg The CSG to union against this CSG
  64947. * @returns The unioned CSG
  64948. */
  64949. union(csg: CSG): CSG;
  64950. /**
  64951. * Unions this CSG with another CSG in place
  64952. * @param csg The CSG to union against this CSG
  64953. */
  64954. unionInPlace(csg: CSG): void;
  64955. /**
  64956. * Subtracts this CSG with another CSG
  64957. * @param csg The CSG to subtract against this CSG
  64958. * @returns A new CSG
  64959. */
  64960. subtract(csg: CSG): CSG;
  64961. /**
  64962. * Subtracts this CSG with another CSG in place
  64963. * @param csg The CSG to subtact against this CSG
  64964. */
  64965. subtractInPlace(csg: CSG): void;
  64966. /**
  64967. * Intersect this CSG with another CSG
  64968. * @param csg The CSG to intersect against this CSG
  64969. * @returns A new CSG
  64970. */
  64971. intersect(csg: CSG): CSG;
  64972. /**
  64973. * Intersects this CSG with another CSG in place
  64974. * @param csg The CSG to intersect against this CSG
  64975. */
  64976. intersectInPlace(csg: CSG): void;
  64977. /**
  64978. * Return a new CSG solid with solid and empty space switched. This solid is
  64979. * not modified.
  64980. * @returns A new CSG solid with solid and empty space switched
  64981. */
  64982. inverse(): CSG;
  64983. /**
  64984. * Inverses the CSG in place
  64985. */
  64986. inverseInPlace(): void;
  64987. /**
  64988. * This is used to keep meshes transformations so they can be restored
  64989. * when we build back a Babylon Mesh
  64990. * NB : All CSG operations are performed in world coordinates
  64991. * @param csg The CSG to copy the transform attributes from
  64992. * @returns This CSG
  64993. */
  64994. copyTransformAttributes(csg: CSG): CSG;
  64995. /**
  64996. * Build Raw mesh from CSG
  64997. * Coordinates here are in world space
  64998. * @param name The name of the mesh geometry
  64999. * @param scene The Scene
  65000. * @param keepSubMeshes Specifies if the submeshes should be kept
  65001. * @returns A new Mesh
  65002. */
  65003. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65004. /**
  65005. * Build Mesh from CSG taking material and transforms into account
  65006. * @param name The name of the Mesh
  65007. * @param material The material of the Mesh
  65008. * @param scene The Scene
  65009. * @param keepSubMeshes Specifies if submeshes should be kept
  65010. * @returns The new Mesh
  65011. */
  65012. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65013. }
  65014. }
  65015. declare module BABYLON {
  65016. /**
  65017. * Class used to create a trail following a mesh
  65018. */
  65019. export class TrailMesh extends Mesh {
  65020. private _generator;
  65021. private _autoStart;
  65022. private _running;
  65023. private _diameter;
  65024. private _length;
  65025. private _sectionPolygonPointsCount;
  65026. private _sectionVectors;
  65027. private _sectionNormalVectors;
  65028. private _beforeRenderObserver;
  65029. /**
  65030. * @constructor
  65031. * @param name The value used by scene.getMeshByName() to do a lookup.
  65032. * @param generator The mesh or transform node to generate a trail.
  65033. * @param scene The scene to add this mesh to.
  65034. * @param diameter Diameter of trailing mesh. Default is 1.
  65035. * @param length Length of trailing mesh. Default is 60.
  65036. * @param autoStart Automatically start trailing mesh. Default true.
  65037. */
  65038. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65039. /**
  65040. * "TrailMesh"
  65041. * @returns "TrailMesh"
  65042. */
  65043. getClassName(): string;
  65044. private _createMesh;
  65045. /**
  65046. * Start trailing mesh.
  65047. */
  65048. start(): void;
  65049. /**
  65050. * Stop trailing mesh.
  65051. */
  65052. stop(): void;
  65053. /**
  65054. * Update trailing mesh geometry.
  65055. */
  65056. update(): void;
  65057. /**
  65058. * Returns a new TrailMesh object.
  65059. * @param name is a string, the name given to the new mesh
  65060. * @param newGenerator use new generator object for cloned trail mesh
  65061. * @returns a new mesh
  65062. */
  65063. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65064. /**
  65065. * Serializes this trail mesh
  65066. * @param serializationObject object to write serialization to
  65067. */
  65068. serialize(serializationObject: any): void;
  65069. /**
  65070. * Parses a serialized trail mesh
  65071. * @param parsedMesh the serialized mesh
  65072. * @param scene the scene to create the trail mesh in
  65073. * @returns the created trail mesh
  65074. */
  65075. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65076. }
  65077. }
  65078. declare module BABYLON {
  65079. /**
  65080. * Class containing static functions to help procedurally build meshes
  65081. */
  65082. export class TiledBoxBuilder {
  65083. /**
  65084. * Creates a box mesh
  65085. * 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)
  65086. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65088. * * 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
  65089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65090. * @param name defines the name of the mesh
  65091. * @param options defines the options used to create the mesh
  65092. * @param scene defines the hosting scene
  65093. * @returns the box mesh
  65094. */
  65095. static CreateTiledBox(name: string, options: {
  65096. pattern?: number;
  65097. width?: number;
  65098. height?: number;
  65099. depth?: number;
  65100. tileSize?: number;
  65101. tileWidth?: number;
  65102. tileHeight?: number;
  65103. alignHorizontal?: number;
  65104. alignVertical?: number;
  65105. faceUV?: Vector4[];
  65106. faceColors?: Color4[];
  65107. sideOrientation?: number;
  65108. updatable?: boolean;
  65109. }, scene?: Nullable<Scene>): Mesh;
  65110. }
  65111. }
  65112. declare module BABYLON {
  65113. /**
  65114. * Class containing static functions to help procedurally build meshes
  65115. */
  65116. export class TorusKnotBuilder {
  65117. /**
  65118. * Creates a torus knot mesh
  65119. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65120. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65121. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65122. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65124. * * 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
  65125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65126. * @param name defines the name of the mesh
  65127. * @param options defines the options used to create the mesh
  65128. * @param scene defines the hosting scene
  65129. * @returns the torus knot mesh
  65130. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65131. */
  65132. static CreateTorusKnot(name: string, options: {
  65133. radius?: number;
  65134. tube?: number;
  65135. radialSegments?: number;
  65136. tubularSegments?: number;
  65137. p?: number;
  65138. q?: number;
  65139. updatable?: boolean;
  65140. sideOrientation?: number;
  65141. frontUVs?: Vector4;
  65142. backUVs?: Vector4;
  65143. }, scene: any): Mesh;
  65144. }
  65145. }
  65146. declare module BABYLON {
  65147. /**
  65148. * Polygon
  65149. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65150. */
  65151. export class Polygon {
  65152. /**
  65153. * Creates a rectangle
  65154. * @param xmin bottom X coord
  65155. * @param ymin bottom Y coord
  65156. * @param xmax top X coord
  65157. * @param ymax top Y coord
  65158. * @returns points that make the resulting rectation
  65159. */
  65160. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65161. /**
  65162. * Creates a circle
  65163. * @param radius radius of circle
  65164. * @param cx scale in x
  65165. * @param cy scale in y
  65166. * @param numberOfSides number of sides that make up the circle
  65167. * @returns points that make the resulting circle
  65168. */
  65169. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65170. /**
  65171. * Creates a polygon from input string
  65172. * @param input Input polygon data
  65173. * @returns the parsed points
  65174. */
  65175. static Parse(input: string): Vector2[];
  65176. /**
  65177. * Starts building a polygon from x and y coordinates
  65178. * @param x x coordinate
  65179. * @param y y coordinate
  65180. * @returns the started path2
  65181. */
  65182. static StartingAt(x: number, y: number): Path2;
  65183. }
  65184. /**
  65185. * Builds a polygon
  65186. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65187. */
  65188. export class PolygonMeshBuilder {
  65189. private _points;
  65190. private _outlinepoints;
  65191. private _holes;
  65192. private _name;
  65193. private _scene;
  65194. private _epoints;
  65195. private _eholes;
  65196. private _addToepoint;
  65197. /**
  65198. * Babylon reference to the earcut plugin.
  65199. */
  65200. bjsEarcut: any;
  65201. /**
  65202. * Creates a PolygonMeshBuilder
  65203. * @param name name of the builder
  65204. * @param contours Path of the polygon
  65205. * @param scene scene to add to when creating the mesh
  65206. * @param earcutInjection can be used to inject your own earcut reference
  65207. */
  65208. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65209. /**
  65210. * Adds a whole within the polygon
  65211. * @param hole Array of points defining the hole
  65212. * @returns this
  65213. */
  65214. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65215. /**
  65216. * Creates the polygon
  65217. * @param updatable If the mesh should be updatable
  65218. * @param depth The depth of the mesh created
  65219. * @returns the created mesh
  65220. */
  65221. build(updatable?: boolean, depth?: number): Mesh;
  65222. /**
  65223. * Creates the polygon
  65224. * @param depth The depth of the mesh created
  65225. * @returns the created VertexData
  65226. */
  65227. buildVertexData(depth?: number): VertexData;
  65228. /**
  65229. * Adds a side to the polygon
  65230. * @param positions points that make the polygon
  65231. * @param normals normals of the polygon
  65232. * @param uvs uvs of the polygon
  65233. * @param indices indices of the polygon
  65234. * @param bounds bounds of the polygon
  65235. * @param points points of the polygon
  65236. * @param depth depth of the polygon
  65237. * @param flip flip of the polygon
  65238. */
  65239. private addSide;
  65240. }
  65241. }
  65242. declare module BABYLON {
  65243. /**
  65244. * Class containing static functions to help procedurally build meshes
  65245. */
  65246. export class PolygonBuilder {
  65247. /**
  65248. * Creates a polygon mesh
  65249. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65250. * * 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
  65251. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * 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)
  65254. * * Remember you can only change the shape positions, not their number when updating a polygon
  65255. * @param name defines the name of the mesh
  65256. * @param options defines the options used to create the mesh
  65257. * @param scene defines the hosting scene
  65258. * @param earcutInjection can be used to inject your own earcut reference
  65259. * @returns the polygon mesh
  65260. */
  65261. static CreatePolygon(name: string, options: {
  65262. shape: Vector3[];
  65263. holes?: Vector3[][];
  65264. depth?: number;
  65265. faceUV?: Vector4[];
  65266. faceColors?: Color4[];
  65267. updatable?: boolean;
  65268. sideOrientation?: number;
  65269. frontUVs?: Vector4;
  65270. backUVs?: Vector4;
  65271. wrap?: boolean;
  65272. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65273. /**
  65274. * Creates an extruded polygon mesh, with depth in the Y direction.
  65275. * * 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)
  65276. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65277. * @param name defines the name of the mesh
  65278. * @param options defines the options used to create the mesh
  65279. * @param scene defines the hosting scene
  65280. * @param earcutInjection can be used to inject your own earcut reference
  65281. * @returns the polygon mesh
  65282. */
  65283. static ExtrudePolygon(name: string, options: {
  65284. shape: Vector3[];
  65285. holes?: Vector3[][];
  65286. depth?: number;
  65287. faceUV?: Vector4[];
  65288. faceColors?: Color4[];
  65289. updatable?: boolean;
  65290. sideOrientation?: number;
  65291. frontUVs?: Vector4;
  65292. backUVs?: Vector4;
  65293. wrap?: boolean;
  65294. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65295. }
  65296. }
  65297. declare module BABYLON {
  65298. /**
  65299. * Class containing static functions to help procedurally build meshes
  65300. */
  65301. export class LatheBuilder {
  65302. /**
  65303. * Creates lathe mesh.
  65304. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65305. * * 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
  65306. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65307. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65308. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65309. * * 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
  65310. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65311. * * 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
  65312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65313. * * 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
  65314. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65316. * @param name defines the name of the mesh
  65317. * @param options defines the options used to create the mesh
  65318. * @param scene defines the hosting scene
  65319. * @returns the lathe mesh
  65320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65321. */
  65322. static CreateLathe(name: string, options: {
  65323. shape: Vector3[];
  65324. radius?: number;
  65325. tessellation?: number;
  65326. clip?: number;
  65327. arc?: number;
  65328. closed?: boolean;
  65329. updatable?: boolean;
  65330. sideOrientation?: number;
  65331. frontUVs?: Vector4;
  65332. backUVs?: Vector4;
  65333. cap?: number;
  65334. invertUV?: boolean;
  65335. }, scene?: Nullable<Scene>): Mesh;
  65336. }
  65337. }
  65338. declare module BABYLON {
  65339. /**
  65340. * Class containing static functions to help procedurally build meshes
  65341. */
  65342. export class TiledPlaneBuilder {
  65343. /**
  65344. * Creates a tiled plane mesh
  65345. * * The parameter `pattern` will, depending on value, do nothing or
  65346. * * * flip (reflect about central vertical) alternate tiles across and up
  65347. * * * flip every tile on alternate rows
  65348. * * * rotate (180 degs) alternate tiles across and up
  65349. * * * rotate every tile on alternate rows
  65350. * * * flip and rotate alternate tiles across and up
  65351. * * * flip and rotate every tile on alternate rows
  65352. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65353. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65354. * * 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
  65355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65356. * * 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)
  65357. * * 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)
  65358. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65359. * @param name defines the name of the mesh
  65360. * @param options defines the options used to create the mesh
  65361. * @param scene defines the hosting scene
  65362. * @returns the box mesh
  65363. */
  65364. static CreateTiledPlane(name: string, options: {
  65365. pattern?: number;
  65366. tileSize?: number;
  65367. tileWidth?: number;
  65368. tileHeight?: number;
  65369. size?: number;
  65370. width?: number;
  65371. height?: number;
  65372. alignHorizontal?: number;
  65373. alignVertical?: number;
  65374. sideOrientation?: number;
  65375. frontUVs?: Vector4;
  65376. backUVs?: Vector4;
  65377. updatable?: boolean;
  65378. }, scene?: Nullable<Scene>): Mesh;
  65379. }
  65380. }
  65381. declare module BABYLON {
  65382. /**
  65383. * Class containing static functions to help procedurally build meshes
  65384. */
  65385. export class TubeBuilder {
  65386. /**
  65387. * Creates a tube mesh.
  65388. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65389. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65390. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65391. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65392. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65393. * * 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)
  65394. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65395. * * 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
  65396. * * 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
  65397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65398. * * 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
  65399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65401. * @param name defines the name of the mesh
  65402. * @param options defines the options used to create the mesh
  65403. * @param scene defines the hosting scene
  65404. * @returns the tube mesh
  65405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65406. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65407. */
  65408. static CreateTube(name: string, options: {
  65409. path: Vector3[];
  65410. radius?: number;
  65411. tessellation?: number;
  65412. radiusFunction?: {
  65413. (i: number, distance: number): number;
  65414. };
  65415. cap?: number;
  65416. arc?: number;
  65417. updatable?: boolean;
  65418. sideOrientation?: number;
  65419. frontUVs?: Vector4;
  65420. backUVs?: Vector4;
  65421. instance?: Mesh;
  65422. invertUV?: boolean;
  65423. }, scene?: Nullable<Scene>): Mesh;
  65424. }
  65425. }
  65426. declare module BABYLON {
  65427. /**
  65428. * Class containing static functions to help procedurally build meshes
  65429. */
  65430. export class IcoSphereBuilder {
  65431. /**
  65432. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65433. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65434. * * 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`)
  65435. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65436. * * 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
  65437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65438. * * 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
  65439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65440. * @param name defines the name of the mesh
  65441. * @param options defines the options used to create the mesh
  65442. * @param scene defines the hosting scene
  65443. * @returns the icosahedron mesh
  65444. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65445. */
  65446. static CreateIcoSphere(name: string, options: {
  65447. radius?: number;
  65448. radiusX?: number;
  65449. radiusY?: number;
  65450. radiusZ?: number;
  65451. flat?: boolean;
  65452. subdivisions?: number;
  65453. sideOrientation?: number;
  65454. frontUVs?: Vector4;
  65455. backUVs?: Vector4;
  65456. updatable?: boolean;
  65457. }, scene?: Nullable<Scene>): Mesh;
  65458. }
  65459. }
  65460. declare module BABYLON {
  65461. /**
  65462. * Class containing static functions to help procedurally build meshes
  65463. */
  65464. export class DecalBuilder {
  65465. /**
  65466. * Creates a decal mesh.
  65467. * 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
  65468. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65469. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65470. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65471. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65472. * @param name defines the name of the mesh
  65473. * @param sourceMesh defines the mesh where the decal must be applied
  65474. * @param options defines the options used to create the mesh
  65475. * @param scene defines the hosting scene
  65476. * @returns the decal mesh
  65477. * @see https://doc.babylonjs.com/how_to/decals
  65478. */
  65479. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65480. position?: Vector3;
  65481. normal?: Vector3;
  65482. size?: Vector3;
  65483. angle?: number;
  65484. }): Mesh;
  65485. }
  65486. }
  65487. declare module BABYLON {
  65488. /**
  65489. * Class containing static functions to help procedurally build meshes
  65490. */
  65491. export class MeshBuilder {
  65492. /**
  65493. * Creates a box mesh
  65494. * * The parameter `size` sets the size (float) of each box side (default 1)
  65495. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65496. * * 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)
  65497. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65499. * * 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
  65500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65501. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65502. * @param name defines the name of the mesh
  65503. * @param options defines the options used to create the mesh
  65504. * @param scene defines the hosting scene
  65505. * @returns the box mesh
  65506. */
  65507. static CreateBox(name: string, options: {
  65508. size?: number;
  65509. width?: number;
  65510. height?: number;
  65511. depth?: number;
  65512. faceUV?: Vector4[];
  65513. faceColors?: Color4[];
  65514. sideOrientation?: number;
  65515. frontUVs?: Vector4;
  65516. backUVs?: Vector4;
  65517. wrap?: boolean;
  65518. topBaseAt?: number;
  65519. bottomBaseAt?: number;
  65520. updatable?: boolean;
  65521. }, scene?: Nullable<Scene>): Mesh;
  65522. /**
  65523. * Creates a tiled box mesh
  65524. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65526. * @param name defines the name of the mesh
  65527. * @param options defines the options used to create the mesh
  65528. * @param scene defines the hosting scene
  65529. * @returns the tiled box mesh
  65530. */
  65531. static CreateTiledBox(name: string, options: {
  65532. pattern?: number;
  65533. size?: number;
  65534. width?: number;
  65535. height?: number;
  65536. depth: number;
  65537. tileSize?: number;
  65538. tileWidth?: number;
  65539. tileHeight?: number;
  65540. faceUV?: Vector4[];
  65541. faceColors?: Color4[];
  65542. alignHorizontal?: number;
  65543. alignVertical?: number;
  65544. sideOrientation?: number;
  65545. updatable?: boolean;
  65546. }, scene?: Nullable<Scene>): Mesh;
  65547. /**
  65548. * Creates a sphere mesh
  65549. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65550. * * 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`)
  65551. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65552. * * 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
  65553. * * 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)
  65554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65555. * * 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
  65556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65557. * @param name defines the name of the mesh
  65558. * @param options defines the options used to create the mesh
  65559. * @param scene defines the hosting scene
  65560. * @returns the sphere mesh
  65561. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65562. */
  65563. static CreateSphere(name: string, options: {
  65564. segments?: number;
  65565. diameter?: number;
  65566. diameterX?: number;
  65567. diameterY?: number;
  65568. diameterZ?: number;
  65569. arc?: number;
  65570. slice?: number;
  65571. sideOrientation?: number;
  65572. frontUVs?: Vector4;
  65573. backUVs?: Vector4;
  65574. updatable?: boolean;
  65575. }, scene?: Nullable<Scene>): Mesh;
  65576. /**
  65577. * Creates a plane polygonal mesh. By default, this is a disc
  65578. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65579. * * 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
  65580. * * 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
  65581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65582. * * 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
  65583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65584. * @param name defines the name of the mesh
  65585. * @param options defines the options used to create the mesh
  65586. * @param scene defines the hosting scene
  65587. * @returns the plane polygonal mesh
  65588. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65589. */
  65590. static CreateDisc(name: string, options: {
  65591. radius?: number;
  65592. tessellation?: number;
  65593. arc?: number;
  65594. updatable?: boolean;
  65595. sideOrientation?: number;
  65596. frontUVs?: Vector4;
  65597. backUVs?: Vector4;
  65598. }, scene?: Nullable<Scene>): Mesh;
  65599. /**
  65600. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65601. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65602. * * 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`)
  65603. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65604. * * 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
  65605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65608. * @param name defines the name of the mesh
  65609. * @param options defines the options used to create the mesh
  65610. * @param scene defines the hosting scene
  65611. * @returns the icosahedron mesh
  65612. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65613. */
  65614. static CreateIcoSphere(name: string, options: {
  65615. radius?: number;
  65616. radiusX?: number;
  65617. radiusY?: number;
  65618. radiusZ?: number;
  65619. flat?: boolean;
  65620. subdivisions?: number;
  65621. sideOrientation?: number;
  65622. frontUVs?: Vector4;
  65623. backUVs?: Vector4;
  65624. updatable?: boolean;
  65625. }, scene?: Nullable<Scene>): Mesh;
  65626. /**
  65627. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65628. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65629. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65630. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65631. * * 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
  65632. * * 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
  65633. * * 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
  65634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65635. * * 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
  65636. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65637. * * 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
  65638. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65639. * * 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
  65640. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65642. * @param name defines the name of the mesh
  65643. * @param options defines the options used to create the mesh
  65644. * @param scene defines the hosting scene
  65645. * @returns the ribbon mesh
  65646. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65647. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65648. */
  65649. static CreateRibbon(name: string, options: {
  65650. pathArray: Vector3[][];
  65651. closeArray?: boolean;
  65652. closePath?: boolean;
  65653. offset?: number;
  65654. updatable?: boolean;
  65655. sideOrientation?: number;
  65656. frontUVs?: Vector4;
  65657. backUVs?: Vector4;
  65658. instance?: Mesh;
  65659. invertUV?: boolean;
  65660. uvs?: Vector2[];
  65661. colors?: Color4[];
  65662. }, scene?: Nullable<Scene>): Mesh;
  65663. /**
  65664. * Creates a cylinder or a cone mesh
  65665. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65666. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65667. * * 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.
  65668. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65669. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65670. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65671. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65672. * * 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).
  65673. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65674. * * 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).
  65675. * * 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
  65676. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65677. * * 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
  65678. * * 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.
  65679. * * If `enclose` is false, a ring surface is one element.
  65680. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65681. * * 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
  65682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65683. * * 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
  65684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65685. * @param name defines the name of the mesh
  65686. * @param options defines the options used to create the mesh
  65687. * @param scene defines the hosting scene
  65688. * @returns the cylinder mesh
  65689. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65690. */
  65691. static CreateCylinder(name: string, options: {
  65692. height?: number;
  65693. diameterTop?: number;
  65694. diameterBottom?: number;
  65695. diameter?: number;
  65696. tessellation?: number;
  65697. subdivisions?: number;
  65698. arc?: number;
  65699. faceColors?: Color4[];
  65700. faceUV?: Vector4[];
  65701. updatable?: boolean;
  65702. hasRings?: boolean;
  65703. enclose?: boolean;
  65704. cap?: number;
  65705. sideOrientation?: number;
  65706. frontUVs?: Vector4;
  65707. backUVs?: Vector4;
  65708. }, scene?: Nullable<Scene>): Mesh;
  65709. /**
  65710. * Creates a torus mesh
  65711. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65712. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65713. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65715. * * 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
  65716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65717. * @param name defines the name of the mesh
  65718. * @param options defines the options used to create the mesh
  65719. * @param scene defines the hosting scene
  65720. * @returns the torus mesh
  65721. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65722. */
  65723. static CreateTorus(name: string, options: {
  65724. diameter?: number;
  65725. thickness?: number;
  65726. tessellation?: number;
  65727. updatable?: boolean;
  65728. sideOrientation?: number;
  65729. frontUVs?: Vector4;
  65730. backUVs?: Vector4;
  65731. }, scene?: Nullable<Scene>): Mesh;
  65732. /**
  65733. * Creates a torus knot mesh
  65734. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65735. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65736. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65737. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65739. * * 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
  65740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65741. * @param name defines the name of the mesh
  65742. * @param options defines the options used to create the mesh
  65743. * @param scene defines the hosting scene
  65744. * @returns the torus knot mesh
  65745. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65746. */
  65747. static CreateTorusKnot(name: string, options: {
  65748. radius?: number;
  65749. tube?: number;
  65750. radialSegments?: number;
  65751. tubularSegments?: number;
  65752. p?: number;
  65753. q?: number;
  65754. updatable?: boolean;
  65755. sideOrientation?: number;
  65756. frontUVs?: Vector4;
  65757. backUVs?: Vector4;
  65758. }, scene?: Nullable<Scene>): Mesh;
  65759. /**
  65760. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65761. * * 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
  65762. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65763. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65764. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65765. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65766. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65767. * * 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
  65768. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65771. * @param name defines the name of the new line system
  65772. * @param options defines the options used to create the line system
  65773. * @param scene defines the hosting scene
  65774. * @returns a new line system mesh
  65775. */
  65776. static CreateLineSystem(name: string, options: {
  65777. lines: Vector3[][];
  65778. updatable?: boolean;
  65779. instance?: Nullable<LinesMesh>;
  65780. colors?: Nullable<Color4[][]>;
  65781. useVertexAlpha?: boolean;
  65782. }, scene: Nullable<Scene>): LinesMesh;
  65783. /**
  65784. * Creates a line mesh
  65785. * 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
  65786. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65787. * * The parameter `points` is an array successive Vector3
  65788. * * 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
  65789. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65790. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65791. * * When updating an instance, remember that only point positions can change, not the number of points
  65792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65794. * @param name defines the name of the new line system
  65795. * @param options defines the options used to create the line system
  65796. * @param scene defines the hosting scene
  65797. * @returns a new line mesh
  65798. */
  65799. static CreateLines(name: string, options: {
  65800. points: Vector3[];
  65801. updatable?: boolean;
  65802. instance?: Nullable<LinesMesh>;
  65803. colors?: Color4[];
  65804. useVertexAlpha?: boolean;
  65805. }, scene?: Nullable<Scene>): LinesMesh;
  65806. /**
  65807. * Creates a dashed line mesh
  65808. * * 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
  65809. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65810. * * The parameter `points` is an array successive Vector3
  65811. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65812. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65813. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65814. * * 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
  65815. * * When updating an instance, remember that only point positions can change, not the number of points
  65816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65817. * @param name defines the name of the mesh
  65818. * @param options defines the options used to create the mesh
  65819. * @param scene defines the hosting scene
  65820. * @returns the dashed line mesh
  65821. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65822. */
  65823. static CreateDashedLines(name: string, options: {
  65824. points: Vector3[];
  65825. dashSize?: number;
  65826. gapSize?: number;
  65827. dashNb?: number;
  65828. updatable?: boolean;
  65829. instance?: LinesMesh;
  65830. }, scene?: Nullable<Scene>): LinesMesh;
  65831. /**
  65832. * 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.
  65833. * * 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.
  65834. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65835. * * 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.
  65836. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65837. * * 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
  65838. * * 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
  65839. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65841. * * 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
  65842. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65844. * @param name defines the name of the mesh
  65845. * @param options defines the options used to create the mesh
  65846. * @param scene defines the hosting scene
  65847. * @returns the extruded shape mesh
  65848. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65850. */
  65851. static ExtrudeShape(name: string, options: {
  65852. shape: Vector3[];
  65853. path: Vector3[];
  65854. scale?: number;
  65855. rotation?: number;
  65856. cap?: number;
  65857. updatable?: boolean;
  65858. sideOrientation?: number;
  65859. frontUVs?: Vector4;
  65860. backUVs?: Vector4;
  65861. instance?: Mesh;
  65862. invertUV?: boolean;
  65863. }, scene?: Nullable<Scene>): Mesh;
  65864. /**
  65865. * Creates an custom extruded shape mesh.
  65866. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65867. * * 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.
  65868. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65869. * * 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
  65870. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65871. * * 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
  65872. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65873. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65874. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65875. * * 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
  65876. * * 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
  65877. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65880. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65882. * @param name defines the name of the mesh
  65883. * @param options defines the options used to create the mesh
  65884. * @param scene defines the hosting scene
  65885. * @returns the custom extruded shape mesh
  65886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65887. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65889. */
  65890. static ExtrudeShapeCustom(name: string, options: {
  65891. shape: Vector3[];
  65892. path: Vector3[];
  65893. scaleFunction?: any;
  65894. rotationFunction?: any;
  65895. ribbonCloseArray?: boolean;
  65896. ribbonClosePath?: boolean;
  65897. cap?: number;
  65898. updatable?: boolean;
  65899. sideOrientation?: number;
  65900. frontUVs?: Vector4;
  65901. backUVs?: Vector4;
  65902. instance?: Mesh;
  65903. invertUV?: boolean;
  65904. }, scene?: Nullable<Scene>): Mesh;
  65905. /**
  65906. * Creates lathe mesh.
  65907. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65908. * * 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
  65909. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65910. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65911. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65912. * * 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
  65913. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65914. * * 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
  65915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65919. * @param name defines the name of the mesh
  65920. * @param options defines the options used to create the mesh
  65921. * @param scene defines the hosting scene
  65922. * @returns the lathe mesh
  65923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65924. */
  65925. static CreateLathe(name: string, options: {
  65926. shape: Vector3[];
  65927. radius?: number;
  65928. tessellation?: number;
  65929. clip?: number;
  65930. arc?: number;
  65931. closed?: boolean;
  65932. updatable?: boolean;
  65933. sideOrientation?: number;
  65934. frontUVs?: Vector4;
  65935. backUVs?: Vector4;
  65936. cap?: number;
  65937. invertUV?: boolean;
  65938. }, scene?: Nullable<Scene>): Mesh;
  65939. /**
  65940. * Creates a tiled plane mesh
  65941. * * You can set a limited pattern arrangement with the tiles
  65942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65943. * * 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
  65944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65945. * @param name defines the name of the mesh
  65946. * @param options defines the options used to create the mesh
  65947. * @param scene defines the hosting scene
  65948. * @returns the plane mesh
  65949. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65950. */
  65951. static CreateTiledPlane(name: string, options: {
  65952. pattern?: number;
  65953. tileSize?: number;
  65954. tileWidth?: number;
  65955. tileHeight?: number;
  65956. size?: number;
  65957. width?: number;
  65958. height?: number;
  65959. alignHorizontal?: number;
  65960. alignVertical?: number;
  65961. sideOrientation?: number;
  65962. frontUVs?: Vector4;
  65963. backUVs?: Vector4;
  65964. updatable?: boolean;
  65965. }, scene?: Nullable<Scene>): Mesh;
  65966. /**
  65967. * Creates a plane mesh
  65968. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65969. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65970. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65972. * * 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
  65973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65974. * @param name defines the name of the mesh
  65975. * @param options defines the options used to create the mesh
  65976. * @param scene defines the hosting scene
  65977. * @returns the plane mesh
  65978. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65979. */
  65980. static CreatePlane(name: string, options: {
  65981. size?: number;
  65982. width?: number;
  65983. height?: number;
  65984. sideOrientation?: number;
  65985. frontUVs?: Vector4;
  65986. backUVs?: Vector4;
  65987. updatable?: boolean;
  65988. sourcePlane?: Plane;
  65989. }, scene?: Nullable<Scene>): Mesh;
  65990. /**
  65991. * Creates a ground mesh
  65992. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65993. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65995. * @param name defines the name of the mesh
  65996. * @param options defines the options used to create the mesh
  65997. * @param scene defines the hosting scene
  65998. * @returns the ground mesh
  65999. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66000. */
  66001. static CreateGround(name: string, options: {
  66002. width?: number;
  66003. height?: number;
  66004. subdivisions?: number;
  66005. subdivisionsX?: number;
  66006. subdivisionsY?: number;
  66007. updatable?: boolean;
  66008. }, scene?: Nullable<Scene>): Mesh;
  66009. /**
  66010. * Creates a tiled ground mesh
  66011. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66012. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66013. * * 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
  66014. * * 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
  66015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66016. * @param name defines the name of the mesh
  66017. * @param options defines the options used to create the mesh
  66018. * @param scene defines the hosting scene
  66019. * @returns the tiled ground mesh
  66020. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66021. */
  66022. static CreateTiledGround(name: string, options: {
  66023. xmin: number;
  66024. zmin: number;
  66025. xmax: number;
  66026. zmax: number;
  66027. subdivisions?: {
  66028. w: number;
  66029. h: number;
  66030. };
  66031. precision?: {
  66032. w: number;
  66033. h: number;
  66034. };
  66035. updatable?: boolean;
  66036. }, scene?: Nullable<Scene>): Mesh;
  66037. /**
  66038. * Creates a ground mesh from a height map
  66039. * * The parameter `url` sets the URL of the height map image resource.
  66040. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66041. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66042. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66043. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66044. * * 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.
  66045. * * 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).
  66046. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66048. * @param name defines the name of the mesh
  66049. * @param url defines the url to the height map
  66050. * @param options defines the options used to create the mesh
  66051. * @param scene defines the hosting scene
  66052. * @returns the ground mesh
  66053. * @see https://doc.babylonjs.com/babylon101/height_map
  66054. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66055. */
  66056. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66057. width?: number;
  66058. height?: number;
  66059. subdivisions?: number;
  66060. minHeight?: number;
  66061. maxHeight?: number;
  66062. colorFilter?: Color3;
  66063. alphaFilter?: number;
  66064. updatable?: boolean;
  66065. onReady?: (mesh: GroundMesh) => void;
  66066. }, scene?: Nullable<Scene>): GroundMesh;
  66067. /**
  66068. * Creates a polygon mesh
  66069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66070. * * 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
  66071. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66073. * * 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)
  66074. * * Remember you can only change the shape positions, not their number when updating a polygon
  66075. * @param name defines the name of the mesh
  66076. * @param options defines the options used to create the mesh
  66077. * @param scene defines the hosting scene
  66078. * @param earcutInjection can be used to inject your own earcut reference
  66079. * @returns the polygon mesh
  66080. */
  66081. static CreatePolygon(name: string, options: {
  66082. shape: Vector3[];
  66083. holes?: Vector3[][];
  66084. depth?: number;
  66085. faceUV?: Vector4[];
  66086. faceColors?: Color4[];
  66087. updatable?: boolean;
  66088. sideOrientation?: number;
  66089. frontUVs?: Vector4;
  66090. backUVs?: Vector4;
  66091. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66092. /**
  66093. * Creates an extruded polygon mesh, with depth in the Y direction.
  66094. * * 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)
  66095. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66096. * @param name defines the name of the mesh
  66097. * @param options defines the options used to create the mesh
  66098. * @param scene defines the hosting scene
  66099. * @param earcutInjection can be used to inject your own earcut reference
  66100. * @returns the polygon mesh
  66101. */
  66102. static ExtrudePolygon(name: string, options: {
  66103. shape: Vector3[];
  66104. holes?: Vector3[][];
  66105. depth?: number;
  66106. faceUV?: Vector4[];
  66107. faceColors?: Color4[];
  66108. updatable?: boolean;
  66109. sideOrientation?: number;
  66110. frontUVs?: Vector4;
  66111. backUVs?: Vector4;
  66112. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66113. /**
  66114. * Creates a tube mesh.
  66115. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66116. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66117. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66118. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66119. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66120. * * 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)
  66121. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66122. * * 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
  66123. * * 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
  66124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66125. * * 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
  66126. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66128. * @param name defines the name of the mesh
  66129. * @param options defines the options used to create the mesh
  66130. * @param scene defines the hosting scene
  66131. * @returns the tube mesh
  66132. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66133. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66134. */
  66135. static CreateTube(name: string, options: {
  66136. path: Vector3[];
  66137. radius?: number;
  66138. tessellation?: number;
  66139. radiusFunction?: {
  66140. (i: number, distance: number): number;
  66141. };
  66142. cap?: number;
  66143. arc?: number;
  66144. updatable?: boolean;
  66145. sideOrientation?: number;
  66146. frontUVs?: Vector4;
  66147. backUVs?: Vector4;
  66148. instance?: Mesh;
  66149. invertUV?: boolean;
  66150. }, scene?: Nullable<Scene>): Mesh;
  66151. /**
  66152. * Creates a polyhedron mesh
  66153. * * 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
  66154. * * The parameter `size` (positive float, default 1) sets the polygon size
  66155. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66156. * * 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`
  66157. * * 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
  66158. * * 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)`)
  66159. * * 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
  66160. * * 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
  66161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66162. * * 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
  66163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66164. * @param name defines the name of the mesh
  66165. * @param options defines the options used to create the mesh
  66166. * @param scene defines the hosting scene
  66167. * @returns the polyhedron mesh
  66168. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66169. */
  66170. static CreatePolyhedron(name: string, options: {
  66171. type?: number;
  66172. size?: number;
  66173. sizeX?: number;
  66174. sizeY?: number;
  66175. sizeZ?: number;
  66176. custom?: any;
  66177. faceUV?: Vector4[];
  66178. faceColors?: Color4[];
  66179. flat?: boolean;
  66180. updatable?: boolean;
  66181. sideOrientation?: number;
  66182. frontUVs?: Vector4;
  66183. backUVs?: Vector4;
  66184. }, scene?: Nullable<Scene>): Mesh;
  66185. /**
  66186. * Creates a decal mesh.
  66187. * 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
  66188. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66189. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66190. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66191. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66192. * @param name defines the name of the mesh
  66193. * @param sourceMesh defines the mesh where the decal must be applied
  66194. * @param options defines the options used to create the mesh
  66195. * @param scene defines the hosting scene
  66196. * @returns the decal mesh
  66197. * @see https://doc.babylonjs.com/how_to/decals
  66198. */
  66199. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66200. position?: Vector3;
  66201. normal?: Vector3;
  66202. size?: Vector3;
  66203. angle?: number;
  66204. }): Mesh;
  66205. }
  66206. }
  66207. declare module BABYLON {
  66208. /**
  66209. * A simplifier interface for future simplification implementations
  66210. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66211. */
  66212. export interface ISimplifier {
  66213. /**
  66214. * Simplification of a given mesh according to the given settings.
  66215. * Since this requires computation, it is assumed that the function runs async.
  66216. * @param settings The settings of the simplification, including quality and distance
  66217. * @param successCallback A callback that will be called after the mesh was simplified.
  66218. * @param errorCallback in case of an error, this callback will be called. optional.
  66219. */
  66220. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66221. }
  66222. /**
  66223. * Expected simplification settings.
  66224. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66225. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66226. */
  66227. export interface ISimplificationSettings {
  66228. /**
  66229. * Gets or sets the expected quality
  66230. */
  66231. quality: number;
  66232. /**
  66233. * Gets or sets the distance when this optimized version should be used
  66234. */
  66235. distance: number;
  66236. /**
  66237. * Gets an already optimized mesh
  66238. */
  66239. optimizeMesh?: boolean;
  66240. }
  66241. /**
  66242. * Class used to specify simplification options
  66243. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66244. */
  66245. export class SimplificationSettings implements ISimplificationSettings {
  66246. /** expected quality */
  66247. quality: number;
  66248. /** distance when this optimized version should be used */
  66249. distance: number;
  66250. /** already optimized mesh */
  66251. optimizeMesh?: boolean | undefined;
  66252. /**
  66253. * Creates a SimplificationSettings
  66254. * @param quality expected quality
  66255. * @param distance distance when this optimized version should be used
  66256. * @param optimizeMesh already optimized mesh
  66257. */
  66258. constructor(
  66259. /** expected quality */
  66260. quality: number,
  66261. /** distance when this optimized version should be used */
  66262. distance: number,
  66263. /** already optimized mesh */
  66264. optimizeMesh?: boolean | undefined);
  66265. }
  66266. /**
  66267. * Interface used to define a simplification task
  66268. */
  66269. export interface ISimplificationTask {
  66270. /**
  66271. * Array of settings
  66272. */
  66273. settings: Array<ISimplificationSettings>;
  66274. /**
  66275. * Simplification type
  66276. */
  66277. simplificationType: SimplificationType;
  66278. /**
  66279. * Mesh to simplify
  66280. */
  66281. mesh: Mesh;
  66282. /**
  66283. * Callback called on success
  66284. */
  66285. successCallback?: () => void;
  66286. /**
  66287. * Defines if parallel processing can be used
  66288. */
  66289. parallelProcessing: boolean;
  66290. }
  66291. /**
  66292. * Queue used to order the simplification tasks
  66293. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66294. */
  66295. export class SimplificationQueue {
  66296. private _simplificationArray;
  66297. /**
  66298. * Gets a boolean indicating that the process is still running
  66299. */
  66300. running: boolean;
  66301. /**
  66302. * Creates a new queue
  66303. */
  66304. constructor();
  66305. /**
  66306. * Adds a new simplification task
  66307. * @param task defines a task to add
  66308. */
  66309. addTask(task: ISimplificationTask): void;
  66310. /**
  66311. * Execute next task
  66312. */
  66313. executeNext(): void;
  66314. /**
  66315. * Execute a simplification task
  66316. * @param task defines the task to run
  66317. */
  66318. runSimplification(task: ISimplificationTask): void;
  66319. private getSimplifier;
  66320. }
  66321. /**
  66322. * The implemented types of simplification
  66323. * At the moment only Quadratic Error Decimation is implemented
  66324. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66325. */
  66326. export enum SimplificationType {
  66327. /** Quadratic error decimation */
  66328. QUADRATIC = 0
  66329. }
  66330. /**
  66331. * An implementation of the Quadratic Error simplification algorithm.
  66332. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66333. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66334. * @author RaananW
  66335. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66336. */
  66337. export class QuadraticErrorSimplification implements ISimplifier {
  66338. private _mesh;
  66339. private triangles;
  66340. private vertices;
  66341. private references;
  66342. private _reconstructedMesh;
  66343. /** Gets or sets the number pf sync interations */
  66344. syncIterations: number;
  66345. /** Gets or sets the aggressiveness of the simplifier */
  66346. aggressiveness: number;
  66347. /** Gets or sets the number of allowed iterations for decimation */
  66348. decimationIterations: number;
  66349. /** Gets or sets the espilon to use for bounding box computation */
  66350. boundingBoxEpsilon: number;
  66351. /**
  66352. * Creates a new QuadraticErrorSimplification
  66353. * @param _mesh defines the target mesh
  66354. */
  66355. constructor(_mesh: Mesh);
  66356. /**
  66357. * Simplification of a given mesh according to the given settings.
  66358. * Since this requires computation, it is assumed that the function runs async.
  66359. * @param settings The settings of the simplification, including quality and distance
  66360. * @param successCallback A callback that will be called after the mesh was simplified.
  66361. */
  66362. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66363. private runDecimation;
  66364. private initWithMesh;
  66365. private init;
  66366. private reconstructMesh;
  66367. private initDecimatedMesh;
  66368. private isFlipped;
  66369. private updateTriangles;
  66370. private identifyBorder;
  66371. private updateMesh;
  66372. private vertexError;
  66373. private calculateError;
  66374. }
  66375. }
  66376. declare module BABYLON {
  66377. interface Scene {
  66378. /** @hidden (Backing field) */
  66379. _simplificationQueue: SimplificationQueue;
  66380. /**
  66381. * Gets or sets the simplification queue attached to the scene
  66382. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66383. */
  66384. simplificationQueue: SimplificationQueue;
  66385. }
  66386. interface Mesh {
  66387. /**
  66388. * Simplify the mesh according to the given array of settings.
  66389. * Function will return immediately and will simplify async
  66390. * @param settings a collection of simplification settings
  66391. * @param parallelProcessing should all levels calculate parallel or one after the other
  66392. * @param simplificationType the type of simplification to run
  66393. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66394. * @returns the current mesh
  66395. */
  66396. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66397. }
  66398. /**
  66399. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66400. * created in a scene
  66401. */
  66402. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66403. /**
  66404. * The component name helpfull to identify the component in the list of scene components.
  66405. */
  66406. readonly name: string;
  66407. /**
  66408. * The scene the component belongs to.
  66409. */
  66410. scene: Scene;
  66411. /**
  66412. * Creates a new instance of the component for the given scene
  66413. * @param scene Defines the scene to register the component in
  66414. */
  66415. constructor(scene: Scene);
  66416. /**
  66417. * Registers the component in a given scene
  66418. */
  66419. register(): void;
  66420. /**
  66421. * Rebuilds the elements related to this component in case of
  66422. * context lost for instance.
  66423. */
  66424. rebuild(): void;
  66425. /**
  66426. * Disposes the component and the associated ressources
  66427. */
  66428. dispose(): void;
  66429. private _beforeCameraUpdate;
  66430. }
  66431. }
  66432. declare module BABYLON {
  66433. interface Mesh {
  66434. /**
  66435. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66436. */
  66437. thinInstanceEnablePicking: boolean;
  66438. /**
  66439. * Creates a new thin instance
  66440. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66441. * @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
  66442. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66443. */
  66444. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66445. /**
  66446. * Adds the transformation (matrix) of the current mesh as a thin instance
  66447. * @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
  66448. * @returns the thin instance index number
  66449. */
  66450. thinInstanceAddSelf(refresh: boolean): number;
  66451. /**
  66452. * Registers a custom attribute to be used with thin instances
  66453. * @param kind name of the attribute
  66454. * @param stride size in floats of the attribute
  66455. */
  66456. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66457. /**
  66458. * Sets the matrix of a thin instance
  66459. * @param index index of the thin instance
  66460. * @param matrix matrix to set
  66461. * @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
  66462. */
  66463. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66464. /**
  66465. * Sets the value of a custom attribute for a thin instance
  66466. * @param kind name of the attribute
  66467. * @param index index of the thin instance
  66468. * @param value value to set
  66469. * @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
  66470. */
  66471. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66472. /**
  66473. * 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.
  66474. */
  66475. thinInstanceCount: number;
  66476. /**
  66477. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66478. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66479. * @param buffer buffer to set
  66480. * @param stride size in floats of each value of the buffer
  66481. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66482. */
  66483. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66484. /**
  66485. * Gets the list of world matrices
  66486. * @return an array containing all the world matrices from the thin instances
  66487. */
  66488. thinInstanceGetWorldMatrices(): Matrix[];
  66489. /**
  66490. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66491. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66492. */
  66493. thinInstanceBufferUpdated(kind: string): void;
  66494. /**
  66495. * Refreshes the bounding info, taking into account all the thin instances defined
  66496. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66497. */
  66498. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66499. /** @hidden */
  66500. _thinInstanceInitializeUserStorage(): void;
  66501. /** @hidden */
  66502. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66503. /** @hidden */
  66504. _userThinInstanceBuffersStorage: {
  66505. data: {
  66506. [key: string]: Float32Array;
  66507. };
  66508. sizes: {
  66509. [key: string]: number;
  66510. };
  66511. vertexBuffers: {
  66512. [key: string]: Nullable<VertexBuffer>;
  66513. };
  66514. strides: {
  66515. [key: string]: number;
  66516. };
  66517. };
  66518. }
  66519. }
  66520. declare module BABYLON {
  66521. /**
  66522. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66523. */
  66524. export interface INavigationEnginePlugin {
  66525. /**
  66526. * plugin name
  66527. */
  66528. name: string;
  66529. /**
  66530. * Creates a navigation mesh
  66531. * @param meshes array of all the geometry used to compute the navigatio mesh
  66532. * @param parameters bunch of parameters used to filter geometry
  66533. */
  66534. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66535. /**
  66536. * Create a navigation mesh debug mesh
  66537. * @param scene is where the mesh will be added
  66538. * @returns debug display mesh
  66539. */
  66540. createDebugNavMesh(scene: Scene): Mesh;
  66541. /**
  66542. * Get a navigation mesh constrained position, closest to the parameter position
  66543. * @param position world position
  66544. * @returns the closest point to position constrained by the navigation mesh
  66545. */
  66546. getClosestPoint(position: Vector3): Vector3;
  66547. /**
  66548. * Get a navigation mesh constrained position, closest to the parameter position
  66549. * @param position world position
  66550. * @param result output the closest point to position constrained by the navigation mesh
  66551. */
  66552. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66553. /**
  66554. * Get a navigation mesh constrained position, within a particular radius
  66555. * @param position world position
  66556. * @param maxRadius the maximum distance to the constrained world position
  66557. * @returns the closest point to position constrained by the navigation mesh
  66558. */
  66559. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66560. /**
  66561. * Get a navigation mesh constrained position, within a particular radius
  66562. * @param position world position
  66563. * @param maxRadius the maximum distance to the constrained world position
  66564. * @param result output the closest point to position constrained by the navigation mesh
  66565. */
  66566. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66567. /**
  66568. * Compute the final position from a segment made of destination-position
  66569. * @param position world position
  66570. * @param destination world position
  66571. * @returns the resulting point along the navmesh
  66572. */
  66573. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66574. /**
  66575. * Compute the final position from a segment made of destination-position
  66576. * @param position world position
  66577. * @param destination world position
  66578. * @param result output the resulting point along the navmesh
  66579. */
  66580. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66581. /**
  66582. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66583. * @param start world position
  66584. * @param end world position
  66585. * @returns array containing world position composing the path
  66586. */
  66587. computePath(start: Vector3, end: Vector3): Vector3[];
  66588. /**
  66589. * If this plugin is supported
  66590. * @returns true if plugin is supported
  66591. */
  66592. isSupported(): boolean;
  66593. /**
  66594. * Create a new Crowd so you can add agents
  66595. * @param maxAgents the maximum agent count in the crowd
  66596. * @param maxAgentRadius the maximum radius an agent can have
  66597. * @param scene to attach the crowd to
  66598. * @returns the crowd you can add agents to
  66599. */
  66600. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66601. /**
  66602. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66603. * The queries will try to find a solution within those bounds
  66604. * default is (1,1,1)
  66605. * @param extent x,y,z value that define the extent around the queries point of reference
  66606. */
  66607. setDefaultQueryExtent(extent: Vector3): void;
  66608. /**
  66609. * Get the Bounding box extent specified by setDefaultQueryExtent
  66610. * @returns the box extent values
  66611. */
  66612. getDefaultQueryExtent(): Vector3;
  66613. /**
  66614. * build the navmesh from a previously saved state using getNavmeshData
  66615. * @param data the Uint8Array returned by getNavmeshData
  66616. */
  66617. buildFromNavmeshData(data: Uint8Array): void;
  66618. /**
  66619. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66620. * @returns data the Uint8Array that can be saved and reused
  66621. */
  66622. getNavmeshData(): Uint8Array;
  66623. /**
  66624. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66625. * @param result output the box extent values
  66626. */
  66627. getDefaultQueryExtentToRef(result: Vector3): void;
  66628. /**
  66629. * Release all resources
  66630. */
  66631. dispose(): void;
  66632. }
  66633. /**
  66634. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66635. */
  66636. export interface ICrowd {
  66637. /**
  66638. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66639. * You can attach anything to that node. The node position is updated in the scene update tick.
  66640. * @param pos world position that will be constrained by the navigation mesh
  66641. * @param parameters agent parameters
  66642. * @param transform hooked to the agent that will be update by the scene
  66643. * @returns agent index
  66644. */
  66645. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66646. /**
  66647. * Returns the agent position in world space
  66648. * @param index agent index returned by addAgent
  66649. * @returns world space position
  66650. */
  66651. getAgentPosition(index: number): Vector3;
  66652. /**
  66653. * Gets the agent position result in world space
  66654. * @param index agent index returned by addAgent
  66655. * @param result output world space position
  66656. */
  66657. getAgentPositionToRef(index: number, result: Vector3): void;
  66658. /**
  66659. * Gets the agent velocity in world space
  66660. * @param index agent index returned by addAgent
  66661. * @returns world space velocity
  66662. */
  66663. getAgentVelocity(index: number): Vector3;
  66664. /**
  66665. * Gets the agent velocity result in world space
  66666. * @param index agent index returned by addAgent
  66667. * @param result output world space velocity
  66668. */
  66669. getAgentVelocityToRef(index: number, result: Vector3): void;
  66670. /**
  66671. * remove a particular agent previously created
  66672. * @param index agent index returned by addAgent
  66673. */
  66674. removeAgent(index: number): void;
  66675. /**
  66676. * get the list of all agents attached to this crowd
  66677. * @returns list of agent indices
  66678. */
  66679. getAgents(): number[];
  66680. /**
  66681. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66682. * @param deltaTime in seconds
  66683. */
  66684. update(deltaTime: number): void;
  66685. /**
  66686. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66687. * @param index agent index returned by addAgent
  66688. * @param destination targeted world position
  66689. */
  66690. agentGoto(index: number, destination: Vector3): void;
  66691. /**
  66692. * Teleport the agent to a new position
  66693. * @param index agent index returned by addAgent
  66694. * @param destination targeted world position
  66695. */
  66696. agentTeleport(index: number, destination: Vector3): void;
  66697. /**
  66698. * Update agent parameters
  66699. * @param index agent index returned by addAgent
  66700. * @param parameters agent parameters
  66701. */
  66702. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66703. /**
  66704. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66705. * The queries will try to find a solution within those bounds
  66706. * default is (1,1,1)
  66707. * @param extent x,y,z value that define the extent around the queries point of reference
  66708. */
  66709. setDefaultQueryExtent(extent: Vector3): void;
  66710. /**
  66711. * Get the Bounding box extent specified by setDefaultQueryExtent
  66712. * @returns the box extent values
  66713. */
  66714. getDefaultQueryExtent(): Vector3;
  66715. /**
  66716. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66717. * @param result output the box extent values
  66718. */
  66719. getDefaultQueryExtentToRef(result: Vector3): void;
  66720. /**
  66721. * Release all resources
  66722. */
  66723. dispose(): void;
  66724. }
  66725. /**
  66726. * Configures an agent
  66727. */
  66728. export interface IAgentParameters {
  66729. /**
  66730. * Agent radius. [Limit: >= 0]
  66731. */
  66732. radius: number;
  66733. /**
  66734. * Agent height. [Limit: > 0]
  66735. */
  66736. height: number;
  66737. /**
  66738. * Maximum allowed acceleration. [Limit: >= 0]
  66739. */
  66740. maxAcceleration: number;
  66741. /**
  66742. * Maximum allowed speed. [Limit: >= 0]
  66743. */
  66744. maxSpeed: number;
  66745. /**
  66746. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66747. */
  66748. collisionQueryRange: number;
  66749. /**
  66750. * The path visibility optimization range. [Limit: > 0]
  66751. */
  66752. pathOptimizationRange: number;
  66753. /**
  66754. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66755. */
  66756. separationWeight: number;
  66757. }
  66758. /**
  66759. * Configures the navigation mesh creation
  66760. */
  66761. export interface INavMeshParameters {
  66762. /**
  66763. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66764. */
  66765. cs: number;
  66766. /**
  66767. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66768. */
  66769. ch: number;
  66770. /**
  66771. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66772. */
  66773. walkableSlopeAngle: number;
  66774. /**
  66775. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66776. * be considered walkable. [Limit: >= 3] [Units: vx]
  66777. */
  66778. walkableHeight: number;
  66779. /**
  66780. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66781. */
  66782. walkableClimb: number;
  66783. /**
  66784. * The distance to erode/shrink the walkable area of the heightfield away from
  66785. * obstructions. [Limit: >=0] [Units: vx]
  66786. */
  66787. walkableRadius: number;
  66788. /**
  66789. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66790. */
  66791. maxEdgeLen: number;
  66792. /**
  66793. * The maximum distance a simplfied contour's border edges should deviate
  66794. * the original raw contour. [Limit: >=0] [Units: vx]
  66795. */
  66796. maxSimplificationError: number;
  66797. /**
  66798. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66799. */
  66800. minRegionArea: number;
  66801. /**
  66802. * Any regions with a span count smaller than this value will, if possible,
  66803. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66804. */
  66805. mergeRegionArea: number;
  66806. /**
  66807. * The maximum number of vertices allowed for polygons generated during the
  66808. * contour to polygon conversion process. [Limit: >= 3]
  66809. */
  66810. maxVertsPerPoly: number;
  66811. /**
  66812. * Sets the sampling distance to use when generating the detail mesh.
  66813. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66814. */
  66815. detailSampleDist: number;
  66816. /**
  66817. * The maximum distance the detail mesh surface should deviate from heightfield
  66818. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66819. */
  66820. detailSampleMaxError: number;
  66821. }
  66822. }
  66823. declare module BABYLON {
  66824. /**
  66825. * RecastJS navigation plugin
  66826. */
  66827. export class RecastJSPlugin implements INavigationEnginePlugin {
  66828. /**
  66829. * Reference to the Recast library
  66830. */
  66831. bjsRECAST: any;
  66832. /**
  66833. * plugin name
  66834. */
  66835. name: string;
  66836. /**
  66837. * the first navmesh created. We might extend this to support multiple navmeshes
  66838. */
  66839. navMesh: any;
  66840. /**
  66841. * Initializes the recastJS plugin
  66842. * @param recastInjection can be used to inject your own recast reference
  66843. */
  66844. constructor(recastInjection?: any);
  66845. /**
  66846. * Creates a navigation mesh
  66847. * @param meshes array of all the geometry used to compute the navigatio mesh
  66848. * @param parameters bunch of parameters used to filter geometry
  66849. */
  66850. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66851. /**
  66852. * Create a navigation mesh debug mesh
  66853. * @param scene is where the mesh will be added
  66854. * @returns debug display mesh
  66855. */
  66856. createDebugNavMesh(scene: Scene): Mesh;
  66857. /**
  66858. * Get a navigation mesh constrained position, closest to the parameter position
  66859. * @param position world position
  66860. * @returns the closest point to position constrained by the navigation mesh
  66861. */
  66862. getClosestPoint(position: Vector3): Vector3;
  66863. /**
  66864. * Get a navigation mesh constrained position, closest to the parameter position
  66865. * @param position world position
  66866. * @param result output the closest point to position constrained by the navigation mesh
  66867. */
  66868. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66869. /**
  66870. * Get a navigation mesh constrained position, within a particular radius
  66871. * @param position world position
  66872. * @param maxRadius the maximum distance to the constrained world position
  66873. * @returns the closest point to position constrained by the navigation mesh
  66874. */
  66875. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66876. /**
  66877. * Get a navigation mesh constrained position, within a particular radius
  66878. * @param position world position
  66879. * @param maxRadius the maximum distance to the constrained world position
  66880. * @param result output the closest point to position constrained by the navigation mesh
  66881. */
  66882. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66883. /**
  66884. * Compute the final position from a segment made of destination-position
  66885. * @param position world position
  66886. * @param destination world position
  66887. * @returns the resulting point along the navmesh
  66888. */
  66889. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66890. /**
  66891. * Compute the final position from a segment made of destination-position
  66892. * @param position world position
  66893. * @param destination world position
  66894. * @param result output the resulting point along the navmesh
  66895. */
  66896. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66897. /**
  66898. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66899. * @param start world position
  66900. * @param end world position
  66901. * @returns array containing world position composing the path
  66902. */
  66903. computePath(start: Vector3, end: Vector3): Vector3[];
  66904. /**
  66905. * Create a new Crowd so you can add agents
  66906. * @param maxAgents the maximum agent count in the crowd
  66907. * @param maxAgentRadius the maximum radius an agent can have
  66908. * @param scene to attach the crowd to
  66909. * @returns the crowd you can add agents to
  66910. */
  66911. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66912. /**
  66913. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66914. * The queries will try to find a solution within those bounds
  66915. * default is (1,1,1)
  66916. * @param extent x,y,z value that define the extent around the queries point of reference
  66917. */
  66918. setDefaultQueryExtent(extent: Vector3): void;
  66919. /**
  66920. * Get the Bounding box extent specified by setDefaultQueryExtent
  66921. * @returns the box extent values
  66922. */
  66923. getDefaultQueryExtent(): Vector3;
  66924. /**
  66925. * build the navmesh from a previously saved state using getNavmeshData
  66926. * @param data the Uint8Array returned by getNavmeshData
  66927. */
  66928. buildFromNavmeshData(data: Uint8Array): void;
  66929. /**
  66930. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66931. * @returns data the Uint8Array that can be saved and reused
  66932. */
  66933. getNavmeshData(): Uint8Array;
  66934. /**
  66935. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66936. * @param result output the box extent values
  66937. */
  66938. getDefaultQueryExtentToRef(result: Vector3): void;
  66939. /**
  66940. * Disposes
  66941. */
  66942. dispose(): void;
  66943. /**
  66944. * If this plugin is supported
  66945. * @returns true if plugin is supported
  66946. */
  66947. isSupported(): boolean;
  66948. }
  66949. /**
  66950. * Recast detour crowd implementation
  66951. */
  66952. export class RecastJSCrowd implements ICrowd {
  66953. /**
  66954. * Recast/detour plugin
  66955. */
  66956. bjsRECASTPlugin: RecastJSPlugin;
  66957. /**
  66958. * Link to the detour crowd
  66959. */
  66960. recastCrowd: any;
  66961. /**
  66962. * One transform per agent
  66963. */
  66964. transforms: TransformNode[];
  66965. /**
  66966. * All agents created
  66967. */
  66968. agents: number[];
  66969. /**
  66970. * Link to the scene is kept to unregister the crowd from the scene
  66971. */
  66972. private _scene;
  66973. /**
  66974. * Observer for crowd updates
  66975. */
  66976. private _onBeforeAnimationsObserver;
  66977. /**
  66978. * Constructor
  66979. * @param plugin recastJS plugin
  66980. * @param maxAgents the maximum agent count in the crowd
  66981. * @param maxAgentRadius the maximum radius an agent can have
  66982. * @param scene to attach the crowd to
  66983. * @returns the crowd you can add agents to
  66984. */
  66985. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66986. /**
  66987. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66988. * You can attach anything to that node. The node position is updated in the scene update tick.
  66989. * @param pos world position that will be constrained by the navigation mesh
  66990. * @param parameters agent parameters
  66991. * @param transform hooked to the agent that will be update by the scene
  66992. * @returns agent index
  66993. */
  66994. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66995. /**
  66996. * Returns the agent position in world space
  66997. * @param index agent index returned by addAgent
  66998. * @returns world space position
  66999. */
  67000. getAgentPosition(index: number): Vector3;
  67001. /**
  67002. * Returns the agent position result in world space
  67003. * @param index agent index returned by addAgent
  67004. * @param result output world space position
  67005. */
  67006. getAgentPositionToRef(index: number, result: Vector3): void;
  67007. /**
  67008. * Returns the agent velocity in world space
  67009. * @param index agent index returned by addAgent
  67010. * @returns world space velocity
  67011. */
  67012. getAgentVelocity(index: number): Vector3;
  67013. /**
  67014. * Returns the agent velocity result in world space
  67015. * @param index agent index returned by addAgent
  67016. * @param result output world space velocity
  67017. */
  67018. getAgentVelocityToRef(index: number, result: Vector3): void;
  67019. /**
  67020. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67021. * @param index agent index returned by addAgent
  67022. * @param destination targeted world position
  67023. */
  67024. agentGoto(index: number, destination: Vector3): void;
  67025. /**
  67026. * Teleport the agent to a new position
  67027. * @param index agent index returned by addAgent
  67028. * @param destination targeted world position
  67029. */
  67030. agentTeleport(index: number, destination: Vector3): void;
  67031. /**
  67032. * Update agent parameters
  67033. * @param index agent index returned by addAgent
  67034. * @param parameters agent parameters
  67035. */
  67036. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67037. /**
  67038. * remove a particular agent previously created
  67039. * @param index agent index returned by addAgent
  67040. */
  67041. removeAgent(index: number): void;
  67042. /**
  67043. * get the list of all agents attached to this crowd
  67044. * @returns list of agent indices
  67045. */
  67046. getAgents(): number[];
  67047. /**
  67048. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67049. * @param deltaTime in seconds
  67050. */
  67051. update(deltaTime: number): void;
  67052. /**
  67053. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67054. * The queries will try to find a solution within those bounds
  67055. * default is (1,1,1)
  67056. * @param extent x,y,z value that define the extent around the queries point of reference
  67057. */
  67058. setDefaultQueryExtent(extent: Vector3): void;
  67059. /**
  67060. * Get the Bounding box extent specified by setDefaultQueryExtent
  67061. * @returns the box extent values
  67062. */
  67063. getDefaultQueryExtent(): Vector3;
  67064. /**
  67065. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67066. * @param result output the box extent values
  67067. */
  67068. getDefaultQueryExtentToRef(result: Vector3): void;
  67069. /**
  67070. * Release all resources
  67071. */
  67072. dispose(): void;
  67073. }
  67074. }
  67075. declare module BABYLON {
  67076. /**
  67077. * Class used to enable access to IndexedDB
  67078. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67079. */
  67080. export class Database implements IOfflineProvider {
  67081. private _callbackManifestChecked;
  67082. private _currentSceneUrl;
  67083. private _db;
  67084. private _enableSceneOffline;
  67085. private _enableTexturesOffline;
  67086. private _manifestVersionFound;
  67087. private _mustUpdateRessources;
  67088. private _hasReachedQuota;
  67089. private _isSupported;
  67090. private _idbFactory;
  67091. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67092. private static IsUASupportingBlobStorage;
  67093. /**
  67094. * Gets a boolean indicating if Database storate is enabled (off by default)
  67095. */
  67096. static IDBStorageEnabled: boolean;
  67097. /**
  67098. * Gets a boolean indicating if scene must be saved in the database
  67099. */
  67100. get enableSceneOffline(): boolean;
  67101. /**
  67102. * Gets a boolean indicating if textures must be saved in the database
  67103. */
  67104. get enableTexturesOffline(): boolean;
  67105. /**
  67106. * Creates a new Database
  67107. * @param urlToScene defines the url to load the scene
  67108. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67109. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67110. */
  67111. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67112. private static _ParseURL;
  67113. private static _ReturnFullUrlLocation;
  67114. private _checkManifestFile;
  67115. /**
  67116. * Open the database and make it available
  67117. * @param successCallback defines the callback to call on success
  67118. * @param errorCallback defines the callback to call on error
  67119. */
  67120. open(successCallback: () => void, errorCallback: () => void): void;
  67121. /**
  67122. * Loads an image from the database
  67123. * @param url defines the url to load from
  67124. * @param image defines the target DOM image
  67125. */
  67126. loadImage(url: string, image: HTMLImageElement): void;
  67127. private _loadImageFromDBAsync;
  67128. private _saveImageIntoDBAsync;
  67129. private _checkVersionFromDB;
  67130. private _loadVersionFromDBAsync;
  67131. private _saveVersionIntoDBAsync;
  67132. /**
  67133. * Loads a file from database
  67134. * @param url defines the URL to load from
  67135. * @param sceneLoaded defines a callback to call on success
  67136. * @param progressCallBack defines a callback to call when progress changed
  67137. * @param errorCallback defines a callback to call on error
  67138. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67139. */
  67140. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67141. private _loadFileAsync;
  67142. private _saveFileAsync;
  67143. /**
  67144. * Validates if xhr data is correct
  67145. * @param xhr defines the request to validate
  67146. * @param dataType defines the expected data type
  67147. * @returns true if data is correct
  67148. */
  67149. private static _ValidateXHRData;
  67150. }
  67151. }
  67152. declare module BABYLON {
  67153. /** @hidden */
  67154. export var gpuUpdateParticlesPixelShader: {
  67155. name: string;
  67156. shader: string;
  67157. };
  67158. }
  67159. declare module BABYLON {
  67160. /** @hidden */
  67161. export var gpuUpdateParticlesVertexShader: {
  67162. name: string;
  67163. shader: string;
  67164. };
  67165. }
  67166. declare module BABYLON {
  67167. /** @hidden */
  67168. export var clipPlaneFragmentDeclaration2: {
  67169. name: string;
  67170. shader: string;
  67171. };
  67172. }
  67173. declare module BABYLON {
  67174. /** @hidden */
  67175. export var gpuRenderParticlesPixelShader: {
  67176. name: string;
  67177. shader: string;
  67178. };
  67179. }
  67180. declare module BABYLON {
  67181. /** @hidden */
  67182. export var clipPlaneVertexDeclaration2: {
  67183. name: string;
  67184. shader: string;
  67185. };
  67186. }
  67187. declare module BABYLON {
  67188. /** @hidden */
  67189. export var gpuRenderParticlesVertexShader: {
  67190. name: string;
  67191. shader: string;
  67192. };
  67193. }
  67194. declare module BABYLON {
  67195. /**
  67196. * This represents a GPU particle system in Babylon
  67197. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67198. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67199. */
  67200. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67201. /**
  67202. * The layer mask we are rendering the particles through.
  67203. */
  67204. layerMask: number;
  67205. private _capacity;
  67206. private _activeCount;
  67207. private _currentActiveCount;
  67208. private _accumulatedCount;
  67209. private _renderEffect;
  67210. private _updateEffect;
  67211. private _buffer0;
  67212. private _buffer1;
  67213. private _spriteBuffer;
  67214. private _updateVAO;
  67215. private _renderVAO;
  67216. private _targetIndex;
  67217. private _sourceBuffer;
  67218. private _targetBuffer;
  67219. private _currentRenderId;
  67220. private _started;
  67221. private _stopped;
  67222. private _timeDelta;
  67223. private _randomTexture;
  67224. private _randomTexture2;
  67225. private _attributesStrideSize;
  67226. private _updateEffectOptions;
  67227. private _randomTextureSize;
  67228. private _actualFrame;
  67229. private _customEffect;
  67230. private readonly _rawTextureWidth;
  67231. /**
  67232. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67233. */
  67234. static get IsSupported(): boolean;
  67235. /**
  67236. * An event triggered when the system is disposed.
  67237. */
  67238. onDisposeObservable: Observable<IParticleSystem>;
  67239. /**
  67240. * Gets the maximum number of particles active at the same time.
  67241. * @returns The max number of active particles.
  67242. */
  67243. getCapacity(): number;
  67244. /**
  67245. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67246. * to override the particles.
  67247. */
  67248. forceDepthWrite: boolean;
  67249. /**
  67250. * Gets or set the number of active particles
  67251. */
  67252. get activeParticleCount(): number;
  67253. set activeParticleCount(value: number);
  67254. private _preWarmDone;
  67255. /**
  67256. * Specifies if the particles are updated in emitter local space or world space.
  67257. */
  67258. isLocal: boolean;
  67259. /** Gets or sets a matrix to use to compute projection */
  67260. defaultProjectionMatrix: Matrix;
  67261. /**
  67262. * Is this system ready to be used/rendered
  67263. * @return true if the system is ready
  67264. */
  67265. isReady(): boolean;
  67266. /**
  67267. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67268. * @returns True if it has been started, otherwise false.
  67269. */
  67270. isStarted(): boolean;
  67271. /**
  67272. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67273. * @returns True if it has been stopped, otherwise false.
  67274. */
  67275. isStopped(): boolean;
  67276. /**
  67277. * Gets a boolean indicating that the system is stopping
  67278. * @returns true if the system is currently stopping
  67279. */
  67280. isStopping(): boolean;
  67281. /**
  67282. * Gets the number of particles active at the same time.
  67283. * @returns The number of active particles.
  67284. */
  67285. getActiveCount(): number;
  67286. /**
  67287. * Starts the particle system and begins to emit
  67288. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67289. */
  67290. start(delay?: number): void;
  67291. /**
  67292. * Stops the particle system.
  67293. */
  67294. stop(): void;
  67295. /**
  67296. * Remove all active particles
  67297. */
  67298. reset(): void;
  67299. /**
  67300. * Returns the string "GPUParticleSystem"
  67301. * @returns a string containing the class name
  67302. */
  67303. getClassName(): string;
  67304. /**
  67305. * Gets the custom effect used to render the particles
  67306. * @param blendMode Blend mode for which the effect should be retrieved
  67307. * @returns The effect
  67308. */
  67309. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67310. /**
  67311. * Sets the custom effect used to render the particles
  67312. * @param effect The effect to set
  67313. * @param blendMode Blend mode for which the effect should be set
  67314. */
  67315. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67316. /** @hidden */
  67317. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67318. /**
  67319. * Observable that will be called just before the particles are drawn
  67320. */
  67321. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67322. /**
  67323. * Gets the name of the particle vertex shader
  67324. */
  67325. get vertexShaderName(): string;
  67326. private _colorGradientsTexture;
  67327. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67328. /**
  67329. * Adds a new color gradient
  67330. * @param gradient defines the gradient to use (between 0 and 1)
  67331. * @param color1 defines the color to affect to the specified gradient
  67332. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67333. * @returns the current particle system
  67334. */
  67335. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67336. private _refreshColorGradient;
  67337. /** Force the system to rebuild all gradients that need to be resync */
  67338. forceRefreshGradients(): void;
  67339. /**
  67340. * Remove a specific color gradient
  67341. * @param gradient defines the gradient to remove
  67342. * @returns the current particle system
  67343. */
  67344. removeColorGradient(gradient: number): GPUParticleSystem;
  67345. private _angularSpeedGradientsTexture;
  67346. private _sizeGradientsTexture;
  67347. private _velocityGradientsTexture;
  67348. private _limitVelocityGradientsTexture;
  67349. private _dragGradientsTexture;
  67350. private _addFactorGradient;
  67351. /**
  67352. * Adds a new size gradient
  67353. * @param gradient defines the gradient to use (between 0 and 1)
  67354. * @param factor defines the size factor to affect to the specified gradient
  67355. * @returns the current particle system
  67356. */
  67357. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67358. /**
  67359. * Remove a specific size gradient
  67360. * @param gradient defines the gradient to remove
  67361. * @returns the current particle system
  67362. */
  67363. removeSizeGradient(gradient: number): GPUParticleSystem;
  67364. private _refreshFactorGradient;
  67365. /**
  67366. * Adds a new angular speed gradient
  67367. * @param gradient defines the gradient to use (between 0 and 1)
  67368. * @param factor defines the angular speed to affect to the specified gradient
  67369. * @returns the current particle system
  67370. */
  67371. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67372. /**
  67373. * Remove a specific angular speed gradient
  67374. * @param gradient defines the gradient to remove
  67375. * @returns the current particle system
  67376. */
  67377. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67378. /**
  67379. * Adds a new velocity gradient
  67380. * @param gradient defines the gradient to use (between 0 and 1)
  67381. * @param factor defines the velocity to affect to the specified gradient
  67382. * @returns the current particle system
  67383. */
  67384. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67385. /**
  67386. * Remove a specific velocity gradient
  67387. * @param gradient defines the gradient to remove
  67388. * @returns the current particle system
  67389. */
  67390. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67391. /**
  67392. * Adds a new limit velocity gradient
  67393. * @param gradient defines the gradient to use (between 0 and 1)
  67394. * @param factor defines the limit velocity value to affect to the specified gradient
  67395. * @returns the current particle system
  67396. */
  67397. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67398. /**
  67399. * Remove a specific limit velocity gradient
  67400. * @param gradient defines the gradient to remove
  67401. * @returns the current particle system
  67402. */
  67403. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67404. /**
  67405. * Adds a new drag gradient
  67406. * @param gradient defines the gradient to use (between 0 and 1)
  67407. * @param factor defines the drag value to affect to the specified gradient
  67408. * @returns the current particle system
  67409. */
  67410. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67411. /**
  67412. * Remove a specific drag gradient
  67413. * @param gradient defines the gradient to remove
  67414. * @returns the current particle system
  67415. */
  67416. removeDragGradient(gradient: number): GPUParticleSystem;
  67417. /**
  67418. * Not supported by GPUParticleSystem
  67419. * @param gradient defines the gradient to use (between 0 and 1)
  67420. * @param factor defines the emit rate value to affect to the specified gradient
  67421. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67422. * @returns the current particle system
  67423. */
  67424. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67425. /**
  67426. * Not supported by GPUParticleSystem
  67427. * @param gradient defines the gradient to remove
  67428. * @returns the current particle system
  67429. */
  67430. removeEmitRateGradient(gradient: number): IParticleSystem;
  67431. /**
  67432. * Not supported by GPUParticleSystem
  67433. * @param gradient defines the gradient to use (between 0 and 1)
  67434. * @param factor defines the start size value to affect to the specified gradient
  67435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67436. * @returns the current particle system
  67437. */
  67438. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67439. /**
  67440. * Not supported by GPUParticleSystem
  67441. * @param gradient defines the gradient to remove
  67442. * @returns the current particle system
  67443. */
  67444. removeStartSizeGradient(gradient: number): IParticleSystem;
  67445. /**
  67446. * Not supported by GPUParticleSystem
  67447. * @param gradient defines the gradient to use (between 0 and 1)
  67448. * @param min defines the color remap minimal range
  67449. * @param max defines the color remap maximal range
  67450. * @returns the current particle system
  67451. */
  67452. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67453. /**
  67454. * Not supported by GPUParticleSystem
  67455. * @param gradient defines the gradient to remove
  67456. * @returns the current particle system
  67457. */
  67458. removeColorRemapGradient(): IParticleSystem;
  67459. /**
  67460. * Not supported by GPUParticleSystem
  67461. * @param gradient defines the gradient to use (between 0 and 1)
  67462. * @param min defines the alpha remap minimal range
  67463. * @param max defines the alpha remap maximal range
  67464. * @returns the current particle system
  67465. */
  67466. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67467. /**
  67468. * Not supported by GPUParticleSystem
  67469. * @param gradient defines the gradient to remove
  67470. * @returns the current particle system
  67471. */
  67472. removeAlphaRemapGradient(): IParticleSystem;
  67473. /**
  67474. * Not supported by GPUParticleSystem
  67475. * @param gradient defines the gradient to use (between 0 and 1)
  67476. * @param color defines the color to affect to the specified gradient
  67477. * @returns the current particle system
  67478. */
  67479. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67480. /**
  67481. * Not supported by GPUParticleSystem
  67482. * @param gradient defines the gradient to remove
  67483. * @returns the current particle system
  67484. */
  67485. removeRampGradient(): IParticleSystem;
  67486. /**
  67487. * Not supported by GPUParticleSystem
  67488. * @returns the list of ramp gradients
  67489. */
  67490. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67491. /**
  67492. * Not supported by GPUParticleSystem
  67493. * Gets or sets a boolean indicating that ramp gradients must be used
  67494. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67495. */
  67496. get useRampGradients(): boolean;
  67497. set useRampGradients(value: boolean);
  67498. /**
  67499. * Not supported by GPUParticleSystem
  67500. * @param gradient defines the gradient to use (between 0 and 1)
  67501. * @param factor defines the life time factor to affect to the specified gradient
  67502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67503. * @returns the current particle system
  67504. */
  67505. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67506. /**
  67507. * Not supported by GPUParticleSystem
  67508. * @param gradient defines the gradient to remove
  67509. * @returns the current particle system
  67510. */
  67511. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67512. /**
  67513. * Instantiates a GPU particle system.
  67514. * 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.
  67515. * @param name The name of the particle system
  67516. * @param options The options used to create the system
  67517. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67518. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67519. * @param customEffect a custom effect used to change the way particles are rendered by default
  67520. */
  67521. constructor(name: string, options: Partial<{
  67522. capacity: number;
  67523. randomTextureSize: number;
  67524. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67525. protected _reset(): void;
  67526. private _createUpdateVAO;
  67527. private _createRenderVAO;
  67528. private _initialize;
  67529. /** @hidden */
  67530. _recreateUpdateEffect(): void;
  67531. private _getEffect;
  67532. /**
  67533. * Fill the defines array according to the current settings of the particle system
  67534. * @param defines Array to be updated
  67535. * @param blendMode blend mode to take into account when updating the array
  67536. */
  67537. fillDefines(defines: Array<string>, blendMode?: number): void;
  67538. /**
  67539. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67540. * @param uniforms Uniforms array to fill
  67541. * @param attributes Attributes array to fill
  67542. * @param samplers Samplers array to fill
  67543. */
  67544. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67545. /** @hidden */
  67546. _recreateRenderEffect(): Effect;
  67547. /**
  67548. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67549. * @param preWarm defines if we are in the pre-warmimg phase
  67550. */
  67551. animate(preWarm?: boolean): void;
  67552. private _createFactorGradientTexture;
  67553. private _createSizeGradientTexture;
  67554. private _createAngularSpeedGradientTexture;
  67555. private _createVelocityGradientTexture;
  67556. private _createLimitVelocityGradientTexture;
  67557. private _createDragGradientTexture;
  67558. private _createColorGradientTexture;
  67559. /**
  67560. * Renders the particle system in its current state
  67561. * @param preWarm defines if the system should only update the particles but not render them
  67562. * @returns the current number of particles
  67563. */
  67564. render(preWarm?: boolean): number;
  67565. /**
  67566. * Rebuilds the particle system
  67567. */
  67568. rebuild(): void;
  67569. private _releaseBuffers;
  67570. private _releaseVAOs;
  67571. /**
  67572. * Disposes the particle system and free the associated resources
  67573. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67574. */
  67575. dispose(disposeTexture?: boolean): void;
  67576. /**
  67577. * Clones the particle system.
  67578. * @param name The name of the cloned object
  67579. * @param newEmitter The new emitter to use
  67580. * @returns the cloned particle system
  67581. */
  67582. clone(name: string, newEmitter: any): GPUParticleSystem;
  67583. /**
  67584. * Serializes the particle system to a JSON object
  67585. * @param serializeTexture defines if the texture must be serialized as well
  67586. * @returns the JSON object
  67587. */
  67588. serialize(serializeTexture?: boolean): any;
  67589. /**
  67590. * Parses a JSON object to create a GPU particle system.
  67591. * @param parsedParticleSystem The JSON object to parse
  67592. * @param sceneOrEngine The scene or the engine to create the particle system in
  67593. * @param rootUrl The root url to use to load external dependencies like texture
  67594. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67595. * @returns the parsed GPU particle system
  67596. */
  67597. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67598. }
  67599. }
  67600. declare module BABYLON {
  67601. /**
  67602. * Represents a set of particle systems working together to create a specific effect
  67603. */
  67604. export class ParticleSystemSet implements IDisposable {
  67605. /**
  67606. * Gets or sets base Assets URL
  67607. */
  67608. static BaseAssetsUrl: string;
  67609. private _emitterCreationOptions;
  67610. private _emitterNode;
  67611. /**
  67612. * Gets the particle system list
  67613. */
  67614. systems: IParticleSystem[];
  67615. /**
  67616. * Gets the emitter node used with this set
  67617. */
  67618. get emitterNode(): Nullable<TransformNode>;
  67619. /**
  67620. * Creates a new emitter mesh as a sphere
  67621. * @param options defines the options used to create the sphere
  67622. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67623. * @param scene defines the hosting scene
  67624. */
  67625. setEmitterAsSphere(options: {
  67626. diameter: number;
  67627. segments: number;
  67628. color: Color3;
  67629. }, renderingGroupId: number, scene: Scene): void;
  67630. /**
  67631. * Starts all particle systems of the set
  67632. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67633. */
  67634. start(emitter?: AbstractMesh): void;
  67635. /**
  67636. * Release all associated resources
  67637. */
  67638. dispose(): void;
  67639. /**
  67640. * Serialize the set into a JSON compatible object
  67641. * @param serializeTexture defines if the texture must be serialized as well
  67642. * @returns a JSON compatible representation of the set
  67643. */
  67644. serialize(serializeTexture?: boolean): any;
  67645. /**
  67646. * Parse a new ParticleSystemSet from a serialized source
  67647. * @param data defines a JSON compatible representation of the set
  67648. * @param scene defines the hosting scene
  67649. * @param gpu defines if we want GPU particles or CPU particles
  67650. * @returns a new ParticleSystemSet
  67651. */
  67652. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67653. }
  67654. }
  67655. declare module BABYLON {
  67656. /**
  67657. * This class is made for on one-liner static method to help creating particle system set.
  67658. */
  67659. export class ParticleHelper {
  67660. /**
  67661. * Gets or sets base Assets URL
  67662. */
  67663. static BaseAssetsUrl: string;
  67664. /** Define the Url to load snippets */
  67665. static SnippetUrl: string;
  67666. /**
  67667. * Create a default particle system that you can tweak
  67668. * @param emitter defines the emitter to use
  67669. * @param capacity defines the system capacity (default is 500 particles)
  67670. * @param scene defines the hosting scene
  67671. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67672. * @returns the new Particle system
  67673. */
  67674. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67675. /**
  67676. * This is the main static method (one-liner) of this helper to create different particle systems
  67677. * @param type This string represents the type to the particle system to create
  67678. * @param scene The scene where the particle system should live
  67679. * @param gpu If the system will use gpu
  67680. * @returns the ParticleSystemSet created
  67681. */
  67682. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67683. /**
  67684. * Static function used to export a particle system to a ParticleSystemSet variable.
  67685. * Please note that the emitter shape is not exported
  67686. * @param systems defines the particle systems to export
  67687. * @returns the created particle system set
  67688. */
  67689. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67690. /**
  67691. * Creates a particle system from a snippet saved in a remote file
  67692. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67693. * @param url defines the url to load from
  67694. * @param scene defines the hosting scene
  67695. * @param gpu If the system will use gpu
  67696. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67697. * @returns a promise that will resolve to the new particle system
  67698. */
  67699. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67700. /**
  67701. * Creates a particle system from a snippet saved by the particle system editor
  67702. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67703. * @param scene defines the hosting scene
  67704. * @param gpu If the system will use gpu
  67705. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67706. * @returns a promise that will resolve to the new particle system
  67707. */
  67708. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67709. }
  67710. }
  67711. declare module BABYLON {
  67712. interface Engine {
  67713. /**
  67714. * Create an effect to use with particle systems.
  67715. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67716. * the particle system for which you want to create a custom effect in the last parameter
  67717. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67718. * @param uniformsNames defines a list of attribute names
  67719. * @param samplers defines an array of string used to represent textures
  67720. * @param defines defines the string containing the defines to use to compile the shaders
  67721. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67722. * @param onCompiled defines a function to call when the effect creation is successful
  67723. * @param onError defines a function to call when the effect creation has failed
  67724. * @param particleSystem the particle system you want to create the effect for
  67725. * @returns the new Effect
  67726. */
  67727. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67728. }
  67729. interface Mesh {
  67730. /**
  67731. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67732. * @returns an array of IParticleSystem
  67733. */
  67734. getEmittedParticleSystems(): IParticleSystem[];
  67735. /**
  67736. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67737. * @returns an array of IParticleSystem
  67738. */
  67739. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67740. }
  67741. }
  67742. declare module BABYLON {
  67743. /** Defines the 4 color options */
  67744. export enum PointColor {
  67745. /** color value */
  67746. Color = 2,
  67747. /** uv value */
  67748. UV = 1,
  67749. /** random value */
  67750. Random = 0,
  67751. /** stated value */
  67752. Stated = 3
  67753. }
  67754. /**
  67755. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67756. * 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.
  67757. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67758. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67759. *
  67760. * Full documentation here : TO BE ENTERED
  67761. */
  67762. export class PointsCloudSystem implements IDisposable {
  67763. /**
  67764. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67765. * Example : var p = SPS.particles[i];
  67766. */
  67767. particles: CloudPoint[];
  67768. /**
  67769. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67770. */
  67771. nbParticles: number;
  67772. /**
  67773. * This a counter for your own usage. It's not set by any SPS functions.
  67774. */
  67775. counter: number;
  67776. /**
  67777. * The PCS name. This name is also given to the underlying mesh.
  67778. */
  67779. name: string;
  67780. /**
  67781. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67782. */
  67783. mesh: Mesh;
  67784. /**
  67785. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67786. * Please read :
  67787. */
  67788. vars: any;
  67789. /**
  67790. * @hidden
  67791. */
  67792. _size: number;
  67793. private _scene;
  67794. private _promises;
  67795. private _positions;
  67796. private _indices;
  67797. private _normals;
  67798. private _colors;
  67799. private _uvs;
  67800. private _indices32;
  67801. private _positions32;
  67802. private _colors32;
  67803. private _uvs32;
  67804. private _updatable;
  67805. private _isVisibilityBoxLocked;
  67806. private _alwaysVisible;
  67807. private _groups;
  67808. private _groupCounter;
  67809. private _computeParticleColor;
  67810. private _computeParticleTexture;
  67811. private _computeParticleRotation;
  67812. private _computeBoundingBox;
  67813. private _isReady;
  67814. /**
  67815. * Creates a PCS (Points Cloud System) object
  67816. * @param name (String) is the PCS name, this will be the underlying mesh name
  67817. * @param pointSize (number) is the size for each point
  67818. * @param scene (Scene) is the scene in which the PCS is added
  67819. * @param options defines the options of the PCS e.g.
  67820. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67821. */
  67822. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67823. updatable?: boolean;
  67824. });
  67825. /**
  67826. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67827. * If no points were added to the PCS, the returned mesh is just a single point.
  67828. * @returns a promise for the created mesh
  67829. */
  67830. buildMeshAsync(): Promise<Mesh>;
  67831. /**
  67832. * @hidden
  67833. */
  67834. private _buildMesh;
  67835. private _addParticle;
  67836. private _randomUnitVector;
  67837. private _getColorIndicesForCoord;
  67838. private _setPointsColorOrUV;
  67839. private _colorFromTexture;
  67840. private _calculateDensity;
  67841. /**
  67842. * Adds points to the PCS in random positions within a unit sphere
  67843. * @param nb (positive integer) the number of particles to be created from this model
  67844. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67845. * @returns the number of groups in the system
  67846. */
  67847. addPoints(nb: number, pointFunction?: any): number;
  67848. /**
  67849. * Adds points to the PCS from the surface of the model shape
  67850. * @param mesh is any Mesh object that will be used as a surface model for the points
  67851. * @param nb (positive integer) the number of particles to be created from this model
  67852. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67853. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67854. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67855. * @returns the number of groups in the system
  67856. */
  67857. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67858. /**
  67859. * Adds points to the PCS inside the model shape
  67860. * @param mesh is any Mesh object that will be used as a surface model for the points
  67861. * @param nb (positive integer) the number of particles to be created from this model
  67862. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67863. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67864. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67865. * @returns the number of groups in the system
  67866. */
  67867. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67868. /**
  67869. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67870. * This method calls `updateParticle()` for each particle of the SPS.
  67871. * For an animated SPS, it is usually called within the render loop.
  67872. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67873. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67874. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67875. * @returns the PCS.
  67876. */
  67877. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67878. /**
  67879. * Disposes the PCS.
  67880. */
  67881. dispose(): void;
  67882. /**
  67883. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67884. * doc :
  67885. * @returns the PCS.
  67886. */
  67887. refreshVisibleSize(): PointsCloudSystem;
  67888. /**
  67889. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67890. * @param size the size (float) of the visibility box
  67891. * note : this doesn't lock the PCS mesh bounding box.
  67892. * doc :
  67893. */
  67894. setVisibilityBox(size: number): void;
  67895. /**
  67896. * Gets whether the PCS is always visible or not
  67897. * doc :
  67898. */
  67899. get isAlwaysVisible(): boolean;
  67900. /**
  67901. * Sets the PCS as always visible or not
  67902. * doc :
  67903. */
  67904. set isAlwaysVisible(val: boolean);
  67905. /**
  67906. * Tells to `setParticles()` to compute the particle rotations or not
  67907. * Default value : false. The PCS is faster when it's set to false
  67908. * Note : particle rotations are only applied to parent particles
  67909. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67910. */
  67911. set computeParticleRotation(val: boolean);
  67912. /**
  67913. * Tells to `setParticles()` to compute the particle colors or not.
  67914. * Default value : true. The PCS is faster when it's set to false.
  67915. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67916. */
  67917. set computeParticleColor(val: boolean);
  67918. set computeParticleTexture(val: boolean);
  67919. /**
  67920. * Gets if `setParticles()` computes the particle colors or not.
  67921. * Default value : false. The PCS is faster when it's set to false.
  67922. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67923. */
  67924. get computeParticleColor(): boolean;
  67925. /**
  67926. * Gets if `setParticles()` computes the particle textures or not.
  67927. * Default value : false. The PCS is faster when it's set to false.
  67928. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67929. */
  67930. get computeParticleTexture(): boolean;
  67931. /**
  67932. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67933. */
  67934. set computeBoundingBox(val: boolean);
  67935. /**
  67936. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67937. */
  67938. get computeBoundingBox(): boolean;
  67939. /**
  67940. * This function does nothing. It may be overwritten to set all the particle first values.
  67941. * The PCS doesn't call this function, you may have to call it by your own.
  67942. * doc :
  67943. */
  67944. initParticles(): void;
  67945. /**
  67946. * This function does nothing. It may be overwritten to recycle a particle
  67947. * The PCS doesn't call this function, you can to call it
  67948. * doc :
  67949. * @param particle The particle to recycle
  67950. * @returns the recycled particle
  67951. */
  67952. recycleParticle(particle: CloudPoint): CloudPoint;
  67953. /**
  67954. * Updates a particle : this function should be overwritten by the user.
  67955. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67956. * doc :
  67957. * @example : just set a particle position or velocity and recycle conditions
  67958. * @param particle The particle to update
  67959. * @returns the updated particle
  67960. */
  67961. updateParticle(particle: CloudPoint): CloudPoint;
  67962. /**
  67963. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67964. * This does nothing and may be overwritten by the user.
  67965. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67966. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67967. * @param update the boolean update value actually passed to setParticles()
  67968. */
  67969. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67970. /**
  67971. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67972. * This will be passed three parameters.
  67973. * This does nothing and may be overwritten by the user.
  67974. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67975. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67976. * @param update the boolean update value actually passed to setParticles()
  67977. */
  67978. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67979. }
  67980. }
  67981. declare module BABYLON {
  67982. /**
  67983. * Represents one particle of a points cloud system.
  67984. */
  67985. export class CloudPoint {
  67986. /**
  67987. * particle global index
  67988. */
  67989. idx: number;
  67990. /**
  67991. * The color of the particle
  67992. */
  67993. color: Nullable<Color4>;
  67994. /**
  67995. * The world space position of the particle.
  67996. */
  67997. position: Vector3;
  67998. /**
  67999. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68000. */
  68001. rotation: Vector3;
  68002. /**
  68003. * The world space rotation quaternion of the particle.
  68004. */
  68005. rotationQuaternion: Nullable<Quaternion>;
  68006. /**
  68007. * The uv of the particle.
  68008. */
  68009. uv: Nullable<Vector2>;
  68010. /**
  68011. * The current speed of the particle.
  68012. */
  68013. velocity: Vector3;
  68014. /**
  68015. * The pivot point in the particle local space.
  68016. */
  68017. pivot: Vector3;
  68018. /**
  68019. * Must the particle be translated from its pivot point in its local space ?
  68020. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68021. * Default : false
  68022. */
  68023. translateFromPivot: boolean;
  68024. /**
  68025. * Index of this particle in the global "positions" array (Internal use)
  68026. * @hidden
  68027. */
  68028. _pos: number;
  68029. /**
  68030. * @hidden Index of this particle in the global "indices" array (Internal use)
  68031. */
  68032. _ind: number;
  68033. /**
  68034. * Group this particle belongs to
  68035. */
  68036. _group: PointsGroup;
  68037. /**
  68038. * Group id of this particle
  68039. */
  68040. groupId: number;
  68041. /**
  68042. * Index of the particle in its group id (Internal use)
  68043. */
  68044. idxInGroup: number;
  68045. /**
  68046. * @hidden Particle BoundingInfo object (Internal use)
  68047. */
  68048. _boundingInfo: BoundingInfo;
  68049. /**
  68050. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68051. */
  68052. _pcs: PointsCloudSystem;
  68053. /**
  68054. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68055. */
  68056. _stillInvisible: boolean;
  68057. /**
  68058. * @hidden Last computed particle rotation matrix
  68059. */
  68060. _rotationMatrix: number[];
  68061. /**
  68062. * Parent particle Id, if any.
  68063. * Default null.
  68064. */
  68065. parentId: Nullable<number>;
  68066. /**
  68067. * @hidden Internal global position in the PCS.
  68068. */
  68069. _globalPosition: Vector3;
  68070. /**
  68071. * Creates a Point Cloud object.
  68072. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68073. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68074. * @param group (PointsGroup) is the group the particle belongs to
  68075. * @param groupId (integer) is the group identifier in the PCS.
  68076. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68077. * @param pcs defines the PCS it is associated to
  68078. */
  68079. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68080. /**
  68081. * get point size
  68082. */
  68083. get size(): Vector3;
  68084. /**
  68085. * Set point size
  68086. */
  68087. set size(scale: Vector3);
  68088. /**
  68089. * Legacy support, changed quaternion to rotationQuaternion
  68090. */
  68091. get quaternion(): Nullable<Quaternion>;
  68092. /**
  68093. * Legacy support, changed quaternion to rotationQuaternion
  68094. */
  68095. set quaternion(q: Nullable<Quaternion>);
  68096. /**
  68097. * Returns a boolean. True if the particle intersects a mesh, else false
  68098. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68099. * @param target is the object (point or mesh) what the intersection is computed against
  68100. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68101. * @returns true if it intersects
  68102. */
  68103. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68104. /**
  68105. * get the rotation matrix of the particle
  68106. * @hidden
  68107. */
  68108. getRotationMatrix(m: Matrix): void;
  68109. }
  68110. /**
  68111. * Represents a group of points in a points cloud system
  68112. * * PCS internal tool, don't use it manually.
  68113. */
  68114. export class PointsGroup {
  68115. /**
  68116. * The group id
  68117. * @hidden
  68118. */
  68119. groupID: number;
  68120. /**
  68121. * image data for group (internal use)
  68122. * @hidden
  68123. */
  68124. _groupImageData: Nullable<ArrayBufferView>;
  68125. /**
  68126. * Image Width (internal use)
  68127. * @hidden
  68128. */
  68129. _groupImgWidth: number;
  68130. /**
  68131. * Image Height (internal use)
  68132. * @hidden
  68133. */
  68134. _groupImgHeight: number;
  68135. /**
  68136. * Custom position function (internal use)
  68137. * @hidden
  68138. */
  68139. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68140. /**
  68141. * density per facet for surface points
  68142. * @hidden
  68143. */
  68144. _groupDensity: number[];
  68145. /**
  68146. * Only when points are colored by texture carries pointer to texture list array
  68147. * @hidden
  68148. */
  68149. _textureNb: number;
  68150. /**
  68151. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68152. * PCS internal tool, don't use it manually.
  68153. * @hidden
  68154. */
  68155. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68156. }
  68157. }
  68158. declare module BABYLON {
  68159. interface Scene {
  68160. /** @hidden (Backing field) */
  68161. _physicsEngine: Nullable<IPhysicsEngine>;
  68162. /** @hidden */
  68163. _physicsTimeAccumulator: number;
  68164. /**
  68165. * Gets the current physics engine
  68166. * @returns a IPhysicsEngine or null if none attached
  68167. */
  68168. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68169. /**
  68170. * Enables physics to the current scene
  68171. * @param gravity defines the scene's gravity for the physics engine
  68172. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68173. * @return a boolean indicating if the physics engine was initialized
  68174. */
  68175. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68176. /**
  68177. * Disables and disposes the physics engine associated with the scene
  68178. */
  68179. disablePhysicsEngine(): void;
  68180. /**
  68181. * Gets a boolean indicating if there is an active physics engine
  68182. * @returns a boolean indicating if there is an active physics engine
  68183. */
  68184. isPhysicsEnabled(): boolean;
  68185. /**
  68186. * Deletes a physics compound impostor
  68187. * @param compound defines the compound to delete
  68188. */
  68189. deleteCompoundImpostor(compound: any): void;
  68190. /**
  68191. * An event triggered when physic simulation is about to be run
  68192. */
  68193. onBeforePhysicsObservable: Observable<Scene>;
  68194. /**
  68195. * An event triggered when physic simulation has been done
  68196. */
  68197. onAfterPhysicsObservable: Observable<Scene>;
  68198. }
  68199. interface AbstractMesh {
  68200. /** @hidden */
  68201. _physicsImpostor: Nullable<PhysicsImpostor>;
  68202. /**
  68203. * Gets or sets impostor used for physic simulation
  68204. * @see https://doc.babylonjs.com/features/physics_engine
  68205. */
  68206. physicsImpostor: Nullable<PhysicsImpostor>;
  68207. /**
  68208. * Gets the current physics impostor
  68209. * @see https://doc.babylonjs.com/features/physics_engine
  68210. * @returns a physics impostor or null
  68211. */
  68212. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68213. /** Apply a physic impulse to the mesh
  68214. * @param force defines the force to apply
  68215. * @param contactPoint defines where to apply the force
  68216. * @returns the current mesh
  68217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68218. */
  68219. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68220. /**
  68221. * Creates a physic joint between two meshes
  68222. * @param otherMesh defines the other mesh to use
  68223. * @param pivot1 defines the pivot to use on this mesh
  68224. * @param pivot2 defines the pivot to use on the other mesh
  68225. * @param options defines additional options (can be plugin dependent)
  68226. * @returns the current mesh
  68227. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68228. */
  68229. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68230. /** @hidden */
  68231. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68232. }
  68233. /**
  68234. * Defines the physics engine scene component responsible to manage a physics engine
  68235. */
  68236. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68237. /**
  68238. * The component name helpful to identify the component in the list of scene components.
  68239. */
  68240. readonly name: string;
  68241. /**
  68242. * The scene the component belongs to.
  68243. */
  68244. scene: Scene;
  68245. /**
  68246. * Creates a new instance of the component for the given scene
  68247. * @param scene Defines the scene to register the component in
  68248. */
  68249. constructor(scene: Scene);
  68250. /**
  68251. * Registers the component in a given scene
  68252. */
  68253. register(): void;
  68254. /**
  68255. * Rebuilds the elements related to this component in case of
  68256. * context lost for instance.
  68257. */
  68258. rebuild(): void;
  68259. /**
  68260. * Disposes the component and the associated ressources
  68261. */
  68262. dispose(): void;
  68263. }
  68264. }
  68265. declare module BABYLON {
  68266. /**
  68267. * A helper for physics simulations
  68268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68269. */
  68270. export class PhysicsHelper {
  68271. private _scene;
  68272. private _physicsEngine;
  68273. /**
  68274. * Initializes the Physics helper
  68275. * @param scene Babylon.js scene
  68276. */
  68277. constructor(scene: Scene);
  68278. /**
  68279. * Applies a radial explosion impulse
  68280. * @param origin the origin of the explosion
  68281. * @param radiusOrEventOptions the radius or the options of radial explosion
  68282. * @param strength the explosion strength
  68283. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68284. * @returns A physics radial explosion event, or null
  68285. */
  68286. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68287. /**
  68288. * Applies a radial explosion force
  68289. * @param origin the origin of the explosion
  68290. * @param radiusOrEventOptions the radius or the options of radial explosion
  68291. * @param strength the explosion strength
  68292. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68293. * @returns A physics radial explosion event, or null
  68294. */
  68295. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68296. /**
  68297. * Creates a gravitational field
  68298. * @param origin the origin of the explosion
  68299. * @param radiusOrEventOptions the radius or the options of radial explosion
  68300. * @param strength the explosion strength
  68301. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68302. * @returns A physics gravitational field event, or null
  68303. */
  68304. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68305. /**
  68306. * Creates a physics updraft event
  68307. * @param origin the origin of the updraft
  68308. * @param radiusOrEventOptions the radius or the options of the updraft
  68309. * @param strength the strength of the updraft
  68310. * @param height the height of the updraft
  68311. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68312. * @returns A physics updraft event, or null
  68313. */
  68314. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68315. /**
  68316. * Creates a physics vortex event
  68317. * @param origin the of the vortex
  68318. * @param radiusOrEventOptions the radius or the options of the vortex
  68319. * @param strength the strength of the vortex
  68320. * @param height the height of the vortex
  68321. * @returns a Physics vortex event, or null
  68322. * A physics vortex event or null
  68323. */
  68324. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68325. }
  68326. /**
  68327. * Represents a physics radial explosion event
  68328. */
  68329. class PhysicsRadialExplosionEvent {
  68330. private _scene;
  68331. private _options;
  68332. private _sphere;
  68333. private _dataFetched;
  68334. /**
  68335. * Initializes a radial explosioin event
  68336. * @param _scene BabylonJS scene
  68337. * @param _options The options for the vortex event
  68338. */
  68339. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68340. /**
  68341. * Returns the data related to the radial explosion event (sphere).
  68342. * @returns The radial explosion event data
  68343. */
  68344. getData(): PhysicsRadialExplosionEventData;
  68345. /**
  68346. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68347. * @param impostor A physics imposter
  68348. * @param origin the origin of the explosion
  68349. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68350. */
  68351. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68352. /**
  68353. * Triggers affecterd impostors callbacks
  68354. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68355. */
  68356. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68357. /**
  68358. * Disposes the sphere.
  68359. * @param force Specifies if the sphere should be disposed by force
  68360. */
  68361. dispose(force?: boolean): void;
  68362. /*** Helpers ***/
  68363. private _prepareSphere;
  68364. private _intersectsWithSphere;
  68365. }
  68366. /**
  68367. * Represents a gravitational field event
  68368. */
  68369. class PhysicsGravitationalFieldEvent {
  68370. private _physicsHelper;
  68371. private _scene;
  68372. private _origin;
  68373. private _options;
  68374. private _tickCallback;
  68375. private _sphere;
  68376. private _dataFetched;
  68377. /**
  68378. * Initializes the physics gravitational field event
  68379. * @param _physicsHelper A physics helper
  68380. * @param _scene BabylonJS scene
  68381. * @param _origin The origin position of the gravitational field event
  68382. * @param _options The options for the vortex event
  68383. */
  68384. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68385. /**
  68386. * Returns the data related to the gravitational field event (sphere).
  68387. * @returns A gravitational field event
  68388. */
  68389. getData(): PhysicsGravitationalFieldEventData;
  68390. /**
  68391. * Enables the gravitational field.
  68392. */
  68393. enable(): void;
  68394. /**
  68395. * Disables the gravitational field.
  68396. */
  68397. disable(): void;
  68398. /**
  68399. * Disposes the sphere.
  68400. * @param force The force to dispose from the gravitational field event
  68401. */
  68402. dispose(force?: boolean): void;
  68403. private _tick;
  68404. }
  68405. /**
  68406. * Represents a physics updraft event
  68407. */
  68408. class PhysicsUpdraftEvent {
  68409. private _scene;
  68410. private _origin;
  68411. private _options;
  68412. private _physicsEngine;
  68413. private _originTop;
  68414. private _originDirection;
  68415. private _tickCallback;
  68416. private _cylinder;
  68417. private _cylinderPosition;
  68418. private _dataFetched;
  68419. /**
  68420. * Initializes the physics updraft event
  68421. * @param _scene BabylonJS scene
  68422. * @param _origin The origin position of the updraft
  68423. * @param _options The options for the updraft event
  68424. */
  68425. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68426. /**
  68427. * Returns the data related to the updraft event (cylinder).
  68428. * @returns A physics updraft event
  68429. */
  68430. getData(): PhysicsUpdraftEventData;
  68431. /**
  68432. * Enables the updraft.
  68433. */
  68434. enable(): void;
  68435. /**
  68436. * Disables the updraft.
  68437. */
  68438. disable(): void;
  68439. /**
  68440. * Disposes the cylinder.
  68441. * @param force Specifies if the updraft should be disposed by force
  68442. */
  68443. dispose(force?: boolean): void;
  68444. private getImpostorHitData;
  68445. private _tick;
  68446. /*** Helpers ***/
  68447. private _prepareCylinder;
  68448. private _intersectsWithCylinder;
  68449. }
  68450. /**
  68451. * Represents a physics vortex event
  68452. */
  68453. class PhysicsVortexEvent {
  68454. private _scene;
  68455. private _origin;
  68456. private _options;
  68457. private _physicsEngine;
  68458. private _originTop;
  68459. private _tickCallback;
  68460. private _cylinder;
  68461. private _cylinderPosition;
  68462. private _dataFetched;
  68463. /**
  68464. * Initializes the physics vortex event
  68465. * @param _scene The BabylonJS scene
  68466. * @param _origin The origin position of the vortex
  68467. * @param _options The options for the vortex event
  68468. */
  68469. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68470. /**
  68471. * Returns the data related to the vortex event (cylinder).
  68472. * @returns The physics vortex event data
  68473. */
  68474. getData(): PhysicsVortexEventData;
  68475. /**
  68476. * Enables the vortex.
  68477. */
  68478. enable(): void;
  68479. /**
  68480. * Disables the cortex.
  68481. */
  68482. disable(): void;
  68483. /**
  68484. * Disposes the sphere.
  68485. * @param force
  68486. */
  68487. dispose(force?: boolean): void;
  68488. private getImpostorHitData;
  68489. private _tick;
  68490. /*** Helpers ***/
  68491. private _prepareCylinder;
  68492. private _intersectsWithCylinder;
  68493. }
  68494. /**
  68495. * Options fot the radial explosion event
  68496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68497. */
  68498. export class PhysicsRadialExplosionEventOptions {
  68499. /**
  68500. * The radius of the sphere for the radial explosion.
  68501. */
  68502. radius: number;
  68503. /**
  68504. * The strenth of the explosion.
  68505. */
  68506. strength: number;
  68507. /**
  68508. * The strenght of the force in correspondence to the distance of the affected object
  68509. */
  68510. falloff: PhysicsRadialImpulseFalloff;
  68511. /**
  68512. * Sphere options for the radial explosion.
  68513. */
  68514. sphere: {
  68515. segments: number;
  68516. diameter: number;
  68517. };
  68518. /**
  68519. * Sphere options for the radial explosion.
  68520. */
  68521. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68522. }
  68523. /**
  68524. * Options fot the updraft event
  68525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68526. */
  68527. export class PhysicsUpdraftEventOptions {
  68528. /**
  68529. * The radius of the cylinder for the vortex
  68530. */
  68531. radius: number;
  68532. /**
  68533. * The strenth of the updraft.
  68534. */
  68535. strength: number;
  68536. /**
  68537. * The height of the cylinder for the updraft.
  68538. */
  68539. height: number;
  68540. /**
  68541. * The mode for the the updraft.
  68542. */
  68543. updraftMode: PhysicsUpdraftMode;
  68544. }
  68545. /**
  68546. * Options fot the vortex event
  68547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68548. */
  68549. export class PhysicsVortexEventOptions {
  68550. /**
  68551. * The radius of the cylinder for the vortex
  68552. */
  68553. radius: number;
  68554. /**
  68555. * The strenth of the vortex.
  68556. */
  68557. strength: number;
  68558. /**
  68559. * The height of the cylinder for the vortex.
  68560. */
  68561. height: number;
  68562. /**
  68563. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68564. */
  68565. centripetalForceThreshold: number;
  68566. /**
  68567. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68568. */
  68569. centripetalForceMultiplier: number;
  68570. /**
  68571. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68572. */
  68573. centrifugalForceMultiplier: number;
  68574. /**
  68575. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68576. */
  68577. updraftForceMultiplier: number;
  68578. }
  68579. /**
  68580. * The strenght of the force in correspondence to the distance of the affected object
  68581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68582. */
  68583. export enum PhysicsRadialImpulseFalloff {
  68584. /** Defines that impulse is constant in strength across it's whole radius */
  68585. Constant = 0,
  68586. /** Defines that impulse gets weaker if it's further from the origin */
  68587. Linear = 1
  68588. }
  68589. /**
  68590. * The strength of the force in correspondence to the distance of the affected object
  68591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68592. */
  68593. export enum PhysicsUpdraftMode {
  68594. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68595. Center = 0,
  68596. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68597. Perpendicular = 1
  68598. }
  68599. /**
  68600. * Interface for a physics hit data
  68601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68602. */
  68603. export interface PhysicsHitData {
  68604. /**
  68605. * The force applied at the contact point
  68606. */
  68607. force: Vector3;
  68608. /**
  68609. * The contact point
  68610. */
  68611. contactPoint: Vector3;
  68612. /**
  68613. * The distance from the origin to the contact point
  68614. */
  68615. distanceFromOrigin: number;
  68616. }
  68617. /**
  68618. * Interface for radial explosion event data
  68619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68620. */
  68621. export interface PhysicsRadialExplosionEventData {
  68622. /**
  68623. * A sphere used for the radial explosion event
  68624. */
  68625. sphere: Mesh;
  68626. }
  68627. /**
  68628. * Interface for gravitational field event data
  68629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68630. */
  68631. export interface PhysicsGravitationalFieldEventData {
  68632. /**
  68633. * A sphere mesh used for the gravitational field event
  68634. */
  68635. sphere: Mesh;
  68636. }
  68637. /**
  68638. * Interface for updraft event data
  68639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68640. */
  68641. export interface PhysicsUpdraftEventData {
  68642. /**
  68643. * A cylinder used for the updraft event
  68644. */
  68645. cylinder: Mesh;
  68646. }
  68647. /**
  68648. * Interface for vortex event data
  68649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68650. */
  68651. export interface PhysicsVortexEventData {
  68652. /**
  68653. * A cylinder used for the vortex event
  68654. */
  68655. cylinder: Mesh;
  68656. }
  68657. /**
  68658. * Interface for an affected physics impostor
  68659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68660. */
  68661. export interface PhysicsAffectedImpostorWithData {
  68662. /**
  68663. * The impostor affected by the effect
  68664. */
  68665. impostor: PhysicsImpostor;
  68666. /**
  68667. * The data about the hit/horce from the explosion
  68668. */
  68669. hitData: PhysicsHitData;
  68670. }
  68671. }
  68672. declare module BABYLON {
  68673. /** @hidden */
  68674. export var blackAndWhitePixelShader: {
  68675. name: string;
  68676. shader: string;
  68677. };
  68678. }
  68679. declare module BABYLON {
  68680. /**
  68681. * Post process used to render in black and white
  68682. */
  68683. export class BlackAndWhitePostProcess extends PostProcess {
  68684. /**
  68685. * Linear about to convert he result to black and white (default: 1)
  68686. */
  68687. degree: number;
  68688. /**
  68689. * Creates a black and white post process
  68690. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68691. * @param name The name of the effect.
  68692. * @param options The required width/height ratio to downsize to before computing the render pass.
  68693. * @param camera The camera to apply the render pass to.
  68694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68695. * @param engine The engine which the post process will be applied. (default: current engine)
  68696. * @param reusable If the post process can be reused on the same frame. (default: false)
  68697. */
  68698. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68699. }
  68700. }
  68701. declare module BABYLON {
  68702. /**
  68703. * This represents a set of one or more post processes in Babylon.
  68704. * A post process can be used to apply a shader to a texture after it is rendered.
  68705. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68706. */
  68707. export class PostProcessRenderEffect {
  68708. private _postProcesses;
  68709. private _getPostProcesses;
  68710. private _singleInstance;
  68711. private _cameras;
  68712. private _indicesForCamera;
  68713. /**
  68714. * Name of the effect
  68715. * @hidden
  68716. */
  68717. _name: string;
  68718. /**
  68719. * Instantiates a post process render effect.
  68720. * A post process can be used to apply a shader to a texture after it is rendered.
  68721. * @param engine The engine the effect is tied to
  68722. * @param name The name of the effect
  68723. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68724. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68725. */
  68726. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68727. /**
  68728. * Checks if all the post processes in the effect are supported.
  68729. */
  68730. get isSupported(): boolean;
  68731. /**
  68732. * Updates the current state of the effect
  68733. * @hidden
  68734. */
  68735. _update(): void;
  68736. /**
  68737. * Attaches the effect on cameras
  68738. * @param cameras The camera to attach to.
  68739. * @hidden
  68740. */
  68741. _attachCameras(cameras: Camera): void;
  68742. /**
  68743. * Attaches the effect on cameras
  68744. * @param cameras The camera to attach to.
  68745. * @hidden
  68746. */
  68747. _attachCameras(cameras: Camera[]): void;
  68748. /**
  68749. * Detaches the effect on cameras
  68750. * @param cameras The camera to detatch from.
  68751. * @hidden
  68752. */
  68753. _detachCameras(cameras: Camera): void;
  68754. /**
  68755. * Detatches the effect on cameras
  68756. * @param cameras The camera to detatch from.
  68757. * @hidden
  68758. */
  68759. _detachCameras(cameras: Camera[]): void;
  68760. /**
  68761. * Enables the effect on given cameras
  68762. * @param cameras The camera to enable.
  68763. * @hidden
  68764. */
  68765. _enable(cameras: Camera): void;
  68766. /**
  68767. * Enables the effect on given cameras
  68768. * @param cameras The camera to enable.
  68769. * @hidden
  68770. */
  68771. _enable(cameras: Nullable<Camera[]>): void;
  68772. /**
  68773. * Disables the effect on the given cameras
  68774. * @param cameras The camera to disable.
  68775. * @hidden
  68776. */
  68777. _disable(cameras: Camera): void;
  68778. /**
  68779. * Disables the effect on the given cameras
  68780. * @param cameras The camera to disable.
  68781. * @hidden
  68782. */
  68783. _disable(cameras: Nullable<Camera[]>): void;
  68784. /**
  68785. * Gets a list of the post processes contained in the effect.
  68786. * @param camera The camera to get the post processes on.
  68787. * @returns The list of the post processes in the effect.
  68788. */
  68789. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68790. }
  68791. }
  68792. declare module BABYLON {
  68793. /** @hidden */
  68794. export var extractHighlightsPixelShader: {
  68795. name: string;
  68796. shader: string;
  68797. };
  68798. }
  68799. declare module BABYLON {
  68800. /**
  68801. * 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.
  68802. */
  68803. export class ExtractHighlightsPostProcess extends PostProcess {
  68804. /**
  68805. * The luminance threshold, pixels below this value will be set to black.
  68806. */
  68807. threshold: number;
  68808. /** @hidden */
  68809. _exposure: number;
  68810. /**
  68811. * Post process which has the input texture to be used when performing highlight extraction
  68812. * @hidden
  68813. */
  68814. _inputPostProcess: Nullable<PostProcess>;
  68815. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68816. }
  68817. }
  68818. declare module BABYLON {
  68819. /** @hidden */
  68820. export var bloomMergePixelShader: {
  68821. name: string;
  68822. shader: string;
  68823. };
  68824. }
  68825. declare module BABYLON {
  68826. /**
  68827. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68828. */
  68829. export class BloomMergePostProcess extends PostProcess {
  68830. /** Weight of the bloom to be added to the original input. */
  68831. weight: number;
  68832. /**
  68833. * Creates a new instance of @see BloomMergePostProcess
  68834. * @param name The name of the effect.
  68835. * @param originalFromInput Post process which's input will be used for the merge.
  68836. * @param blurred Blurred highlights post process which's output will be used.
  68837. * @param weight Weight of the bloom to be added to the original input.
  68838. * @param options The required width/height ratio to downsize to before computing the render pass.
  68839. * @param camera The camera to apply the render pass to.
  68840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68841. * @param engine The engine which the post process will be applied. (default: current engine)
  68842. * @param reusable If the post process can be reused on the same frame. (default: false)
  68843. * @param textureType Type of textures used when performing the post process. (default: 0)
  68844. * @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)
  68845. */
  68846. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68847. /** Weight of the bloom to be added to the original input. */
  68848. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68849. }
  68850. }
  68851. declare module BABYLON {
  68852. /**
  68853. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68854. */
  68855. export class BloomEffect extends PostProcessRenderEffect {
  68856. private bloomScale;
  68857. /**
  68858. * @hidden Internal
  68859. */
  68860. _effects: Array<PostProcess>;
  68861. /**
  68862. * @hidden Internal
  68863. */
  68864. _downscale: ExtractHighlightsPostProcess;
  68865. private _blurX;
  68866. private _blurY;
  68867. private _merge;
  68868. /**
  68869. * The luminance threshold to find bright areas of the image to bloom.
  68870. */
  68871. get threshold(): number;
  68872. set threshold(value: number);
  68873. /**
  68874. * The strength of the bloom.
  68875. */
  68876. get weight(): number;
  68877. set weight(value: number);
  68878. /**
  68879. * Specifies the size of the bloom blur kernel, relative to the final output size
  68880. */
  68881. get kernel(): number;
  68882. set kernel(value: number);
  68883. /**
  68884. * Creates a new instance of @see BloomEffect
  68885. * @param scene The scene the effect belongs to.
  68886. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68887. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68888. * @param bloomWeight The the strength of bloom.
  68889. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68890. * @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)
  68891. */
  68892. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68893. /**
  68894. * Disposes each of the internal effects for a given camera.
  68895. * @param camera The camera to dispose the effect on.
  68896. */
  68897. disposeEffects(camera: Camera): void;
  68898. /**
  68899. * @hidden Internal
  68900. */
  68901. _updateEffects(): void;
  68902. /**
  68903. * Internal
  68904. * @returns if all the contained post processes are ready.
  68905. * @hidden
  68906. */
  68907. _isReady(): boolean;
  68908. }
  68909. }
  68910. declare module BABYLON {
  68911. /** @hidden */
  68912. export var chromaticAberrationPixelShader: {
  68913. name: string;
  68914. shader: string;
  68915. };
  68916. }
  68917. declare module BABYLON {
  68918. /**
  68919. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68920. */
  68921. export class ChromaticAberrationPostProcess extends PostProcess {
  68922. /**
  68923. * The amount of seperation of rgb channels (default: 30)
  68924. */
  68925. aberrationAmount: number;
  68926. /**
  68927. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68928. */
  68929. radialIntensity: number;
  68930. /**
  68931. * 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))
  68932. */
  68933. direction: Vector2;
  68934. /**
  68935. * 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))
  68936. */
  68937. centerPosition: Vector2;
  68938. /**
  68939. * Creates a new instance ChromaticAberrationPostProcess
  68940. * @param name The name of the effect.
  68941. * @param screenWidth The width of the screen to apply the effect on.
  68942. * @param screenHeight The height of the screen to apply the effect on.
  68943. * @param options The required width/height ratio to downsize to before computing the render pass.
  68944. * @param camera The camera to apply the render pass to.
  68945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68946. * @param engine The engine which the post process will be applied. (default: current engine)
  68947. * @param reusable If the post process can be reused on the same frame. (default: false)
  68948. * @param textureType Type of textures used when performing the post process. (default: 0)
  68949. * @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)
  68950. */
  68951. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68952. }
  68953. }
  68954. declare module BABYLON {
  68955. /** @hidden */
  68956. export var circleOfConfusionPixelShader: {
  68957. name: string;
  68958. shader: string;
  68959. };
  68960. }
  68961. declare module BABYLON {
  68962. /**
  68963. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68964. */
  68965. export class CircleOfConfusionPostProcess extends PostProcess {
  68966. /**
  68967. * 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.
  68968. */
  68969. lensSize: number;
  68970. /**
  68971. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68972. */
  68973. fStop: number;
  68974. /**
  68975. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68976. */
  68977. focusDistance: number;
  68978. /**
  68979. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68980. */
  68981. focalLength: number;
  68982. private _depthTexture;
  68983. /**
  68984. * Creates a new instance CircleOfConfusionPostProcess
  68985. * @param name The name of the effect.
  68986. * @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.
  68987. * @param options The required width/height ratio to downsize to before computing the render pass.
  68988. * @param camera The camera to apply the render pass to.
  68989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68990. * @param engine The engine which the post process will be applied. (default: current engine)
  68991. * @param reusable If the post process can be reused on the same frame. (default: false)
  68992. * @param textureType Type of textures used when performing the post process. (default: 0)
  68993. * @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)
  68994. */
  68995. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68996. /**
  68997. * 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.
  68998. */
  68999. set depthTexture(value: RenderTargetTexture);
  69000. }
  69001. }
  69002. declare module BABYLON {
  69003. /** @hidden */
  69004. export var colorCorrectionPixelShader: {
  69005. name: string;
  69006. shader: string;
  69007. };
  69008. }
  69009. declare module BABYLON {
  69010. /**
  69011. *
  69012. * This post-process allows the modification of rendered colors by using
  69013. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69014. *
  69015. * The object needs to be provided an url to a texture containing the color
  69016. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69017. * Use an image editing software to tweak the LUT to match your needs.
  69018. *
  69019. * For an example of a color LUT, see here:
  69020. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69021. * For explanations on color grading, see here:
  69022. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69023. *
  69024. */
  69025. export class ColorCorrectionPostProcess extends PostProcess {
  69026. private _colorTableTexture;
  69027. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69028. }
  69029. }
  69030. declare module BABYLON {
  69031. /** @hidden */
  69032. export var convolutionPixelShader: {
  69033. name: string;
  69034. shader: string;
  69035. };
  69036. }
  69037. declare module BABYLON {
  69038. /**
  69039. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69040. * input texture to perform effects such as edge detection or sharpening
  69041. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69042. */
  69043. export class ConvolutionPostProcess extends PostProcess {
  69044. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69045. kernel: number[];
  69046. /**
  69047. * Creates a new instance ConvolutionPostProcess
  69048. * @param name The name of the effect.
  69049. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69050. * @param options The required width/height ratio to downsize to before computing the render pass.
  69051. * @param camera The camera to apply the render pass to.
  69052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69053. * @param engine The engine which the post process will be applied. (default: current engine)
  69054. * @param reusable If the post process can be reused on the same frame. (default: false)
  69055. * @param textureType Type of textures used when performing the post process. (default: 0)
  69056. */
  69057. constructor(name: string,
  69058. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69059. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69060. /**
  69061. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69062. */
  69063. static EdgeDetect0Kernel: number[];
  69064. /**
  69065. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69066. */
  69067. static EdgeDetect1Kernel: number[];
  69068. /**
  69069. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69070. */
  69071. static EdgeDetect2Kernel: number[];
  69072. /**
  69073. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69074. */
  69075. static SharpenKernel: number[];
  69076. /**
  69077. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69078. */
  69079. static EmbossKernel: number[];
  69080. /**
  69081. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69082. */
  69083. static GaussianKernel: number[];
  69084. }
  69085. }
  69086. declare module BABYLON {
  69087. /**
  69088. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69089. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69090. * based on samples that have a large difference in distance than the center pixel.
  69091. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69092. */
  69093. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69094. direction: Vector2;
  69095. /**
  69096. * Creates a new instance CircleOfConfusionPostProcess
  69097. * @param name The name of the effect.
  69098. * @param scene The scene the effect belongs to.
  69099. * @param direction The direction the blur should be applied.
  69100. * @param kernel The size of the kernel used to blur.
  69101. * @param options The required width/height ratio to downsize to before computing the render pass.
  69102. * @param camera The camera to apply the render pass to.
  69103. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69104. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69106. * @param engine The engine which the post process will be applied. (default: current engine)
  69107. * @param reusable If the post process can be reused on the same frame. (default: false)
  69108. * @param textureType Type of textures used when performing the post process. (default: 0)
  69109. * @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)
  69110. */
  69111. 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);
  69112. }
  69113. }
  69114. declare module BABYLON {
  69115. /** @hidden */
  69116. export var depthOfFieldMergePixelShader: {
  69117. name: string;
  69118. shader: string;
  69119. };
  69120. }
  69121. declare module BABYLON {
  69122. /**
  69123. * Options to be set when merging outputs from the default pipeline.
  69124. */
  69125. export class DepthOfFieldMergePostProcessOptions {
  69126. /**
  69127. * The original image to merge on top of
  69128. */
  69129. originalFromInput: PostProcess;
  69130. /**
  69131. * Parameters to perform the merge of the depth of field effect
  69132. */
  69133. depthOfField?: {
  69134. circleOfConfusion: PostProcess;
  69135. blurSteps: Array<PostProcess>;
  69136. };
  69137. /**
  69138. * Parameters to perform the merge of bloom effect
  69139. */
  69140. bloom?: {
  69141. blurred: PostProcess;
  69142. weight: number;
  69143. };
  69144. }
  69145. /**
  69146. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69147. */
  69148. export class DepthOfFieldMergePostProcess extends PostProcess {
  69149. private blurSteps;
  69150. /**
  69151. * Creates a new instance of DepthOfFieldMergePostProcess
  69152. * @param name The name of the effect.
  69153. * @param originalFromInput Post process which's input will be used for the merge.
  69154. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69155. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69156. * @param options The required width/height ratio to downsize to before computing the render pass.
  69157. * @param camera The camera to apply the render pass to.
  69158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69159. * @param engine The engine which the post process will be applied. (default: current engine)
  69160. * @param reusable If the post process can be reused on the same frame. (default: false)
  69161. * @param textureType Type of textures used when performing the post process. (default: 0)
  69162. * @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)
  69163. */
  69164. 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);
  69165. /**
  69166. * Updates the effect with the current post process compile time values and recompiles the shader.
  69167. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69168. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69169. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69170. * @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
  69171. * @param onCompiled Called when the shader has been compiled.
  69172. * @param onError Called if there is an error when compiling a shader.
  69173. */
  69174. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69175. }
  69176. }
  69177. declare module BABYLON {
  69178. /**
  69179. * Specifies the level of max blur that should be applied when using the depth of field effect
  69180. */
  69181. export enum DepthOfFieldEffectBlurLevel {
  69182. /**
  69183. * Subtle blur
  69184. */
  69185. Low = 0,
  69186. /**
  69187. * Medium blur
  69188. */
  69189. Medium = 1,
  69190. /**
  69191. * Large blur
  69192. */
  69193. High = 2
  69194. }
  69195. /**
  69196. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69197. */
  69198. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69199. private _circleOfConfusion;
  69200. /**
  69201. * @hidden Internal, blurs from high to low
  69202. */
  69203. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69204. private _depthOfFieldBlurY;
  69205. private _dofMerge;
  69206. /**
  69207. * @hidden Internal post processes in depth of field effect
  69208. */
  69209. _effects: Array<PostProcess>;
  69210. /**
  69211. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69212. */
  69213. set focalLength(value: number);
  69214. get focalLength(): number;
  69215. /**
  69216. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69217. */
  69218. set fStop(value: number);
  69219. get fStop(): number;
  69220. /**
  69221. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69222. */
  69223. set focusDistance(value: number);
  69224. get focusDistance(): number;
  69225. /**
  69226. * 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.
  69227. */
  69228. set lensSize(value: number);
  69229. get lensSize(): number;
  69230. /**
  69231. * Creates a new instance DepthOfFieldEffect
  69232. * @param scene The scene the effect belongs to.
  69233. * @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.
  69234. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69235. * @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)
  69236. */
  69237. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69238. /**
  69239. * Get the current class name of the current effet
  69240. * @returns "DepthOfFieldEffect"
  69241. */
  69242. getClassName(): string;
  69243. /**
  69244. * 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.
  69245. */
  69246. set depthTexture(value: RenderTargetTexture);
  69247. /**
  69248. * Disposes each of the internal effects for a given camera.
  69249. * @param camera The camera to dispose the effect on.
  69250. */
  69251. disposeEffects(camera: Camera): void;
  69252. /**
  69253. * @hidden Internal
  69254. */
  69255. _updateEffects(): void;
  69256. /**
  69257. * Internal
  69258. * @returns if all the contained post processes are ready.
  69259. * @hidden
  69260. */
  69261. _isReady(): boolean;
  69262. }
  69263. }
  69264. declare module BABYLON {
  69265. /** @hidden */
  69266. export var displayPassPixelShader: {
  69267. name: string;
  69268. shader: string;
  69269. };
  69270. }
  69271. declare module BABYLON {
  69272. /**
  69273. * DisplayPassPostProcess which produces an output the same as it's input
  69274. */
  69275. export class DisplayPassPostProcess extends PostProcess {
  69276. /**
  69277. * Creates the DisplayPassPostProcess
  69278. * @param name The name of the effect.
  69279. * @param options The required width/height ratio to downsize to before computing the render pass.
  69280. * @param camera The camera to apply the render pass to.
  69281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69282. * @param engine The engine which the post process will be applied. (default: current engine)
  69283. * @param reusable If the post process can be reused on the same frame. (default: false)
  69284. */
  69285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69286. }
  69287. }
  69288. declare module BABYLON {
  69289. /** @hidden */
  69290. export var filterPixelShader: {
  69291. name: string;
  69292. shader: string;
  69293. };
  69294. }
  69295. declare module BABYLON {
  69296. /**
  69297. * Applies a kernel filter to the image
  69298. */
  69299. export class FilterPostProcess extends PostProcess {
  69300. /** The matrix to be applied to the image */
  69301. kernelMatrix: Matrix;
  69302. /**
  69303. *
  69304. * @param name The name of the effect.
  69305. * @param kernelMatrix The matrix to be applied to the image
  69306. * @param options The required width/height ratio to downsize to before computing the render pass.
  69307. * @param camera The camera to apply the render pass to.
  69308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69309. * @param engine The engine which the post process will be applied. (default: current engine)
  69310. * @param reusable If the post process can be reused on the same frame. (default: false)
  69311. */
  69312. constructor(name: string,
  69313. /** The matrix to be applied to the image */
  69314. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69315. }
  69316. }
  69317. declare module BABYLON {
  69318. /** @hidden */
  69319. export var fxaaPixelShader: {
  69320. name: string;
  69321. shader: string;
  69322. };
  69323. }
  69324. declare module BABYLON {
  69325. /** @hidden */
  69326. export var fxaaVertexShader: {
  69327. name: string;
  69328. shader: string;
  69329. };
  69330. }
  69331. declare module BABYLON {
  69332. /**
  69333. * Fxaa post process
  69334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69335. */
  69336. export class FxaaPostProcess extends PostProcess {
  69337. /** @hidden */
  69338. texelWidth: number;
  69339. /** @hidden */
  69340. texelHeight: number;
  69341. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69342. private _getDefines;
  69343. }
  69344. }
  69345. declare module BABYLON {
  69346. /** @hidden */
  69347. export var grainPixelShader: {
  69348. name: string;
  69349. shader: string;
  69350. };
  69351. }
  69352. declare module BABYLON {
  69353. /**
  69354. * The GrainPostProcess adds noise to the image at mid luminance levels
  69355. */
  69356. export class GrainPostProcess extends PostProcess {
  69357. /**
  69358. * The intensity of the grain added (default: 30)
  69359. */
  69360. intensity: number;
  69361. /**
  69362. * If the grain should be randomized on every frame
  69363. */
  69364. animated: boolean;
  69365. /**
  69366. * Creates a new instance of @see GrainPostProcess
  69367. * @param name The name of the effect.
  69368. * @param options The required width/height ratio to downsize to before computing the render pass.
  69369. * @param camera The camera to apply the render pass to.
  69370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69371. * @param engine The engine which the post process will be applied. (default: current engine)
  69372. * @param reusable If the post process can be reused on the same frame. (default: false)
  69373. * @param textureType Type of textures used when performing the post process. (default: 0)
  69374. * @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)
  69375. */
  69376. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69377. }
  69378. }
  69379. declare module BABYLON {
  69380. /** @hidden */
  69381. export var highlightsPixelShader: {
  69382. name: string;
  69383. shader: string;
  69384. };
  69385. }
  69386. declare module BABYLON {
  69387. /**
  69388. * Extracts highlights from the image
  69389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69390. */
  69391. export class HighlightsPostProcess extends PostProcess {
  69392. /**
  69393. * Extracts highlights from the image
  69394. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69395. * @param name The name of the effect.
  69396. * @param options The required width/height ratio to downsize to before computing the render pass.
  69397. * @param camera The camera to apply the render pass to.
  69398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69399. * @param engine The engine which the post process will be applied. (default: current engine)
  69400. * @param reusable If the post process can be reused on the same frame. (default: false)
  69401. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69402. */
  69403. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69404. }
  69405. }
  69406. declare module BABYLON {
  69407. /** @hidden */
  69408. export var mrtFragmentDeclaration: {
  69409. name: string;
  69410. shader: string;
  69411. };
  69412. }
  69413. declare module BABYLON {
  69414. /** @hidden */
  69415. export var geometryPixelShader: {
  69416. name: string;
  69417. shader: string;
  69418. };
  69419. }
  69420. declare module BABYLON {
  69421. /** @hidden */
  69422. export var geometryVertexShader: {
  69423. name: string;
  69424. shader: string;
  69425. };
  69426. }
  69427. declare module BABYLON {
  69428. /** @hidden */
  69429. interface ISavedTransformationMatrix {
  69430. world: Matrix;
  69431. viewProjection: Matrix;
  69432. }
  69433. /**
  69434. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69435. */
  69436. export class GeometryBufferRenderer {
  69437. /**
  69438. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69439. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69440. */
  69441. static readonly POSITION_TEXTURE_TYPE: number;
  69442. /**
  69443. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69444. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69445. */
  69446. static readonly VELOCITY_TEXTURE_TYPE: number;
  69447. /**
  69448. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69449. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69450. */
  69451. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69452. /**
  69453. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69454. * in order to compute objects velocities when enableVelocity is set to "true"
  69455. * @hidden
  69456. */
  69457. _previousTransformationMatrices: {
  69458. [index: number]: ISavedTransformationMatrix;
  69459. };
  69460. /**
  69461. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69462. * in order to compute objects velocities when enableVelocity is set to "true"
  69463. * @hidden
  69464. */
  69465. _previousBonesTransformationMatrices: {
  69466. [index: number]: Float32Array;
  69467. };
  69468. /**
  69469. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69470. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69471. */
  69472. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69473. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69474. renderTransparentMeshes: boolean;
  69475. private _scene;
  69476. private _resizeObserver;
  69477. private _multiRenderTarget;
  69478. private _ratio;
  69479. private _enablePosition;
  69480. private _enableVelocity;
  69481. private _enableReflectivity;
  69482. private _positionIndex;
  69483. private _velocityIndex;
  69484. private _reflectivityIndex;
  69485. protected _effect: Effect;
  69486. protected _cachedDefines: string;
  69487. /**
  69488. * Set the render list (meshes to be rendered) used in the G buffer.
  69489. */
  69490. set renderList(meshes: Mesh[]);
  69491. /**
  69492. * Gets wether or not G buffer are supported by the running hardware.
  69493. * This requires draw buffer supports
  69494. */
  69495. get isSupported(): boolean;
  69496. /**
  69497. * Returns the index of the given texture type in the G-Buffer textures array
  69498. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69499. * @returns the index of the given texture type in the G-Buffer textures array
  69500. */
  69501. getTextureIndex(textureType: number): number;
  69502. /**
  69503. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69504. */
  69505. get enablePosition(): boolean;
  69506. /**
  69507. * Sets whether or not objects positions are enabled for the G buffer.
  69508. */
  69509. set enablePosition(enable: boolean);
  69510. /**
  69511. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69512. */
  69513. get enableVelocity(): boolean;
  69514. /**
  69515. * Sets wether or not objects velocities are enabled for the G buffer.
  69516. */
  69517. set enableVelocity(enable: boolean);
  69518. /**
  69519. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69520. */
  69521. get enableReflectivity(): boolean;
  69522. /**
  69523. * Sets wether or not objects roughness are enabled for the G buffer.
  69524. */
  69525. set enableReflectivity(enable: boolean);
  69526. /**
  69527. * Gets the scene associated with the buffer.
  69528. */
  69529. get scene(): Scene;
  69530. /**
  69531. * Gets the ratio used by the buffer during its creation.
  69532. * How big is the buffer related to the main canvas.
  69533. */
  69534. get ratio(): number;
  69535. /** @hidden */
  69536. static _SceneComponentInitialization: (scene: Scene) => void;
  69537. /**
  69538. * Creates a new G Buffer for the scene
  69539. * @param scene The scene the buffer belongs to
  69540. * @param ratio How big is the buffer related to the main canvas.
  69541. */
  69542. constructor(scene: Scene, ratio?: number);
  69543. /**
  69544. * Checks wether everything is ready to render a submesh to the G buffer.
  69545. * @param subMesh the submesh to check readiness for
  69546. * @param useInstances is the mesh drawn using instance or not
  69547. * @returns true if ready otherwise false
  69548. */
  69549. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69550. /**
  69551. * Gets the current underlying G Buffer.
  69552. * @returns the buffer
  69553. */
  69554. getGBuffer(): MultiRenderTarget;
  69555. /**
  69556. * Gets the number of samples used to render the buffer (anti aliasing).
  69557. */
  69558. get samples(): number;
  69559. /**
  69560. * Sets the number of samples used to render the buffer (anti aliasing).
  69561. */
  69562. set samples(value: number);
  69563. /**
  69564. * Disposes the renderer and frees up associated resources.
  69565. */
  69566. dispose(): void;
  69567. protected _createRenderTargets(): void;
  69568. private _copyBonesTransformationMatrices;
  69569. }
  69570. }
  69571. declare module BABYLON {
  69572. interface Scene {
  69573. /** @hidden (Backing field) */
  69574. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69575. /**
  69576. * Gets or Sets the current geometry buffer associated to the scene.
  69577. */
  69578. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69579. /**
  69580. * Enables a GeometryBufferRender and associates it with the scene
  69581. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69582. * @returns the GeometryBufferRenderer
  69583. */
  69584. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69585. /**
  69586. * Disables the GeometryBufferRender associated with the scene
  69587. */
  69588. disableGeometryBufferRenderer(): void;
  69589. }
  69590. /**
  69591. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69592. * in several rendering techniques.
  69593. */
  69594. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69595. /**
  69596. * The component name helpful to identify the component in the list of scene components.
  69597. */
  69598. readonly name: string;
  69599. /**
  69600. * The scene the component belongs to.
  69601. */
  69602. scene: Scene;
  69603. /**
  69604. * Creates a new instance of the component for the given scene
  69605. * @param scene Defines the scene to register the component in
  69606. */
  69607. constructor(scene: Scene);
  69608. /**
  69609. * Registers the component in a given scene
  69610. */
  69611. register(): void;
  69612. /**
  69613. * Rebuilds the elements related to this component in case of
  69614. * context lost for instance.
  69615. */
  69616. rebuild(): void;
  69617. /**
  69618. * Disposes the component and the associated ressources
  69619. */
  69620. dispose(): void;
  69621. private _gatherRenderTargets;
  69622. }
  69623. }
  69624. declare module BABYLON {
  69625. /** @hidden */
  69626. export var motionBlurPixelShader: {
  69627. name: string;
  69628. shader: string;
  69629. };
  69630. }
  69631. declare module BABYLON {
  69632. /**
  69633. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69634. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69635. * As an example, all you have to do is to create the post-process:
  69636. * var mb = new BABYLON.MotionBlurPostProcess(
  69637. * 'mb', // The name of the effect.
  69638. * scene, // The scene containing the objects to blur according to their velocity.
  69639. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69640. * camera // The camera to apply the render pass to.
  69641. * );
  69642. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69643. */
  69644. export class MotionBlurPostProcess extends PostProcess {
  69645. /**
  69646. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69647. */
  69648. motionStrength: number;
  69649. /**
  69650. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69651. */
  69652. get motionBlurSamples(): number;
  69653. /**
  69654. * Sets the number of iterations to be used for motion blur quality
  69655. */
  69656. set motionBlurSamples(samples: number);
  69657. private _motionBlurSamples;
  69658. private _geometryBufferRenderer;
  69659. /**
  69660. * Creates a new instance MotionBlurPostProcess
  69661. * @param name The name of the effect.
  69662. * @param scene The scene containing the objects to blur according to their velocity.
  69663. * @param options The required width/height ratio to downsize to before computing the render pass.
  69664. * @param camera The camera to apply the render pass to.
  69665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69666. * @param engine The engine which the post process will be applied. (default: current engine)
  69667. * @param reusable If the post process can be reused on the same frame. (default: false)
  69668. * @param textureType Type of textures used when performing the post process. (default: 0)
  69669. * @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)
  69670. */
  69671. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69672. /**
  69673. * Excludes the given skinned mesh from computing bones velocities.
  69674. * 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.
  69675. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69676. */
  69677. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69678. /**
  69679. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69680. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69681. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69682. */
  69683. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69684. /**
  69685. * Disposes the post process.
  69686. * @param camera The camera to dispose the post process on.
  69687. */
  69688. dispose(camera?: Camera): void;
  69689. }
  69690. }
  69691. declare module BABYLON {
  69692. /** @hidden */
  69693. export var refractionPixelShader: {
  69694. name: string;
  69695. shader: string;
  69696. };
  69697. }
  69698. declare module BABYLON {
  69699. /**
  69700. * Post process which applies a refractin texture
  69701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69702. */
  69703. export class RefractionPostProcess extends PostProcess {
  69704. /** the base color of the refraction (used to taint the rendering) */
  69705. color: Color3;
  69706. /** simulated refraction depth */
  69707. depth: number;
  69708. /** the coefficient of the base color (0 to remove base color tainting) */
  69709. colorLevel: number;
  69710. private _refTexture;
  69711. private _ownRefractionTexture;
  69712. /**
  69713. * Gets or sets the refraction texture
  69714. * Please note that you are responsible for disposing the texture if you set it manually
  69715. */
  69716. get refractionTexture(): Texture;
  69717. set refractionTexture(value: Texture);
  69718. /**
  69719. * Initializes the RefractionPostProcess
  69720. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69721. * @param name The name of the effect.
  69722. * @param refractionTextureUrl Url of the refraction texture to use
  69723. * @param color the base color of the refraction (used to taint the rendering)
  69724. * @param depth simulated refraction depth
  69725. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69726. * @param camera The camera to apply the render pass to.
  69727. * @param options The required width/height ratio to downsize to before computing the render pass.
  69728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69729. * @param engine The engine which the post process will be applied. (default: current engine)
  69730. * @param reusable If the post process can be reused on the same frame. (default: false)
  69731. */
  69732. constructor(name: string, refractionTextureUrl: string,
  69733. /** the base color of the refraction (used to taint the rendering) */
  69734. color: Color3,
  69735. /** simulated refraction depth */
  69736. depth: number,
  69737. /** the coefficient of the base color (0 to remove base color tainting) */
  69738. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69739. /**
  69740. * Disposes of the post process
  69741. * @param camera Camera to dispose post process on
  69742. */
  69743. dispose(camera: Camera): void;
  69744. }
  69745. }
  69746. declare module BABYLON {
  69747. /** @hidden */
  69748. export var sharpenPixelShader: {
  69749. name: string;
  69750. shader: string;
  69751. };
  69752. }
  69753. declare module BABYLON {
  69754. /**
  69755. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69756. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69757. */
  69758. export class SharpenPostProcess extends PostProcess {
  69759. /**
  69760. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69761. */
  69762. colorAmount: number;
  69763. /**
  69764. * How much sharpness should be applied (default: 0.3)
  69765. */
  69766. edgeAmount: number;
  69767. /**
  69768. * Creates a new instance ConvolutionPostProcess
  69769. * @param name The name of the effect.
  69770. * @param options The required width/height ratio to downsize to before computing the render pass.
  69771. * @param camera The camera to apply the render pass to.
  69772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69773. * @param engine The engine which the post process will be applied. (default: current engine)
  69774. * @param reusable If the post process can be reused on the same frame. (default: false)
  69775. * @param textureType Type of textures used when performing the post process. (default: 0)
  69776. * @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)
  69777. */
  69778. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69779. }
  69780. }
  69781. declare module BABYLON {
  69782. /**
  69783. * PostProcessRenderPipeline
  69784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69785. */
  69786. export class PostProcessRenderPipeline {
  69787. private engine;
  69788. private _renderEffects;
  69789. private _renderEffectsForIsolatedPass;
  69790. /**
  69791. * List of inspectable custom properties (used by the Inspector)
  69792. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69793. */
  69794. inspectableCustomProperties: IInspectable[];
  69795. /**
  69796. * @hidden
  69797. */
  69798. protected _cameras: Camera[];
  69799. /** @hidden */
  69800. _name: string;
  69801. /**
  69802. * Gets pipeline name
  69803. */
  69804. get name(): string;
  69805. /** Gets the list of attached cameras */
  69806. get cameras(): Camera[];
  69807. /**
  69808. * Initializes a PostProcessRenderPipeline
  69809. * @param engine engine to add the pipeline to
  69810. * @param name name of the pipeline
  69811. */
  69812. constructor(engine: Engine, name: string);
  69813. /**
  69814. * Gets the class name
  69815. * @returns "PostProcessRenderPipeline"
  69816. */
  69817. getClassName(): string;
  69818. /**
  69819. * If all the render effects in the pipeline are supported
  69820. */
  69821. get isSupported(): boolean;
  69822. /**
  69823. * Adds an effect to the pipeline
  69824. * @param renderEffect the effect to add
  69825. */
  69826. addEffect(renderEffect: PostProcessRenderEffect): void;
  69827. /** @hidden */
  69828. _rebuild(): void;
  69829. /** @hidden */
  69830. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69831. /** @hidden */
  69832. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69833. /** @hidden */
  69834. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69835. /** @hidden */
  69836. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69837. /** @hidden */
  69838. _attachCameras(cameras: Camera, unique: boolean): void;
  69839. /** @hidden */
  69840. _attachCameras(cameras: Camera[], unique: boolean): void;
  69841. /** @hidden */
  69842. _detachCameras(cameras: Camera): void;
  69843. /** @hidden */
  69844. _detachCameras(cameras: Nullable<Camera[]>): void;
  69845. /** @hidden */
  69846. _update(): void;
  69847. /** @hidden */
  69848. _reset(): void;
  69849. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69850. /**
  69851. * Sets the required values to the prepass renderer.
  69852. * @param prePassRenderer defines the prepass renderer to setup.
  69853. * @returns true if the pre pass is needed.
  69854. */
  69855. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  69856. /**
  69857. * Disposes of the pipeline
  69858. */
  69859. dispose(): void;
  69860. }
  69861. }
  69862. declare module BABYLON {
  69863. /**
  69864. * PostProcessRenderPipelineManager class
  69865. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69866. */
  69867. export class PostProcessRenderPipelineManager {
  69868. private _renderPipelines;
  69869. /**
  69870. * Initializes a PostProcessRenderPipelineManager
  69871. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69872. */
  69873. constructor();
  69874. /**
  69875. * Gets the list of supported render pipelines
  69876. */
  69877. get supportedPipelines(): PostProcessRenderPipeline[];
  69878. /**
  69879. * Adds a pipeline to the manager
  69880. * @param renderPipeline The pipeline to add
  69881. */
  69882. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69883. /**
  69884. * Attaches a camera to the pipeline
  69885. * @param renderPipelineName The name of the pipeline to attach to
  69886. * @param cameras the camera to attach
  69887. * @param unique if the camera can be attached multiple times to the pipeline
  69888. */
  69889. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69890. /**
  69891. * Detaches a camera from the pipeline
  69892. * @param renderPipelineName The name of the pipeline to detach from
  69893. * @param cameras the camera to detach
  69894. */
  69895. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69896. /**
  69897. * Enables an effect by name on a pipeline
  69898. * @param renderPipelineName the name of the pipeline to enable the effect in
  69899. * @param renderEffectName the name of the effect to enable
  69900. * @param cameras the cameras that the effect should be enabled on
  69901. */
  69902. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69903. /**
  69904. * Disables an effect by name on a pipeline
  69905. * @param renderPipelineName the name of the pipeline to disable the effect in
  69906. * @param renderEffectName the name of the effect to disable
  69907. * @param cameras the cameras that the effect should be disabled on
  69908. */
  69909. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69910. /**
  69911. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69912. */
  69913. update(): void;
  69914. /** @hidden */
  69915. _rebuild(): void;
  69916. /**
  69917. * Disposes of the manager and pipelines
  69918. */
  69919. dispose(): void;
  69920. }
  69921. }
  69922. declare module BABYLON {
  69923. interface Scene {
  69924. /** @hidden (Backing field) */
  69925. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69926. /**
  69927. * Gets the postprocess render pipeline manager
  69928. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69929. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69930. */
  69931. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69932. }
  69933. /**
  69934. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69935. */
  69936. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69937. /**
  69938. * The component name helpfull to identify the component in the list of scene components.
  69939. */
  69940. readonly name: string;
  69941. /**
  69942. * The scene the component belongs to.
  69943. */
  69944. scene: Scene;
  69945. /**
  69946. * Creates a new instance of the component for the given scene
  69947. * @param scene Defines the scene to register the component in
  69948. */
  69949. constructor(scene: Scene);
  69950. /**
  69951. * Registers the component in a given scene
  69952. */
  69953. register(): void;
  69954. /**
  69955. * Rebuilds the elements related to this component in case of
  69956. * context lost for instance.
  69957. */
  69958. rebuild(): void;
  69959. /**
  69960. * Disposes the component and the associated ressources
  69961. */
  69962. dispose(): void;
  69963. private _gatherRenderTargets;
  69964. }
  69965. }
  69966. declare module BABYLON {
  69967. /**
  69968. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69969. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69970. */
  69971. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69972. private _scene;
  69973. private _camerasToBeAttached;
  69974. /**
  69975. * ID of the sharpen post process,
  69976. */
  69977. private readonly SharpenPostProcessId;
  69978. /**
  69979. * @ignore
  69980. * ID of the image processing post process;
  69981. */
  69982. readonly ImageProcessingPostProcessId: string;
  69983. /**
  69984. * @ignore
  69985. * ID of the Fast Approximate Anti-Aliasing post process;
  69986. */
  69987. readonly FxaaPostProcessId: string;
  69988. /**
  69989. * ID of the chromatic aberration post process,
  69990. */
  69991. private readonly ChromaticAberrationPostProcessId;
  69992. /**
  69993. * ID of the grain post process
  69994. */
  69995. private readonly GrainPostProcessId;
  69996. /**
  69997. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69998. */
  69999. sharpen: SharpenPostProcess;
  70000. private _sharpenEffect;
  70001. private bloom;
  70002. /**
  70003. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70004. */
  70005. depthOfField: DepthOfFieldEffect;
  70006. /**
  70007. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70008. */
  70009. fxaa: FxaaPostProcess;
  70010. /**
  70011. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70012. */
  70013. imageProcessing: ImageProcessingPostProcess;
  70014. /**
  70015. * Chromatic aberration post process which will shift rgb colors in the image
  70016. */
  70017. chromaticAberration: ChromaticAberrationPostProcess;
  70018. private _chromaticAberrationEffect;
  70019. /**
  70020. * Grain post process which add noise to the image
  70021. */
  70022. grain: GrainPostProcess;
  70023. private _grainEffect;
  70024. /**
  70025. * Glow post process which adds a glow to emissive areas of the image
  70026. */
  70027. private _glowLayer;
  70028. /**
  70029. * Animations which can be used to tweak settings over a period of time
  70030. */
  70031. animations: Animation[];
  70032. private _imageProcessingConfigurationObserver;
  70033. private _sharpenEnabled;
  70034. private _bloomEnabled;
  70035. private _depthOfFieldEnabled;
  70036. private _depthOfFieldBlurLevel;
  70037. private _fxaaEnabled;
  70038. private _imageProcessingEnabled;
  70039. private _defaultPipelineTextureType;
  70040. private _bloomScale;
  70041. private _chromaticAberrationEnabled;
  70042. private _grainEnabled;
  70043. private _buildAllowed;
  70044. /**
  70045. * Gets active scene
  70046. */
  70047. get scene(): Scene;
  70048. /**
  70049. * Enable or disable the sharpen process from the pipeline
  70050. */
  70051. set sharpenEnabled(enabled: boolean);
  70052. get sharpenEnabled(): boolean;
  70053. private _resizeObserver;
  70054. private _hardwareScaleLevel;
  70055. private _bloomKernel;
  70056. /**
  70057. * Specifies the size of the bloom blur kernel, relative to the final output size
  70058. */
  70059. get bloomKernel(): number;
  70060. set bloomKernel(value: number);
  70061. /**
  70062. * Specifies the weight of the bloom in the final rendering
  70063. */
  70064. private _bloomWeight;
  70065. /**
  70066. * Specifies the luma threshold for the area that will be blurred by the bloom
  70067. */
  70068. private _bloomThreshold;
  70069. private _hdr;
  70070. /**
  70071. * The strength of the bloom.
  70072. */
  70073. set bloomWeight(value: number);
  70074. get bloomWeight(): number;
  70075. /**
  70076. * The strength of the bloom.
  70077. */
  70078. set bloomThreshold(value: number);
  70079. get bloomThreshold(): number;
  70080. /**
  70081. * The scale of the bloom, lower value will provide better performance.
  70082. */
  70083. set bloomScale(value: number);
  70084. get bloomScale(): number;
  70085. /**
  70086. * Enable or disable the bloom from the pipeline
  70087. */
  70088. set bloomEnabled(enabled: boolean);
  70089. get bloomEnabled(): boolean;
  70090. private _rebuildBloom;
  70091. /**
  70092. * If the depth of field is enabled.
  70093. */
  70094. get depthOfFieldEnabled(): boolean;
  70095. set depthOfFieldEnabled(enabled: boolean);
  70096. /**
  70097. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70098. */
  70099. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70100. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70101. /**
  70102. * If the anti aliasing is enabled.
  70103. */
  70104. set fxaaEnabled(enabled: boolean);
  70105. get fxaaEnabled(): boolean;
  70106. private _samples;
  70107. /**
  70108. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70109. */
  70110. set samples(sampleCount: number);
  70111. get samples(): number;
  70112. /**
  70113. * If image processing is enabled.
  70114. */
  70115. set imageProcessingEnabled(enabled: boolean);
  70116. get imageProcessingEnabled(): boolean;
  70117. /**
  70118. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70119. */
  70120. set glowLayerEnabled(enabled: boolean);
  70121. get glowLayerEnabled(): boolean;
  70122. /**
  70123. * Gets the glow layer (or null if not defined)
  70124. */
  70125. get glowLayer(): Nullable<GlowLayer>;
  70126. /**
  70127. * Enable or disable the chromaticAberration process from the pipeline
  70128. */
  70129. set chromaticAberrationEnabled(enabled: boolean);
  70130. get chromaticAberrationEnabled(): boolean;
  70131. /**
  70132. * Enable or disable the grain process from the pipeline
  70133. */
  70134. set grainEnabled(enabled: boolean);
  70135. get grainEnabled(): boolean;
  70136. /**
  70137. * @constructor
  70138. * @param name - The rendering pipeline name (default: "")
  70139. * @param hdr - If high dynamic range textures should be used (default: true)
  70140. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70141. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70142. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70143. */
  70144. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70145. /**
  70146. * Get the class name
  70147. * @returns "DefaultRenderingPipeline"
  70148. */
  70149. getClassName(): string;
  70150. /**
  70151. * Force the compilation of the entire pipeline.
  70152. */
  70153. prepare(): void;
  70154. private _hasCleared;
  70155. private _prevPostProcess;
  70156. private _prevPrevPostProcess;
  70157. private _setAutoClearAndTextureSharing;
  70158. private _depthOfFieldSceneObserver;
  70159. private _buildPipeline;
  70160. private _disposePostProcesses;
  70161. /**
  70162. * Adds a camera to the pipeline
  70163. * @param camera the camera to be added
  70164. */
  70165. addCamera(camera: Camera): void;
  70166. /**
  70167. * Removes a camera from the pipeline
  70168. * @param camera the camera to remove
  70169. */
  70170. removeCamera(camera: Camera): void;
  70171. /**
  70172. * Dispose of the pipeline and stop all post processes
  70173. */
  70174. dispose(): void;
  70175. /**
  70176. * Serialize the rendering pipeline (Used when exporting)
  70177. * @returns the serialized object
  70178. */
  70179. serialize(): any;
  70180. /**
  70181. * Parse the serialized pipeline
  70182. * @param source Source pipeline.
  70183. * @param scene The scene to load the pipeline to.
  70184. * @param rootUrl The URL of the serialized pipeline.
  70185. * @returns An instantiated pipeline from the serialized object.
  70186. */
  70187. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70188. }
  70189. }
  70190. declare module BABYLON {
  70191. /** @hidden */
  70192. export var lensHighlightsPixelShader: {
  70193. name: string;
  70194. shader: string;
  70195. };
  70196. }
  70197. declare module BABYLON {
  70198. /** @hidden */
  70199. export var depthOfFieldPixelShader: {
  70200. name: string;
  70201. shader: string;
  70202. };
  70203. }
  70204. declare module BABYLON {
  70205. /**
  70206. * BABYLON.JS Chromatic Aberration GLSL Shader
  70207. * Author: Olivier Guyot
  70208. * Separates very slightly R, G and B colors on the edges of the screen
  70209. * Inspired by Francois Tarlier & Martins Upitis
  70210. */
  70211. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70212. /**
  70213. * @ignore
  70214. * The chromatic aberration PostProcess id in the pipeline
  70215. */
  70216. LensChromaticAberrationEffect: string;
  70217. /**
  70218. * @ignore
  70219. * The highlights enhancing PostProcess id in the pipeline
  70220. */
  70221. HighlightsEnhancingEffect: string;
  70222. /**
  70223. * @ignore
  70224. * The depth-of-field PostProcess id in the pipeline
  70225. */
  70226. LensDepthOfFieldEffect: string;
  70227. private _scene;
  70228. private _depthTexture;
  70229. private _grainTexture;
  70230. private _chromaticAberrationPostProcess;
  70231. private _highlightsPostProcess;
  70232. private _depthOfFieldPostProcess;
  70233. private _edgeBlur;
  70234. private _grainAmount;
  70235. private _chromaticAberration;
  70236. private _distortion;
  70237. private _highlightsGain;
  70238. private _highlightsThreshold;
  70239. private _dofDistance;
  70240. private _dofAperture;
  70241. private _dofDarken;
  70242. private _dofPentagon;
  70243. private _blurNoise;
  70244. /**
  70245. * @constructor
  70246. *
  70247. * Effect parameters are as follow:
  70248. * {
  70249. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70250. * edge_blur: number; // from 0 to x (1 for realism)
  70251. * distortion: number; // from 0 to x (1 for realism)
  70252. * grain_amount: number; // from 0 to 1
  70253. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70254. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70255. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70256. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70257. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70258. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70259. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70260. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70261. * }
  70262. * Note: if an effect parameter is unset, effect is disabled
  70263. *
  70264. * @param name The rendering pipeline name
  70265. * @param parameters - An object containing all parameters (see above)
  70266. * @param scene The scene linked to this pipeline
  70267. * @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)
  70268. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70269. */
  70270. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70271. /**
  70272. * Get the class name
  70273. * @returns "LensRenderingPipeline"
  70274. */
  70275. getClassName(): string;
  70276. /**
  70277. * Gets associated scene
  70278. */
  70279. get scene(): Scene;
  70280. /**
  70281. * Gets or sets the edge blur
  70282. */
  70283. get edgeBlur(): number;
  70284. set edgeBlur(value: number);
  70285. /**
  70286. * Gets or sets the grain amount
  70287. */
  70288. get grainAmount(): number;
  70289. set grainAmount(value: number);
  70290. /**
  70291. * Gets or sets the chromatic aberration amount
  70292. */
  70293. get chromaticAberration(): number;
  70294. set chromaticAberration(value: number);
  70295. /**
  70296. * Gets or sets the depth of field aperture
  70297. */
  70298. get dofAperture(): number;
  70299. set dofAperture(value: number);
  70300. /**
  70301. * Gets or sets the edge distortion
  70302. */
  70303. get edgeDistortion(): number;
  70304. set edgeDistortion(value: number);
  70305. /**
  70306. * Gets or sets the depth of field distortion
  70307. */
  70308. get dofDistortion(): number;
  70309. set dofDistortion(value: number);
  70310. /**
  70311. * Gets or sets the darken out of focus amount
  70312. */
  70313. get darkenOutOfFocus(): number;
  70314. set darkenOutOfFocus(value: number);
  70315. /**
  70316. * Gets or sets a boolean indicating if blur noise is enabled
  70317. */
  70318. get blurNoise(): boolean;
  70319. set blurNoise(value: boolean);
  70320. /**
  70321. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70322. */
  70323. get pentagonBokeh(): boolean;
  70324. set pentagonBokeh(value: boolean);
  70325. /**
  70326. * Gets or sets the highlight grain amount
  70327. */
  70328. get highlightsGain(): number;
  70329. set highlightsGain(value: number);
  70330. /**
  70331. * Gets or sets the highlight threshold
  70332. */
  70333. get highlightsThreshold(): number;
  70334. set highlightsThreshold(value: number);
  70335. /**
  70336. * Sets the amount of blur at the edges
  70337. * @param amount blur amount
  70338. */
  70339. setEdgeBlur(amount: number): void;
  70340. /**
  70341. * Sets edge blur to 0
  70342. */
  70343. disableEdgeBlur(): void;
  70344. /**
  70345. * Sets the amout of grain
  70346. * @param amount Amount of grain
  70347. */
  70348. setGrainAmount(amount: number): void;
  70349. /**
  70350. * Set grain amount to 0
  70351. */
  70352. disableGrain(): void;
  70353. /**
  70354. * Sets the chromatic aberration amount
  70355. * @param amount amount of chromatic aberration
  70356. */
  70357. setChromaticAberration(amount: number): void;
  70358. /**
  70359. * Sets chromatic aberration amount to 0
  70360. */
  70361. disableChromaticAberration(): void;
  70362. /**
  70363. * Sets the EdgeDistortion amount
  70364. * @param amount amount of EdgeDistortion
  70365. */
  70366. setEdgeDistortion(amount: number): void;
  70367. /**
  70368. * Sets edge distortion to 0
  70369. */
  70370. disableEdgeDistortion(): void;
  70371. /**
  70372. * Sets the FocusDistance amount
  70373. * @param amount amount of FocusDistance
  70374. */
  70375. setFocusDistance(amount: number): void;
  70376. /**
  70377. * Disables depth of field
  70378. */
  70379. disableDepthOfField(): void;
  70380. /**
  70381. * Sets the Aperture amount
  70382. * @param amount amount of Aperture
  70383. */
  70384. setAperture(amount: number): void;
  70385. /**
  70386. * Sets the DarkenOutOfFocus amount
  70387. * @param amount amount of DarkenOutOfFocus
  70388. */
  70389. setDarkenOutOfFocus(amount: number): void;
  70390. private _pentagonBokehIsEnabled;
  70391. /**
  70392. * Creates a pentagon bokeh effect
  70393. */
  70394. enablePentagonBokeh(): void;
  70395. /**
  70396. * Disables the pentagon bokeh effect
  70397. */
  70398. disablePentagonBokeh(): void;
  70399. /**
  70400. * Enables noise blur
  70401. */
  70402. enableNoiseBlur(): void;
  70403. /**
  70404. * Disables noise blur
  70405. */
  70406. disableNoiseBlur(): void;
  70407. /**
  70408. * Sets the HighlightsGain amount
  70409. * @param amount amount of HighlightsGain
  70410. */
  70411. setHighlightsGain(amount: number): void;
  70412. /**
  70413. * Sets the HighlightsThreshold amount
  70414. * @param amount amount of HighlightsThreshold
  70415. */
  70416. setHighlightsThreshold(amount: number): void;
  70417. /**
  70418. * Disables highlights
  70419. */
  70420. disableHighlights(): void;
  70421. /**
  70422. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70423. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70424. */
  70425. dispose(disableDepthRender?: boolean): void;
  70426. private _createChromaticAberrationPostProcess;
  70427. private _createHighlightsPostProcess;
  70428. private _createDepthOfFieldPostProcess;
  70429. private _createGrainTexture;
  70430. }
  70431. }
  70432. declare module BABYLON {
  70433. /** @hidden */
  70434. export var ssao2PixelShader: {
  70435. name: string;
  70436. shader: string;
  70437. };
  70438. }
  70439. declare module BABYLON {
  70440. /** @hidden */
  70441. export var ssaoCombinePixelShader: {
  70442. name: string;
  70443. shader: string;
  70444. };
  70445. }
  70446. declare module BABYLON {
  70447. /**
  70448. * Render pipeline to produce ssao effect
  70449. */
  70450. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70451. /**
  70452. * @ignore
  70453. * The PassPostProcess id in the pipeline that contains the original scene color
  70454. */
  70455. SSAOOriginalSceneColorEffect: string;
  70456. /**
  70457. * @ignore
  70458. * The SSAO PostProcess id in the pipeline
  70459. */
  70460. SSAORenderEffect: string;
  70461. /**
  70462. * @ignore
  70463. * The horizontal blur PostProcess id in the pipeline
  70464. */
  70465. SSAOBlurHRenderEffect: string;
  70466. /**
  70467. * @ignore
  70468. * The vertical blur PostProcess id in the pipeline
  70469. */
  70470. SSAOBlurVRenderEffect: string;
  70471. /**
  70472. * @ignore
  70473. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70474. */
  70475. SSAOCombineRenderEffect: string;
  70476. /**
  70477. * The output strength of the SSAO post-process. Default value is 1.0.
  70478. */
  70479. totalStrength: number;
  70480. /**
  70481. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70482. */
  70483. maxZ: number;
  70484. /**
  70485. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70486. */
  70487. minZAspect: number;
  70488. private _samples;
  70489. /**
  70490. * Number of samples used for the SSAO calculations. Default value is 8
  70491. */
  70492. set samples(n: number);
  70493. get samples(): number;
  70494. private _textureSamples;
  70495. /**
  70496. * Number of samples to use for antialiasing
  70497. */
  70498. set textureSamples(n: number);
  70499. get textureSamples(): number;
  70500. /**
  70501. * Force rendering the geometry through geometry buffer
  70502. */
  70503. private _forceGeometryBuffer;
  70504. /**
  70505. * Ratio object used for SSAO ratio and blur ratio
  70506. */
  70507. private _ratio;
  70508. /**
  70509. * Dynamically generated sphere sampler.
  70510. */
  70511. private _sampleSphere;
  70512. /**
  70513. * Blur filter offsets
  70514. */
  70515. private _samplerOffsets;
  70516. private _expensiveBlur;
  70517. /**
  70518. * If bilateral blur should be used
  70519. */
  70520. set expensiveBlur(b: boolean);
  70521. get expensiveBlur(): boolean;
  70522. /**
  70523. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70524. */
  70525. radius: number;
  70526. /**
  70527. * The base color of the SSAO post-process
  70528. * The final result is "base + ssao" between [0, 1]
  70529. */
  70530. base: number;
  70531. /**
  70532. * Support test.
  70533. */
  70534. static get IsSupported(): boolean;
  70535. private _scene;
  70536. private _randomTexture;
  70537. private _originalColorPostProcess;
  70538. private _ssaoPostProcess;
  70539. private _blurHPostProcess;
  70540. private _blurVPostProcess;
  70541. private _ssaoCombinePostProcess;
  70542. private _prePassRenderer;
  70543. /**
  70544. * Gets active scene
  70545. */
  70546. get scene(): Scene;
  70547. /**
  70548. * @constructor
  70549. * @param name The rendering pipeline name
  70550. * @param scene The scene linked to this pipeline
  70551. * @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 }
  70552. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70553. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70554. */
  70555. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70556. /**
  70557. * Get the class name
  70558. * @returns "SSAO2RenderingPipeline"
  70559. */
  70560. getClassName(): string;
  70561. /**
  70562. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70563. */
  70564. dispose(disableGeometryBufferRenderer?: boolean): void;
  70565. private _createBlurPostProcess;
  70566. /** @hidden */
  70567. _rebuild(): void;
  70568. private _bits;
  70569. private _radicalInverse_VdC;
  70570. private _hammersley;
  70571. private _hemisphereSample_uniform;
  70572. private _generateHemisphere;
  70573. private _getDefinesForSSAO;
  70574. private _createSSAOPostProcess;
  70575. private _createSSAOCombinePostProcess;
  70576. private _createRandomTexture;
  70577. /**
  70578. * Serialize the rendering pipeline (Used when exporting)
  70579. * @returns the serialized object
  70580. */
  70581. serialize(): any;
  70582. /**
  70583. * Parse the serialized pipeline
  70584. * @param source Source pipeline.
  70585. * @param scene The scene to load the pipeline to.
  70586. * @param rootUrl The URL of the serialized pipeline.
  70587. * @returns An instantiated pipeline from the serialized object.
  70588. */
  70589. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70590. /**
  70591. * Sets the required values to the prepass renderer.
  70592. * @param prePassRenderer defines the prepass renderer to setup
  70593. * @returns true if the pre pass is needed.
  70594. */
  70595. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70596. }
  70597. }
  70598. declare module BABYLON {
  70599. /** @hidden */
  70600. export var ssaoPixelShader: {
  70601. name: string;
  70602. shader: string;
  70603. };
  70604. }
  70605. declare module BABYLON {
  70606. /**
  70607. * Render pipeline to produce ssao effect
  70608. */
  70609. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70610. /**
  70611. * @ignore
  70612. * The PassPostProcess id in the pipeline that contains the original scene color
  70613. */
  70614. SSAOOriginalSceneColorEffect: string;
  70615. /**
  70616. * @ignore
  70617. * The SSAO PostProcess id in the pipeline
  70618. */
  70619. SSAORenderEffect: string;
  70620. /**
  70621. * @ignore
  70622. * The horizontal blur PostProcess id in the pipeline
  70623. */
  70624. SSAOBlurHRenderEffect: string;
  70625. /**
  70626. * @ignore
  70627. * The vertical blur PostProcess id in the pipeline
  70628. */
  70629. SSAOBlurVRenderEffect: string;
  70630. /**
  70631. * @ignore
  70632. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70633. */
  70634. SSAOCombineRenderEffect: string;
  70635. /**
  70636. * The output strength of the SSAO post-process. Default value is 1.0.
  70637. */
  70638. totalStrength: number;
  70639. /**
  70640. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70641. */
  70642. radius: number;
  70643. /**
  70644. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70645. * Must not be equal to fallOff and superior to fallOff.
  70646. * Default value is 0.0075
  70647. */
  70648. area: number;
  70649. /**
  70650. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70651. * Must not be equal to area and inferior to area.
  70652. * Default value is 0.000001
  70653. */
  70654. fallOff: number;
  70655. /**
  70656. * The base color of the SSAO post-process
  70657. * The final result is "base + ssao" between [0, 1]
  70658. */
  70659. base: number;
  70660. private _scene;
  70661. private _depthTexture;
  70662. private _randomTexture;
  70663. private _originalColorPostProcess;
  70664. private _ssaoPostProcess;
  70665. private _blurHPostProcess;
  70666. private _blurVPostProcess;
  70667. private _ssaoCombinePostProcess;
  70668. private _firstUpdate;
  70669. /**
  70670. * Gets active scene
  70671. */
  70672. get scene(): Scene;
  70673. /**
  70674. * @constructor
  70675. * @param name - The rendering pipeline name
  70676. * @param scene - The scene linked to this pipeline
  70677. * @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 }
  70678. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70679. */
  70680. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70681. /**
  70682. * Get the class name
  70683. * @returns "SSAORenderingPipeline"
  70684. */
  70685. getClassName(): string;
  70686. /**
  70687. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70688. */
  70689. dispose(disableDepthRender?: boolean): void;
  70690. private _createBlurPostProcess;
  70691. /** @hidden */
  70692. _rebuild(): void;
  70693. private _createSSAOPostProcess;
  70694. private _createSSAOCombinePostProcess;
  70695. private _createRandomTexture;
  70696. }
  70697. }
  70698. declare module BABYLON {
  70699. /** @hidden */
  70700. export var screenSpaceReflectionPixelShader: {
  70701. name: string;
  70702. shader: string;
  70703. };
  70704. }
  70705. declare module BABYLON {
  70706. /**
  70707. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70708. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70709. */
  70710. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70711. /**
  70712. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70713. */
  70714. threshold: number;
  70715. /**
  70716. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70717. */
  70718. strength: number;
  70719. /**
  70720. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70721. */
  70722. reflectionSpecularFalloffExponent: number;
  70723. /**
  70724. * 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]
  70725. */
  70726. step: number;
  70727. /**
  70728. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70729. */
  70730. roughnessFactor: number;
  70731. private _geometryBufferRenderer;
  70732. private _enableSmoothReflections;
  70733. private _reflectionSamples;
  70734. private _smoothSteps;
  70735. /**
  70736. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70737. * @param name The name of the effect.
  70738. * @param scene The scene containing the objects to calculate reflections.
  70739. * @param options The required width/height ratio to downsize to before computing the render pass.
  70740. * @param camera The camera to apply the render pass to.
  70741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70742. * @param engine The engine which the post process will be applied. (default: current engine)
  70743. * @param reusable If the post process can be reused on the same frame. (default: false)
  70744. * @param textureType Type of textures used when performing the post process. (default: 0)
  70745. * @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)
  70746. */
  70747. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70748. /**
  70749. * Gets wether or not smoothing reflections is enabled.
  70750. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70751. */
  70752. get enableSmoothReflections(): boolean;
  70753. /**
  70754. * Sets wether or not smoothing reflections is enabled.
  70755. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70756. */
  70757. set enableSmoothReflections(enabled: boolean);
  70758. /**
  70759. * Gets the number of samples taken while computing reflections. More samples count is high,
  70760. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70761. */
  70762. get reflectionSamples(): number;
  70763. /**
  70764. * Sets the number of samples taken while computing reflections. More samples count is high,
  70765. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70766. */
  70767. set reflectionSamples(samples: number);
  70768. /**
  70769. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70770. * more the post-process will require GPU power and can generate a drop in FPS.
  70771. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70772. */
  70773. get smoothSteps(): number;
  70774. set smoothSteps(steps: number);
  70775. private _updateEffectDefines;
  70776. }
  70777. }
  70778. declare module BABYLON {
  70779. /** @hidden */
  70780. export var standardPixelShader: {
  70781. name: string;
  70782. shader: string;
  70783. };
  70784. }
  70785. declare module BABYLON {
  70786. /**
  70787. * Standard rendering pipeline
  70788. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70789. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70790. */
  70791. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70792. /**
  70793. * Public members
  70794. */
  70795. /**
  70796. * Post-process which contains the original scene color before the pipeline applies all the effects
  70797. */
  70798. originalPostProcess: Nullable<PostProcess>;
  70799. /**
  70800. * Post-process used to down scale an image x4
  70801. */
  70802. downSampleX4PostProcess: Nullable<PostProcess>;
  70803. /**
  70804. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70805. */
  70806. brightPassPostProcess: Nullable<PostProcess>;
  70807. /**
  70808. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70809. */
  70810. blurHPostProcesses: PostProcess[];
  70811. /**
  70812. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70813. */
  70814. blurVPostProcesses: PostProcess[];
  70815. /**
  70816. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70817. */
  70818. textureAdderPostProcess: Nullable<PostProcess>;
  70819. /**
  70820. * Post-process used to create volumetric lighting effect
  70821. */
  70822. volumetricLightPostProcess: Nullable<PostProcess>;
  70823. /**
  70824. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70825. */
  70826. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70827. /**
  70828. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70829. */
  70830. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70831. /**
  70832. * Post-process used to merge the volumetric light effect and the real scene color
  70833. */
  70834. volumetricLightMergePostProces: Nullable<PostProcess>;
  70835. /**
  70836. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70837. */
  70838. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70839. /**
  70840. * Base post-process used to calculate the average luminance of the final image for HDR
  70841. */
  70842. luminancePostProcess: Nullable<PostProcess>;
  70843. /**
  70844. * Post-processes used to create down sample post-processes in order to get
  70845. * the average luminance of the final image for HDR
  70846. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70847. */
  70848. luminanceDownSamplePostProcesses: PostProcess[];
  70849. /**
  70850. * Post-process used to create a HDR effect (light adaptation)
  70851. */
  70852. hdrPostProcess: Nullable<PostProcess>;
  70853. /**
  70854. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70855. */
  70856. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70857. /**
  70858. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70859. */
  70860. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70861. /**
  70862. * Post-process used to merge the final HDR post-process and the real scene color
  70863. */
  70864. hdrFinalPostProcess: Nullable<PostProcess>;
  70865. /**
  70866. * Post-process used to create a lens flare effect
  70867. */
  70868. lensFlarePostProcess: Nullable<PostProcess>;
  70869. /**
  70870. * Post-process that merges the result of the lens flare post-process and the real scene color
  70871. */
  70872. lensFlareComposePostProcess: Nullable<PostProcess>;
  70873. /**
  70874. * Post-process used to create a motion blur effect
  70875. */
  70876. motionBlurPostProcess: Nullable<PostProcess>;
  70877. /**
  70878. * Post-process used to create a depth of field effect
  70879. */
  70880. depthOfFieldPostProcess: Nullable<PostProcess>;
  70881. /**
  70882. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70883. */
  70884. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70885. /**
  70886. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70887. */
  70888. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70889. /**
  70890. * Represents the brightness threshold in order to configure the illuminated surfaces
  70891. */
  70892. brightThreshold: number;
  70893. /**
  70894. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70895. */
  70896. blurWidth: number;
  70897. /**
  70898. * Sets if the blur for highlighted surfaces must be only horizontal
  70899. */
  70900. horizontalBlur: boolean;
  70901. /**
  70902. * Gets the overall exposure used by the pipeline
  70903. */
  70904. get exposure(): number;
  70905. /**
  70906. * Sets the overall exposure used by the pipeline
  70907. */
  70908. set exposure(value: number);
  70909. /**
  70910. * Texture used typically to simulate "dirty" on camera lens
  70911. */
  70912. lensTexture: Nullable<Texture>;
  70913. /**
  70914. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70915. */
  70916. volumetricLightCoefficient: number;
  70917. /**
  70918. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70919. */
  70920. volumetricLightPower: number;
  70921. /**
  70922. * Used the set the blur intensity to smooth the volumetric lights
  70923. */
  70924. volumetricLightBlurScale: number;
  70925. /**
  70926. * Light (spot or directional) used to generate the volumetric lights rays
  70927. * The source light must have a shadow generate so the pipeline can get its
  70928. * depth map
  70929. */
  70930. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70931. /**
  70932. * For eye adaptation, represents the minimum luminance the eye can see
  70933. */
  70934. hdrMinimumLuminance: number;
  70935. /**
  70936. * For eye adaptation, represents the decrease luminance speed
  70937. */
  70938. hdrDecreaseRate: number;
  70939. /**
  70940. * For eye adaptation, represents the increase luminance speed
  70941. */
  70942. hdrIncreaseRate: number;
  70943. /**
  70944. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70945. */
  70946. get hdrAutoExposure(): boolean;
  70947. /**
  70948. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70949. */
  70950. set hdrAutoExposure(value: boolean);
  70951. /**
  70952. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70953. */
  70954. lensColorTexture: Nullable<Texture>;
  70955. /**
  70956. * The overall strengh for the lens flare effect
  70957. */
  70958. lensFlareStrength: number;
  70959. /**
  70960. * Dispersion coefficient for lens flare ghosts
  70961. */
  70962. lensFlareGhostDispersal: number;
  70963. /**
  70964. * Main lens flare halo width
  70965. */
  70966. lensFlareHaloWidth: number;
  70967. /**
  70968. * Based on the lens distortion effect, defines how much the lens flare result
  70969. * is distorted
  70970. */
  70971. lensFlareDistortionStrength: number;
  70972. /**
  70973. * Configures the blur intensity used for for lens flare (halo)
  70974. */
  70975. lensFlareBlurWidth: number;
  70976. /**
  70977. * Lens star texture must be used to simulate rays on the flares and is available
  70978. * in the documentation
  70979. */
  70980. lensStarTexture: Nullable<Texture>;
  70981. /**
  70982. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70983. * flare effect by taking account of the dirt texture
  70984. */
  70985. lensFlareDirtTexture: Nullable<Texture>;
  70986. /**
  70987. * Represents the focal length for the depth of field effect
  70988. */
  70989. depthOfFieldDistance: number;
  70990. /**
  70991. * Represents the blur intensity for the blurred part of the depth of field effect
  70992. */
  70993. depthOfFieldBlurWidth: number;
  70994. /**
  70995. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70996. */
  70997. get motionStrength(): number;
  70998. /**
  70999. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71000. */
  71001. set motionStrength(strength: number);
  71002. /**
  71003. * Gets wether or not the motion blur post-process is object based or screen based.
  71004. */
  71005. get objectBasedMotionBlur(): boolean;
  71006. /**
  71007. * Sets wether or not the motion blur post-process should be object based or screen based
  71008. */
  71009. set objectBasedMotionBlur(value: boolean);
  71010. /**
  71011. * List of animations for the pipeline (IAnimatable implementation)
  71012. */
  71013. animations: Animation[];
  71014. /**
  71015. * Private members
  71016. */
  71017. private _scene;
  71018. private _currentDepthOfFieldSource;
  71019. private _basePostProcess;
  71020. private _fixedExposure;
  71021. private _currentExposure;
  71022. private _hdrAutoExposure;
  71023. private _hdrCurrentLuminance;
  71024. private _motionStrength;
  71025. private _isObjectBasedMotionBlur;
  71026. private _floatTextureType;
  71027. private _camerasToBeAttached;
  71028. private _ratio;
  71029. private _bloomEnabled;
  71030. private _depthOfFieldEnabled;
  71031. private _vlsEnabled;
  71032. private _lensFlareEnabled;
  71033. private _hdrEnabled;
  71034. private _motionBlurEnabled;
  71035. private _fxaaEnabled;
  71036. private _screenSpaceReflectionsEnabled;
  71037. private _motionBlurSamples;
  71038. private _volumetricLightStepsCount;
  71039. private _samples;
  71040. /**
  71041. * @ignore
  71042. * Specifies if the bloom pipeline is enabled
  71043. */
  71044. get BloomEnabled(): boolean;
  71045. set BloomEnabled(enabled: boolean);
  71046. /**
  71047. * @ignore
  71048. * Specifies if the depth of field pipeline is enabed
  71049. */
  71050. get DepthOfFieldEnabled(): boolean;
  71051. set DepthOfFieldEnabled(enabled: boolean);
  71052. /**
  71053. * @ignore
  71054. * Specifies if the lens flare pipeline is enabed
  71055. */
  71056. get LensFlareEnabled(): boolean;
  71057. set LensFlareEnabled(enabled: boolean);
  71058. /**
  71059. * @ignore
  71060. * Specifies if the HDR pipeline is enabled
  71061. */
  71062. get HDREnabled(): boolean;
  71063. set HDREnabled(enabled: boolean);
  71064. /**
  71065. * @ignore
  71066. * Specifies if the volumetric lights scattering effect is enabled
  71067. */
  71068. get VLSEnabled(): boolean;
  71069. set VLSEnabled(enabled: boolean);
  71070. /**
  71071. * @ignore
  71072. * Specifies if the motion blur effect is enabled
  71073. */
  71074. get MotionBlurEnabled(): boolean;
  71075. set MotionBlurEnabled(enabled: boolean);
  71076. /**
  71077. * Specifies if anti-aliasing is enabled
  71078. */
  71079. get fxaaEnabled(): boolean;
  71080. set fxaaEnabled(enabled: boolean);
  71081. /**
  71082. * Specifies if screen space reflections are enabled.
  71083. */
  71084. get screenSpaceReflectionsEnabled(): boolean;
  71085. set screenSpaceReflectionsEnabled(enabled: boolean);
  71086. /**
  71087. * Specifies the number of steps used to calculate the volumetric lights
  71088. * Typically in interval [50, 200]
  71089. */
  71090. get volumetricLightStepsCount(): number;
  71091. set volumetricLightStepsCount(count: number);
  71092. /**
  71093. * Specifies the number of samples used for the motion blur effect
  71094. * Typically in interval [16, 64]
  71095. */
  71096. get motionBlurSamples(): number;
  71097. set motionBlurSamples(samples: number);
  71098. /**
  71099. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71100. */
  71101. get samples(): number;
  71102. set samples(sampleCount: number);
  71103. /**
  71104. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71105. * @constructor
  71106. * @param name The rendering pipeline name
  71107. * @param scene The scene linked to this pipeline
  71108. * @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)
  71109. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71110. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71111. */
  71112. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71113. private _buildPipeline;
  71114. private _createDownSampleX4PostProcess;
  71115. private _createBrightPassPostProcess;
  71116. private _createBlurPostProcesses;
  71117. private _createTextureAdderPostProcess;
  71118. private _createVolumetricLightPostProcess;
  71119. private _createLuminancePostProcesses;
  71120. private _createHdrPostProcess;
  71121. private _createLensFlarePostProcess;
  71122. private _createDepthOfFieldPostProcess;
  71123. private _createMotionBlurPostProcess;
  71124. private _getDepthTexture;
  71125. private _disposePostProcesses;
  71126. /**
  71127. * Dispose of the pipeline and stop all post processes
  71128. */
  71129. dispose(): void;
  71130. /**
  71131. * Serialize the rendering pipeline (Used when exporting)
  71132. * @returns the serialized object
  71133. */
  71134. serialize(): any;
  71135. /**
  71136. * Parse the serialized pipeline
  71137. * @param source Source pipeline.
  71138. * @param scene The scene to load the pipeline to.
  71139. * @param rootUrl The URL of the serialized pipeline.
  71140. * @returns An instantiated pipeline from the serialized object.
  71141. */
  71142. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71143. /**
  71144. * Luminance steps
  71145. */
  71146. static LuminanceSteps: number;
  71147. }
  71148. }
  71149. declare module BABYLON {
  71150. /** @hidden */
  71151. export var stereoscopicInterlacePixelShader: {
  71152. name: string;
  71153. shader: string;
  71154. };
  71155. }
  71156. declare module BABYLON {
  71157. /**
  71158. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71159. */
  71160. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71161. private _stepSize;
  71162. private _passedProcess;
  71163. /**
  71164. * Initializes a StereoscopicInterlacePostProcessI
  71165. * @param name The name of the effect.
  71166. * @param rigCameras The rig cameras to be appled to the post process
  71167. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71168. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71170. * @param engine The engine which the post process will be applied. (default: current engine)
  71171. * @param reusable If the post process can be reused on the same frame. (default: false)
  71172. */
  71173. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71174. }
  71175. /**
  71176. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71177. */
  71178. export class StereoscopicInterlacePostProcess extends PostProcess {
  71179. private _stepSize;
  71180. private _passedProcess;
  71181. /**
  71182. * Initializes a StereoscopicInterlacePostProcess
  71183. * @param name The name of the effect.
  71184. * @param rigCameras The rig cameras to be appled to the post process
  71185. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71187. * @param engine The engine which the post process will be applied. (default: current engine)
  71188. * @param reusable If the post process can be reused on the same frame. (default: false)
  71189. */
  71190. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71191. }
  71192. }
  71193. declare module BABYLON {
  71194. /** @hidden */
  71195. export var tonemapPixelShader: {
  71196. name: string;
  71197. shader: string;
  71198. };
  71199. }
  71200. declare module BABYLON {
  71201. /** Defines operator used for tonemapping */
  71202. export enum TonemappingOperator {
  71203. /** Hable */
  71204. Hable = 0,
  71205. /** Reinhard */
  71206. Reinhard = 1,
  71207. /** HejiDawson */
  71208. HejiDawson = 2,
  71209. /** Photographic */
  71210. Photographic = 3
  71211. }
  71212. /**
  71213. * Defines a post process to apply tone mapping
  71214. */
  71215. export class TonemapPostProcess extends PostProcess {
  71216. private _operator;
  71217. /** Defines the required exposure adjustement */
  71218. exposureAdjustment: number;
  71219. /**
  71220. * Creates a new TonemapPostProcess
  71221. * @param name defines the name of the postprocess
  71222. * @param _operator defines the operator to use
  71223. * @param exposureAdjustment defines the required exposure adjustement
  71224. * @param camera defines the camera to use (can be null)
  71225. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71226. * @param engine defines the hosting engine (can be ignore if camera is set)
  71227. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71228. */
  71229. constructor(name: string, _operator: TonemappingOperator,
  71230. /** Defines the required exposure adjustement */
  71231. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71232. }
  71233. }
  71234. declare module BABYLON {
  71235. /** @hidden */
  71236. export var volumetricLightScatteringPixelShader: {
  71237. name: string;
  71238. shader: string;
  71239. };
  71240. }
  71241. declare module BABYLON {
  71242. /** @hidden */
  71243. export var volumetricLightScatteringPassVertexShader: {
  71244. name: string;
  71245. shader: string;
  71246. };
  71247. }
  71248. declare module BABYLON {
  71249. /** @hidden */
  71250. export var volumetricLightScatteringPassPixelShader: {
  71251. name: string;
  71252. shader: string;
  71253. };
  71254. }
  71255. declare module BABYLON {
  71256. /**
  71257. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71258. */
  71259. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71260. private _volumetricLightScatteringPass;
  71261. private _volumetricLightScatteringRTT;
  71262. private _viewPort;
  71263. private _screenCoordinates;
  71264. private _cachedDefines;
  71265. /**
  71266. * If not undefined, the mesh position is computed from the attached node position
  71267. */
  71268. attachedNode: {
  71269. position: Vector3;
  71270. };
  71271. /**
  71272. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71273. */
  71274. customMeshPosition: Vector3;
  71275. /**
  71276. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71277. */
  71278. useCustomMeshPosition: boolean;
  71279. /**
  71280. * If the post-process should inverse the light scattering direction
  71281. */
  71282. invert: boolean;
  71283. /**
  71284. * The internal mesh used by the post-process
  71285. */
  71286. mesh: Mesh;
  71287. /**
  71288. * @hidden
  71289. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71290. */
  71291. get useDiffuseColor(): boolean;
  71292. set useDiffuseColor(useDiffuseColor: boolean);
  71293. /**
  71294. * Array containing the excluded meshes not rendered in the internal pass
  71295. */
  71296. excludedMeshes: AbstractMesh[];
  71297. /**
  71298. * Controls the overall intensity of the post-process
  71299. */
  71300. exposure: number;
  71301. /**
  71302. * Dissipates each sample's contribution in range [0, 1]
  71303. */
  71304. decay: number;
  71305. /**
  71306. * Controls the overall intensity of each sample
  71307. */
  71308. weight: number;
  71309. /**
  71310. * Controls the density of each sample
  71311. */
  71312. density: number;
  71313. /**
  71314. * @constructor
  71315. * @param name The post-process name
  71316. * @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)
  71317. * @param camera The camera that the post-process will be attached to
  71318. * @param mesh The mesh used to create the light scattering
  71319. * @param samples The post-process quality, default 100
  71320. * @param samplingModeThe post-process filtering mode
  71321. * @param engine The babylon engine
  71322. * @param reusable If the post-process is reusable
  71323. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71324. */
  71325. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71326. /**
  71327. * Returns the string "VolumetricLightScatteringPostProcess"
  71328. * @returns "VolumetricLightScatteringPostProcess"
  71329. */
  71330. getClassName(): string;
  71331. private _isReady;
  71332. /**
  71333. * Sets the new light position for light scattering effect
  71334. * @param position The new custom light position
  71335. */
  71336. setCustomMeshPosition(position: Vector3): void;
  71337. /**
  71338. * Returns the light position for light scattering effect
  71339. * @return Vector3 The custom light position
  71340. */
  71341. getCustomMeshPosition(): Vector3;
  71342. /**
  71343. * Disposes the internal assets and detaches the post-process from the camera
  71344. */
  71345. dispose(camera: Camera): void;
  71346. /**
  71347. * Returns the render target texture used by the post-process
  71348. * @return the render target texture used by the post-process
  71349. */
  71350. getPass(): RenderTargetTexture;
  71351. private _meshExcluded;
  71352. private _createPass;
  71353. private _updateMeshScreenCoordinates;
  71354. /**
  71355. * Creates a default mesh for the Volumeric Light Scattering post-process
  71356. * @param name The mesh name
  71357. * @param scene The scene where to create the mesh
  71358. * @return the default mesh
  71359. */
  71360. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71361. }
  71362. }
  71363. declare module BABYLON {
  71364. /** @hidden */
  71365. export var screenSpaceCurvaturePixelShader: {
  71366. name: string;
  71367. shader: string;
  71368. };
  71369. }
  71370. declare module BABYLON {
  71371. /**
  71372. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71373. */
  71374. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71375. /**
  71376. * Defines how much ridge the curvature effect displays.
  71377. */
  71378. ridge: number;
  71379. /**
  71380. * Defines how much valley the curvature effect displays.
  71381. */
  71382. valley: number;
  71383. private _geometryBufferRenderer;
  71384. /**
  71385. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71386. * @param name The name of the effect.
  71387. * @param scene The scene containing the objects to blur according to their velocity.
  71388. * @param options The required width/height ratio to downsize to before computing the render pass.
  71389. * @param camera The camera to apply the render pass to.
  71390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71391. * @param engine The engine which the post process will be applied. (default: current engine)
  71392. * @param reusable If the post process can be reused on the same frame. (default: false)
  71393. * @param textureType Type of textures used when performing the post process. (default: 0)
  71394. * @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)
  71395. */
  71396. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71397. /**
  71398. * Support test.
  71399. */
  71400. static get IsSupported(): boolean;
  71401. }
  71402. }
  71403. declare module BABYLON {
  71404. interface Scene {
  71405. /** @hidden (Backing field) */
  71406. _boundingBoxRenderer: BoundingBoxRenderer;
  71407. /** @hidden (Backing field) */
  71408. _forceShowBoundingBoxes: boolean;
  71409. /**
  71410. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71411. */
  71412. forceShowBoundingBoxes: boolean;
  71413. /**
  71414. * Gets the bounding box renderer associated with the scene
  71415. * @returns a BoundingBoxRenderer
  71416. */
  71417. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71418. }
  71419. interface AbstractMesh {
  71420. /** @hidden (Backing field) */
  71421. _showBoundingBox: boolean;
  71422. /**
  71423. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71424. */
  71425. showBoundingBox: boolean;
  71426. }
  71427. /**
  71428. * Component responsible of rendering the bounding box of the meshes in a scene.
  71429. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71430. */
  71431. export class BoundingBoxRenderer implements ISceneComponent {
  71432. /**
  71433. * The component name helpfull to identify the component in the list of scene components.
  71434. */
  71435. readonly name: string;
  71436. /**
  71437. * The scene the component belongs to.
  71438. */
  71439. scene: Scene;
  71440. /**
  71441. * Color of the bounding box lines placed in front of an object
  71442. */
  71443. frontColor: Color3;
  71444. /**
  71445. * Color of the bounding box lines placed behind an object
  71446. */
  71447. backColor: Color3;
  71448. /**
  71449. * Defines if the renderer should show the back lines or not
  71450. */
  71451. showBackLines: boolean;
  71452. /**
  71453. * Observable raised before rendering a bounding box
  71454. */
  71455. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71456. /**
  71457. * Observable raised after rendering a bounding box
  71458. */
  71459. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71460. /**
  71461. * @hidden
  71462. */
  71463. renderList: SmartArray<BoundingBox>;
  71464. private _colorShader;
  71465. private _vertexBuffers;
  71466. private _indexBuffer;
  71467. private _fillIndexBuffer;
  71468. private _fillIndexData;
  71469. /**
  71470. * Instantiates a new bounding box renderer in a scene.
  71471. * @param scene the scene the renderer renders in
  71472. */
  71473. constructor(scene: Scene);
  71474. /**
  71475. * Registers the component in a given scene
  71476. */
  71477. register(): void;
  71478. private _evaluateSubMesh;
  71479. private _activeMesh;
  71480. private _prepareRessources;
  71481. private _createIndexBuffer;
  71482. /**
  71483. * Rebuilds the elements related to this component in case of
  71484. * context lost for instance.
  71485. */
  71486. rebuild(): void;
  71487. /**
  71488. * @hidden
  71489. */
  71490. reset(): void;
  71491. /**
  71492. * Render the bounding boxes of a specific rendering group
  71493. * @param renderingGroupId defines the rendering group to render
  71494. */
  71495. render(renderingGroupId: number): void;
  71496. /**
  71497. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71498. * @param mesh Define the mesh to render the occlusion bounding box for
  71499. */
  71500. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71501. /**
  71502. * Dispose and release the resources attached to this renderer.
  71503. */
  71504. dispose(): void;
  71505. }
  71506. }
  71507. declare module BABYLON {
  71508. interface Scene {
  71509. /** @hidden (Backing field) */
  71510. _depthRenderer: {
  71511. [id: string]: DepthRenderer;
  71512. };
  71513. /**
  71514. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71515. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71516. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71517. * @returns the created depth renderer
  71518. */
  71519. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71520. /**
  71521. * Disables a depth renderer for a given camera
  71522. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71523. */
  71524. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71525. }
  71526. /**
  71527. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71528. * in several rendering techniques.
  71529. */
  71530. export class DepthRendererSceneComponent implements ISceneComponent {
  71531. /**
  71532. * The component name helpfull to identify the component in the list of scene components.
  71533. */
  71534. readonly name: string;
  71535. /**
  71536. * The scene the component belongs to.
  71537. */
  71538. scene: Scene;
  71539. /**
  71540. * Creates a new instance of the component for the given scene
  71541. * @param scene Defines the scene to register the component in
  71542. */
  71543. constructor(scene: Scene);
  71544. /**
  71545. * Registers the component in a given scene
  71546. */
  71547. register(): void;
  71548. /**
  71549. * Rebuilds the elements related to this component in case of
  71550. * context lost for instance.
  71551. */
  71552. rebuild(): void;
  71553. /**
  71554. * Disposes the component and the associated ressources
  71555. */
  71556. dispose(): void;
  71557. private _gatherRenderTargets;
  71558. private _gatherActiveCameraRenderTargets;
  71559. }
  71560. }
  71561. declare module BABYLON {
  71562. interface AbstractScene {
  71563. /** @hidden (Backing field) */
  71564. _prePassRenderer: Nullable<PrePassRenderer>;
  71565. /**
  71566. * Gets or Sets the current prepass renderer associated to the scene.
  71567. */
  71568. prePassRenderer: Nullable<PrePassRenderer>;
  71569. /**
  71570. * Enables the prepass and associates it with the scene
  71571. * @returns the PrePassRenderer
  71572. */
  71573. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71574. /**
  71575. * Disables the prepass associated with the scene
  71576. */
  71577. disablePrePassRenderer(): void;
  71578. }
  71579. /**
  71580. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71581. * in several rendering techniques.
  71582. */
  71583. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71584. /**
  71585. * The component name helpful to identify the component in the list of scene components.
  71586. */
  71587. readonly name: string;
  71588. /**
  71589. * The scene the component belongs to.
  71590. */
  71591. scene: Scene;
  71592. /**
  71593. * Creates a new instance of the component for the given scene
  71594. * @param scene Defines the scene to register the component in
  71595. */
  71596. constructor(scene: Scene);
  71597. /**
  71598. * Registers the component in a given scene
  71599. */
  71600. register(): void;
  71601. private _beforeCameraDraw;
  71602. private _afterCameraDraw;
  71603. private _beforeClearStage;
  71604. /**
  71605. * Serializes the component data to the specified json object
  71606. * @param serializationObject The object to serialize to
  71607. */
  71608. serialize(serializationObject: any): void;
  71609. /**
  71610. * Adds all the elements from the container to the scene
  71611. * @param container the container holding the elements
  71612. */
  71613. addFromContainer(container: AbstractScene): void;
  71614. /**
  71615. * Removes all the elements in the container from the scene
  71616. * @param container contains the elements to remove
  71617. * @param dispose if the removed element should be disposed (default: false)
  71618. */
  71619. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71620. /**
  71621. * Rebuilds the elements related to this component in case of
  71622. * context lost for instance.
  71623. */
  71624. rebuild(): void;
  71625. /**
  71626. * Disposes the component and the associated ressources
  71627. */
  71628. dispose(): void;
  71629. }
  71630. }
  71631. declare module BABYLON {
  71632. /** @hidden */
  71633. export var outlinePixelShader: {
  71634. name: string;
  71635. shader: string;
  71636. };
  71637. }
  71638. declare module BABYLON {
  71639. /** @hidden */
  71640. export var outlineVertexShader: {
  71641. name: string;
  71642. shader: string;
  71643. };
  71644. }
  71645. declare module BABYLON {
  71646. interface Scene {
  71647. /** @hidden */
  71648. _outlineRenderer: OutlineRenderer;
  71649. /**
  71650. * Gets the outline renderer associated with the scene
  71651. * @returns a OutlineRenderer
  71652. */
  71653. getOutlineRenderer(): OutlineRenderer;
  71654. }
  71655. interface AbstractMesh {
  71656. /** @hidden (Backing field) */
  71657. _renderOutline: boolean;
  71658. /**
  71659. * Gets or sets a boolean indicating if the outline must be rendered as well
  71660. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71661. */
  71662. renderOutline: boolean;
  71663. /** @hidden (Backing field) */
  71664. _renderOverlay: boolean;
  71665. /**
  71666. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71667. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71668. */
  71669. renderOverlay: boolean;
  71670. }
  71671. /**
  71672. * This class is responsible to draw bothe outline/overlay of meshes.
  71673. * It should not be used directly but through the available method on mesh.
  71674. */
  71675. export class OutlineRenderer implements ISceneComponent {
  71676. /**
  71677. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71678. */
  71679. private static _StencilReference;
  71680. /**
  71681. * The name of the component. Each component must have a unique name.
  71682. */
  71683. name: string;
  71684. /**
  71685. * The scene the component belongs to.
  71686. */
  71687. scene: Scene;
  71688. /**
  71689. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71690. */
  71691. zOffset: number;
  71692. private _engine;
  71693. private _effect;
  71694. private _cachedDefines;
  71695. private _savedDepthWrite;
  71696. /**
  71697. * Instantiates a new outline renderer. (There could be only one per scene).
  71698. * @param scene Defines the scene it belongs to
  71699. */
  71700. constructor(scene: Scene);
  71701. /**
  71702. * Register the component to one instance of a scene.
  71703. */
  71704. register(): void;
  71705. /**
  71706. * Rebuilds the elements related to this component in case of
  71707. * context lost for instance.
  71708. */
  71709. rebuild(): void;
  71710. /**
  71711. * Disposes the component and the associated ressources.
  71712. */
  71713. dispose(): void;
  71714. /**
  71715. * Renders the outline in the canvas.
  71716. * @param subMesh Defines the sumesh to render
  71717. * @param batch Defines the batch of meshes in case of instances
  71718. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71719. */
  71720. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71721. /**
  71722. * Returns whether or not the outline renderer is ready for a given submesh.
  71723. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71724. * @param subMesh Defines the submesh to check readyness for
  71725. * @param useInstances Defines wheter wee are trying to render instances or not
  71726. * @returns true if ready otherwise false
  71727. */
  71728. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71729. private _beforeRenderingMesh;
  71730. private _afterRenderingMesh;
  71731. }
  71732. }
  71733. declare module BABYLON {
  71734. /**
  71735. * Defines the basic options interface of a Sprite Frame Source Size.
  71736. */
  71737. export interface ISpriteJSONSpriteSourceSize {
  71738. /**
  71739. * number of the original width of the Frame
  71740. */
  71741. w: number;
  71742. /**
  71743. * number of the original height of the Frame
  71744. */
  71745. h: number;
  71746. }
  71747. /**
  71748. * Defines the basic options interface of a Sprite Frame Data.
  71749. */
  71750. export interface ISpriteJSONSpriteFrameData {
  71751. /**
  71752. * number of the x offset of the Frame
  71753. */
  71754. x: number;
  71755. /**
  71756. * number of the y offset of the Frame
  71757. */
  71758. y: number;
  71759. /**
  71760. * number of the width of the Frame
  71761. */
  71762. w: number;
  71763. /**
  71764. * number of the height of the Frame
  71765. */
  71766. h: number;
  71767. }
  71768. /**
  71769. * Defines the basic options interface of a JSON Sprite.
  71770. */
  71771. export interface ISpriteJSONSprite {
  71772. /**
  71773. * string name of the Frame
  71774. */
  71775. filename: string;
  71776. /**
  71777. * ISpriteJSONSpriteFrame basic object of the frame data
  71778. */
  71779. frame: ISpriteJSONSpriteFrameData;
  71780. /**
  71781. * boolean to flag is the frame was rotated.
  71782. */
  71783. rotated: boolean;
  71784. /**
  71785. * boolean to flag is the frame was trimmed.
  71786. */
  71787. trimmed: boolean;
  71788. /**
  71789. * ISpriteJSONSpriteFrame basic object of the source data
  71790. */
  71791. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71792. /**
  71793. * ISpriteJSONSpriteFrame basic object of the source data
  71794. */
  71795. sourceSize: ISpriteJSONSpriteSourceSize;
  71796. }
  71797. /**
  71798. * Defines the basic options interface of a JSON atlas.
  71799. */
  71800. export interface ISpriteJSONAtlas {
  71801. /**
  71802. * Array of objects that contain the frame data.
  71803. */
  71804. frames: Array<ISpriteJSONSprite>;
  71805. /**
  71806. * object basic object containing the sprite meta data.
  71807. */
  71808. meta?: object;
  71809. }
  71810. }
  71811. declare module BABYLON {
  71812. /** @hidden */
  71813. export var spriteMapPixelShader: {
  71814. name: string;
  71815. shader: string;
  71816. };
  71817. }
  71818. declare module BABYLON {
  71819. /** @hidden */
  71820. export var spriteMapVertexShader: {
  71821. name: string;
  71822. shader: string;
  71823. };
  71824. }
  71825. declare module BABYLON {
  71826. /**
  71827. * Defines the basic options interface of a SpriteMap
  71828. */
  71829. export interface ISpriteMapOptions {
  71830. /**
  71831. * Vector2 of the number of cells in the grid.
  71832. */
  71833. stageSize?: Vector2;
  71834. /**
  71835. * Vector2 of the size of the output plane in World Units.
  71836. */
  71837. outputSize?: Vector2;
  71838. /**
  71839. * Vector3 of the position of the output plane in World Units.
  71840. */
  71841. outputPosition?: Vector3;
  71842. /**
  71843. * Vector3 of the rotation of the output plane.
  71844. */
  71845. outputRotation?: Vector3;
  71846. /**
  71847. * number of layers that the system will reserve in resources.
  71848. */
  71849. layerCount?: number;
  71850. /**
  71851. * number of max animation frames a single cell will reserve in resources.
  71852. */
  71853. maxAnimationFrames?: number;
  71854. /**
  71855. * number cell index of the base tile when the system compiles.
  71856. */
  71857. baseTile?: number;
  71858. /**
  71859. * boolean flip the sprite after its been repositioned by the framing data.
  71860. */
  71861. flipU?: boolean;
  71862. /**
  71863. * Vector3 scalar of the global RGB values of the SpriteMap.
  71864. */
  71865. colorMultiply?: Vector3;
  71866. }
  71867. /**
  71868. * Defines the IDisposable interface in order to be cleanable from resources.
  71869. */
  71870. export interface ISpriteMap extends IDisposable {
  71871. /**
  71872. * String name of the SpriteMap.
  71873. */
  71874. name: string;
  71875. /**
  71876. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71877. */
  71878. atlasJSON: ISpriteJSONAtlas;
  71879. /**
  71880. * Texture of the SpriteMap.
  71881. */
  71882. spriteSheet: Texture;
  71883. /**
  71884. * The parameters to initialize the SpriteMap with.
  71885. */
  71886. options: ISpriteMapOptions;
  71887. }
  71888. /**
  71889. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71890. */
  71891. export class SpriteMap implements ISpriteMap {
  71892. /** The Name of the spriteMap */
  71893. name: string;
  71894. /** The JSON file with the frame and meta data */
  71895. atlasJSON: ISpriteJSONAtlas;
  71896. /** The systems Sprite Sheet Texture */
  71897. spriteSheet: Texture;
  71898. /** Arguments passed with the Constructor */
  71899. options: ISpriteMapOptions;
  71900. /** Public Sprite Storage array, parsed from atlasJSON */
  71901. sprites: Array<ISpriteJSONSprite>;
  71902. /** Returns the Number of Sprites in the System */
  71903. get spriteCount(): number;
  71904. /** Returns the Position of Output Plane*/
  71905. get position(): Vector3;
  71906. /** Returns the Position of Output Plane*/
  71907. set position(v: Vector3);
  71908. /** Returns the Rotation of Output Plane*/
  71909. get rotation(): Vector3;
  71910. /** Returns the Rotation of Output Plane*/
  71911. set rotation(v: Vector3);
  71912. /** Sets the AnimationMap*/
  71913. get animationMap(): RawTexture;
  71914. /** Sets the AnimationMap*/
  71915. set animationMap(v: RawTexture);
  71916. /** Scene that the SpriteMap was created in */
  71917. private _scene;
  71918. /** Texture Buffer of Float32 that holds tile frame data*/
  71919. private _frameMap;
  71920. /** Texture Buffers of Float32 that holds tileMap data*/
  71921. private _tileMaps;
  71922. /** Texture Buffer of Float32 that holds Animation Data*/
  71923. private _animationMap;
  71924. /** Custom ShaderMaterial Central to the System*/
  71925. private _material;
  71926. /** Custom ShaderMaterial Central to the System*/
  71927. private _output;
  71928. /** Systems Time Ticker*/
  71929. private _time;
  71930. /**
  71931. * Creates a new SpriteMap
  71932. * @param name defines the SpriteMaps Name
  71933. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71934. * @param spriteSheet is the Texture that the Sprites are on.
  71935. * @param options a basic deployment configuration
  71936. * @param scene The Scene that the map is deployed on
  71937. */
  71938. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71939. /**
  71940. * Returns tileID location
  71941. * @returns Vector2 the cell position ID
  71942. */
  71943. getTileID(): Vector2;
  71944. /**
  71945. * Gets the UV location of the mouse over the SpriteMap.
  71946. * @returns Vector2 the UV position of the mouse interaction
  71947. */
  71948. getMousePosition(): Vector2;
  71949. /**
  71950. * Creates the "frame" texture Buffer
  71951. * -------------------------------------
  71952. * Structure of frames
  71953. * "filename": "Falling-Water-2.png",
  71954. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71955. * "rotated": true,
  71956. * "trimmed": true,
  71957. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71958. * "sourceSize": {"w":32,"h":32}
  71959. * @returns RawTexture of the frameMap
  71960. */
  71961. private _createFrameBuffer;
  71962. /**
  71963. * Creates the tileMap texture Buffer
  71964. * @param buffer normally and array of numbers, or a false to generate from scratch
  71965. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71966. * @returns RawTexture of the tileMap
  71967. */
  71968. private _createTileBuffer;
  71969. /**
  71970. * Modifies the data of the tileMaps
  71971. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71972. * @param pos is the iVector2 Coordinates of the Tile
  71973. * @param tile The SpriteIndex of the new Tile
  71974. */
  71975. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71976. /**
  71977. * Creates the animationMap texture Buffer
  71978. * @param buffer normally and array of numbers, or a false to generate from scratch
  71979. * @returns RawTexture of the animationMap
  71980. */
  71981. private _createTileAnimationBuffer;
  71982. /**
  71983. * Modifies the data of the animationMap
  71984. * @param cellID is the Index of the Sprite
  71985. * @param _frame is the target Animation frame
  71986. * @param toCell is the Target Index of the next frame of the animation
  71987. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71988. * @param speed is a global scalar of the time variable on the map.
  71989. */
  71990. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71991. /**
  71992. * Exports the .tilemaps file
  71993. */
  71994. saveTileMaps(): void;
  71995. /**
  71996. * Imports the .tilemaps file
  71997. * @param url of the .tilemaps file
  71998. */
  71999. loadTileMaps(url: string): void;
  72000. /**
  72001. * Release associated resources
  72002. */
  72003. dispose(): void;
  72004. }
  72005. }
  72006. declare module BABYLON {
  72007. /**
  72008. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72009. * @see https://doc.babylonjs.com/babylon101/sprites
  72010. */
  72011. export class SpritePackedManager extends SpriteManager {
  72012. /** defines the packed manager's name */
  72013. name: string;
  72014. /**
  72015. * Creates a new sprite manager from a packed sprite sheet
  72016. * @param name defines the manager's name
  72017. * @param imgUrl defines the sprite sheet url
  72018. * @param capacity defines the maximum allowed number of sprites
  72019. * @param scene defines the hosting scene
  72020. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72021. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72022. * @param samplingMode defines the smapling mode to use with spritesheet
  72023. * @param fromPacked set to true; do not alter
  72024. */
  72025. constructor(
  72026. /** defines the packed manager's name */
  72027. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72028. }
  72029. }
  72030. declare module BABYLON {
  72031. /**
  72032. * Defines the list of states available for a task inside a AssetsManager
  72033. */
  72034. export enum AssetTaskState {
  72035. /**
  72036. * Initialization
  72037. */
  72038. INIT = 0,
  72039. /**
  72040. * Running
  72041. */
  72042. RUNNING = 1,
  72043. /**
  72044. * Done
  72045. */
  72046. DONE = 2,
  72047. /**
  72048. * Error
  72049. */
  72050. ERROR = 3
  72051. }
  72052. /**
  72053. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72054. */
  72055. export abstract class AbstractAssetTask {
  72056. /**
  72057. * Task name
  72058. */ name: string;
  72059. /**
  72060. * Callback called when the task is successful
  72061. */
  72062. onSuccess: (task: any) => void;
  72063. /**
  72064. * Callback called when the task is not successful
  72065. */
  72066. onError: (task: any, message?: string, exception?: any) => void;
  72067. /**
  72068. * Creates a new AssetsManager
  72069. * @param name defines the name of the task
  72070. */
  72071. constructor(
  72072. /**
  72073. * Task name
  72074. */ name: string);
  72075. private _isCompleted;
  72076. private _taskState;
  72077. private _errorObject;
  72078. /**
  72079. * Get if the task is completed
  72080. */
  72081. get isCompleted(): boolean;
  72082. /**
  72083. * Gets the current state of the task
  72084. */
  72085. get taskState(): AssetTaskState;
  72086. /**
  72087. * Gets the current error object (if task is in error)
  72088. */
  72089. get errorObject(): {
  72090. message?: string;
  72091. exception?: any;
  72092. };
  72093. /**
  72094. * Internal only
  72095. * @hidden
  72096. */
  72097. _setErrorObject(message?: string, exception?: any): void;
  72098. /**
  72099. * Execute the current task
  72100. * @param scene defines the scene where you want your assets to be loaded
  72101. * @param onSuccess is a callback called when the task is successfully executed
  72102. * @param onError is a callback called if an error occurs
  72103. */
  72104. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72105. /**
  72106. * Execute the current task
  72107. * @param scene defines the scene where you want your assets to be loaded
  72108. * @param onSuccess is a callback called when the task is successfully executed
  72109. * @param onError is a callback called if an error occurs
  72110. */
  72111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72112. /**
  72113. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72114. * This can be used with failed tasks that have the reason for failure fixed.
  72115. */
  72116. reset(): void;
  72117. private onErrorCallback;
  72118. private onDoneCallback;
  72119. }
  72120. /**
  72121. * Define the interface used by progress events raised during assets loading
  72122. */
  72123. export interface IAssetsProgressEvent {
  72124. /**
  72125. * Defines the number of remaining tasks to process
  72126. */
  72127. remainingCount: number;
  72128. /**
  72129. * Defines the total number of tasks
  72130. */
  72131. totalCount: number;
  72132. /**
  72133. * Defines the task that was just processed
  72134. */
  72135. task: AbstractAssetTask;
  72136. }
  72137. /**
  72138. * Class used to share progress information about assets loading
  72139. */
  72140. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72141. /**
  72142. * Defines the number of remaining tasks to process
  72143. */
  72144. remainingCount: number;
  72145. /**
  72146. * Defines the total number of tasks
  72147. */
  72148. totalCount: number;
  72149. /**
  72150. * Defines the task that was just processed
  72151. */
  72152. task: AbstractAssetTask;
  72153. /**
  72154. * Creates a AssetsProgressEvent
  72155. * @param remainingCount defines the number of remaining tasks to process
  72156. * @param totalCount defines the total number of tasks
  72157. * @param task defines the task that was just processed
  72158. */
  72159. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72160. }
  72161. /**
  72162. * Define a task used by AssetsManager to load assets into a container
  72163. */
  72164. export class ContainerAssetTask extends AbstractAssetTask {
  72165. /**
  72166. * Defines the name of the task
  72167. */
  72168. name: string;
  72169. /**
  72170. * Defines the list of mesh's names you want to load
  72171. */
  72172. meshesNames: any;
  72173. /**
  72174. * Defines the root url to use as a base to load your meshes and associated resources
  72175. */
  72176. rootUrl: string;
  72177. /**
  72178. * Defines the filename or File of the scene to load from
  72179. */
  72180. sceneFilename: string | File;
  72181. /**
  72182. * Get the loaded asset container
  72183. */
  72184. loadedContainer: AssetContainer;
  72185. /**
  72186. * Gets the list of loaded meshes
  72187. */
  72188. loadedMeshes: Array<AbstractMesh>;
  72189. /**
  72190. * Gets the list of loaded particle systems
  72191. */
  72192. loadedParticleSystems: Array<IParticleSystem>;
  72193. /**
  72194. * Gets the list of loaded skeletons
  72195. */
  72196. loadedSkeletons: Array<Skeleton>;
  72197. /**
  72198. * Gets the list of loaded animation groups
  72199. */
  72200. loadedAnimationGroups: Array<AnimationGroup>;
  72201. /**
  72202. * Callback called when the task is successful
  72203. */
  72204. onSuccess: (task: ContainerAssetTask) => void;
  72205. /**
  72206. * Callback called when the task is successful
  72207. */
  72208. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72209. /**
  72210. * Creates a new ContainerAssetTask
  72211. * @param name defines the name of the task
  72212. * @param meshesNames defines the list of mesh's names you want to load
  72213. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72214. * @param sceneFilename defines the filename or File of the scene to load from
  72215. */
  72216. constructor(
  72217. /**
  72218. * Defines the name of the task
  72219. */
  72220. name: string,
  72221. /**
  72222. * Defines the list of mesh's names you want to load
  72223. */
  72224. meshesNames: any,
  72225. /**
  72226. * Defines the root url to use as a base to load your meshes and associated resources
  72227. */
  72228. rootUrl: string,
  72229. /**
  72230. * Defines the filename or File of the scene to load from
  72231. */
  72232. sceneFilename: string | File);
  72233. /**
  72234. * Execute the current task
  72235. * @param scene defines the scene where you want your assets to be loaded
  72236. * @param onSuccess is a callback called when the task is successfully executed
  72237. * @param onError is a callback called if an error occurs
  72238. */
  72239. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72240. }
  72241. /**
  72242. * Define a task used by AssetsManager to load meshes
  72243. */
  72244. export class MeshAssetTask extends AbstractAssetTask {
  72245. /**
  72246. * Defines the name of the task
  72247. */
  72248. name: string;
  72249. /**
  72250. * Defines the list of mesh's names you want to load
  72251. */
  72252. meshesNames: any;
  72253. /**
  72254. * Defines the root url to use as a base to load your meshes and associated resources
  72255. */
  72256. rootUrl: string;
  72257. /**
  72258. * Defines the filename or File of the scene to load from
  72259. */
  72260. sceneFilename: string | File;
  72261. /**
  72262. * Gets the list of loaded meshes
  72263. */
  72264. loadedMeshes: Array<AbstractMesh>;
  72265. /**
  72266. * Gets the list of loaded particle systems
  72267. */
  72268. loadedParticleSystems: Array<IParticleSystem>;
  72269. /**
  72270. * Gets the list of loaded skeletons
  72271. */
  72272. loadedSkeletons: Array<Skeleton>;
  72273. /**
  72274. * Gets the list of loaded animation groups
  72275. */
  72276. loadedAnimationGroups: Array<AnimationGroup>;
  72277. /**
  72278. * Callback called when the task is successful
  72279. */
  72280. onSuccess: (task: MeshAssetTask) => void;
  72281. /**
  72282. * Callback called when the task is successful
  72283. */
  72284. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72285. /**
  72286. * Creates a new MeshAssetTask
  72287. * @param name defines the name of the task
  72288. * @param meshesNames defines the list of mesh's names you want to load
  72289. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72290. * @param sceneFilename defines the filename or File of the scene to load from
  72291. */
  72292. constructor(
  72293. /**
  72294. * Defines the name of the task
  72295. */
  72296. name: string,
  72297. /**
  72298. * Defines the list of mesh's names you want to load
  72299. */
  72300. meshesNames: any,
  72301. /**
  72302. * Defines the root url to use as a base to load your meshes and associated resources
  72303. */
  72304. rootUrl: string,
  72305. /**
  72306. * Defines the filename or File of the scene to load from
  72307. */
  72308. sceneFilename: string | File);
  72309. /**
  72310. * Execute the current task
  72311. * @param scene defines the scene where you want your assets to be loaded
  72312. * @param onSuccess is a callback called when the task is successfully executed
  72313. * @param onError is a callback called if an error occurs
  72314. */
  72315. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72316. }
  72317. /**
  72318. * Define a task used by AssetsManager to load text content
  72319. */
  72320. export class TextFileAssetTask extends AbstractAssetTask {
  72321. /**
  72322. * Defines the name of the task
  72323. */
  72324. name: string;
  72325. /**
  72326. * Defines the location of the file to load
  72327. */
  72328. url: string;
  72329. /**
  72330. * Gets the loaded text string
  72331. */
  72332. text: string;
  72333. /**
  72334. * Callback called when the task is successful
  72335. */
  72336. onSuccess: (task: TextFileAssetTask) => void;
  72337. /**
  72338. * Callback called when the task is successful
  72339. */
  72340. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72341. /**
  72342. * Creates a new TextFileAssetTask object
  72343. * @param name defines the name of the task
  72344. * @param url defines the location of the file to load
  72345. */
  72346. constructor(
  72347. /**
  72348. * Defines the name of the task
  72349. */
  72350. name: string,
  72351. /**
  72352. * Defines the location of the file to load
  72353. */
  72354. url: string);
  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 binary data
  72365. */
  72366. export class BinaryFileAssetTask extends AbstractAssetTask {
  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. * Gets the lodaded data (as an array buffer)
  72377. */
  72378. data: ArrayBuffer;
  72379. /**
  72380. * Callback called when the task is successful
  72381. */
  72382. onSuccess: (task: BinaryFileAssetTask) => void;
  72383. /**
  72384. * Callback called when the task is successful
  72385. */
  72386. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72387. /**
  72388. * Creates a new BinaryFileAssetTask object
  72389. * @param name defines the name of the new task
  72390. * @param url defines the location of the file to load
  72391. */
  72392. constructor(
  72393. /**
  72394. * Defines the name of the task
  72395. */
  72396. name: string,
  72397. /**
  72398. * Defines the location of the file to load
  72399. */
  72400. url: string);
  72401. /**
  72402. * Execute the current task
  72403. * @param scene defines the scene where you want your assets to be loaded
  72404. * @param onSuccess is a callback called when the task is successfully executed
  72405. * @param onError is a callback called if an error occurs
  72406. */
  72407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72408. }
  72409. /**
  72410. * Define a task used by AssetsManager to load images
  72411. */
  72412. export class ImageAssetTask extends AbstractAssetTask {
  72413. /**
  72414. * Defines the name of the task
  72415. */
  72416. name: string;
  72417. /**
  72418. * Defines the location of the image to load
  72419. */
  72420. url: string;
  72421. /**
  72422. * Gets the loaded images
  72423. */
  72424. image: HTMLImageElement;
  72425. /**
  72426. * Callback called when the task is successful
  72427. */
  72428. onSuccess: (task: ImageAssetTask) => void;
  72429. /**
  72430. * Callback called when the task is successful
  72431. */
  72432. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72433. /**
  72434. * Creates a new ImageAssetTask
  72435. * @param name defines the name of the task
  72436. * @param url defines the location of the image to load
  72437. */
  72438. constructor(
  72439. /**
  72440. * Defines the name of the task
  72441. */
  72442. name: string,
  72443. /**
  72444. * Defines the location of the image to load
  72445. */
  72446. url: string);
  72447. /**
  72448. * Execute the current task
  72449. * @param scene defines the scene where you want your assets to be loaded
  72450. * @param onSuccess is a callback called when the task is successfully executed
  72451. * @param onError is a callback called if an error occurs
  72452. */
  72453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72454. }
  72455. /**
  72456. * Defines the interface used by texture loading tasks
  72457. */
  72458. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72459. /**
  72460. * Gets the loaded texture
  72461. */
  72462. texture: TEX;
  72463. }
  72464. /**
  72465. * Define a task used by AssetsManager to load 2D textures
  72466. */
  72467. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72468. /**
  72469. * Defines the name of the task
  72470. */
  72471. name: string;
  72472. /**
  72473. * Defines the location of the file to load
  72474. */
  72475. url: string;
  72476. /**
  72477. * Defines if mipmap should not be generated (default is false)
  72478. */
  72479. noMipmap?: boolean | undefined;
  72480. /**
  72481. * Defines if texture must be inverted on Y axis (default is true)
  72482. */
  72483. invertY: boolean;
  72484. /**
  72485. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72486. */
  72487. samplingMode: number;
  72488. /**
  72489. * Gets the loaded texture
  72490. */
  72491. texture: Texture;
  72492. /**
  72493. * Callback called when the task is successful
  72494. */
  72495. onSuccess: (task: TextureAssetTask) => void;
  72496. /**
  72497. * Callback called when the task is successful
  72498. */
  72499. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72500. /**
  72501. * Creates a new TextureAssetTask object
  72502. * @param name defines the name of the task
  72503. * @param url defines the location of the file to load
  72504. * @param noMipmap defines if mipmap should not be generated (default is false)
  72505. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72506. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72507. */
  72508. constructor(
  72509. /**
  72510. * Defines the name of the task
  72511. */
  72512. name: string,
  72513. /**
  72514. * Defines the location of the file to load
  72515. */
  72516. url: string,
  72517. /**
  72518. * Defines if mipmap should not be generated (default is false)
  72519. */
  72520. noMipmap?: boolean | undefined,
  72521. /**
  72522. * Defines if texture must be inverted on Y axis (default is true)
  72523. */
  72524. invertY?: boolean,
  72525. /**
  72526. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72527. */
  72528. samplingMode?: number);
  72529. /**
  72530. * Execute the current task
  72531. * @param scene defines the scene where you want your assets to be loaded
  72532. * @param onSuccess is a callback called when the task is successfully executed
  72533. * @param onError is a callback called if an error occurs
  72534. */
  72535. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72536. }
  72537. /**
  72538. * Define a task used by AssetsManager to load cube textures
  72539. */
  72540. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72541. /**
  72542. * Defines the name of the task
  72543. */
  72544. name: string;
  72545. /**
  72546. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72547. */
  72548. url: string;
  72549. /**
  72550. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72551. */
  72552. extensions?: string[] | undefined;
  72553. /**
  72554. * Defines if mipmaps should not be generated (default is false)
  72555. */
  72556. noMipmap?: boolean | undefined;
  72557. /**
  72558. * Defines the explicit list of files (undefined by default)
  72559. */
  72560. files?: string[] | undefined;
  72561. /**
  72562. * Gets the loaded texture
  72563. */
  72564. texture: CubeTexture;
  72565. /**
  72566. * Callback called when the task is successful
  72567. */
  72568. onSuccess: (task: CubeTextureAssetTask) => void;
  72569. /**
  72570. * Callback called when the task is successful
  72571. */
  72572. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72573. /**
  72574. * Creates a new CubeTextureAssetTask
  72575. * @param name defines the name of the task
  72576. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72577. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72578. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72579. * @param files defines the explicit list of files (undefined by default)
  72580. */
  72581. constructor(
  72582. /**
  72583. * Defines the name of the task
  72584. */
  72585. name: string,
  72586. /**
  72587. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72588. */
  72589. url: string,
  72590. /**
  72591. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72592. */
  72593. extensions?: string[] | undefined,
  72594. /**
  72595. * Defines if mipmaps should not be generated (default is false)
  72596. */
  72597. noMipmap?: boolean | undefined,
  72598. /**
  72599. * Defines the explicit list of files (undefined by default)
  72600. */
  72601. files?: string[] | undefined);
  72602. /**
  72603. * Execute the current task
  72604. * @param scene defines the scene where you want your assets to be loaded
  72605. * @param onSuccess is a callback called when the task is successfully executed
  72606. * @param onError is a callback called if an error occurs
  72607. */
  72608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72609. }
  72610. /**
  72611. * Define a task used by AssetsManager to load HDR cube textures
  72612. */
  72613. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72614. /**
  72615. * Defines the name of the task
  72616. */
  72617. name: string;
  72618. /**
  72619. * Defines the location of the file to load
  72620. */
  72621. url: string;
  72622. /**
  72623. * Defines the desired size (the more it increases the longer the generation will be)
  72624. */
  72625. size: number;
  72626. /**
  72627. * Defines if mipmaps should not be generated (default is false)
  72628. */
  72629. noMipmap: boolean;
  72630. /**
  72631. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72632. */
  72633. generateHarmonics: boolean;
  72634. /**
  72635. * 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)
  72636. */
  72637. gammaSpace: boolean;
  72638. /**
  72639. * Internal Use Only
  72640. */
  72641. reserved: boolean;
  72642. /**
  72643. * Gets the loaded texture
  72644. */
  72645. texture: HDRCubeTexture;
  72646. /**
  72647. * Callback called when the task is successful
  72648. */
  72649. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72650. /**
  72651. * Callback called when the task is successful
  72652. */
  72653. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72654. /**
  72655. * Creates a new HDRCubeTextureAssetTask object
  72656. * @param name defines the name of the task
  72657. * @param url defines the location of the file to load
  72658. * @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.
  72659. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72660. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72661. * @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)
  72662. * @param reserved Internal use only
  72663. */
  72664. constructor(
  72665. /**
  72666. * Defines the name of the task
  72667. */
  72668. name: string,
  72669. /**
  72670. * Defines the location of the file to load
  72671. */
  72672. url: string,
  72673. /**
  72674. * Defines the desired size (the more it increases the longer the generation will be)
  72675. */
  72676. size: number,
  72677. /**
  72678. * Defines if mipmaps should not be generated (default is false)
  72679. */
  72680. noMipmap?: boolean,
  72681. /**
  72682. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72683. */
  72684. generateHarmonics?: boolean,
  72685. /**
  72686. * 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)
  72687. */
  72688. gammaSpace?: boolean,
  72689. /**
  72690. * Internal Use Only
  72691. */
  72692. reserved?: boolean);
  72693. /**
  72694. * Execute the current task
  72695. * @param scene defines the scene where you want your assets to be loaded
  72696. * @param onSuccess is a callback called when the task is successfully executed
  72697. * @param onError is a callback called if an error occurs
  72698. */
  72699. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72700. }
  72701. /**
  72702. * Define a task used by AssetsManager to load Equirectangular cube textures
  72703. */
  72704. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72705. /**
  72706. * Defines the name of the task
  72707. */
  72708. name: string;
  72709. /**
  72710. * Defines the location of the file to load
  72711. */
  72712. url: string;
  72713. /**
  72714. * Defines the desired size (the more it increases the longer the generation will be)
  72715. */
  72716. size: number;
  72717. /**
  72718. * Defines if mipmaps should not be generated (default is false)
  72719. */
  72720. noMipmap: boolean;
  72721. /**
  72722. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72723. * but the standard material would require them in Gamma space) (default is true)
  72724. */
  72725. gammaSpace: boolean;
  72726. /**
  72727. * Gets the loaded texture
  72728. */
  72729. texture: EquiRectangularCubeTexture;
  72730. /**
  72731. * Callback called when the task is successful
  72732. */
  72733. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72734. /**
  72735. * Callback called when the task is successful
  72736. */
  72737. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72738. /**
  72739. * Creates a new EquiRectangularCubeTextureAssetTask object
  72740. * @param name defines the name of the task
  72741. * @param url defines the location of the file to load
  72742. * @param size defines the desired size (the more it increases the longer the generation will be)
  72743. * If the size is omitted this implies you are using a preprocessed cubemap.
  72744. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72745. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72746. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72747. * (default is true)
  72748. */
  72749. constructor(
  72750. /**
  72751. * Defines the name of the task
  72752. */
  72753. name: string,
  72754. /**
  72755. * Defines the location of the file to load
  72756. */
  72757. url: string,
  72758. /**
  72759. * Defines the desired size (the more it increases the longer the generation will be)
  72760. */
  72761. size: number,
  72762. /**
  72763. * Defines if mipmaps should not be generated (default is false)
  72764. */
  72765. noMipmap?: boolean,
  72766. /**
  72767. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72768. * but the standard material would require them in Gamma space) (default is true)
  72769. */
  72770. gammaSpace?: boolean);
  72771. /**
  72772. * Execute the current task
  72773. * @param scene defines the scene where you want your assets to be loaded
  72774. * @param onSuccess is a callback called when the task is successfully executed
  72775. * @param onError is a callback called if an error occurs
  72776. */
  72777. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72778. }
  72779. /**
  72780. * This class can be used to easily import assets into a scene
  72781. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72782. */
  72783. export class AssetsManager {
  72784. private _scene;
  72785. private _isLoading;
  72786. protected _tasks: AbstractAssetTask[];
  72787. protected _waitingTasksCount: number;
  72788. protected _totalTasksCount: number;
  72789. /**
  72790. * Callback called when all tasks are processed
  72791. */
  72792. onFinish: (tasks: AbstractAssetTask[]) => void;
  72793. /**
  72794. * Callback called when a task is successful
  72795. */
  72796. onTaskSuccess: (task: AbstractAssetTask) => void;
  72797. /**
  72798. * Callback called when a task had an error
  72799. */
  72800. onTaskError: (task: AbstractAssetTask) => void;
  72801. /**
  72802. * Callback called when a task is done (whatever the result is)
  72803. */
  72804. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72805. /**
  72806. * Observable called when all tasks are processed
  72807. */
  72808. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72809. /**
  72810. * Observable called when a task had an error
  72811. */
  72812. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72813. /**
  72814. * Observable called when all tasks were executed
  72815. */
  72816. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72817. /**
  72818. * Observable called when a task is done (whatever the result is)
  72819. */
  72820. onProgressObservable: Observable<IAssetsProgressEvent>;
  72821. /**
  72822. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72823. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72824. */
  72825. useDefaultLoadingScreen: boolean;
  72826. /**
  72827. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72828. * when all assets have been downloaded.
  72829. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72830. */
  72831. autoHideLoadingUI: boolean;
  72832. /**
  72833. * Creates a new AssetsManager
  72834. * @param scene defines the scene to work on
  72835. */
  72836. constructor(scene: Scene);
  72837. /**
  72838. * Add a ContainerAssetTask to the list of active tasks
  72839. * @param taskName defines the name of the new task
  72840. * @param meshesNames defines the name of meshes to load
  72841. * @param rootUrl defines the root url to use to locate files
  72842. * @param sceneFilename defines the filename of the scene file
  72843. * @returns a new ContainerAssetTask object
  72844. */
  72845. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  72846. /**
  72847. * Add a MeshAssetTask to the list of active tasks
  72848. * @param taskName defines the name of the new task
  72849. * @param meshesNames defines the name of meshes to load
  72850. * @param rootUrl defines the root url to use to locate files
  72851. * @param sceneFilename defines the filename of the scene file
  72852. * @returns a new MeshAssetTask object
  72853. */
  72854. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72855. /**
  72856. * Add a TextFileAssetTask to the list of active tasks
  72857. * @param taskName defines the name of the new task
  72858. * @param url defines the url of the file to load
  72859. * @returns a new TextFileAssetTask object
  72860. */
  72861. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72862. /**
  72863. * Add a BinaryFileAssetTask to the list of active tasks
  72864. * @param taskName defines the name of the new task
  72865. * @param url defines the url of the file to load
  72866. * @returns a new BinaryFileAssetTask object
  72867. */
  72868. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72869. /**
  72870. * Add a ImageAssetTask to the list of active tasks
  72871. * @param taskName defines the name of the new task
  72872. * @param url defines the url of the file to load
  72873. * @returns a new ImageAssetTask object
  72874. */
  72875. addImageTask(taskName: string, url: string): ImageAssetTask;
  72876. /**
  72877. * Add a TextureAssetTask to the list of active tasks
  72878. * @param taskName defines the name of the new task
  72879. * @param url defines the url of the file to load
  72880. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72881. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72882. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72883. * @returns a new TextureAssetTask object
  72884. */
  72885. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72886. /**
  72887. * Add a CubeTextureAssetTask to the list of active tasks
  72888. * @param taskName defines the name of the new task
  72889. * @param url defines the url of the file to load
  72890. * @param extensions defines the extension to use to load the cube map (can be null)
  72891. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72892. * @param files defines the list of files to load (can be null)
  72893. * @returns a new CubeTextureAssetTask object
  72894. */
  72895. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72896. /**
  72897. *
  72898. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72899. * @param taskName defines the name of the new task
  72900. * @param url defines the url of the file to load
  72901. * @param size defines the size you want for the cubemap (can be null)
  72902. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72903. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72904. * @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)
  72905. * @param reserved Internal use only
  72906. * @returns a new HDRCubeTextureAssetTask object
  72907. */
  72908. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72909. /**
  72910. *
  72911. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72912. * @param taskName defines the name of the new task
  72913. * @param url defines the url of the file to load
  72914. * @param size defines the size you want for the cubemap (can be null)
  72915. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72916. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72917. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72918. * @returns a new EquiRectangularCubeTextureAssetTask object
  72919. */
  72920. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72921. /**
  72922. * Remove a task from the assets manager.
  72923. * @param task the task to remove
  72924. */
  72925. removeTask(task: AbstractAssetTask): void;
  72926. private _decreaseWaitingTasksCount;
  72927. private _runTask;
  72928. /**
  72929. * Reset the AssetsManager and remove all tasks
  72930. * @return the current instance of the AssetsManager
  72931. */
  72932. reset(): AssetsManager;
  72933. /**
  72934. * Start the loading process
  72935. * @return the current instance of the AssetsManager
  72936. */
  72937. load(): AssetsManager;
  72938. /**
  72939. * Start the loading process as an async operation
  72940. * @return a promise returning the list of failed tasks
  72941. */
  72942. loadAsync(): Promise<void>;
  72943. }
  72944. }
  72945. declare module BABYLON {
  72946. /**
  72947. * Wrapper class for promise with external resolve and reject.
  72948. */
  72949. export class Deferred<T> {
  72950. /**
  72951. * The promise associated with this deferred object.
  72952. */
  72953. readonly promise: Promise<T>;
  72954. private _resolve;
  72955. private _reject;
  72956. /**
  72957. * The resolve method of the promise associated with this deferred object.
  72958. */
  72959. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72960. /**
  72961. * The reject method of the promise associated with this deferred object.
  72962. */
  72963. get reject(): (reason?: any) => void;
  72964. /**
  72965. * Constructor for this deferred object.
  72966. */
  72967. constructor();
  72968. }
  72969. }
  72970. declare module BABYLON {
  72971. /**
  72972. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72973. */
  72974. export class MeshExploder {
  72975. private _centerMesh;
  72976. private _meshes;
  72977. private _meshesOrigins;
  72978. private _toCenterVectors;
  72979. private _scaledDirection;
  72980. private _newPosition;
  72981. private _centerPosition;
  72982. /**
  72983. * Explodes meshes from a center mesh.
  72984. * @param meshes The meshes to explode.
  72985. * @param centerMesh The mesh to be center of explosion.
  72986. */
  72987. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72988. private _setCenterMesh;
  72989. /**
  72990. * Get class name
  72991. * @returns "MeshExploder"
  72992. */
  72993. getClassName(): string;
  72994. /**
  72995. * "Exploded meshes"
  72996. * @returns Array of meshes with the centerMesh at index 0.
  72997. */
  72998. getMeshes(): Array<Mesh>;
  72999. /**
  73000. * Explodes meshes giving a specific direction
  73001. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73002. */
  73003. explode(direction?: number): void;
  73004. }
  73005. }
  73006. declare module BABYLON {
  73007. /**
  73008. * Class used to help managing file picking and drag'n'drop
  73009. */
  73010. export class FilesInput {
  73011. /**
  73012. * List of files ready to be loaded
  73013. */
  73014. static get FilesToLoad(): {
  73015. [key: string]: File;
  73016. };
  73017. /**
  73018. * Callback called when a file is processed
  73019. */
  73020. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73021. private _engine;
  73022. private _currentScene;
  73023. private _sceneLoadedCallback;
  73024. private _progressCallback;
  73025. private _additionalRenderLoopLogicCallback;
  73026. private _textureLoadingCallback;
  73027. private _startingProcessingFilesCallback;
  73028. private _onReloadCallback;
  73029. private _errorCallback;
  73030. private _elementToMonitor;
  73031. private _sceneFileToLoad;
  73032. private _filesToLoad;
  73033. /**
  73034. * Creates a new FilesInput
  73035. * @param engine defines the rendering engine
  73036. * @param scene defines the hosting scene
  73037. * @param sceneLoadedCallback callback called when scene is loaded
  73038. * @param progressCallback callback called to track progress
  73039. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73040. * @param textureLoadingCallback callback called when a texture is loading
  73041. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73042. * @param onReloadCallback callback called when a reload is requested
  73043. * @param errorCallback callback call if an error occurs
  73044. */
  73045. 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>);
  73046. private _dragEnterHandler;
  73047. private _dragOverHandler;
  73048. private _dropHandler;
  73049. /**
  73050. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73051. * @param elementToMonitor defines the DOM element to track
  73052. */
  73053. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73054. /** Gets the current list of files to load */
  73055. get filesToLoad(): File[];
  73056. /**
  73057. * Release all associated resources
  73058. */
  73059. dispose(): void;
  73060. private renderFunction;
  73061. private drag;
  73062. private drop;
  73063. private _traverseFolder;
  73064. private _processFiles;
  73065. /**
  73066. * Load files from a drop event
  73067. * @param event defines the drop event to use as source
  73068. */
  73069. loadFiles(event: any): void;
  73070. private _processReload;
  73071. /**
  73072. * Reload the current scene from the loaded files
  73073. */
  73074. reload(): void;
  73075. }
  73076. }
  73077. declare module BABYLON {
  73078. /**
  73079. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73080. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73081. */
  73082. export class SceneOptimization {
  73083. /**
  73084. * Defines the priority of this optimization (0 by default which means first in the list)
  73085. */
  73086. priority: number;
  73087. /**
  73088. * Gets a string describing the action executed by the current optimization
  73089. * @returns description string
  73090. */
  73091. getDescription(): string;
  73092. /**
  73093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73094. * @param scene defines the current scene where to apply this optimization
  73095. * @param optimizer defines the current optimizer
  73096. * @returns true if everything that can be done was applied
  73097. */
  73098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73099. /**
  73100. * Creates the SceneOptimization object
  73101. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73102. * @param desc defines the description associated with the optimization
  73103. */
  73104. constructor(
  73105. /**
  73106. * Defines the priority of this optimization (0 by default which means first in the list)
  73107. */
  73108. priority?: number);
  73109. }
  73110. /**
  73111. * Defines an optimization used to reduce the size of render target textures
  73112. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73113. */
  73114. export class TextureOptimization extends SceneOptimization {
  73115. /**
  73116. * Defines the priority of this optimization (0 by default which means first in the list)
  73117. */
  73118. priority: number;
  73119. /**
  73120. * 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
  73121. */
  73122. maximumSize: number;
  73123. /**
  73124. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73125. */
  73126. step: number;
  73127. /**
  73128. * Gets a string describing the action executed by the current optimization
  73129. * @returns description string
  73130. */
  73131. getDescription(): string;
  73132. /**
  73133. * Creates the TextureOptimization object
  73134. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73135. * @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
  73136. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73137. */
  73138. constructor(
  73139. /**
  73140. * Defines the priority of this optimization (0 by default which means first in the list)
  73141. */
  73142. priority?: number,
  73143. /**
  73144. * 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
  73145. */
  73146. maximumSize?: number,
  73147. /**
  73148. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73149. */
  73150. step?: number);
  73151. /**
  73152. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73153. * @param scene defines the current scene where to apply this optimization
  73154. * @param optimizer defines the current optimizer
  73155. * @returns true if everything that can be done was applied
  73156. */
  73157. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73158. }
  73159. /**
  73160. * Defines an optimization used to increase or decrease the rendering resolution
  73161. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73162. */
  73163. export class HardwareScalingOptimization extends SceneOptimization {
  73164. /**
  73165. * Defines the priority of this optimization (0 by default which means first in the list)
  73166. */
  73167. priority: number;
  73168. /**
  73169. * Defines the maximum scale to use (2 by default)
  73170. */
  73171. maximumScale: number;
  73172. /**
  73173. * Defines the step to use between two passes (0.5 by default)
  73174. */
  73175. step: number;
  73176. private _currentScale;
  73177. private _directionOffset;
  73178. /**
  73179. * Gets a string describing the action executed by the current optimization
  73180. * @return description string
  73181. */
  73182. getDescription(): string;
  73183. /**
  73184. * Creates the HardwareScalingOptimization object
  73185. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73186. * @param maximumScale defines the maximum scale to use (2 by default)
  73187. * @param step defines the step to use between two passes (0.5 by default)
  73188. */
  73189. constructor(
  73190. /**
  73191. * Defines the priority of this optimization (0 by default which means first in the list)
  73192. */
  73193. priority?: number,
  73194. /**
  73195. * Defines the maximum scale to use (2 by default)
  73196. */
  73197. maximumScale?: number,
  73198. /**
  73199. * Defines the step to use between two passes (0.5 by default)
  73200. */
  73201. step?: number);
  73202. /**
  73203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73204. * @param scene defines the current scene where to apply this optimization
  73205. * @param optimizer defines the current optimizer
  73206. * @returns true if everything that can be done was applied
  73207. */
  73208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73209. }
  73210. /**
  73211. * Defines an optimization used to remove shadows
  73212. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73213. */
  73214. export class ShadowsOptimization extends SceneOptimization {
  73215. /**
  73216. * Gets a string describing the action executed by the current optimization
  73217. * @return description string
  73218. */
  73219. getDescription(): string;
  73220. /**
  73221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73222. * @param scene defines the current scene where to apply this optimization
  73223. * @param optimizer defines the current optimizer
  73224. * @returns true if everything that can be done was applied
  73225. */
  73226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73227. }
  73228. /**
  73229. * Defines an optimization used to turn post-processes off
  73230. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73231. */
  73232. export class PostProcessesOptimization extends SceneOptimization {
  73233. /**
  73234. * Gets a string describing the action executed by the current optimization
  73235. * @return description string
  73236. */
  73237. getDescription(): string;
  73238. /**
  73239. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73240. * @param scene defines the current scene where to apply this optimization
  73241. * @param optimizer defines the current optimizer
  73242. * @returns true if everything that can be done was applied
  73243. */
  73244. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73245. }
  73246. /**
  73247. * Defines an optimization used to turn lens flares off
  73248. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73249. */
  73250. export class LensFlaresOptimization extends SceneOptimization {
  73251. /**
  73252. * Gets a string describing the action executed by the current optimization
  73253. * @return description string
  73254. */
  73255. getDescription(): string;
  73256. /**
  73257. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73258. * @param scene defines the current scene where to apply this optimization
  73259. * @param optimizer defines the current optimizer
  73260. * @returns true if everything that can be done was applied
  73261. */
  73262. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73263. }
  73264. /**
  73265. * Defines an optimization based on user defined callback.
  73266. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73267. */
  73268. export class CustomOptimization extends SceneOptimization {
  73269. /**
  73270. * Callback called to apply the custom optimization.
  73271. */
  73272. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73273. /**
  73274. * Callback called to get custom description
  73275. */
  73276. onGetDescription: () => string;
  73277. /**
  73278. * Gets a string describing the action executed by the current optimization
  73279. * @returns description string
  73280. */
  73281. getDescription(): string;
  73282. /**
  73283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73284. * @param scene defines the current scene where to apply this optimization
  73285. * @param optimizer defines the current optimizer
  73286. * @returns true if everything that can be done was applied
  73287. */
  73288. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73289. }
  73290. /**
  73291. * Defines an optimization used to turn particles off
  73292. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73293. */
  73294. export class ParticlesOptimization extends SceneOptimization {
  73295. /**
  73296. * Gets a string describing the action executed by the current optimization
  73297. * @return description string
  73298. */
  73299. getDescription(): string;
  73300. /**
  73301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73302. * @param scene defines the current scene where to apply this optimization
  73303. * @param optimizer defines the current optimizer
  73304. * @returns true if everything that can be done was applied
  73305. */
  73306. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73307. }
  73308. /**
  73309. * Defines an optimization used to turn render targets off
  73310. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73311. */
  73312. export class RenderTargetsOptimization extends SceneOptimization {
  73313. /**
  73314. * Gets a string describing the action executed by the current optimization
  73315. * @return description string
  73316. */
  73317. getDescription(): string;
  73318. /**
  73319. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73320. * @param scene defines the current scene where to apply this optimization
  73321. * @param optimizer defines the current optimizer
  73322. * @returns true if everything that can be done was applied
  73323. */
  73324. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73325. }
  73326. /**
  73327. * Defines an optimization used to merge meshes with compatible materials
  73328. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73329. */
  73330. export class MergeMeshesOptimization extends SceneOptimization {
  73331. private static _UpdateSelectionTree;
  73332. /**
  73333. * Gets or sets a boolean which defines if optimization octree has to be updated
  73334. */
  73335. static get UpdateSelectionTree(): boolean;
  73336. /**
  73337. * Gets or sets a boolean which defines if optimization octree has to be updated
  73338. */
  73339. static set UpdateSelectionTree(value: boolean);
  73340. /**
  73341. * Gets a string describing the action executed by the current optimization
  73342. * @return description string
  73343. */
  73344. getDescription(): string;
  73345. private _canBeMerged;
  73346. /**
  73347. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73348. * @param scene defines the current scene where to apply this optimization
  73349. * @param optimizer defines the current optimizer
  73350. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73351. * @returns true if everything that can be done was applied
  73352. */
  73353. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73354. }
  73355. /**
  73356. * Defines a list of options used by SceneOptimizer
  73357. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73358. */
  73359. export class SceneOptimizerOptions {
  73360. /**
  73361. * Defines the target frame rate to reach (60 by default)
  73362. */
  73363. targetFrameRate: number;
  73364. /**
  73365. * Defines the interval between two checkes (2000ms by default)
  73366. */
  73367. trackerDuration: number;
  73368. /**
  73369. * Gets the list of optimizations to apply
  73370. */
  73371. optimizations: SceneOptimization[];
  73372. /**
  73373. * Creates a new list of options used by SceneOptimizer
  73374. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73375. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73376. */
  73377. constructor(
  73378. /**
  73379. * Defines the target frame rate to reach (60 by default)
  73380. */
  73381. targetFrameRate?: number,
  73382. /**
  73383. * Defines the interval between two checkes (2000ms by default)
  73384. */
  73385. trackerDuration?: number);
  73386. /**
  73387. * Add a new optimization
  73388. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73389. * @returns the current SceneOptimizerOptions
  73390. */
  73391. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73392. /**
  73393. * Add a new custom optimization
  73394. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73395. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73396. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73397. * @returns the current SceneOptimizerOptions
  73398. */
  73399. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73400. /**
  73401. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73402. * @param targetFrameRate defines the target frame rate (60 by default)
  73403. * @returns a SceneOptimizerOptions object
  73404. */
  73405. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73406. /**
  73407. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73408. * @param targetFrameRate defines the target frame rate (60 by default)
  73409. * @returns a SceneOptimizerOptions object
  73410. */
  73411. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73412. /**
  73413. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73414. * @param targetFrameRate defines the target frame rate (60 by default)
  73415. * @returns a SceneOptimizerOptions object
  73416. */
  73417. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73418. }
  73419. /**
  73420. * Class used to run optimizations in order to reach a target frame rate
  73421. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73422. */
  73423. export class SceneOptimizer implements IDisposable {
  73424. private _isRunning;
  73425. private _options;
  73426. private _scene;
  73427. private _currentPriorityLevel;
  73428. private _targetFrameRate;
  73429. private _trackerDuration;
  73430. private _currentFrameRate;
  73431. private _sceneDisposeObserver;
  73432. private _improvementMode;
  73433. /**
  73434. * Defines an observable called when the optimizer reaches the target frame rate
  73435. */
  73436. onSuccessObservable: Observable<SceneOptimizer>;
  73437. /**
  73438. * Defines an observable called when the optimizer enables an optimization
  73439. */
  73440. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73441. /**
  73442. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73443. */
  73444. onFailureObservable: Observable<SceneOptimizer>;
  73445. /**
  73446. * Gets a boolean indicating if the optimizer is in improvement mode
  73447. */
  73448. get isInImprovementMode(): boolean;
  73449. /**
  73450. * Gets the current priority level (0 at start)
  73451. */
  73452. get currentPriorityLevel(): number;
  73453. /**
  73454. * Gets the current frame rate checked by the SceneOptimizer
  73455. */
  73456. get currentFrameRate(): number;
  73457. /**
  73458. * Gets or sets the current target frame rate (60 by default)
  73459. */
  73460. get targetFrameRate(): number;
  73461. /**
  73462. * Gets or sets the current target frame rate (60 by default)
  73463. */
  73464. set targetFrameRate(value: number);
  73465. /**
  73466. * Gets or sets the current interval between two checks (every 2000ms by default)
  73467. */
  73468. get trackerDuration(): number;
  73469. /**
  73470. * Gets or sets the current interval between two checks (every 2000ms by default)
  73471. */
  73472. set trackerDuration(value: number);
  73473. /**
  73474. * Gets the list of active optimizations
  73475. */
  73476. get optimizations(): SceneOptimization[];
  73477. /**
  73478. * Creates a new SceneOptimizer
  73479. * @param scene defines the scene to work on
  73480. * @param options defines the options to use with the SceneOptimizer
  73481. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73482. * @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)
  73483. */
  73484. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73485. /**
  73486. * Stops the current optimizer
  73487. */
  73488. stop(): void;
  73489. /**
  73490. * Reset the optimizer to initial step (current priority level = 0)
  73491. */
  73492. reset(): void;
  73493. /**
  73494. * Start the optimizer. By default it will try to reach a specific framerate
  73495. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73496. */
  73497. start(): void;
  73498. private _checkCurrentState;
  73499. /**
  73500. * Release all resources
  73501. */
  73502. dispose(): void;
  73503. /**
  73504. * Helper function to create a SceneOptimizer with one single line of code
  73505. * @param scene defines the scene to work on
  73506. * @param options defines the options to use with the SceneOptimizer
  73507. * @param onSuccess defines a callback to call on success
  73508. * @param onFailure defines a callback to call on failure
  73509. * @returns the new SceneOptimizer object
  73510. */
  73511. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73512. }
  73513. }
  73514. declare module BABYLON {
  73515. /**
  73516. * Class used to serialize a scene into a string
  73517. */
  73518. export class SceneSerializer {
  73519. /**
  73520. * Clear cache used by a previous serialization
  73521. */
  73522. static ClearCache(): void;
  73523. /**
  73524. * Serialize a scene into a JSON compatible object
  73525. * @param scene defines the scene to serialize
  73526. * @returns a JSON compatible object
  73527. */
  73528. static Serialize(scene: Scene): any;
  73529. /**
  73530. * Serialize a mesh into a JSON compatible object
  73531. * @param toSerialize defines the mesh to serialize
  73532. * @param withParents defines if parents must be serialized as well
  73533. * @param withChildren defines if children must be serialized as well
  73534. * @returns a JSON compatible object
  73535. */
  73536. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73537. }
  73538. }
  73539. declare module BABYLON {
  73540. /**
  73541. * Class used to host texture specific utilities
  73542. */
  73543. export class TextureTools {
  73544. /**
  73545. * Uses the GPU to create a copy texture rescaled at a given size
  73546. * @param texture Texture to copy from
  73547. * @param width defines the desired width
  73548. * @param height defines the desired height
  73549. * @param useBilinearMode defines if bilinear mode has to be used
  73550. * @return the generated texture
  73551. */
  73552. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73553. }
  73554. }
  73555. declare module BABYLON {
  73556. /**
  73557. * This represents the different options available for the video capture.
  73558. */
  73559. export interface VideoRecorderOptions {
  73560. /** Defines the mime type of the video. */
  73561. mimeType: string;
  73562. /** Defines the FPS the video should be recorded at. */
  73563. fps: number;
  73564. /** Defines the chunk size for the recording data. */
  73565. recordChunckSize: number;
  73566. /** The audio tracks to attach to the recording. */
  73567. audioTracks?: MediaStreamTrack[];
  73568. }
  73569. /**
  73570. * This can help with recording videos from BabylonJS.
  73571. * This is based on the available WebRTC functionalities of the browser.
  73572. *
  73573. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73574. */
  73575. export class VideoRecorder {
  73576. private static readonly _defaultOptions;
  73577. /**
  73578. * Returns whether or not the VideoRecorder is available in your browser.
  73579. * @param engine Defines the Babylon Engine.
  73580. * @returns true if supported otherwise false.
  73581. */
  73582. static IsSupported(engine: Engine): boolean;
  73583. private readonly _options;
  73584. private _canvas;
  73585. private _mediaRecorder;
  73586. private _recordedChunks;
  73587. private _fileName;
  73588. private _resolve;
  73589. private _reject;
  73590. /**
  73591. * True when a recording is already in progress.
  73592. */
  73593. get isRecording(): boolean;
  73594. /**
  73595. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73596. * @param engine Defines the BabylonJS Engine you wish to record.
  73597. * @param options Defines options that can be used to customize the capture.
  73598. */
  73599. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73600. /**
  73601. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73602. */
  73603. stopRecording(): void;
  73604. /**
  73605. * Starts recording the canvas for a max duration specified in parameters.
  73606. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73607. * If null no automatic download will start and you can rely on the promise to get the data back.
  73608. * @param maxDuration Defines the maximum recording time in seconds.
  73609. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73610. * @return A promise callback at the end of the recording with the video data in Blob.
  73611. */
  73612. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73613. /**
  73614. * Releases internal resources used during the recording.
  73615. */
  73616. dispose(): void;
  73617. private _handleDataAvailable;
  73618. private _handleError;
  73619. private _handleStop;
  73620. }
  73621. }
  73622. declare module BABYLON {
  73623. /**
  73624. * Class containing a set of static utilities functions for screenshots
  73625. */
  73626. export class ScreenshotTools {
  73627. /**
  73628. * Captures a screenshot of the current rendering
  73629. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73630. * @param engine defines the rendering engine
  73631. * @param camera defines the source camera
  73632. * @param size This parameter can be set to a single number or to an object with the
  73633. * following (optional) properties: precision, width, height. If a single number is passed,
  73634. * it will be used for both width and height. If an object is passed, the screenshot size
  73635. * will be derived from the parameters. The precision property is a multiplier allowing
  73636. * rendering at a higher or lower resolution
  73637. * @param successCallback defines the callback receives a single parameter which contains the
  73638. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73639. * src parameter of an <img> to display it
  73640. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73641. * Check your browser for supported MIME types
  73642. */
  73643. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73644. /**
  73645. * Captures a screenshot of the current rendering
  73646. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73647. * @param engine defines the rendering engine
  73648. * @param camera defines the source camera
  73649. * @param size This parameter can be set to a single number or to an object with the
  73650. * following (optional) properties: precision, width, height. If a single number is passed,
  73651. * it will be used for both width and height. If an object is passed, the screenshot size
  73652. * will be derived from the parameters. The precision property is a multiplier allowing
  73653. * rendering at a higher or lower resolution
  73654. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73655. * Check your browser for supported MIME types
  73656. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73657. * to the src parameter of an <img> to display it
  73658. */
  73659. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73660. /**
  73661. * Generates an image screenshot from the specified camera.
  73662. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73663. * @param engine The engine to use for rendering
  73664. * @param camera The camera to use for rendering
  73665. * @param size This parameter can be set to a single number or to an object with the
  73666. * following (optional) properties: precision, width, height. If a single number is passed,
  73667. * it will be used for both width and height. If an object is passed, the screenshot size
  73668. * will be derived from the parameters. The precision property is a multiplier allowing
  73669. * rendering at a higher or lower resolution
  73670. * @param successCallback The callback receives a single parameter which contains the
  73671. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73672. * src parameter of an <img> to display it
  73673. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73674. * Check your browser for supported MIME types
  73675. * @param samples Texture samples (default: 1)
  73676. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73677. * @param fileName A name for for the downloaded file.
  73678. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73679. */
  73680. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73681. /**
  73682. * Generates an image screenshot from the specified camera.
  73683. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73684. * @param engine The engine to use for rendering
  73685. * @param camera The camera to use for rendering
  73686. * @param size This parameter can be set to a single number or to an object with the
  73687. * following (optional) properties: precision, width, height. If a single number is passed,
  73688. * it will be used for both width and height. If an object is passed, the screenshot size
  73689. * will be derived from the parameters. The precision property is a multiplier allowing
  73690. * rendering at a higher or lower resolution
  73691. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73692. * Check your browser for supported MIME types
  73693. * @param samples Texture samples (default: 1)
  73694. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73695. * @param fileName A name for for the downloaded file.
  73696. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73697. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73698. * to the src parameter of an <img> to display it
  73699. */
  73700. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73701. /**
  73702. * Gets height and width for screenshot size
  73703. * @private
  73704. */
  73705. private static _getScreenshotSize;
  73706. }
  73707. }
  73708. declare module BABYLON {
  73709. /**
  73710. * Interface for a data buffer
  73711. */
  73712. export interface IDataBuffer {
  73713. /**
  73714. * Reads bytes from the data buffer.
  73715. * @param byteOffset The byte offset to read
  73716. * @param byteLength The byte length to read
  73717. * @returns A promise that resolves when the bytes are read
  73718. */
  73719. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73720. /**
  73721. * The byte length of the buffer.
  73722. */
  73723. readonly byteLength: number;
  73724. }
  73725. /**
  73726. * Utility class for reading from a data buffer
  73727. */
  73728. export class DataReader {
  73729. /**
  73730. * The data buffer associated with this data reader.
  73731. */
  73732. readonly buffer: IDataBuffer;
  73733. /**
  73734. * The current byte offset from the beginning of the data buffer.
  73735. */
  73736. byteOffset: number;
  73737. private _dataView;
  73738. private _dataByteOffset;
  73739. /**
  73740. * Constructor
  73741. * @param buffer The buffer to read
  73742. */
  73743. constructor(buffer: IDataBuffer);
  73744. /**
  73745. * Loads the given byte length.
  73746. * @param byteLength The byte length to load
  73747. * @returns A promise that resolves when the load is complete
  73748. */
  73749. loadAsync(byteLength: number): Promise<void>;
  73750. /**
  73751. * Read a unsigned 32-bit integer from the currently loaded data range.
  73752. * @returns The 32-bit integer read
  73753. */
  73754. readUint32(): number;
  73755. /**
  73756. * Read a byte array from the currently loaded data range.
  73757. * @param byteLength The byte length to read
  73758. * @returns The byte array read
  73759. */
  73760. readUint8Array(byteLength: number): Uint8Array;
  73761. /**
  73762. * Read a string from the currently loaded data range.
  73763. * @param byteLength The byte length to read
  73764. * @returns The string read
  73765. */
  73766. readString(byteLength: number): string;
  73767. /**
  73768. * Skips the given byte length the currently loaded data range.
  73769. * @param byteLength The byte length to skip
  73770. */
  73771. skipBytes(byteLength: number): void;
  73772. }
  73773. }
  73774. declare module BABYLON {
  73775. /**
  73776. * Class for storing data to local storage if available or in-memory storage otherwise
  73777. */
  73778. export class DataStorage {
  73779. private static _Storage;
  73780. private static _GetStorage;
  73781. /**
  73782. * Reads a string from the data storage
  73783. * @param key The key to read
  73784. * @param defaultValue The value if the key doesn't exist
  73785. * @returns The string value
  73786. */
  73787. static ReadString(key: string, defaultValue: string): string;
  73788. /**
  73789. * Writes a string to the data storage
  73790. * @param key The key to write
  73791. * @param value The value to write
  73792. */
  73793. static WriteString(key: string, value: string): void;
  73794. /**
  73795. * Reads a boolean from the data storage
  73796. * @param key The key to read
  73797. * @param defaultValue The value if the key doesn't exist
  73798. * @returns The boolean value
  73799. */
  73800. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73801. /**
  73802. * Writes a boolean to the data storage
  73803. * @param key The key to write
  73804. * @param value The value to write
  73805. */
  73806. static WriteBoolean(key: string, value: boolean): void;
  73807. /**
  73808. * Reads a number from the data storage
  73809. * @param key The key to read
  73810. * @param defaultValue The value if the key doesn't exist
  73811. * @returns The number value
  73812. */
  73813. static ReadNumber(key: string, defaultValue: number): number;
  73814. /**
  73815. * Writes a number to the data storage
  73816. * @param key The key to write
  73817. * @param value The value to write
  73818. */
  73819. static WriteNumber(key: string, value: number): void;
  73820. }
  73821. }
  73822. declare module BABYLON {
  73823. /**
  73824. * Class used to record delta files between 2 scene states
  73825. */
  73826. export class SceneRecorder {
  73827. private _trackedScene;
  73828. private _savedJSON;
  73829. /**
  73830. * Track a given scene. This means the current scene state will be considered the original state
  73831. * @param scene defines the scene to track
  73832. */
  73833. track(scene: Scene): void;
  73834. /**
  73835. * Get the delta between current state and original state
  73836. * @returns a string containing the delta
  73837. */
  73838. getDelta(): any;
  73839. private _compareArray;
  73840. private _compareObjects;
  73841. private _compareCollections;
  73842. private static GetShadowGeneratorById;
  73843. /**
  73844. * Apply a given delta to a given scene
  73845. * @param deltaJSON defines the JSON containing the delta
  73846. * @param scene defines the scene to apply the delta to
  73847. */
  73848. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  73849. private static _ApplyPropertiesToEntity;
  73850. private static _ApplyDeltaForEntity;
  73851. }
  73852. }
  73853. declare module BABYLON {
  73854. /**
  73855. * An interface for all Hit test features
  73856. */
  73857. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73858. /**
  73859. * Triggered when new babylon (transformed) hit test results are available
  73860. */
  73861. onHitTestResultObservable: Observable<T[]>;
  73862. }
  73863. /**
  73864. * Options used for hit testing
  73865. */
  73866. export interface IWebXRLegacyHitTestOptions {
  73867. /**
  73868. * Only test when user interacted with the scene. Default - hit test every frame
  73869. */
  73870. testOnPointerDownOnly?: boolean;
  73871. /**
  73872. * The node to use to transform the local results to world coordinates
  73873. */
  73874. worldParentNode?: TransformNode;
  73875. }
  73876. /**
  73877. * Interface defining the babylon result of raycasting/hit-test
  73878. */
  73879. export interface IWebXRLegacyHitResult {
  73880. /**
  73881. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73882. */
  73883. transformationMatrix: Matrix;
  73884. /**
  73885. * The native hit test result
  73886. */
  73887. xrHitResult: XRHitResult | XRHitTestResult;
  73888. }
  73889. /**
  73890. * The currently-working hit-test module.
  73891. * Hit test (or Ray-casting) is used to interact with the real world.
  73892. * For further information read here - https://github.com/immersive-web/hit-test
  73893. */
  73894. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73895. /**
  73896. * options to use when constructing this feature
  73897. */
  73898. readonly options: IWebXRLegacyHitTestOptions;
  73899. private _direction;
  73900. private _mat;
  73901. private _onSelectEnabled;
  73902. private _origin;
  73903. /**
  73904. * The module's name
  73905. */
  73906. static readonly Name: string;
  73907. /**
  73908. * The (Babylon) version of this module.
  73909. * This is an integer representing the implementation version.
  73910. * This number does not correspond to the WebXR specs version
  73911. */
  73912. static readonly Version: number;
  73913. /**
  73914. * Populated with the last native XR Hit Results
  73915. */
  73916. lastNativeXRHitResults: XRHitResult[];
  73917. /**
  73918. * Triggered when new babylon (transformed) hit test results are available
  73919. */
  73920. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73921. /**
  73922. * Creates a new instance of the (legacy version) hit test feature
  73923. * @param _xrSessionManager an instance of WebXRSessionManager
  73924. * @param options options to use when constructing this feature
  73925. */
  73926. constructor(_xrSessionManager: WebXRSessionManager,
  73927. /**
  73928. * options to use when constructing this feature
  73929. */
  73930. options?: IWebXRLegacyHitTestOptions);
  73931. /**
  73932. * execute a hit test with an XR Ray
  73933. *
  73934. * @param xrSession a native xrSession that will execute this hit test
  73935. * @param xrRay the ray (position and direction) to use for ray-casting
  73936. * @param referenceSpace native XR reference space to use for the hit-test
  73937. * @param filter filter function that will filter the results
  73938. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73939. */
  73940. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73941. /**
  73942. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73943. * @param event the (select) event to use to select with
  73944. * @param referenceSpace the reference space to use for this hit test
  73945. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73946. */
  73947. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73948. /**
  73949. * attach this feature
  73950. * Will usually be called by the features manager
  73951. *
  73952. * @returns true if successful.
  73953. */
  73954. attach(): boolean;
  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 _onHitTestResults;
  73968. private _onSelect;
  73969. }
  73970. }
  73971. declare module BABYLON {
  73972. /**
  73973. * Options used for hit testing (version 2)
  73974. */
  73975. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73976. /**
  73977. * Do not create a permanent hit test. Will usually be used when only
  73978. * transient inputs are needed.
  73979. */
  73980. disablePermanentHitTest?: boolean;
  73981. /**
  73982. * Enable transient (for example touch-based) hit test inspections
  73983. */
  73984. enableTransientHitTest?: boolean;
  73985. /**
  73986. * Offset ray for the permanent hit test
  73987. */
  73988. offsetRay?: Vector3;
  73989. /**
  73990. * Offset ray for the transient hit test
  73991. */
  73992. transientOffsetRay?: Vector3;
  73993. /**
  73994. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73995. */
  73996. useReferenceSpace?: boolean;
  73997. }
  73998. /**
  73999. * Interface defining the babylon result of hit-test
  74000. */
  74001. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74002. /**
  74003. * The input source that generated this hit test (if transient)
  74004. */
  74005. inputSource?: XRInputSource;
  74006. /**
  74007. * Is this a transient hit test
  74008. */
  74009. isTransient?: boolean;
  74010. /**
  74011. * Position of the hit test result
  74012. */
  74013. position: Vector3;
  74014. /**
  74015. * Rotation of the hit test result
  74016. */
  74017. rotationQuaternion: Quaternion;
  74018. /**
  74019. * The native hit test result
  74020. */
  74021. xrHitResult: XRHitTestResult;
  74022. }
  74023. /**
  74024. * The currently-working hit-test module.
  74025. * Hit test (or Ray-casting) is used to interact with the real world.
  74026. * For further information read here - https://github.com/immersive-web/hit-test
  74027. *
  74028. * Tested on chrome (mobile) 80.
  74029. */
  74030. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74031. /**
  74032. * options to use when constructing this feature
  74033. */
  74034. readonly options: IWebXRHitTestOptions;
  74035. private _tmpMat;
  74036. private _tmpPos;
  74037. private _tmpQuat;
  74038. private _transientXrHitTestSource;
  74039. private _xrHitTestSource;
  74040. private initHitTestSource;
  74041. /**
  74042. * The module's name
  74043. */
  74044. static readonly Name: string;
  74045. /**
  74046. * The (Babylon) version of this module.
  74047. * This is an integer representing the implementation version.
  74048. * This number does not correspond to the WebXR specs version
  74049. */
  74050. static readonly Version: number;
  74051. /**
  74052. * When set to true, each hit test will have its own position/rotation objects
  74053. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74054. * the developers will clone them or copy them as they see fit.
  74055. */
  74056. autoCloneTransformation: boolean;
  74057. /**
  74058. * Triggered when new babylon (transformed) hit test results are available
  74059. */
  74060. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74061. /**
  74062. * Use this to temporarily pause hit test checks.
  74063. */
  74064. paused: boolean;
  74065. /**
  74066. * Creates a new instance of the hit test feature
  74067. * @param _xrSessionManager an instance of WebXRSessionManager
  74068. * @param options options to use when constructing this feature
  74069. */
  74070. constructor(_xrSessionManager: WebXRSessionManager,
  74071. /**
  74072. * options to use when constructing this feature
  74073. */
  74074. options?: IWebXRHitTestOptions);
  74075. /**
  74076. * attach this feature
  74077. * Will usually be called by the features manager
  74078. *
  74079. * @returns true if successful.
  74080. */
  74081. attach(): boolean;
  74082. /**
  74083. * detach this feature.
  74084. * Will usually be called by the features manager
  74085. *
  74086. * @returns true if successful.
  74087. */
  74088. detach(): boolean;
  74089. /**
  74090. * Dispose this feature and all of the resources attached
  74091. */
  74092. dispose(): void;
  74093. protected _onXRFrame(frame: XRFrame): void;
  74094. private _processWebXRHitTestResult;
  74095. }
  74096. }
  74097. declare module BABYLON {
  74098. /**
  74099. * Configuration options of the anchor system
  74100. */
  74101. export interface IWebXRAnchorSystemOptions {
  74102. /**
  74103. * a node that will be used to convert local to world coordinates
  74104. */
  74105. worldParentNode?: TransformNode;
  74106. /**
  74107. * If set to true a reference of the created anchors will be kept until the next session starts
  74108. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74109. */
  74110. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74111. }
  74112. /**
  74113. * A babylon container for an XR Anchor
  74114. */
  74115. export interface IWebXRAnchor {
  74116. /**
  74117. * A babylon-assigned ID for this anchor
  74118. */
  74119. id: number;
  74120. /**
  74121. * Transformation matrix to apply to an object attached to this anchor
  74122. */
  74123. transformationMatrix: Matrix;
  74124. /**
  74125. * The native anchor object
  74126. */
  74127. xrAnchor: XRAnchor;
  74128. /**
  74129. * if defined, this object will be constantly updated by the anchor's position and rotation
  74130. */
  74131. attachedNode?: TransformNode;
  74132. }
  74133. /**
  74134. * An implementation of the anchor system for WebXR.
  74135. * For further information see https://github.com/immersive-web/anchors/
  74136. */
  74137. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74138. private _options;
  74139. private _lastFrameDetected;
  74140. private _trackedAnchors;
  74141. private _referenceSpaceForFrameAnchors;
  74142. private _futureAnchors;
  74143. /**
  74144. * The module's name
  74145. */
  74146. static readonly Name: string;
  74147. /**
  74148. * The (Babylon) version of this module.
  74149. * This is an integer representing the implementation version.
  74150. * This number does not correspond to the WebXR specs version
  74151. */
  74152. static readonly Version: number;
  74153. /**
  74154. * Observers registered here will be executed when a new anchor was added to the session
  74155. */
  74156. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74157. /**
  74158. * Observers registered here will be executed when an anchor was removed from the session
  74159. */
  74160. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74161. /**
  74162. * Observers registered here will be executed when an existing anchor updates
  74163. * This can execute N times every frame
  74164. */
  74165. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74166. /**
  74167. * Set the reference space to use for anchor creation, when not using a hit test.
  74168. * Will default to the session's reference space if not defined
  74169. */
  74170. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74171. /**
  74172. * constructs a new anchor system
  74173. * @param _xrSessionManager an instance of WebXRSessionManager
  74174. * @param _options configuration object for this feature
  74175. */
  74176. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74177. private _tmpVector;
  74178. private _tmpQuaternion;
  74179. private _populateTmpTransformation;
  74180. /**
  74181. * Create a new anchor point using a hit test result at a specific point in the scene
  74182. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74183. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74184. *
  74185. * @param hitTestResult The hit test result to use for this anchor creation
  74186. * @param position an optional position offset for this anchor
  74187. * @param rotationQuaternion an optional rotation offset for this anchor
  74188. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74189. */
  74190. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74191. /**
  74192. * Add a new anchor at a specific position and rotation
  74193. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74194. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74195. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74196. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74197. *
  74198. * @param position the position in which to add an anchor
  74199. * @param rotationQuaternion an optional rotation for the anchor transformation
  74200. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74201. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74202. */
  74203. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74204. /**
  74205. * detach this feature.
  74206. * Will usually be called by the features manager
  74207. *
  74208. * @returns true if successful.
  74209. */
  74210. detach(): boolean;
  74211. /**
  74212. * Dispose this feature and all of the resources attached
  74213. */
  74214. dispose(): void;
  74215. protected _onXRFrame(frame: XRFrame): void;
  74216. /**
  74217. * avoiding using Array.find for global support.
  74218. * @param xrAnchor the plane to find in the array
  74219. */
  74220. private _findIndexInAnchorArray;
  74221. private _updateAnchorWithXRFrame;
  74222. private _createAnchorAtTransformation;
  74223. }
  74224. }
  74225. declare module BABYLON {
  74226. /**
  74227. * Options used in the plane detector module
  74228. */
  74229. export interface IWebXRPlaneDetectorOptions {
  74230. /**
  74231. * The node to use to transform the local results to world coordinates
  74232. */
  74233. worldParentNode?: TransformNode;
  74234. /**
  74235. * If set to true a reference of the created planes will be kept until the next session starts
  74236. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74237. */
  74238. doNotRemovePlanesOnSessionEnded?: boolean;
  74239. }
  74240. /**
  74241. * A babylon interface for a WebXR plane.
  74242. * A Plane is actually a polygon, built from N points in space
  74243. *
  74244. * Supported in chrome 79, not supported in canary 81 ATM
  74245. */
  74246. export interface IWebXRPlane {
  74247. /**
  74248. * a babylon-assigned ID for this polygon
  74249. */
  74250. id: number;
  74251. /**
  74252. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74253. */
  74254. polygonDefinition: Array<Vector3>;
  74255. /**
  74256. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74257. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74258. */
  74259. transformationMatrix: Matrix;
  74260. /**
  74261. * the native xr-plane object
  74262. */
  74263. xrPlane: XRPlane;
  74264. }
  74265. /**
  74266. * The plane detector is used to detect planes in the real world when in AR
  74267. * For more information see https://github.com/immersive-web/real-world-geometry/
  74268. */
  74269. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74270. private _options;
  74271. private _detectedPlanes;
  74272. private _enabled;
  74273. private _lastFrameDetected;
  74274. /**
  74275. * The module's name
  74276. */
  74277. static readonly Name: string;
  74278. /**
  74279. * The (Babylon) version of this module.
  74280. * This is an integer representing the implementation version.
  74281. * This number does not correspond to the WebXR specs version
  74282. */
  74283. static readonly Version: number;
  74284. /**
  74285. * Observers registered here will be executed when a new plane was added to the session
  74286. */
  74287. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74288. /**
  74289. * Observers registered here will be executed when a plane is no longer detected in the session
  74290. */
  74291. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74292. /**
  74293. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74294. * This can execute N times every frame
  74295. */
  74296. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74297. /**
  74298. * construct a new Plane Detector
  74299. * @param _xrSessionManager an instance of xr Session manager
  74300. * @param _options configuration to use when constructing this feature
  74301. */
  74302. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74303. /**
  74304. * detach this feature.
  74305. * Will usually be called by the features manager
  74306. *
  74307. * @returns true if successful.
  74308. */
  74309. detach(): boolean;
  74310. /**
  74311. * Dispose this feature and all of the resources attached
  74312. */
  74313. dispose(): void;
  74314. protected _onXRFrame(frame: XRFrame): void;
  74315. private _init;
  74316. private _updatePlaneWithXRPlane;
  74317. /**
  74318. * avoiding using Array.find for global support.
  74319. * @param xrPlane the plane to find in the array
  74320. */
  74321. private findIndexInPlaneArray;
  74322. }
  74323. }
  74324. declare module BABYLON {
  74325. /**
  74326. * Options interface for the background remover plugin
  74327. */
  74328. export interface IWebXRBackgroundRemoverOptions {
  74329. /**
  74330. * Further background meshes to disable when entering AR
  74331. */
  74332. backgroundMeshes?: AbstractMesh[];
  74333. /**
  74334. * flags to configure the removal of the environment helper.
  74335. * If not set, the entire background will be removed. If set, flags should be set as well.
  74336. */
  74337. environmentHelperRemovalFlags?: {
  74338. /**
  74339. * Should the skybox be removed (default false)
  74340. */
  74341. skyBox?: boolean;
  74342. /**
  74343. * Should the ground be removed (default false)
  74344. */
  74345. ground?: boolean;
  74346. };
  74347. /**
  74348. * don't disable the environment helper
  74349. */
  74350. ignoreEnvironmentHelper?: boolean;
  74351. }
  74352. /**
  74353. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74354. */
  74355. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74356. /**
  74357. * read-only options to be used in this module
  74358. */
  74359. readonly options: IWebXRBackgroundRemoverOptions;
  74360. /**
  74361. * The module's name
  74362. */
  74363. static readonly Name: string;
  74364. /**
  74365. * The (Babylon) version of this module.
  74366. * This is an integer representing the implementation version.
  74367. * This number does not correspond to the WebXR specs version
  74368. */
  74369. static readonly Version: number;
  74370. /**
  74371. * registered observers will be triggered when the background state changes
  74372. */
  74373. onBackgroundStateChangedObservable: Observable<boolean>;
  74374. /**
  74375. * constructs a new background remover module
  74376. * @param _xrSessionManager the session manager for this module
  74377. * @param options read-only options to be used in this module
  74378. */
  74379. constructor(_xrSessionManager: WebXRSessionManager,
  74380. /**
  74381. * read-only options to be used in this module
  74382. */
  74383. options?: IWebXRBackgroundRemoverOptions);
  74384. /**
  74385. * attach this feature
  74386. * Will usually be called by the features manager
  74387. *
  74388. * @returns true if successful.
  74389. */
  74390. attach(): boolean;
  74391. /**
  74392. * detach this feature.
  74393. * Will usually be called by the features manager
  74394. *
  74395. * @returns true if successful.
  74396. */
  74397. detach(): boolean;
  74398. /**
  74399. * Dispose this feature and all of the resources attached
  74400. */
  74401. dispose(): void;
  74402. protected _onXRFrame(_xrFrame: XRFrame): void;
  74403. private _setBackgroundState;
  74404. }
  74405. }
  74406. declare module BABYLON {
  74407. /**
  74408. * Options for the controller physics feature
  74409. */
  74410. export class IWebXRControllerPhysicsOptions {
  74411. /**
  74412. * Should the headset get its own impostor
  74413. */
  74414. enableHeadsetImpostor?: boolean;
  74415. /**
  74416. * Optional parameters for the headset impostor
  74417. */
  74418. headsetImpostorParams?: {
  74419. /**
  74420. * The type of impostor to create. Default is sphere
  74421. */
  74422. impostorType: number;
  74423. /**
  74424. * the size of the impostor. Defaults to 10cm
  74425. */
  74426. impostorSize?: number | {
  74427. width: number;
  74428. height: number;
  74429. depth: number;
  74430. };
  74431. /**
  74432. * Friction definitions
  74433. */
  74434. friction?: number;
  74435. /**
  74436. * Restitution
  74437. */
  74438. restitution?: number;
  74439. };
  74440. /**
  74441. * The physics properties of the future impostors
  74442. */
  74443. physicsProperties?: {
  74444. /**
  74445. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74446. * Note that this requires a physics engine that supports mesh impostors!
  74447. */
  74448. useControllerMesh?: boolean;
  74449. /**
  74450. * The type of impostor to create. Default is sphere
  74451. */
  74452. impostorType?: number;
  74453. /**
  74454. * the size of the impostor. Defaults to 10cm
  74455. */
  74456. impostorSize?: number | {
  74457. width: number;
  74458. height: number;
  74459. depth: number;
  74460. };
  74461. /**
  74462. * Friction definitions
  74463. */
  74464. friction?: number;
  74465. /**
  74466. * Restitution
  74467. */
  74468. restitution?: number;
  74469. };
  74470. /**
  74471. * the xr input to use with this pointer selection
  74472. */
  74473. xrInput: WebXRInput;
  74474. }
  74475. /**
  74476. * Add physics impostor to your webxr controllers,
  74477. * including naive calculation of their linear and angular velocity
  74478. */
  74479. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74480. private readonly _options;
  74481. private _attachController;
  74482. private _controllers;
  74483. private _debugMode;
  74484. private _delta;
  74485. private _headsetImpostor?;
  74486. private _headsetMesh?;
  74487. private _lastTimestamp;
  74488. private _tmpQuaternion;
  74489. private _tmpVector;
  74490. /**
  74491. * The module's name
  74492. */
  74493. static readonly Name: string;
  74494. /**
  74495. * The (Babylon) version of this module.
  74496. * This is an integer representing the implementation version.
  74497. * This number does not correspond to the webxr specs version
  74498. */
  74499. static readonly Version: number;
  74500. /**
  74501. * Construct a new Controller Physics Feature
  74502. * @param _xrSessionManager the corresponding xr session manager
  74503. * @param _options options to create this feature with
  74504. */
  74505. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74506. /**
  74507. * @hidden
  74508. * enable debugging - will show console outputs and the impostor mesh
  74509. */
  74510. _enablePhysicsDebug(): void;
  74511. /**
  74512. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74513. * @param xrController the controller to add
  74514. */
  74515. addController(xrController: WebXRInputSource): void;
  74516. /**
  74517. * attach this feature
  74518. * Will usually be called by the features manager
  74519. *
  74520. * @returns true if successful.
  74521. */
  74522. attach(): boolean;
  74523. /**
  74524. * detach this feature.
  74525. * Will usually be called by the features manager
  74526. *
  74527. * @returns true if successful.
  74528. */
  74529. detach(): boolean;
  74530. /**
  74531. * Get the headset impostor, if enabled
  74532. * @returns the impostor
  74533. */
  74534. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74535. /**
  74536. * Get the physics impostor of a specific controller.
  74537. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74538. * @param controller the controller or the controller id of which to get the impostor
  74539. * @returns the impostor or null
  74540. */
  74541. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74542. /**
  74543. * Update the physics properties provided in the constructor
  74544. * @param newProperties the new properties object
  74545. */
  74546. setPhysicsProperties(newProperties: {
  74547. impostorType?: number;
  74548. impostorSize?: number | {
  74549. width: number;
  74550. height: number;
  74551. depth: number;
  74552. };
  74553. friction?: number;
  74554. restitution?: number;
  74555. }): void;
  74556. protected _onXRFrame(_xrFrame: any): void;
  74557. private _detachController;
  74558. }
  74559. }
  74560. declare module BABYLON {
  74561. /**
  74562. * The motion controller class for all microsoft mixed reality controllers
  74563. */
  74564. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74565. protected readonly _mapping: {
  74566. defaultButton: {
  74567. valueNodeName: string;
  74568. unpressedNodeName: string;
  74569. pressedNodeName: string;
  74570. };
  74571. defaultAxis: {
  74572. valueNodeName: string;
  74573. minNodeName: string;
  74574. maxNodeName: string;
  74575. };
  74576. buttons: {
  74577. "xr-standard-trigger": {
  74578. rootNodeName: string;
  74579. componentProperty: string;
  74580. states: string[];
  74581. };
  74582. "xr-standard-squeeze": {
  74583. rootNodeName: string;
  74584. componentProperty: string;
  74585. states: string[];
  74586. };
  74587. "xr-standard-touchpad": {
  74588. rootNodeName: string;
  74589. labelAnchorNodeName: string;
  74590. touchPointNodeName: string;
  74591. };
  74592. "xr-standard-thumbstick": {
  74593. rootNodeName: string;
  74594. componentProperty: string;
  74595. states: string[];
  74596. };
  74597. };
  74598. axes: {
  74599. "xr-standard-touchpad": {
  74600. "x-axis": {
  74601. rootNodeName: string;
  74602. };
  74603. "y-axis": {
  74604. rootNodeName: string;
  74605. };
  74606. };
  74607. "xr-standard-thumbstick": {
  74608. "x-axis": {
  74609. rootNodeName: string;
  74610. };
  74611. "y-axis": {
  74612. rootNodeName: string;
  74613. };
  74614. };
  74615. };
  74616. };
  74617. /**
  74618. * The base url used to load the left and right controller models
  74619. */
  74620. static MODEL_BASE_URL: string;
  74621. /**
  74622. * The name of the left controller model file
  74623. */
  74624. static MODEL_LEFT_FILENAME: string;
  74625. /**
  74626. * The name of the right controller model file
  74627. */
  74628. static MODEL_RIGHT_FILENAME: string;
  74629. profileId: string;
  74630. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74631. protected _getFilenameAndPath(): {
  74632. filename: string;
  74633. path: string;
  74634. };
  74635. protected _getModelLoadingConstraints(): boolean;
  74636. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74637. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74638. protected _updateModel(): void;
  74639. }
  74640. }
  74641. declare module BABYLON {
  74642. /**
  74643. * The motion controller class for oculus touch (quest, rift).
  74644. * This class supports legacy mapping as well the standard xr mapping
  74645. */
  74646. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74647. private _forceLegacyControllers;
  74648. private _modelRootNode;
  74649. /**
  74650. * The base url used to load the left and right controller models
  74651. */
  74652. static MODEL_BASE_URL: string;
  74653. /**
  74654. * The name of the left controller model file
  74655. */
  74656. static MODEL_LEFT_FILENAME: string;
  74657. /**
  74658. * The name of the right controller model file
  74659. */
  74660. static MODEL_RIGHT_FILENAME: string;
  74661. /**
  74662. * Base Url for the Quest controller model.
  74663. */
  74664. static QUEST_MODEL_BASE_URL: string;
  74665. profileId: string;
  74666. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74667. protected _getFilenameAndPath(): {
  74668. filename: string;
  74669. path: string;
  74670. };
  74671. protected _getModelLoadingConstraints(): boolean;
  74672. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74673. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74674. protected _updateModel(): void;
  74675. /**
  74676. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74677. * between the touch and touch 2.
  74678. */
  74679. private _isQuest;
  74680. }
  74681. }
  74682. declare module BABYLON {
  74683. /**
  74684. * The motion controller class for the standard HTC-Vive controllers
  74685. */
  74686. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74687. private _modelRootNode;
  74688. /**
  74689. * The base url used to load the left and right controller models
  74690. */
  74691. static MODEL_BASE_URL: string;
  74692. /**
  74693. * File name for the controller model.
  74694. */
  74695. static MODEL_FILENAME: string;
  74696. profileId: string;
  74697. /**
  74698. * Create a new Vive motion controller object
  74699. * @param scene the scene to use to create this controller
  74700. * @param gamepadObject the corresponding gamepad object
  74701. * @param handedness the handedness of the controller
  74702. */
  74703. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74704. protected _getFilenameAndPath(): {
  74705. filename: string;
  74706. path: string;
  74707. };
  74708. protected _getModelLoadingConstraints(): boolean;
  74709. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74710. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74711. protected _updateModel(): void;
  74712. }
  74713. }
  74714. declare module BABYLON {
  74715. /**
  74716. * A cursor which tracks a point on a path
  74717. */
  74718. export class PathCursor {
  74719. private path;
  74720. /**
  74721. * Stores path cursor callbacks for when an onchange event is triggered
  74722. */
  74723. private _onchange;
  74724. /**
  74725. * The value of the path cursor
  74726. */
  74727. value: number;
  74728. /**
  74729. * The animation array of the path cursor
  74730. */
  74731. animations: Animation[];
  74732. /**
  74733. * Initializes the path cursor
  74734. * @param path The path to track
  74735. */
  74736. constructor(path: Path2);
  74737. /**
  74738. * Gets the cursor point on the path
  74739. * @returns A point on the path cursor at the cursor location
  74740. */
  74741. getPoint(): Vector3;
  74742. /**
  74743. * Moves the cursor ahead by the step amount
  74744. * @param step The amount to move the cursor forward
  74745. * @returns This path cursor
  74746. */
  74747. moveAhead(step?: number): PathCursor;
  74748. /**
  74749. * Moves the cursor behind by the step amount
  74750. * @param step The amount to move the cursor back
  74751. * @returns This path cursor
  74752. */
  74753. moveBack(step?: number): PathCursor;
  74754. /**
  74755. * Moves the cursor by the step amount
  74756. * If the step amount is greater than one, an exception is thrown
  74757. * @param step The amount to move the cursor
  74758. * @returns This path cursor
  74759. */
  74760. move(step: number): PathCursor;
  74761. /**
  74762. * Ensures that the value is limited between zero and one
  74763. * @returns This path cursor
  74764. */
  74765. private ensureLimits;
  74766. /**
  74767. * Runs onchange callbacks on change (used by the animation engine)
  74768. * @returns This path cursor
  74769. */
  74770. private raiseOnChange;
  74771. /**
  74772. * Executes a function on change
  74773. * @param f A path cursor onchange callback
  74774. * @returns This path cursor
  74775. */
  74776. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74777. }
  74778. }
  74779. declare module BABYLON {
  74780. /** @hidden */
  74781. export var blurPixelShader: {
  74782. name: string;
  74783. shader: string;
  74784. };
  74785. }
  74786. declare module BABYLON {
  74787. /** @hidden */
  74788. export var pointCloudVertexDeclaration: {
  74789. name: string;
  74790. shader: string;
  74791. };
  74792. }
  74793. // Mixins
  74794. interface Window {
  74795. mozIndexedDB: IDBFactory;
  74796. webkitIndexedDB: IDBFactory;
  74797. msIndexedDB: IDBFactory;
  74798. webkitURL: typeof URL;
  74799. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74800. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74801. WebGLRenderingContext: WebGLRenderingContext;
  74802. MSGesture: MSGesture;
  74803. CANNON: any;
  74804. AudioContext: AudioContext;
  74805. webkitAudioContext: AudioContext;
  74806. PointerEvent: any;
  74807. Math: Math;
  74808. Uint8Array: Uint8ArrayConstructor;
  74809. Float32Array: Float32ArrayConstructor;
  74810. mozURL: typeof URL;
  74811. msURL: typeof URL;
  74812. VRFrameData: any; // WebVR, from specs 1.1
  74813. DracoDecoderModule: any;
  74814. setImmediate(handler: (...args: any[]) => void): number;
  74815. }
  74816. interface HTMLCanvasElement {
  74817. requestPointerLock(): void;
  74818. msRequestPointerLock?(): void;
  74819. mozRequestPointerLock?(): void;
  74820. webkitRequestPointerLock?(): void;
  74821. /** Track wether a record is in progress */
  74822. isRecording: boolean;
  74823. /** Capture Stream method defined by some browsers */
  74824. captureStream(fps?: number): MediaStream;
  74825. }
  74826. interface CanvasRenderingContext2D {
  74827. msImageSmoothingEnabled: boolean;
  74828. }
  74829. interface MouseEvent {
  74830. mozMovementX: number;
  74831. mozMovementY: number;
  74832. webkitMovementX: number;
  74833. webkitMovementY: number;
  74834. msMovementX: number;
  74835. msMovementY: number;
  74836. }
  74837. interface Navigator {
  74838. mozGetVRDevices: (any: any) => any;
  74839. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74840. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74841. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74842. webkitGetGamepads(): Gamepad[];
  74843. msGetGamepads(): Gamepad[];
  74844. webkitGamepads(): Gamepad[];
  74845. }
  74846. interface HTMLVideoElement {
  74847. mozSrcObject: any;
  74848. }
  74849. interface Math {
  74850. fround(x: number): number;
  74851. imul(a: number, b: number): number;
  74852. }
  74853. interface WebGLRenderingContext {
  74854. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74855. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74856. vertexAttribDivisor(index: number, divisor: number): void;
  74857. createVertexArray(): any;
  74858. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74859. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74860. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74861. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74862. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74863. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74864. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74865. // Queries
  74866. createQuery(): WebGLQuery;
  74867. deleteQuery(query: WebGLQuery): void;
  74868. beginQuery(target: number, query: WebGLQuery): void;
  74869. endQuery(target: number): void;
  74870. getQueryParameter(query: WebGLQuery, pname: number): any;
  74871. getQuery(target: number, pname: number): any;
  74872. MAX_SAMPLES: number;
  74873. RGBA8: number;
  74874. READ_FRAMEBUFFER: number;
  74875. DRAW_FRAMEBUFFER: number;
  74876. UNIFORM_BUFFER: number;
  74877. HALF_FLOAT_OES: number;
  74878. RGBA16F: number;
  74879. RGBA32F: number;
  74880. R32F: number;
  74881. RG32F: number;
  74882. RGB32F: number;
  74883. R16F: number;
  74884. RG16F: number;
  74885. RGB16F: number;
  74886. RED: number;
  74887. RG: number;
  74888. R8: number;
  74889. RG8: number;
  74890. UNSIGNED_INT_24_8: number;
  74891. DEPTH24_STENCIL8: number;
  74892. MIN: number;
  74893. MAX: number;
  74894. /* Multiple Render Targets */
  74895. drawBuffers(buffers: number[]): void;
  74896. readBuffer(src: number): void;
  74897. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74898. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74899. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74900. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74901. // Occlusion Query
  74902. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74903. ANY_SAMPLES_PASSED: number;
  74904. QUERY_RESULT_AVAILABLE: number;
  74905. QUERY_RESULT: number;
  74906. }
  74907. interface WebGLProgram {
  74908. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74909. }
  74910. interface EXT_disjoint_timer_query {
  74911. QUERY_COUNTER_BITS_EXT: number;
  74912. TIME_ELAPSED_EXT: number;
  74913. TIMESTAMP_EXT: number;
  74914. GPU_DISJOINT_EXT: number;
  74915. QUERY_RESULT_EXT: number;
  74916. QUERY_RESULT_AVAILABLE_EXT: number;
  74917. queryCounterEXT(query: WebGLQuery, target: number): void;
  74918. createQueryEXT(): WebGLQuery;
  74919. beginQueryEXT(target: number, query: WebGLQuery): void;
  74920. endQueryEXT(target: number): void;
  74921. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74922. deleteQueryEXT(query: WebGLQuery): void;
  74923. }
  74924. interface WebGLUniformLocation {
  74925. _currentState: any;
  74926. }
  74927. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74928. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74929. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74930. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74931. interface WebGLRenderingContext {
  74932. readonly RASTERIZER_DISCARD: number;
  74933. readonly DEPTH_COMPONENT24: number;
  74934. readonly TEXTURE_3D: number;
  74935. readonly TEXTURE_2D_ARRAY: number;
  74936. readonly TEXTURE_COMPARE_FUNC: number;
  74937. readonly TEXTURE_COMPARE_MODE: number;
  74938. readonly COMPARE_REF_TO_TEXTURE: number;
  74939. readonly TEXTURE_WRAP_R: number;
  74940. readonly HALF_FLOAT: number;
  74941. readonly RGB8: number;
  74942. readonly RED_INTEGER: number;
  74943. readonly RG_INTEGER: number;
  74944. readonly RGB_INTEGER: number;
  74945. readonly RGBA_INTEGER: number;
  74946. readonly R8_SNORM: number;
  74947. readonly RG8_SNORM: number;
  74948. readonly RGB8_SNORM: number;
  74949. readonly RGBA8_SNORM: number;
  74950. readonly R8I: number;
  74951. readonly RG8I: number;
  74952. readonly RGB8I: number;
  74953. readonly RGBA8I: number;
  74954. readonly R8UI: number;
  74955. readonly RG8UI: number;
  74956. readonly RGB8UI: number;
  74957. readonly RGBA8UI: number;
  74958. readonly R16I: number;
  74959. readonly RG16I: number;
  74960. readonly RGB16I: number;
  74961. readonly RGBA16I: number;
  74962. readonly R16UI: number;
  74963. readonly RG16UI: number;
  74964. readonly RGB16UI: number;
  74965. readonly RGBA16UI: number;
  74966. readonly R32I: number;
  74967. readonly RG32I: number;
  74968. readonly RGB32I: number;
  74969. readonly RGBA32I: number;
  74970. readonly R32UI: number;
  74971. readonly RG32UI: number;
  74972. readonly RGB32UI: number;
  74973. readonly RGBA32UI: number;
  74974. readonly RGB10_A2UI: number;
  74975. readonly R11F_G11F_B10F: number;
  74976. readonly RGB9_E5: number;
  74977. readonly RGB10_A2: number;
  74978. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74979. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74980. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74981. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74982. readonly DEPTH_COMPONENT32F: number;
  74983. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74984. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74985. 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;
  74986. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74987. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74988. readonly TRANSFORM_FEEDBACK: number;
  74989. readonly INTERLEAVED_ATTRIBS: number;
  74990. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74991. createTransformFeedback(): WebGLTransformFeedback;
  74992. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74993. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74994. beginTransformFeedback(primitiveMode: number): void;
  74995. endTransformFeedback(): void;
  74996. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74997. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74998. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74999. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75000. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75001. }
  75002. interface ImageBitmap {
  75003. readonly width: number;
  75004. readonly height: number;
  75005. close(): void;
  75006. }
  75007. interface WebGLQuery extends WebGLObject {
  75008. }
  75009. declare var WebGLQuery: {
  75010. prototype: WebGLQuery;
  75011. new(): WebGLQuery;
  75012. };
  75013. interface WebGLSampler extends WebGLObject {
  75014. }
  75015. declare var WebGLSampler: {
  75016. prototype: WebGLSampler;
  75017. new(): WebGLSampler;
  75018. };
  75019. interface WebGLSync extends WebGLObject {
  75020. }
  75021. declare var WebGLSync: {
  75022. prototype: WebGLSync;
  75023. new(): WebGLSync;
  75024. };
  75025. interface WebGLTransformFeedback extends WebGLObject {
  75026. }
  75027. declare var WebGLTransformFeedback: {
  75028. prototype: WebGLTransformFeedback;
  75029. new(): WebGLTransformFeedback;
  75030. };
  75031. interface WebGLVertexArrayObject extends WebGLObject {
  75032. }
  75033. declare var WebGLVertexArrayObject: {
  75034. prototype: WebGLVertexArrayObject;
  75035. new(): WebGLVertexArrayObject;
  75036. };
  75037. // Type definitions for WebVR API
  75038. // Project: https://w3c.github.io/webvr/
  75039. // Definitions by: six a <https://github.com/lostfictions>
  75040. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75041. interface VRDisplay extends EventTarget {
  75042. /**
  75043. * Dictionary of capabilities describing the VRDisplay.
  75044. */
  75045. readonly capabilities: VRDisplayCapabilities;
  75046. /**
  75047. * z-depth defining the far plane of the eye view frustum
  75048. * enables mapping of values in the render target depth
  75049. * attachment to scene coordinates. Initially set to 10000.0.
  75050. */
  75051. depthFar: number;
  75052. /**
  75053. * z-depth defining the near plane of the eye view frustum
  75054. * enables mapping of values in the render target depth
  75055. * attachment to scene coordinates. Initially set to 0.01.
  75056. */
  75057. depthNear: number;
  75058. /**
  75059. * An identifier for this distinct VRDisplay. Used as an
  75060. * association point in the Gamepad API.
  75061. */
  75062. readonly displayId: number;
  75063. /**
  75064. * A display name, a user-readable name identifying it.
  75065. */
  75066. readonly displayName: string;
  75067. readonly isConnected: boolean;
  75068. readonly isPresenting: boolean;
  75069. /**
  75070. * If this VRDisplay supports room-scale experiences, the optional
  75071. * stage attribute contains details on the room-scale parameters.
  75072. */
  75073. readonly stageParameters: VRStageParameters | null;
  75074. /**
  75075. * Passing the value returned by `requestAnimationFrame` to
  75076. * `cancelAnimationFrame` will unregister the callback.
  75077. * @param handle Define the hanle of the request to cancel
  75078. */
  75079. cancelAnimationFrame(handle: number): void;
  75080. /**
  75081. * Stops presenting to the VRDisplay.
  75082. * @returns a promise to know when it stopped
  75083. */
  75084. exitPresent(): Promise<void>;
  75085. /**
  75086. * Return the current VREyeParameters for the given eye.
  75087. * @param whichEye Define the eye we want the parameter for
  75088. * @returns the eye parameters
  75089. */
  75090. getEyeParameters(whichEye: string): VREyeParameters;
  75091. /**
  75092. * Populates the passed VRFrameData with the information required to render
  75093. * the current frame.
  75094. * @param frameData Define the data structure to populate
  75095. * @returns true if ok otherwise false
  75096. */
  75097. getFrameData(frameData: VRFrameData): boolean;
  75098. /**
  75099. * Get the layers currently being presented.
  75100. * @returns the list of VR layers
  75101. */
  75102. getLayers(): VRLayer[];
  75103. /**
  75104. * Return a VRPose containing the future predicted pose of the VRDisplay
  75105. * when the current frame will be presented. The value returned will not
  75106. * change until JavaScript has returned control to the browser.
  75107. *
  75108. * The VRPose will contain the position, orientation, velocity,
  75109. * and acceleration of each of these properties.
  75110. * @returns the pose object
  75111. */
  75112. getPose(): VRPose;
  75113. /**
  75114. * Return the current instantaneous pose of the VRDisplay, with no
  75115. * prediction applied.
  75116. * @returns the current instantaneous pose
  75117. */
  75118. getImmediatePose(): VRPose;
  75119. /**
  75120. * The callback passed to `requestAnimationFrame` will be called
  75121. * any time a new frame should be rendered. When the VRDisplay is
  75122. * presenting the callback will be called at the native refresh
  75123. * rate of the HMD. When not presenting this function acts
  75124. * identically to how window.requestAnimationFrame acts. Content should
  75125. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75126. * asynchronously from other displays and at differing refresh rates.
  75127. * @param callback Define the eaction to run next frame
  75128. * @returns the request handle it
  75129. */
  75130. requestAnimationFrame(callback: FrameRequestCallback): number;
  75131. /**
  75132. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75133. * Repeat calls while already presenting will update the VRLayers being displayed.
  75134. * @param layers Define the list of layer to present
  75135. * @returns a promise to know when the request has been fulfilled
  75136. */
  75137. requestPresent(layers: VRLayer[]): Promise<void>;
  75138. /**
  75139. * Reset the pose for this display, treating its current position and
  75140. * orientation as the "origin/zero" values. VRPose.position,
  75141. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75142. * updated when calling resetPose(). This should be called in only
  75143. * sitting-space experiences.
  75144. */
  75145. resetPose(): void;
  75146. /**
  75147. * The VRLayer provided to the VRDisplay will be captured and presented
  75148. * in the HMD. Calling this function has the same effect on the source
  75149. * canvas as any other operation that uses its source image, and canvases
  75150. * created without preserveDrawingBuffer set to true will be cleared.
  75151. * @param pose Define the pose to submit
  75152. */
  75153. submitFrame(pose?: VRPose): void;
  75154. }
  75155. declare var VRDisplay: {
  75156. prototype: VRDisplay;
  75157. new(): VRDisplay;
  75158. };
  75159. interface VRLayer {
  75160. leftBounds?: number[] | Float32Array | null;
  75161. rightBounds?: number[] | Float32Array | null;
  75162. source?: HTMLCanvasElement | null;
  75163. }
  75164. interface VRDisplayCapabilities {
  75165. readonly canPresent: boolean;
  75166. readonly hasExternalDisplay: boolean;
  75167. readonly hasOrientation: boolean;
  75168. readonly hasPosition: boolean;
  75169. readonly maxLayers: number;
  75170. }
  75171. interface VREyeParameters {
  75172. /** @deprecated */
  75173. readonly fieldOfView: VRFieldOfView;
  75174. readonly offset: Float32Array;
  75175. readonly renderHeight: number;
  75176. readonly renderWidth: number;
  75177. }
  75178. interface VRFieldOfView {
  75179. readonly downDegrees: number;
  75180. readonly leftDegrees: number;
  75181. readonly rightDegrees: number;
  75182. readonly upDegrees: number;
  75183. }
  75184. interface VRFrameData {
  75185. readonly leftProjectionMatrix: Float32Array;
  75186. readonly leftViewMatrix: Float32Array;
  75187. readonly pose: VRPose;
  75188. readonly rightProjectionMatrix: Float32Array;
  75189. readonly rightViewMatrix: Float32Array;
  75190. readonly timestamp: number;
  75191. }
  75192. interface VRPose {
  75193. readonly angularAcceleration: Float32Array | null;
  75194. readonly angularVelocity: Float32Array | null;
  75195. readonly linearAcceleration: Float32Array | null;
  75196. readonly linearVelocity: Float32Array | null;
  75197. readonly orientation: Float32Array | null;
  75198. readonly position: Float32Array | null;
  75199. readonly timestamp: number;
  75200. }
  75201. interface VRStageParameters {
  75202. sittingToStandingTransform?: Float32Array;
  75203. sizeX?: number;
  75204. sizeY?: number;
  75205. }
  75206. interface Navigator {
  75207. getVRDisplays(): Promise<VRDisplay[]>;
  75208. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75209. }
  75210. interface Window {
  75211. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75212. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75213. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75214. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75215. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75216. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75217. }
  75218. interface Gamepad {
  75219. readonly displayId: number;
  75220. }
  75221. type XRSessionMode =
  75222. | "inline"
  75223. | "immersive-vr"
  75224. | "immersive-ar";
  75225. type XRReferenceSpaceType =
  75226. | "viewer"
  75227. | "local"
  75228. | "local-floor"
  75229. | "bounded-floor"
  75230. | "unbounded";
  75231. type XREnvironmentBlendMode =
  75232. | "opaque"
  75233. | "additive"
  75234. | "alpha-blend";
  75235. type XRVisibilityState =
  75236. | "visible"
  75237. | "visible-blurred"
  75238. | "hidden";
  75239. type XRHandedness =
  75240. | "none"
  75241. | "left"
  75242. | "right";
  75243. type XRTargetRayMode =
  75244. | "gaze"
  75245. | "tracked-pointer"
  75246. | "screen";
  75247. type XREye =
  75248. | "none"
  75249. | "left"
  75250. | "right";
  75251. type XREventType =
  75252. | "devicechange"
  75253. | "visibilitychange"
  75254. | "end"
  75255. | "inputsourceschange"
  75256. | "select"
  75257. | "selectstart"
  75258. | "selectend"
  75259. | "squeeze"
  75260. | "squeezestart"
  75261. | "squeezeend"
  75262. | "reset";
  75263. interface XRSpace extends EventTarget {
  75264. }
  75265. interface XRRenderState {
  75266. depthNear?: number;
  75267. depthFar?: number;
  75268. inlineVerticalFieldOfView?: number;
  75269. baseLayer?: XRWebGLLayer;
  75270. }
  75271. interface XRInputSource {
  75272. handedness: XRHandedness;
  75273. targetRayMode: XRTargetRayMode;
  75274. targetRaySpace: XRSpace;
  75275. gripSpace: XRSpace | undefined;
  75276. gamepad: Gamepad | undefined;
  75277. profiles: Array<string>;
  75278. }
  75279. interface XRSessionInit {
  75280. optionalFeatures?: string[];
  75281. requiredFeatures?: string[];
  75282. }
  75283. interface XRSession {
  75284. addEventListener: Function;
  75285. removeEventListener: Function;
  75286. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75287. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75288. requestAnimationFrame: Function;
  75289. end(): Promise<void>;
  75290. renderState: XRRenderState;
  75291. inputSources: Array<XRInputSource>;
  75292. // hit test
  75293. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75294. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75295. // legacy AR hit test
  75296. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75297. // legacy plane detection
  75298. updateWorldTrackingState(options: {
  75299. planeDetectionState?: { enabled: boolean; }
  75300. }): void;
  75301. }
  75302. interface XRReferenceSpace extends XRSpace {
  75303. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75304. onreset: any;
  75305. }
  75306. type XRPlaneSet = Set<XRPlane>;
  75307. type XRAnchorSet = Set<XRAnchor>;
  75308. interface XRFrame {
  75309. session: XRSession;
  75310. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75311. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75312. // AR
  75313. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  75314. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75315. // Anchors
  75316. trackedAnchors?: XRAnchorSet;
  75317. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75318. // Planes
  75319. worldInformation: {
  75320. detectedPlanes?: XRPlaneSet;
  75321. };
  75322. }
  75323. interface XRViewerPose extends XRPose {
  75324. views: Array<XRView>;
  75325. }
  75326. interface XRPose {
  75327. transform: XRRigidTransform;
  75328. emulatedPosition: boolean;
  75329. }
  75330. interface XRWebGLLayerOptions {
  75331. antialias?: boolean;
  75332. depth?: boolean;
  75333. stencil?: boolean;
  75334. alpha?: boolean;
  75335. multiview?: boolean;
  75336. framebufferScaleFactor?: number;
  75337. }
  75338. declare var XRWebGLLayer: {
  75339. prototype: XRWebGLLayer;
  75340. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75341. };
  75342. interface XRWebGLLayer {
  75343. framebuffer: WebGLFramebuffer;
  75344. framebufferWidth: number;
  75345. framebufferHeight: number;
  75346. getViewport: Function;
  75347. }
  75348. declare class XRRigidTransform {
  75349. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75350. position: DOMPointReadOnly;
  75351. orientation: DOMPointReadOnly;
  75352. matrix: Float32Array;
  75353. inverse: XRRigidTransform;
  75354. }
  75355. interface XRView {
  75356. eye: XREye;
  75357. projectionMatrix: Float32Array;
  75358. transform: XRRigidTransform;
  75359. }
  75360. interface XRInputSourceChangeEvent {
  75361. session: XRSession;
  75362. removed: Array<XRInputSource>;
  75363. added: Array<XRInputSource>;
  75364. }
  75365. interface XRInputSourceEvent extends Event {
  75366. readonly frame: XRFrame;
  75367. readonly inputSource: XRInputSource;
  75368. }
  75369. // Experimental(er) features
  75370. declare class XRRay {
  75371. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75372. origin: DOMPointReadOnly;
  75373. direction: DOMPointReadOnly;
  75374. matrix: Float32Array;
  75375. }
  75376. declare enum XRHitTestTrackableType {
  75377. "point",
  75378. "plane"
  75379. }
  75380. interface XRHitResult {
  75381. hitMatrix: Float32Array;
  75382. }
  75383. interface XRTransientInputHitTestResult {
  75384. readonly inputSource: XRInputSource;
  75385. readonly results: Array<XRHitTestResult>;
  75386. }
  75387. interface XRHitTestResult {
  75388. getPose(baseSpace: XRSpace): XRPose | undefined;
  75389. // When anchor system is enabled
  75390. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75391. }
  75392. interface XRHitTestSource {
  75393. cancel(): void;
  75394. }
  75395. interface XRTransientInputHitTestSource {
  75396. cancel(): void;
  75397. }
  75398. interface XRHitTestOptionsInit {
  75399. space: XRSpace;
  75400. entityTypes?: Array<XRHitTestTrackableType>;
  75401. offsetRay?: XRRay;
  75402. }
  75403. interface XRTransientInputHitTestOptionsInit {
  75404. profile: string;
  75405. entityTypes?: Array<XRHitTestTrackableType>;
  75406. offsetRay?: XRRay;
  75407. }
  75408. interface XRAnchor {
  75409. anchorSpace: XRSpace;
  75410. delete(): void;
  75411. }
  75412. interface XRPlane {
  75413. orientation: "Horizontal" | "Vertical";
  75414. planeSpace: XRSpace;
  75415. polygon: Array<DOMPointReadOnly>;
  75416. lastChangedTime: number;
  75417. }
  75418. /**
  75419. * @ignore
  75420. */
  75421. declare module BABYLON.GLTF2.Exporter {
  75422. }
  75423. /**
  75424. * @ignore
  75425. */
  75426. declare module BABYLON.GLTF1 {
  75427. }
  75428. declare module BABYLON.GUI {
  75429. /**
  75430. * Class used to specific a value and its associated unit
  75431. */
  75432. export class ValueAndUnit {
  75433. /** defines the unit to store */
  75434. unit: number;
  75435. /** defines a boolean indicating if the value can be negative */
  75436. negativeValueAllowed: boolean;
  75437. private _value;
  75438. private _originalUnit;
  75439. /**
  75440. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75441. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75442. */
  75443. ignoreAdaptiveScaling: boolean;
  75444. /**
  75445. * Creates a new ValueAndUnit
  75446. * @param value defines the value to store
  75447. * @param unit defines the unit to store
  75448. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75449. */
  75450. constructor(value: number,
  75451. /** defines the unit to store */
  75452. unit?: number,
  75453. /** defines a boolean indicating if the value can be negative */
  75454. negativeValueAllowed?: boolean);
  75455. /** Gets a boolean indicating if the value is a percentage */
  75456. get isPercentage(): boolean;
  75457. /** Gets a boolean indicating if the value is store as pixel */
  75458. get isPixel(): boolean;
  75459. /** Gets direct internal value */
  75460. get internalValue(): number;
  75461. /**
  75462. * Gets value as pixel
  75463. * @param host defines the root host
  75464. * @param refValue defines the reference value for percentages
  75465. * @returns the value as pixel
  75466. */
  75467. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  75468. /**
  75469. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  75470. * @param value defines the value to store
  75471. * @param unit defines the unit to store
  75472. * @returns the current ValueAndUnit
  75473. */
  75474. updateInPlace(value: number, unit?: number): ValueAndUnit;
  75475. /**
  75476. * Gets the value accordingly to its unit
  75477. * @param host defines the root host
  75478. * @returns the value
  75479. */
  75480. getValue(host: AdvancedDynamicTexture): number;
  75481. /**
  75482. * Gets a string representation of the value
  75483. * @param host defines the root host
  75484. * @param decimals defines an optional number of decimals to display
  75485. * @returns a string
  75486. */
  75487. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  75488. /**
  75489. * Store a value parsed from a string
  75490. * @param source defines the source string
  75491. * @returns true if the value was successfully parsed
  75492. */
  75493. fromString(source: string | number): boolean;
  75494. private static _Regex;
  75495. private static _UNITMODE_PERCENTAGE;
  75496. private static _UNITMODE_PIXEL;
  75497. /** UNITMODE_PERCENTAGE */
  75498. static get UNITMODE_PERCENTAGE(): number;
  75499. /** UNITMODE_PIXEL */
  75500. static get UNITMODE_PIXEL(): number;
  75501. }
  75502. }
  75503. declare module BABYLON.GUI {
  75504. /**
  75505. * Define a style used by control to automatically setup properties based on a template.
  75506. * Only support font related properties so far
  75507. */
  75508. export class Style implements BABYLON.IDisposable {
  75509. private _fontFamily;
  75510. private _fontStyle;
  75511. private _fontWeight;
  75512. /** @hidden */
  75513. _host: AdvancedDynamicTexture;
  75514. /** @hidden */
  75515. _fontSize: ValueAndUnit;
  75516. /**
  75517. * BABYLON.Observable raised when the style values are changed
  75518. */
  75519. onChangedObservable: BABYLON.Observable<Style>;
  75520. /**
  75521. * Creates a new style object
  75522. * @param host defines the AdvancedDynamicTexture which hosts this style
  75523. */
  75524. constructor(host: AdvancedDynamicTexture);
  75525. /**
  75526. * Gets or sets the font size
  75527. */
  75528. get fontSize(): string | number;
  75529. set fontSize(value: string | number);
  75530. /**
  75531. * Gets or sets the font family
  75532. */
  75533. get fontFamily(): string;
  75534. set fontFamily(value: string);
  75535. /**
  75536. * Gets or sets the font style
  75537. */
  75538. get fontStyle(): string;
  75539. set fontStyle(value: string);
  75540. /** Gets or sets font weight */
  75541. get fontWeight(): string;
  75542. set fontWeight(value: string);
  75543. /** Dispose all associated resources */
  75544. dispose(): void;
  75545. }
  75546. }
  75547. declare module BABYLON.GUI {
  75548. /**
  75549. * Class used to transport BABYLON.Vector2 information for pointer events
  75550. */
  75551. export class Vector2WithInfo extends BABYLON.Vector2 {
  75552. /** defines the current mouse button index */
  75553. buttonIndex: number;
  75554. /**
  75555. * Creates a new Vector2WithInfo
  75556. * @param source defines the vector2 data to transport
  75557. * @param buttonIndex defines the current mouse button index
  75558. */
  75559. constructor(source: BABYLON.Vector2,
  75560. /** defines the current mouse button index */
  75561. buttonIndex?: number);
  75562. }
  75563. /** Class used to provide 2D matrix features */
  75564. export class Matrix2D {
  75565. /** Gets the internal array of 6 floats used to store matrix data */
  75566. m: Float32Array;
  75567. /**
  75568. * Creates a new matrix
  75569. * @param m00 defines value for (0, 0)
  75570. * @param m01 defines value for (0, 1)
  75571. * @param m10 defines value for (1, 0)
  75572. * @param m11 defines value for (1, 1)
  75573. * @param m20 defines value for (2, 0)
  75574. * @param m21 defines value for (2, 1)
  75575. */
  75576. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  75577. /**
  75578. * Fills the matrix from direct values
  75579. * @param m00 defines value for (0, 0)
  75580. * @param m01 defines value for (0, 1)
  75581. * @param m10 defines value for (1, 0)
  75582. * @param m11 defines value for (1, 1)
  75583. * @param m20 defines value for (2, 0)
  75584. * @param m21 defines value for (2, 1)
  75585. * @returns the current modified matrix
  75586. */
  75587. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  75588. /**
  75589. * Gets matrix determinant
  75590. * @returns the determinant
  75591. */
  75592. determinant(): number;
  75593. /**
  75594. * Inverses the matrix and stores it in a target matrix
  75595. * @param result defines the target matrix
  75596. * @returns the current matrix
  75597. */
  75598. invertToRef(result: Matrix2D): Matrix2D;
  75599. /**
  75600. * Multiplies the current matrix with another one
  75601. * @param other defines the second operand
  75602. * @param result defines the target matrix
  75603. * @returns the current matrix
  75604. */
  75605. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  75606. /**
  75607. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  75608. * @param x defines the x coordinate to transform
  75609. * @param y defines the x coordinate to transform
  75610. * @param result defines the target vector2
  75611. * @returns the current matrix
  75612. */
  75613. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  75614. /**
  75615. * Creates an identity matrix
  75616. * @returns a new matrix
  75617. */
  75618. static Identity(): Matrix2D;
  75619. /**
  75620. * Creates a translation matrix and stores it in a target matrix
  75621. * @param x defines the x coordinate of the translation
  75622. * @param y defines the y coordinate of the translation
  75623. * @param result defines the target matrix
  75624. */
  75625. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  75626. /**
  75627. * Creates a scaling matrix and stores it in a target matrix
  75628. * @param x defines the x coordinate of the scaling
  75629. * @param y defines the y coordinate of the scaling
  75630. * @param result defines the target matrix
  75631. */
  75632. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  75633. /**
  75634. * Creates a rotation matrix and stores it in a target matrix
  75635. * @param angle defines the rotation angle
  75636. * @param result defines the target matrix
  75637. */
  75638. static RotationToRef(angle: number, result: Matrix2D): void;
  75639. private static _TempPreTranslationMatrix;
  75640. private static _TempPostTranslationMatrix;
  75641. private static _TempRotationMatrix;
  75642. private static _TempScalingMatrix;
  75643. private static _TempCompose0;
  75644. private static _TempCompose1;
  75645. private static _TempCompose2;
  75646. /**
  75647. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75648. * @param tx defines the x coordinate of the translation
  75649. * @param ty defines the y coordinate of the translation
  75650. * @param angle defines the rotation angle
  75651. * @param scaleX defines the x coordinate of the scaling
  75652. * @param scaleY defines the y coordinate of the scaling
  75653. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75654. * @param result defines the target matrix
  75655. */
  75656. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75657. }
  75658. }
  75659. declare module BABYLON.GUI {
  75660. /**
  75661. * Class used to store 2D control sizes
  75662. */
  75663. export class Measure {
  75664. /** defines left coordinate */
  75665. left: number;
  75666. /** defines top coordinate */
  75667. top: number;
  75668. /** defines width dimension */
  75669. width: number;
  75670. /** defines height dimension */
  75671. height: number;
  75672. /**
  75673. * Creates a new measure
  75674. * @param left defines left coordinate
  75675. * @param top defines top coordinate
  75676. * @param width defines width dimension
  75677. * @param height defines height dimension
  75678. */
  75679. constructor(
  75680. /** defines left coordinate */
  75681. left: number,
  75682. /** defines top coordinate */
  75683. top: number,
  75684. /** defines width dimension */
  75685. width: number,
  75686. /** defines height dimension */
  75687. height: number);
  75688. /**
  75689. * Copy from another measure
  75690. * @param other defines the other measure to copy from
  75691. */
  75692. copyFrom(other: Measure): void;
  75693. /**
  75694. * Copy from a group of 4 floats
  75695. * @param left defines left coordinate
  75696. * @param top defines top coordinate
  75697. * @param width defines width dimension
  75698. * @param height defines height dimension
  75699. */
  75700. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75701. /**
  75702. * Computes the axis aligned bounding box measure for two given measures
  75703. * @param a Input measure
  75704. * @param b Input measure
  75705. * @param result the resulting bounding measure
  75706. */
  75707. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75708. /**
  75709. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75710. * @param transform the matrix to transform the measure before computing the AABB
  75711. * @param result the resulting AABB
  75712. */
  75713. transformToRef(transform: Matrix2D, result: Measure): void;
  75714. /**
  75715. * Check equality between this measure and another one
  75716. * @param other defines the other measures
  75717. * @returns true if both measures are equals
  75718. */
  75719. isEqualsTo(other: Measure): boolean;
  75720. /**
  75721. * Creates an empty measure
  75722. * @returns a new measure
  75723. */
  75724. static Empty(): Measure;
  75725. }
  75726. }
  75727. declare module BABYLON.GUI {
  75728. /**
  75729. * Interface used to define a control that can receive focus
  75730. */
  75731. export interface IFocusableControl {
  75732. /**
  75733. * Function called when the control receives the focus
  75734. */
  75735. onFocus(): void;
  75736. /**
  75737. * Function called when the control loses the focus
  75738. */
  75739. onBlur(): void;
  75740. /**
  75741. * Function called to let the control handle keyboard events
  75742. * @param evt defines the current keyboard event
  75743. */
  75744. processKeyboard(evt: KeyboardEvent): void;
  75745. /**
  75746. * Function called to get the list of controls that should not steal the focus from this control
  75747. * @returns an array of controls
  75748. */
  75749. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75750. }
  75751. /**
  75752. * Class used to create texture to support 2D GUI elements
  75753. * @see https://doc.babylonjs.com/how_to/gui
  75754. */
  75755. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75756. private _isDirty;
  75757. private _renderObserver;
  75758. private _resizeObserver;
  75759. private _preKeyboardObserver;
  75760. private _pointerMoveObserver;
  75761. private _pointerObserver;
  75762. private _canvasPointerOutObserver;
  75763. private _background;
  75764. /** @hidden */
  75765. _rootContainer: Container;
  75766. /** @hidden */
  75767. _lastPickedControl: Control;
  75768. /** @hidden */
  75769. _lastControlOver: {
  75770. [pointerId: number]: Control;
  75771. };
  75772. /** @hidden */
  75773. _lastControlDown: {
  75774. [pointerId: number]: Control;
  75775. };
  75776. /** @hidden */
  75777. _capturingControl: {
  75778. [pointerId: number]: Control;
  75779. };
  75780. /** @hidden */
  75781. _shouldBlockPointer: boolean;
  75782. /** @hidden */
  75783. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75784. /** @hidden */
  75785. _linkedControls: Control[];
  75786. private _isFullscreen;
  75787. private _fullscreenViewport;
  75788. private _idealWidth;
  75789. private _idealHeight;
  75790. private _useSmallestIdeal;
  75791. private _renderAtIdealSize;
  75792. private _focusedControl;
  75793. private _blockNextFocusCheck;
  75794. private _renderScale;
  75795. private _rootElement;
  75796. private _cursorChanged;
  75797. private _defaultMousePointerId;
  75798. /** @hidden */
  75799. _numLayoutCalls: number;
  75800. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75801. get numLayoutCalls(): number;
  75802. /** @hidden */
  75803. _numRenderCalls: number;
  75804. /** Gets the number of render calls made the last time the ADT has been rendered */
  75805. get numRenderCalls(): number;
  75806. /**
  75807. * Define type to string to ensure compatibility across browsers
  75808. * Safari doesn't support DataTransfer constructor
  75809. */
  75810. private _clipboardData;
  75811. /**
  75812. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75813. */
  75814. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75815. /**
  75816. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75817. */
  75818. onControlPickedObservable: BABYLON.Observable<Control>;
  75819. /**
  75820. * BABYLON.Observable event triggered before layout is evaluated
  75821. */
  75822. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75823. /**
  75824. * BABYLON.Observable event triggered after the layout was evaluated
  75825. */
  75826. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75827. /**
  75828. * BABYLON.Observable event triggered before the texture is rendered
  75829. */
  75830. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75831. /**
  75832. * BABYLON.Observable event triggered after the texture was rendered
  75833. */
  75834. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75835. /**
  75836. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75837. */
  75838. premulAlpha: boolean;
  75839. /**
  75840. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75841. * Useful when you want more antialiasing
  75842. */
  75843. get renderScale(): number;
  75844. set renderScale(value: number);
  75845. /** Gets or sets the background color */
  75846. get background(): string;
  75847. set background(value: string);
  75848. /**
  75849. * Gets or sets the ideal width used to design controls.
  75850. * The GUI will then rescale everything accordingly
  75851. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75852. */
  75853. get idealWidth(): number;
  75854. set idealWidth(value: number);
  75855. /**
  75856. * Gets or sets the ideal height used to design controls.
  75857. * The GUI will then rescale everything accordingly
  75858. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75859. */
  75860. get idealHeight(): number;
  75861. set idealHeight(value: number);
  75862. /**
  75863. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75864. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75865. */
  75866. get useSmallestIdeal(): boolean;
  75867. set useSmallestIdeal(value: boolean);
  75868. /**
  75869. * Gets or sets a boolean indicating if adaptive scaling must be used
  75870. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75871. */
  75872. get renderAtIdealSize(): boolean;
  75873. set renderAtIdealSize(value: boolean);
  75874. /**
  75875. * Gets the ratio used when in "ideal mode"
  75876. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75877. * */
  75878. get idealRatio(): number;
  75879. /**
  75880. * Gets the underlying layer used to render the texture when in fullscreen mode
  75881. */
  75882. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75883. /**
  75884. * Gets the root container control
  75885. */
  75886. get rootContainer(): Container;
  75887. /**
  75888. * Returns an array containing the root container.
  75889. * This is mostly used to let the Inspector introspects the ADT
  75890. * @returns an array containing the rootContainer
  75891. */
  75892. getChildren(): Array<Container>;
  75893. /**
  75894. * Will return all controls that are inside this texture
  75895. * @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
  75896. * @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
  75897. * @return all child controls
  75898. */
  75899. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75900. /**
  75901. * Gets or sets the current focused control
  75902. */
  75903. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75904. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75905. /**
  75906. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75907. */
  75908. get isForeground(): boolean;
  75909. set isForeground(value: boolean);
  75910. /**
  75911. * Gets or set information about clipboardData
  75912. */
  75913. get clipboardData(): string;
  75914. set clipboardData(value: string);
  75915. /**
  75916. * Creates a new AdvancedDynamicTexture
  75917. * @param name defines the name of the texture
  75918. * @param width defines the width of the texture
  75919. * @param height defines the height of the texture
  75920. * @param scene defines the hosting scene
  75921. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75922. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75923. */
  75924. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75925. /**
  75926. * Get the current class name of the texture useful for serialization or dynamic coding.
  75927. * @returns "AdvancedDynamicTexture"
  75928. */
  75929. getClassName(): string;
  75930. /**
  75931. * Function used to execute a function on all controls
  75932. * @param func defines the function to execute
  75933. * @param container defines the container where controls belong. If null the root container will be used
  75934. */
  75935. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75936. private _useInvalidateRectOptimization;
  75937. /**
  75938. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75939. */
  75940. get useInvalidateRectOptimization(): boolean;
  75941. set useInvalidateRectOptimization(value: boolean);
  75942. private _invalidatedRectangle;
  75943. /**
  75944. * Invalidates a rectangle area on the gui texture
  75945. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75946. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75947. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75948. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75949. */
  75950. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75951. /**
  75952. * Marks the texture as dirty forcing a complete update
  75953. */
  75954. markAsDirty(): void;
  75955. /**
  75956. * Helper function used to create a new style
  75957. * @returns a new style
  75958. * @see https://doc.babylonjs.com/how_to/gui#styles
  75959. */
  75960. createStyle(): Style;
  75961. /**
  75962. * Adds a new control to the root container
  75963. * @param control defines the control to add
  75964. * @returns the current texture
  75965. */
  75966. addControl(control: Control): AdvancedDynamicTexture;
  75967. /**
  75968. * Removes a control from the root container
  75969. * @param control defines the control to remove
  75970. * @returns the current texture
  75971. */
  75972. removeControl(control: Control): AdvancedDynamicTexture;
  75973. /**
  75974. * Release all resources
  75975. */
  75976. dispose(): void;
  75977. private _onResize;
  75978. /** @hidden */
  75979. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75980. /**
  75981. * Get screen coordinates for a vector3
  75982. * @param position defines the position to project
  75983. * @param worldMatrix defines the world matrix to use
  75984. * @returns the projected position
  75985. */
  75986. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75987. private _checkUpdate;
  75988. private _clearMeasure;
  75989. private _render;
  75990. /** @hidden */
  75991. _changeCursor(cursor: string): void;
  75992. /** @hidden */
  75993. _registerLastControlDown(control: Control, pointerId: number): void;
  75994. private _doPicking;
  75995. /** @hidden */
  75996. _cleanControlAfterRemovalFromList(list: {
  75997. [pointerId: number]: Control;
  75998. }, control: Control): void;
  75999. /** @hidden */
  76000. _cleanControlAfterRemoval(control: Control): void;
  76001. /** Attach to all scene events required to support pointer events */
  76002. attach(): void;
  76003. /** @hidden */
  76004. private onClipboardCopy;
  76005. /** @hidden */
  76006. private onClipboardCut;
  76007. /** @hidden */
  76008. private onClipboardPaste;
  76009. /**
  76010. * Register the clipboard Events onto the canvas
  76011. */
  76012. registerClipboardEvents(): void;
  76013. /**
  76014. * Unregister the clipboard Events from the canvas
  76015. */
  76016. unRegisterClipboardEvents(): void;
  76017. /**
  76018. * Connect the texture to a hosting mesh to enable interactions
  76019. * @param mesh defines the mesh to attach to
  76020. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  76021. */
  76022. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  76023. /**
  76024. * Move the focus to a specific control
  76025. * @param control defines the control which will receive the focus
  76026. */
  76027. moveFocusToControl(control: IFocusableControl): void;
  76028. private _manageFocus;
  76029. private _attachToOnPointerOut;
  76030. /**
  76031. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  76032. * @param mesh defines the mesh which will receive the texture
  76033. * @param width defines the texture width (1024 by default)
  76034. * @param height defines the texture height (1024 by default)
  76035. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  76036. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  76037. * @returns a new AdvancedDynamicTexture
  76038. */
  76039. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  76040. /**
  76041. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  76042. * In this mode the texture will rely on a layer for its rendering.
  76043. * This allows it to be treated like any other layer.
  76044. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  76045. * LayerMask is set through advancedTexture.layer.layerMask
  76046. * @param name defines name for the texture
  76047. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  76048. * @param scene defines the hsoting scene
  76049. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  76050. * @returns a new AdvancedDynamicTexture
  76051. */
  76052. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  76053. }
  76054. }
  76055. declare module BABYLON.GUI {
  76056. /**
  76057. * Root class used for all 2D controls
  76058. * @see https://doc.babylonjs.com/how_to/gui#controls
  76059. */
  76060. export class Control {
  76061. /** defines the name of the control */
  76062. name?: string | undefined;
  76063. /**
  76064. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  76065. */
  76066. static AllowAlphaInheritance: boolean;
  76067. private _alpha;
  76068. private _alphaSet;
  76069. private _zIndex;
  76070. /** @hidden */
  76071. _host: AdvancedDynamicTexture;
  76072. /** Gets or sets the control parent */
  76073. parent: BABYLON.Nullable<Container>;
  76074. /** @hidden */
  76075. _currentMeasure: Measure;
  76076. private _fontFamily;
  76077. private _fontStyle;
  76078. private _fontWeight;
  76079. private _fontSize;
  76080. private _font;
  76081. /** @hidden */
  76082. _width: ValueAndUnit;
  76083. /** @hidden */
  76084. _height: ValueAndUnit;
  76085. /** @hidden */
  76086. protected _fontOffset: {
  76087. ascent: number;
  76088. height: number;
  76089. descent: number;
  76090. };
  76091. private _color;
  76092. private _style;
  76093. private _styleObserver;
  76094. /** @hidden */
  76095. protected _horizontalAlignment: number;
  76096. /** @hidden */
  76097. protected _verticalAlignment: number;
  76098. /** @hidden */
  76099. protected _isDirty: boolean;
  76100. /** @hidden */
  76101. protected _wasDirty: boolean;
  76102. /** @hidden */
  76103. _tempParentMeasure: Measure;
  76104. /** @hidden */
  76105. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76106. /** @hidden */
  76107. protected _cachedParentMeasure: Measure;
  76108. private _paddingLeft;
  76109. private _paddingRight;
  76110. private _paddingTop;
  76111. private _paddingBottom;
  76112. /** @hidden */
  76113. _left: ValueAndUnit;
  76114. /** @hidden */
  76115. _top: ValueAndUnit;
  76116. private _scaleX;
  76117. private _scaleY;
  76118. private _rotation;
  76119. private _transformCenterX;
  76120. private _transformCenterY;
  76121. /** @hidden */
  76122. _transformMatrix: Matrix2D;
  76123. /** @hidden */
  76124. protected _invertTransformMatrix: Matrix2D;
  76125. /** @hidden */
  76126. protected _transformedPosition: BABYLON.Vector2;
  76127. private _isMatrixDirty;
  76128. private _cachedOffsetX;
  76129. private _cachedOffsetY;
  76130. private _isVisible;
  76131. private _isHighlighted;
  76132. /** @hidden */
  76133. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76134. private _fontSet;
  76135. private _dummyVector2;
  76136. private _downCount;
  76137. private _enterCount;
  76138. private _doNotRender;
  76139. private _downPointerIds;
  76140. protected _isEnabled: boolean;
  76141. protected _disabledColor: string;
  76142. protected _disabledColorItem: string;
  76143. /** @hidden */
  76144. protected _rebuildLayout: boolean;
  76145. /** @hidden */
  76146. _customData: any;
  76147. /** @hidden */
  76148. _isClipped: boolean;
  76149. /** @hidden */
  76150. _automaticSize: boolean;
  76151. /** @hidden */
  76152. _tag: any;
  76153. /**
  76154. * 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
  76155. */
  76156. uniqueId: number;
  76157. /**
  76158. * Gets or sets an object used to store user defined information for the node
  76159. */
  76160. metadata: any;
  76161. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76162. isHitTestVisible: boolean;
  76163. /** Gets or sets a boolean indicating if the control can block pointer events */
  76164. isPointerBlocker: boolean;
  76165. /** Gets or sets a boolean indicating if the control can be focusable */
  76166. isFocusInvisible: boolean;
  76167. /**
  76168. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76169. * 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
  76170. */
  76171. clipChildren: boolean;
  76172. /**
  76173. * Gets or sets a boolean indicating that control content must be clipped
  76174. * 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
  76175. */
  76176. clipContent: boolean;
  76177. /**
  76178. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76179. */
  76180. useBitmapCache: boolean;
  76181. private _cacheData;
  76182. private _shadowOffsetX;
  76183. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76184. get shadowOffsetX(): number;
  76185. set shadowOffsetX(value: number);
  76186. private _shadowOffsetY;
  76187. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76188. get shadowOffsetY(): number;
  76189. set shadowOffsetY(value: number);
  76190. private _shadowBlur;
  76191. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76192. get shadowBlur(): number;
  76193. set shadowBlur(value: number);
  76194. private _shadowColor;
  76195. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76196. get shadowColor(): string;
  76197. set shadowColor(value: string);
  76198. /** Gets or sets the cursor to use when the control is hovered */
  76199. hoverCursor: string;
  76200. /** @hidden */
  76201. protected _linkOffsetX: ValueAndUnit;
  76202. /** @hidden */
  76203. protected _linkOffsetY: ValueAndUnit;
  76204. /** Gets the control type name */
  76205. get typeName(): string;
  76206. /**
  76207. * Get the current class name of the control.
  76208. * @returns current class name
  76209. */
  76210. getClassName(): string;
  76211. /**
  76212. * An event triggered when pointer wheel is scrolled
  76213. */
  76214. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  76215. /**
  76216. * An event triggered when the pointer move over the control.
  76217. */
  76218. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  76219. /**
  76220. * An event triggered when the pointer move out of the control.
  76221. */
  76222. onPointerOutObservable: BABYLON.Observable<Control>;
  76223. /**
  76224. * An event triggered when the pointer taps the control
  76225. */
  76226. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  76227. /**
  76228. * An event triggered when pointer up
  76229. */
  76230. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  76231. /**
  76232. * An event triggered when a control is clicked on
  76233. */
  76234. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  76235. /**
  76236. * An event triggered when pointer enters the control
  76237. */
  76238. onPointerEnterObservable: BABYLON.Observable<Control>;
  76239. /**
  76240. * An event triggered when the control is marked as dirty
  76241. */
  76242. onDirtyObservable: BABYLON.Observable<Control>;
  76243. /**
  76244. * An event triggered before drawing the control
  76245. */
  76246. onBeforeDrawObservable: BABYLON.Observable<Control>;
  76247. /**
  76248. * An event triggered after the control was drawn
  76249. */
  76250. onAfterDrawObservable: BABYLON.Observable<Control>;
  76251. /**
  76252. * An event triggered when the control has been disposed
  76253. */
  76254. onDisposeObservable: BABYLON.Observable<Control>;
  76255. /**
  76256. * Get the hosting AdvancedDynamicTexture
  76257. */
  76258. get host(): AdvancedDynamicTexture;
  76259. /** Gets or set information about font offsets (used to render and align text) */
  76260. get fontOffset(): {
  76261. ascent: number;
  76262. height: number;
  76263. descent: number;
  76264. };
  76265. set fontOffset(offset: {
  76266. ascent: number;
  76267. height: number;
  76268. descent: number;
  76269. });
  76270. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  76271. get alpha(): number;
  76272. set alpha(value: number);
  76273. /**
  76274. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  76275. */
  76276. get isHighlighted(): boolean;
  76277. set isHighlighted(value: boolean);
  76278. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  76279. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76280. */
  76281. get scaleX(): number;
  76282. set scaleX(value: number);
  76283. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  76284. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76285. */
  76286. get scaleY(): number;
  76287. set scaleY(value: number);
  76288. /** Gets or sets the rotation angle (0 by default)
  76289. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76290. */
  76291. get rotation(): number;
  76292. set rotation(value: number);
  76293. /** Gets or sets the transformation center on Y axis (0 by default)
  76294. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76295. */
  76296. get transformCenterY(): number;
  76297. set transformCenterY(value: number);
  76298. /** Gets or sets the transformation center on X axis (0 by default)
  76299. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76300. */
  76301. get transformCenterX(): number;
  76302. set transformCenterX(value: number);
  76303. /**
  76304. * Gets or sets the horizontal alignment
  76305. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76306. */
  76307. get horizontalAlignment(): number;
  76308. set horizontalAlignment(value: number);
  76309. /**
  76310. * Gets or sets the vertical alignment
  76311. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76312. */
  76313. get verticalAlignment(): number;
  76314. set verticalAlignment(value: number);
  76315. /**
  76316. * Gets or sets a fixed ratio for this control.
  76317. * When different from 0, the ratio is used to compute the "second" dimension.
  76318. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  76319. * second dimension is computed as first dimension * fixedRatio
  76320. */
  76321. fixedRatio: number;
  76322. private _fixedRatioMasterIsWidth;
  76323. /**
  76324. * Gets or sets control width
  76325. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76326. */
  76327. get width(): string | number;
  76328. set width(value: string | number);
  76329. /**
  76330. * Gets or sets the control width in pixel
  76331. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76332. */
  76333. get widthInPixels(): number;
  76334. set widthInPixels(value: number);
  76335. /**
  76336. * Gets or sets control height
  76337. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76338. */
  76339. get height(): string | number;
  76340. set height(value: string | number);
  76341. /**
  76342. * Gets or sets control height in pixel
  76343. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76344. */
  76345. get heightInPixels(): number;
  76346. set heightInPixels(value: number);
  76347. /** Gets or set font family */
  76348. get fontFamily(): string;
  76349. set fontFamily(value: string);
  76350. /** Gets or sets font style */
  76351. get fontStyle(): string;
  76352. set fontStyle(value: string);
  76353. /** Gets or sets font weight */
  76354. get fontWeight(): string;
  76355. set fontWeight(value: string);
  76356. /**
  76357. * Gets or sets style
  76358. * @see https://doc.babylonjs.com/how_to/gui#styles
  76359. */
  76360. get style(): BABYLON.Nullable<Style>;
  76361. set style(value: BABYLON.Nullable<Style>);
  76362. /** @hidden */
  76363. get _isFontSizeInPercentage(): boolean;
  76364. /** Gets or sets font size in pixels */
  76365. get fontSizeInPixels(): number;
  76366. set fontSizeInPixels(value: number);
  76367. /** Gets or sets font size */
  76368. get fontSize(): string | number;
  76369. set fontSize(value: string | number);
  76370. /** Gets or sets foreground color */
  76371. get color(): string;
  76372. set color(value: string);
  76373. /** Gets or sets z index which is used to reorder controls on the z axis */
  76374. get zIndex(): number;
  76375. set zIndex(value: number);
  76376. /** Gets or sets a boolean indicating if the control can be rendered */
  76377. get notRenderable(): boolean;
  76378. set notRenderable(value: boolean);
  76379. /** Gets or sets a boolean indicating if the control is visible */
  76380. get isVisible(): boolean;
  76381. set isVisible(value: boolean);
  76382. /** Gets a boolean indicating that the control needs to update its rendering */
  76383. get isDirty(): boolean;
  76384. /**
  76385. * Gets the current linked mesh (or null if none)
  76386. */
  76387. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76388. /**
  76389. * Gets or sets a value indicating the padding to use on the left of the control
  76390. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76391. */
  76392. get paddingLeft(): string | number;
  76393. set paddingLeft(value: string | number);
  76394. /**
  76395. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76396. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76397. */
  76398. get paddingLeftInPixels(): number;
  76399. set paddingLeftInPixels(value: number);
  76400. /**
  76401. * Gets or sets a value indicating the padding to use on the right of the control
  76402. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76403. */
  76404. get paddingRight(): string | number;
  76405. set paddingRight(value: string | number);
  76406. /**
  76407. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76408. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76409. */
  76410. get paddingRightInPixels(): number;
  76411. set paddingRightInPixels(value: number);
  76412. /**
  76413. * Gets or sets a value indicating the padding to use on the top of the control
  76414. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76415. */
  76416. get paddingTop(): string | number;
  76417. set paddingTop(value: string | number);
  76418. /**
  76419. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76420. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76421. */
  76422. get paddingTopInPixels(): number;
  76423. set paddingTopInPixels(value: number);
  76424. /**
  76425. * Gets or sets a value indicating the padding to use on the bottom of the control
  76426. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76427. */
  76428. get paddingBottom(): string | number;
  76429. set paddingBottom(value: string | number);
  76430. /**
  76431. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76432. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76433. */
  76434. get paddingBottomInPixels(): number;
  76435. set paddingBottomInPixels(value: number);
  76436. /**
  76437. * Gets or sets a value indicating the left coordinate of the control
  76438. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76439. */
  76440. get left(): string | number;
  76441. set left(value: string | number);
  76442. /**
  76443. * Gets or sets a value indicating the left coordinate in pixels of the control
  76444. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76445. */
  76446. get leftInPixels(): number;
  76447. set leftInPixels(value: number);
  76448. /**
  76449. * Gets or sets a value indicating the top coordinate of the control
  76450. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76451. */
  76452. get top(): string | number;
  76453. set top(value: string | number);
  76454. /**
  76455. * Gets or sets a value indicating the top coordinate in pixels of the control
  76456. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76457. */
  76458. get topInPixels(): number;
  76459. set topInPixels(value: number);
  76460. /**
  76461. * Gets or sets a value indicating the offset on X axis to the linked mesh
  76462. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76463. */
  76464. get linkOffsetX(): string | number;
  76465. set linkOffsetX(value: string | number);
  76466. /**
  76467. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  76468. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76469. */
  76470. get linkOffsetXInPixels(): number;
  76471. set linkOffsetXInPixels(value: number);
  76472. /**
  76473. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  76474. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76475. */
  76476. get linkOffsetY(): string | number;
  76477. set linkOffsetY(value: string | number);
  76478. /**
  76479. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  76480. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76481. */
  76482. get linkOffsetYInPixels(): number;
  76483. set linkOffsetYInPixels(value: number);
  76484. /** Gets the center coordinate on X axis */
  76485. get centerX(): number;
  76486. /** Gets the center coordinate on Y axis */
  76487. get centerY(): number;
  76488. /** Gets or sets if control is Enabled*/
  76489. get isEnabled(): boolean;
  76490. set isEnabled(value: boolean);
  76491. /** Gets or sets background color of control if it's disabled*/
  76492. get disabledColor(): string;
  76493. set disabledColor(value: string);
  76494. /** Gets or sets front color of control if it's disabled*/
  76495. get disabledColorItem(): string;
  76496. set disabledColorItem(value: string);
  76497. /**
  76498. * Creates a new control
  76499. * @param name defines the name of the control
  76500. */
  76501. constructor(
  76502. /** defines the name of the control */
  76503. name?: string | undefined);
  76504. /** @hidden */
  76505. protected _getTypeName(): string;
  76506. /**
  76507. * Gets the first ascendant in the hierarchy of the given type
  76508. * @param className defines the required type
  76509. * @returns the ascendant or null if not found
  76510. */
  76511. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  76512. /** @hidden */
  76513. _resetFontCache(): void;
  76514. /**
  76515. * Determines if a container is an ascendant of the current control
  76516. * @param container defines the container to look for
  76517. * @returns true if the container is one of the ascendant of the control
  76518. */
  76519. isAscendant(container: Control): boolean;
  76520. /**
  76521. * Gets coordinates in local control space
  76522. * @param globalCoordinates defines the coordinates to transform
  76523. * @returns the new coordinates in local space
  76524. */
  76525. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76526. /**
  76527. * Gets coordinates in local control space
  76528. * @param globalCoordinates defines the coordinates to transform
  76529. * @param result defines the target vector2 where to store the result
  76530. * @returns the current control
  76531. */
  76532. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  76533. /**
  76534. * Gets coordinates in parent local control space
  76535. * @param globalCoordinates defines the coordinates to transform
  76536. * @returns the new coordinates in parent local space
  76537. */
  76538. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76539. /**
  76540. * Move the current control to a vector3 position projected onto the screen.
  76541. * @param position defines the target position
  76542. * @param scene defines the hosting scene
  76543. */
  76544. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  76545. /**
  76546. * Will store all controls that have this control as ascendant in a given array
  76547. * @param results defines the array where to store the descendants
  76548. * @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
  76549. * @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
  76550. */
  76551. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76552. /**
  76553. * Will return all controls that have this control as ascendant
  76554. * @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
  76555. * @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
  76556. * @return all child controls
  76557. */
  76558. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76559. /**
  76560. * Link current control with a target mesh
  76561. * @param mesh defines the mesh to link with
  76562. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76563. */
  76564. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  76565. /** @hidden */
  76566. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  76567. /** @hidden */
  76568. _offsetLeft(offset: number): void;
  76569. /** @hidden */
  76570. _offsetTop(offset: number): void;
  76571. /** @hidden */
  76572. _markMatrixAsDirty(): void;
  76573. /** @hidden */
  76574. _flagDescendantsAsMatrixDirty(): void;
  76575. /** @hidden */
  76576. _intersectsRect(rect: Measure): boolean;
  76577. /** @hidden */
  76578. protected invalidateRect(): void;
  76579. /** @hidden */
  76580. _markAsDirty(force?: boolean): void;
  76581. /** @hidden */
  76582. _markAllAsDirty(): void;
  76583. /** @hidden */
  76584. _link(host: AdvancedDynamicTexture): void;
  76585. /** @hidden */
  76586. protected _transform(context?: CanvasRenderingContext2D): void;
  76587. /** @hidden */
  76588. _renderHighlight(context: CanvasRenderingContext2D): void;
  76589. /** @hidden */
  76590. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76591. /** @hidden */
  76592. protected _applyStates(context: CanvasRenderingContext2D): void;
  76593. /** @hidden */
  76594. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76595. /** @hidden */
  76596. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76597. protected _evaluateClippingState(parentMeasure: Measure): void;
  76598. /** @hidden */
  76599. _measure(): void;
  76600. /** @hidden */
  76601. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76602. /** @hidden */
  76603. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76604. /** @hidden */
  76605. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76606. /** @hidden */
  76607. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76608. private static _ClipMeasure;
  76609. private _tmpMeasureA;
  76610. private _clip;
  76611. /** @hidden */
  76612. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  76613. /** @hidden */
  76614. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76615. /**
  76616. * Tests if a given coordinates belong to the current control
  76617. * @param x defines x coordinate to test
  76618. * @param y defines y coordinate to test
  76619. * @returns true if the coordinates are inside the control
  76620. */
  76621. contains(x: number, y: number): boolean;
  76622. /** @hidden */
  76623. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76624. /** @hidden */
  76625. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76626. /** @hidden */
  76627. _onPointerEnter(target: Control): boolean;
  76628. /** @hidden */
  76629. _onPointerOut(target: Control, force?: boolean): void;
  76630. /** @hidden */
  76631. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76632. /** @hidden */
  76633. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76634. /** @hidden */
  76635. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76636. /** @hidden */
  76637. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  76638. /** @hidden */
  76639. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76640. private _prepareFont;
  76641. /** Releases associated resources */
  76642. dispose(): void;
  76643. private static _HORIZONTAL_ALIGNMENT_LEFT;
  76644. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  76645. private static _HORIZONTAL_ALIGNMENT_CENTER;
  76646. private static _VERTICAL_ALIGNMENT_TOP;
  76647. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76648. private static _VERTICAL_ALIGNMENT_CENTER;
  76649. /** HORIZONTAL_ALIGNMENT_LEFT */
  76650. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76651. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76652. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76653. /** HORIZONTAL_ALIGNMENT_CENTER */
  76654. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76655. /** VERTICAL_ALIGNMENT_TOP */
  76656. static get VERTICAL_ALIGNMENT_TOP(): number;
  76657. /** VERTICAL_ALIGNMENT_BOTTOM */
  76658. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76659. /** VERTICAL_ALIGNMENT_CENTER */
  76660. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76661. private static _FontHeightSizes;
  76662. /** @hidden */
  76663. static _GetFontOffset(font: string): {
  76664. ascent: number;
  76665. height: number;
  76666. descent: number;
  76667. };
  76668. /**
  76669. * Creates a stack panel that can be used to render headers
  76670. * @param control defines the control to associate with the header
  76671. * @param text defines the text of the header
  76672. * @param size defines the size of the header
  76673. * @param options defines options used to configure the header
  76674. * @returns a new StackPanel
  76675. * @ignore
  76676. * @hidden
  76677. */
  76678. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76679. isHorizontal: boolean;
  76680. controlFirst: boolean;
  76681. }) => any;
  76682. /** @hidden */
  76683. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76684. }
  76685. }
  76686. declare module BABYLON.GUI {
  76687. /**
  76688. * Root class for 2D containers
  76689. * @see https://doc.babylonjs.com/how_to/gui#containers
  76690. */
  76691. export class Container extends Control {
  76692. name?: string | undefined;
  76693. /** @hidden */
  76694. _children: Control[];
  76695. /** @hidden */
  76696. protected _measureForChildren: Measure;
  76697. /** @hidden */
  76698. protected _background: string;
  76699. /** @hidden */
  76700. protected _adaptWidthToChildren: boolean;
  76701. /** @hidden */
  76702. protected _adaptHeightToChildren: boolean;
  76703. /**
  76704. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76705. */
  76706. logLayoutCycleErrors: boolean;
  76707. /**
  76708. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76709. */
  76710. maxLayoutCycle: number;
  76711. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76712. get adaptHeightToChildren(): boolean;
  76713. set adaptHeightToChildren(value: boolean);
  76714. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76715. get adaptWidthToChildren(): boolean;
  76716. set adaptWidthToChildren(value: boolean);
  76717. /** Gets or sets background color */
  76718. get background(): string;
  76719. set background(value: string);
  76720. /** Gets the list of children */
  76721. get children(): Control[];
  76722. /**
  76723. * Creates a new Container
  76724. * @param name defines the name of the container
  76725. */
  76726. constructor(name?: string | undefined);
  76727. protected _getTypeName(): string;
  76728. _flagDescendantsAsMatrixDirty(): void;
  76729. /**
  76730. * Gets a child using its name
  76731. * @param name defines the child name to look for
  76732. * @returns the child control if found
  76733. */
  76734. getChildByName(name: string): BABYLON.Nullable<Control>;
  76735. /**
  76736. * Gets a child using its type and its name
  76737. * @param name defines the child name to look for
  76738. * @param type defines the child type to look for
  76739. * @returns the child control if found
  76740. */
  76741. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76742. /**
  76743. * Search for a specific control in children
  76744. * @param control defines the control to look for
  76745. * @returns true if the control is in child list
  76746. */
  76747. containsControl(control: Control): boolean;
  76748. /**
  76749. * Adds a new control to the current container
  76750. * @param control defines the control to add
  76751. * @returns the current container
  76752. */
  76753. addControl(control: BABYLON.Nullable<Control>): Container;
  76754. /**
  76755. * Removes all controls from the current container
  76756. * @returns the current container
  76757. */
  76758. clearControls(): Container;
  76759. /**
  76760. * Removes a control from the current container
  76761. * @param control defines the control to remove
  76762. * @returns the current container
  76763. */
  76764. removeControl(control: Control): Container;
  76765. /** @hidden */
  76766. _reOrderControl(control: Control): void;
  76767. /** @hidden */
  76768. _offsetLeft(offset: number): void;
  76769. /** @hidden */
  76770. _offsetTop(offset: number): void;
  76771. /** @hidden */
  76772. _markAllAsDirty(): void;
  76773. /** @hidden */
  76774. protected _localDraw(context: CanvasRenderingContext2D): void;
  76775. /** @hidden */
  76776. _link(host: AdvancedDynamicTexture): void;
  76777. /** @hidden */
  76778. protected _beforeLayout(): void;
  76779. /** @hidden */
  76780. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76781. /** @hidden */
  76782. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76783. protected _postMeasure(): void;
  76784. /** @hidden */
  76785. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76786. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76787. /** @hidden */
  76788. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76789. /** @hidden */
  76790. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76791. /** Releases associated resources */
  76792. dispose(): void;
  76793. }
  76794. }
  76795. declare module BABYLON.GUI {
  76796. /** Class used to create rectangle container */
  76797. export class Rectangle extends Container {
  76798. name?: string | undefined;
  76799. private _thickness;
  76800. private _cornerRadius;
  76801. /** Gets or sets border thickness */
  76802. get thickness(): number;
  76803. set thickness(value: number);
  76804. /** Gets or sets the corner radius angle */
  76805. get cornerRadius(): number;
  76806. set cornerRadius(value: number);
  76807. /**
  76808. * Creates a new Rectangle
  76809. * @param name defines the control name
  76810. */
  76811. constructor(name?: string | undefined);
  76812. protected _getTypeName(): string;
  76813. protected _localDraw(context: CanvasRenderingContext2D): void;
  76814. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76815. private _drawRoundedRect;
  76816. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76817. }
  76818. }
  76819. declare module BABYLON.GUI {
  76820. /**
  76821. * Enum that determines the text-wrapping mode to use.
  76822. */
  76823. export enum TextWrapping {
  76824. /**
  76825. * Clip the text when it's larger than Control.width; this is the default mode.
  76826. */
  76827. Clip = 0,
  76828. /**
  76829. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76830. */
  76831. WordWrap = 1,
  76832. /**
  76833. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76834. */
  76835. Ellipsis = 2
  76836. }
  76837. /**
  76838. * Class used to create text block control
  76839. */
  76840. export class TextBlock extends Control {
  76841. /**
  76842. * Defines the name of the control
  76843. */
  76844. name?: string | undefined;
  76845. private _text;
  76846. private _textWrapping;
  76847. private _textHorizontalAlignment;
  76848. private _textVerticalAlignment;
  76849. private _lines;
  76850. private _resizeToFit;
  76851. private _lineSpacing;
  76852. private _outlineWidth;
  76853. private _outlineColor;
  76854. /**
  76855. * An event triggered after the text is changed
  76856. */
  76857. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76858. /**
  76859. * An event triggered after the text was broken up into lines
  76860. */
  76861. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76862. /**
  76863. * Function used to split a string into words. By default, a string is split at each space character found
  76864. */
  76865. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76866. /**
  76867. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76868. */
  76869. get lines(): any[];
  76870. /**
  76871. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76872. */
  76873. get resizeToFit(): boolean;
  76874. /**
  76875. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76876. */
  76877. set resizeToFit(value: boolean);
  76878. /**
  76879. * Gets or sets a boolean indicating if text must be wrapped
  76880. */
  76881. get textWrapping(): TextWrapping | boolean;
  76882. /**
  76883. * Gets or sets a boolean indicating if text must be wrapped
  76884. */
  76885. set textWrapping(value: TextWrapping | boolean);
  76886. /**
  76887. * Gets or sets text to display
  76888. */
  76889. get text(): string;
  76890. /**
  76891. * Gets or sets text to display
  76892. */
  76893. set text(value: string);
  76894. /**
  76895. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76896. */
  76897. get textHorizontalAlignment(): number;
  76898. /**
  76899. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76900. */
  76901. set textHorizontalAlignment(value: number);
  76902. /**
  76903. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76904. */
  76905. get textVerticalAlignment(): number;
  76906. /**
  76907. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76908. */
  76909. set textVerticalAlignment(value: number);
  76910. /**
  76911. * Gets or sets line spacing value
  76912. */
  76913. set lineSpacing(value: string | number);
  76914. /**
  76915. * Gets or sets line spacing value
  76916. */
  76917. get lineSpacing(): string | number;
  76918. /**
  76919. * Gets or sets outlineWidth of the text to display
  76920. */
  76921. get outlineWidth(): number;
  76922. /**
  76923. * Gets or sets outlineWidth of the text to display
  76924. */
  76925. set outlineWidth(value: number);
  76926. /**
  76927. * Gets or sets outlineColor of the text to display
  76928. */
  76929. get outlineColor(): string;
  76930. /**
  76931. * Gets or sets outlineColor of the text to display
  76932. */
  76933. set outlineColor(value: string);
  76934. /**
  76935. * Creates a new TextBlock object
  76936. * @param name defines the name of the control
  76937. * @param text defines the text to display (emptry string by default)
  76938. */
  76939. constructor(
  76940. /**
  76941. * Defines the name of the control
  76942. */
  76943. name?: string | undefined, text?: string);
  76944. protected _getTypeName(): string;
  76945. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76946. private _drawText;
  76947. /** @hidden */
  76948. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76949. protected _applyStates(context: CanvasRenderingContext2D): void;
  76950. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76951. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76952. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76953. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76954. protected _renderLines(context: CanvasRenderingContext2D): void;
  76955. /**
  76956. * Given a width constraint applied on the text block, find the expected height
  76957. * @returns expected height
  76958. */
  76959. computeExpectedHeight(): number;
  76960. dispose(): void;
  76961. }
  76962. }
  76963. declare module BABYLON.GUI {
  76964. /**
  76965. * Class used to create 2D images
  76966. */
  76967. export class Image extends Control {
  76968. name?: string | undefined;
  76969. private _workingCanvas;
  76970. private _domImage;
  76971. private _imageWidth;
  76972. private _imageHeight;
  76973. private _loaded;
  76974. private _stretch;
  76975. private _source;
  76976. private _autoScale;
  76977. private _sourceLeft;
  76978. private _sourceTop;
  76979. private _sourceWidth;
  76980. private _sourceHeight;
  76981. private _svgAttributesComputationCompleted;
  76982. private _isSVG;
  76983. private _cellWidth;
  76984. private _cellHeight;
  76985. private _cellId;
  76986. private _populateNinePatchSlicesFromImage;
  76987. private _sliceLeft;
  76988. private _sliceRight;
  76989. private _sliceTop;
  76990. private _sliceBottom;
  76991. private _detectPointerOnOpaqueOnly;
  76992. private _imageDataCache;
  76993. /**
  76994. * BABYLON.Observable notified when the content is loaded
  76995. */
  76996. onImageLoadedObservable: BABYLON.Observable<Image>;
  76997. /**
  76998. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76999. */
  77000. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  77001. /**
  77002. * Gets a boolean indicating that the content is loaded
  77003. */
  77004. get isLoaded(): boolean;
  77005. /**
  77006. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  77007. */
  77008. get populateNinePatchSlicesFromImage(): boolean;
  77009. set populateNinePatchSlicesFromImage(value: boolean);
  77010. /**
  77011. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  77012. * Beware using this as this will comsume more memory as the image has to be stored twice
  77013. */
  77014. get detectPointerOnOpaqueOnly(): boolean;
  77015. set detectPointerOnOpaqueOnly(value: boolean);
  77016. /**
  77017. * Gets or sets the left value for slicing (9-patch)
  77018. */
  77019. get sliceLeft(): number;
  77020. set sliceLeft(value: number);
  77021. /**
  77022. * Gets or sets the right value for slicing (9-patch)
  77023. */
  77024. get sliceRight(): number;
  77025. set sliceRight(value: number);
  77026. /**
  77027. * Gets or sets the top value for slicing (9-patch)
  77028. */
  77029. get sliceTop(): number;
  77030. set sliceTop(value: number);
  77031. /**
  77032. * Gets or sets the bottom value for slicing (9-patch)
  77033. */
  77034. get sliceBottom(): number;
  77035. set sliceBottom(value: number);
  77036. /**
  77037. * Gets or sets the left coordinate in the source image
  77038. */
  77039. get sourceLeft(): number;
  77040. set sourceLeft(value: number);
  77041. /**
  77042. * Gets or sets the top coordinate in the source image
  77043. */
  77044. get sourceTop(): number;
  77045. set sourceTop(value: number);
  77046. /**
  77047. * Gets or sets the width to capture in the source image
  77048. */
  77049. get sourceWidth(): number;
  77050. set sourceWidth(value: number);
  77051. /**
  77052. * Gets or sets the height to capture in the source image
  77053. */
  77054. get sourceHeight(): number;
  77055. set sourceHeight(value: number);
  77056. /** Indicates if the format of the image is SVG */
  77057. get isSVG(): boolean;
  77058. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  77059. get svgAttributesComputationCompleted(): boolean;
  77060. /**
  77061. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  77062. * @see https://doc.babylonjs.com/how_to/gui#image
  77063. */
  77064. get autoScale(): boolean;
  77065. set autoScale(value: boolean);
  77066. /** Gets or sets the streching mode used by the image */
  77067. get stretch(): number;
  77068. set stretch(value: number);
  77069. /** @hidden */
  77070. _rotate90(n: number, preserveProperties?: boolean): Image;
  77071. private _handleRotationForSVGImage;
  77072. private _rotate90SourceProperties;
  77073. /**
  77074. * Gets or sets the internal DOM image used to render the control
  77075. */
  77076. set domImage(value: HTMLImageElement);
  77077. get domImage(): HTMLImageElement;
  77078. private _onImageLoaded;
  77079. private _extractNinePatchSliceDataFromImage;
  77080. /**
  77081. * Gets or sets image source url
  77082. */
  77083. set source(value: BABYLON.Nullable<string>);
  77084. /**
  77085. * Checks for svg document with icon id present
  77086. */
  77087. private _svgCheck;
  77088. /**
  77089. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  77090. * given external svg file and icon id
  77091. */
  77092. private _getSVGAttribs;
  77093. /**
  77094. * Gets or sets the cell width to use when animation sheet is enabled
  77095. * @see https://doc.babylonjs.com/how_to/gui#image
  77096. */
  77097. get cellWidth(): number;
  77098. set cellWidth(value: number);
  77099. /**
  77100. * Gets or sets the cell height to use when animation sheet is enabled
  77101. * @see https://doc.babylonjs.com/how_to/gui#image
  77102. */
  77103. get cellHeight(): number;
  77104. set cellHeight(value: number);
  77105. /**
  77106. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77107. * @see https://doc.babylonjs.com/how_to/gui#image
  77108. */
  77109. get cellId(): number;
  77110. set cellId(value: number);
  77111. /**
  77112. * Creates a new Image
  77113. * @param name defines the control name
  77114. * @param url defines the image url
  77115. */
  77116. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77117. /**
  77118. * Tests if a given coordinates belong to the current control
  77119. * @param x defines x coordinate to test
  77120. * @param y defines y coordinate to test
  77121. * @returns true if the coordinates are inside the control
  77122. */
  77123. contains(x: number, y: number): boolean;
  77124. protected _getTypeName(): string;
  77125. /** Force the control to synchronize with its content */
  77126. synchronizeSizeWithContent(): void;
  77127. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77128. private _prepareWorkingCanvasForOpaqueDetection;
  77129. private _drawImage;
  77130. _draw(context: CanvasRenderingContext2D): void;
  77131. private _renderCornerPatch;
  77132. private _renderNinePatch;
  77133. dispose(): void;
  77134. /** STRETCH_NONE */
  77135. static readonly STRETCH_NONE: number;
  77136. /** STRETCH_FILL */
  77137. static readonly STRETCH_FILL: number;
  77138. /** STRETCH_UNIFORM */
  77139. static readonly STRETCH_UNIFORM: number;
  77140. /** STRETCH_EXTEND */
  77141. static readonly STRETCH_EXTEND: number;
  77142. /** NINE_PATCH */
  77143. static readonly STRETCH_NINE_PATCH: number;
  77144. }
  77145. }
  77146. declare module BABYLON.GUI {
  77147. /**
  77148. * Class used to create 2D buttons
  77149. */
  77150. export class Button extends Rectangle {
  77151. name?: string | undefined;
  77152. /**
  77153. * Function called to generate a pointer enter animation
  77154. */
  77155. pointerEnterAnimation: () => void;
  77156. /**
  77157. * Function called to generate a pointer out animation
  77158. */
  77159. pointerOutAnimation: () => void;
  77160. /**
  77161. * Function called to generate a pointer down animation
  77162. */
  77163. pointerDownAnimation: () => void;
  77164. /**
  77165. * Function called to generate a pointer up animation
  77166. */
  77167. pointerUpAnimation: () => void;
  77168. /**
  77169. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  77170. */
  77171. delegatePickingToChildren: boolean;
  77172. private _image;
  77173. /**
  77174. * Returns the image part of the button (if any)
  77175. */
  77176. get image(): BABYLON.Nullable<Image>;
  77177. private _textBlock;
  77178. /**
  77179. * Returns the image part of the button (if any)
  77180. */
  77181. get textBlock(): BABYLON.Nullable<TextBlock>;
  77182. /**
  77183. * Creates a new Button
  77184. * @param name defines the name of the button
  77185. */
  77186. constructor(name?: string | undefined);
  77187. protected _getTypeName(): string;
  77188. /** @hidden */
  77189. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77190. /** @hidden */
  77191. _onPointerEnter(target: Control): boolean;
  77192. /** @hidden */
  77193. _onPointerOut(target: Control, force?: boolean): void;
  77194. /** @hidden */
  77195. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77196. /** @hidden */
  77197. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77198. /**
  77199. * Creates a new button made with an image and a text
  77200. * @param name defines the name of the button
  77201. * @param text defines the text of the button
  77202. * @param imageUrl defines the url of the image
  77203. * @returns a new Button
  77204. */
  77205. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  77206. /**
  77207. * Creates a new button made with an image
  77208. * @param name defines the name of the button
  77209. * @param imageUrl defines the url of the image
  77210. * @returns a new Button
  77211. */
  77212. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  77213. /**
  77214. * Creates a new button made with a text
  77215. * @param name defines the name of the button
  77216. * @param text defines the text of the button
  77217. * @returns a new Button
  77218. */
  77219. static CreateSimpleButton(name: string, text: string): Button;
  77220. /**
  77221. * Creates a new button made with an image and a centered text
  77222. * @param name defines the name of the button
  77223. * @param text defines the text of the button
  77224. * @param imageUrl defines the url of the image
  77225. * @returns a new Button
  77226. */
  77227. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  77228. }
  77229. }
  77230. declare module BABYLON.GUI {
  77231. /**
  77232. * Class used to create a 2D stack panel container
  77233. */
  77234. export class StackPanel extends Container {
  77235. name?: string | undefined;
  77236. private _isVertical;
  77237. private _manualWidth;
  77238. private _manualHeight;
  77239. private _doNotTrackManualChanges;
  77240. /**
  77241. * Gets or sets a boolean indicating that layou warnings should be ignored
  77242. */
  77243. ignoreLayoutWarnings: boolean;
  77244. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  77245. get isVertical(): boolean;
  77246. set isVertical(value: boolean);
  77247. /**
  77248. * Gets or sets panel width.
  77249. * This value should not be set when in horizontal mode as it will be computed automatically
  77250. */
  77251. set width(value: string | number);
  77252. get width(): string | number;
  77253. /**
  77254. * Gets or sets panel height.
  77255. * This value should not be set when in vertical mode as it will be computed automatically
  77256. */
  77257. set height(value: string | number);
  77258. get height(): string | number;
  77259. /**
  77260. * Creates a new StackPanel
  77261. * @param name defines control name
  77262. */
  77263. constructor(name?: string | undefined);
  77264. protected _getTypeName(): string;
  77265. /** @hidden */
  77266. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77267. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77268. protected _postMeasure(): void;
  77269. }
  77270. }
  77271. declare module BABYLON.GUI {
  77272. /**
  77273. * Class used to represent a 2D checkbox
  77274. */
  77275. export class Checkbox extends Control {
  77276. name?: string | undefined;
  77277. private _isChecked;
  77278. private _background;
  77279. private _checkSizeRatio;
  77280. private _thickness;
  77281. /** Gets or sets border thickness */
  77282. get thickness(): number;
  77283. set thickness(value: number);
  77284. /**
  77285. * BABYLON.Observable raised when isChecked property changes
  77286. */
  77287. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77288. /** Gets or sets a value indicating the ratio between overall size and check size */
  77289. get checkSizeRatio(): number;
  77290. set checkSizeRatio(value: number);
  77291. /** Gets or sets background color */
  77292. get background(): string;
  77293. set background(value: string);
  77294. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77295. get isChecked(): boolean;
  77296. set isChecked(value: boolean);
  77297. /**
  77298. * Creates a new CheckBox
  77299. * @param name defines the control name
  77300. */
  77301. constructor(name?: string | undefined);
  77302. protected _getTypeName(): string;
  77303. /** @hidden */
  77304. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77305. /** @hidden */
  77306. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77307. /**
  77308. * Utility function to easily create a checkbox with a header
  77309. * @param title defines the label to use for the header
  77310. * @param onValueChanged defines the callback to call when value changes
  77311. * @returns a StackPanel containing the checkbox and a textBlock
  77312. */
  77313. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  77314. }
  77315. }
  77316. declare module BABYLON.GUI {
  77317. /**
  77318. * Class used to store key control properties
  77319. */
  77320. export class KeyPropertySet {
  77321. /** Width */
  77322. width?: string;
  77323. /** Height */
  77324. height?: string;
  77325. /** Left padding */
  77326. paddingLeft?: string;
  77327. /** Right padding */
  77328. paddingRight?: string;
  77329. /** Top padding */
  77330. paddingTop?: string;
  77331. /** Bottom padding */
  77332. paddingBottom?: string;
  77333. /** Foreground color */
  77334. color?: string;
  77335. /** Background color */
  77336. background?: string;
  77337. }
  77338. /**
  77339. * Class used to create virtual keyboard
  77340. */
  77341. export class VirtualKeyboard extends StackPanel {
  77342. /** BABYLON.Observable raised when a key is pressed */
  77343. onKeyPressObservable: BABYLON.Observable<string>;
  77344. /** Gets or sets default key button width */
  77345. defaultButtonWidth: string;
  77346. /** Gets or sets default key button height */
  77347. defaultButtonHeight: string;
  77348. /** Gets or sets default key button left padding */
  77349. defaultButtonPaddingLeft: string;
  77350. /** Gets or sets default key button right padding */
  77351. defaultButtonPaddingRight: string;
  77352. /** Gets or sets default key button top padding */
  77353. defaultButtonPaddingTop: string;
  77354. /** Gets or sets default key button bottom padding */
  77355. defaultButtonPaddingBottom: string;
  77356. /** Gets or sets default key button foreground color */
  77357. defaultButtonColor: string;
  77358. /** Gets or sets default key button background color */
  77359. defaultButtonBackground: string;
  77360. /** Gets or sets shift button foreground color */
  77361. shiftButtonColor: string;
  77362. /** Gets or sets shift button thickness*/
  77363. selectedShiftThickness: number;
  77364. /** Gets shift key state */
  77365. shiftState: number;
  77366. protected _getTypeName(): string;
  77367. private _createKey;
  77368. /**
  77369. * Adds a new row of keys
  77370. * @param keys defines the list of keys to add
  77371. * @param propertySets defines the associated property sets
  77372. */
  77373. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77374. /**
  77375. * Set the shift key to a specific state
  77376. * @param shiftState defines the new shift state
  77377. */
  77378. applyShiftState(shiftState: number): void;
  77379. private _currentlyConnectedInputText;
  77380. private _connectedInputTexts;
  77381. private _onKeyPressObserver;
  77382. /** Gets the input text control currently attached to the keyboard */
  77383. get connectedInputText(): BABYLON.Nullable<InputText>;
  77384. /**
  77385. * Connects the keyboard with an input text control
  77386. *
  77387. * @param input defines the target control
  77388. */
  77389. connect(input: InputText): void;
  77390. /**
  77391. * Disconnects the keyboard from connected InputText controls
  77392. *
  77393. * @param input optionally defines a target control, otherwise all are disconnected
  77394. */
  77395. disconnect(input?: InputText): void;
  77396. private _removeConnectedInputObservables;
  77397. /**
  77398. * Release all resources
  77399. */
  77400. dispose(): void;
  77401. /**
  77402. * Creates a new keyboard using a default layout
  77403. *
  77404. * @param name defines control name
  77405. * @returns a new VirtualKeyboard
  77406. */
  77407. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77408. }
  77409. }
  77410. declare module BABYLON.GUI {
  77411. /**
  77412. * Class used to create input text control
  77413. */
  77414. export class InputText extends Control implements IFocusableControl {
  77415. name?: string | undefined;
  77416. private _text;
  77417. private _placeholderText;
  77418. private _background;
  77419. private _focusedBackground;
  77420. private _focusedColor;
  77421. private _placeholderColor;
  77422. private _thickness;
  77423. private _margin;
  77424. private _autoStretchWidth;
  77425. private _maxWidth;
  77426. private _isFocused;
  77427. private _blinkTimeout;
  77428. private _blinkIsEven;
  77429. private _cursorOffset;
  77430. private _scrollLeft;
  77431. private _textWidth;
  77432. private _clickedCoordinate;
  77433. private _deadKey;
  77434. private _addKey;
  77435. private _currentKey;
  77436. private _isTextHighlightOn;
  77437. private _textHighlightColor;
  77438. private _highligherOpacity;
  77439. private _highlightedText;
  77440. private _startHighlightIndex;
  77441. private _endHighlightIndex;
  77442. private _cursorIndex;
  77443. private _onFocusSelectAll;
  77444. private _isPointerDown;
  77445. private _onClipboardObserver;
  77446. private _onPointerDblTapObserver;
  77447. /** @hidden */
  77448. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  77449. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  77450. promptMessage: string;
  77451. /** Force disable prompt on mobile device */
  77452. disableMobilePrompt: boolean;
  77453. /** BABYLON.Observable raised when the text changes */
  77454. onTextChangedObservable: BABYLON.Observable<InputText>;
  77455. /** BABYLON.Observable raised just before an entered character is to be added */
  77456. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  77457. /** BABYLON.Observable raised when the control gets the focus */
  77458. onFocusObservable: BABYLON.Observable<InputText>;
  77459. /** BABYLON.Observable raised when the control loses the focus */
  77460. onBlurObservable: BABYLON.Observable<InputText>;
  77461. /**Observable raised when the text is highlighted */
  77462. onTextHighlightObservable: BABYLON.Observable<InputText>;
  77463. /**Observable raised when copy event is triggered */
  77464. onTextCopyObservable: BABYLON.Observable<InputText>;
  77465. /** BABYLON.Observable raised when cut event is triggered */
  77466. onTextCutObservable: BABYLON.Observable<InputText>;
  77467. /** BABYLON.Observable raised when paste event is triggered */
  77468. onTextPasteObservable: BABYLON.Observable<InputText>;
  77469. /** BABYLON.Observable raised when a key event was processed */
  77470. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  77471. /** Gets or sets the maximum width allowed by the control */
  77472. get maxWidth(): string | number;
  77473. /** Gets the maximum width allowed by the control in pixels */
  77474. get maxWidthInPixels(): number;
  77475. set maxWidth(value: string | number);
  77476. /** Gets or sets the text highlighter transparency; default: 0.4 */
  77477. get highligherOpacity(): number;
  77478. set highligherOpacity(value: number);
  77479. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  77480. get onFocusSelectAll(): boolean;
  77481. set onFocusSelectAll(value: boolean);
  77482. /** Gets or sets the text hightlight color */
  77483. get textHighlightColor(): string;
  77484. set textHighlightColor(value: string);
  77485. /** Gets or sets control margin */
  77486. get margin(): string;
  77487. /** Gets control margin in pixels */
  77488. get marginInPixels(): number;
  77489. set margin(value: string);
  77490. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  77491. get autoStretchWidth(): boolean;
  77492. set autoStretchWidth(value: boolean);
  77493. /** Gets or sets border thickness */
  77494. get thickness(): number;
  77495. set thickness(value: number);
  77496. /** Gets or sets the background color when focused */
  77497. get focusedBackground(): string;
  77498. set focusedBackground(value: string);
  77499. /** Gets or sets the background color when focused */
  77500. get focusedColor(): string;
  77501. set focusedColor(value: string);
  77502. /** Gets or sets the background color */
  77503. get background(): string;
  77504. set background(value: string);
  77505. /** Gets or sets the placeholder color */
  77506. get placeholderColor(): string;
  77507. set placeholderColor(value: string);
  77508. /** Gets or sets the text displayed when the control is empty */
  77509. get placeholderText(): string;
  77510. set placeholderText(value: string);
  77511. /** Gets or sets the dead key flag */
  77512. get deadKey(): boolean;
  77513. set deadKey(flag: boolean);
  77514. /** Gets or sets the highlight text */
  77515. get highlightedText(): string;
  77516. set highlightedText(text: string);
  77517. /** Gets or sets if the current key should be added */
  77518. get addKey(): boolean;
  77519. set addKey(flag: boolean);
  77520. /** Gets or sets the value of the current key being entered */
  77521. get currentKey(): string;
  77522. set currentKey(key: string);
  77523. /** Gets or sets the text displayed in the control */
  77524. get text(): string;
  77525. set text(value: string);
  77526. /** Gets or sets control width */
  77527. get width(): string | number;
  77528. set width(value: string | number);
  77529. /**
  77530. * Creates a new InputText
  77531. * @param name defines the control name
  77532. * @param text defines the text of the control
  77533. */
  77534. constructor(name?: string | undefined, text?: string);
  77535. /** @hidden */
  77536. onBlur(): void;
  77537. /** @hidden */
  77538. onFocus(): void;
  77539. protected _getTypeName(): string;
  77540. /**
  77541. * Function called to get the list of controls that should not steal the focus from this control
  77542. * @returns an array of controls
  77543. */
  77544. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77545. /** @hidden */
  77546. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  77547. /** @hidden */
  77548. private _updateValueFromCursorIndex;
  77549. /** @hidden */
  77550. private _processDblClick;
  77551. /** @hidden */
  77552. private _selectAllText;
  77553. /**
  77554. * Handles the keyboard event
  77555. * @param evt Defines the KeyboardEvent
  77556. */
  77557. processKeyboard(evt: KeyboardEvent): void;
  77558. /** @hidden */
  77559. private _onCopyText;
  77560. /** @hidden */
  77561. private _onCutText;
  77562. /** @hidden */
  77563. private _onPasteText;
  77564. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77565. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77566. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77567. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77568. protected _beforeRenderText(text: string): string;
  77569. dispose(): void;
  77570. }
  77571. }
  77572. declare module BABYLON.GUI {
  77573. /**
  77574. * Class used to create a 2D grid container
  77575. */
  77576. export class Grid extends Container {
  77577. name?: string | undefined;
  77578. private _rowDefinitions;
  77579. private _columnDefinitions;
  77580. private _cells;
  77581. private _childControls;
  77582. /**
  77583. * Gets the number of columns
  77584. */
  77585. get columnCount(): number;
  77586. /**
  77587. * Gets the number of rows
  77588. */
  77589. get rowCount(): number;
  77590. /** Gets the list of children */
  77591. get children(): Control[];
  77592. /** Gets the list of cells (e.g. the containers) */
  77593. get cells(): {
  77594. [key: string]: Container;
  77595. };
  77596. /**
  77597. * Gets the definition of a specific row
  77598. * @param index defines the index of the row
  77599. * @returns the row definition
  77600. */
  77601. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77602. /**
  77603. * Gets the definition of a specific column
  77604. * @param index defines the index of the column
  77605. * @returns the column definition
  77606. */
  77607. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77608. /**
  77609. * Adds a new row to the grid
  77610. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77611. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  77612. * @returns the current grid
  77613. */
  77614. addRowDefinition(height: number, isPixel?: boolean): Grid;
  77615. /**
  77616. * Adds a new column to the grid
  77617. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77618. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77619. * @returns the current grid
  77620. */
  77621. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  77622. /**
  77623. * Update a row definition
  77624. * @param index defines the index of the row to update
  77625. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77626. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  77627. * @returns the current grid
  77628. */
  77629. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  77630. /**
  77631. * Update a column definition
  77632. * @param index defines the index of the column to update
  77633. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77634. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77635. * @returns the current grid
  77636. */
  77637. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  77638. /**
  77639. * Gets the list of children stored in a specific cell
  77640. * @param row defines the row to check
  77641. * @param column defines the column to check
  77642. * @returns the list of controls
  77643. */
  77644. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  77645. /**
  77646. * Gets a string representing the child cell info (row x column)
  77647. * @param child defines the control to get info from
  77648. * @returns a string containing the child cell info (row x column)
  77649. */
  77650. getChildCellInfo(child: Control): string;
  77651. private _removeCell;
  77652. private _offsetCell;
  77653. /**
  77654. * Remove a column definition at specified index
  77655. * @param index defines the index of the column to remove
  77656. * @returns the current grid
  77657. */
  77658. removeColumnDefinition(index: number): Grid;
  77659. /**
  77660. * Remove a row definition at specified index
  77661. * @param index defines the index of the row to remove
  77662. * @returns the current grid
  77663. */
  77664. removeRowDefinition(index: number): Grid;
  77665. /**
  77666. * Adds a new control to the current grid
  77667. * @param control defines the control to add
  77668. * @param row defines the row where to add the control (0 by default)
  77669. * @param column defines the column where to add the control (0 by default)
  77670. * @returns the current grid
  77671. */
  77672. addControl(control: Control, row?: number, column?: number): Grid;
  77673. /**
  77674. * Removes a control from the current container
  77675. * @param control defines the control to remove
  77676. * @returns the current container
  77677. */
  77678. removeControl(control: Control): Container;
  77679. /**
  77680. * Creates a new Grid
  77681. * @param name defines control name
  77682. */
  77683. constructor(name?: string | undefined);
  77684. protected _getTypeName(): string;
  77685. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77686. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77687. _flagDescendantsAsMatrixDirty(): void;
  77688. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77689. /** Releases associated resources */
  77690. dispose(): void;
  77691. }
  77692. }
  77693. declare module BABYLON.GUI {
  77694. /** Class used to create color pickers */
  77695. export class ColorPicker extends Control {
  77696. name?: string | undefined;
  77697. private static _Epsilon;
  77698. private _colorWheelCanvas;
  77699. private _value;
  77700. private _tmpColor;
  77701. private _pointerStartedOnSquare;
  77702. private _pointerStartedOnWheel;
  77703. private _squareLeft;
  77704. private _squareTop;
  77705. private _squareSize;
  77706. private _h;
  77707. private _s;
  77708. private _v;
  77709. private _lastPointerDownID;
  77710. /**
  77711. * BABYLON.Observable raised when the value changes
  77712. */
  77713. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77714. /** Gets or sets the color of the color picker */
  77715. get value(): BABYLON.Color3;
  77716. set value(value: BABYLON.Color3);
  77717. /**
  77718. * Gets or sets control width
  77719. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77720. */
  77721. get width(): string | number;
  77722. set width(value: string | number);
  77723. /**
  77724. * Gets or sets control height
  77725. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77726. */
  77727. get height(): string | number;
  77728. /** Gets or sets control height */
  77729. set height(value: string | number);
  77730. /** Gets or sets control size */
  77731. get size(): string | number;
  77732. set size(value: string | number);
  77733. /**
  77734. * Creates a new ColorPicker
  77735. * @param name defines the control name
  77736. */
  77737. constructor(name?: string | undefined);
  77738. protected _getTypeName(): string;
  77739. /** @hidden */
  77740. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77741. private _updateSquareProps;
  77742. private _drawGradientSquare;
  77743. private _drawCircle;
  77744. private _createColorWheelCanvas;
  77745. /** @hidden */
  77746. _draw(context: CanvasRenderingContext2D): void;
  77747. private _pointerIsDown;
  77748. private _updateValueFromPointer;
  77749. private _isPointOnSquare;
  77750. private _isPointOnWheel;
  77751. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77752. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77753. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77754. /**
  77755. * This function expands the color picker by creating a color picker dialog with manual
  77756. * color value input and the ability to save colors into an array to be used later in
  77757. * subsequent launches of the dialogue.
  77758. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77759. * @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.
  77760. * @returns picked color as a hex string and the saved colors array as hex strings.
  77761. */
  77762. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77763. pickerWidth?: string;
  77764. pickerHeight?: string;
  77765. headerHeight?: string;
  77766. lastColor?: string;
  77767. swatchLimit?: number;
  77768. numSwatchesPerLine?: number;
  77769. savedColors?: Array<string>;
  77770. }): Promise<{
  77771. savedColors?: string[];
  77772. pickedColor: string;
  77773. }>;
  77774. }
  77775. }
  77776. declare module BABYLON.GUI {
  77777. /** Class used to create 2D ellipse containers */
  77778. export class Ellipse extends Container {
  77779. name?: string | undefined;
  77780. private _thickness;
  77781. /** Gets or sets border thickness */
  77782. get thickness(): number;
  77783. set thickness(value: number);
  77784. /**
  77785. * Creates a new Ellipse
  77786. * @param name defines the control name
  77787. */
  77788. constructor(name?: string | undefined);
  77789. protected _getTypeName(): string;
  77790. protected _localDraw(context: CanvasRenderingContext2D): void;
  77791. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77792. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77793. }
  77794. }
  77795. declare module BABYLON.GUI {
  77796. /**
  77797. * Class used to create a password control
  77798. */
  77799. export class InputPassword extends InputText {
  77800. protected _beforeRenderText(text: string): string;
  77801. }
  77802. }
  77803. declare module BABYLON.GUI {
  77804. /** Class used to render 2D lines */
  77805. export class Line extends Control {
  77806. name?: string | undefined;
  77807. private _lineWidth;
  77808. private _x1;
  77809. private _y1;
  77810. private _x2;
  77811. private _y2;
  77812. private _dash;
  77813. private _connectedControl;
  77814. private _connectedControlDirtyObserver;
  77815. /** Gets or sets the dash pattern */
  77816. get dash(): Array<number>;
  77817. set dash(value: Array<number>);
  77818. /** Gets or sets the control connected with the line end */
  77819. get connectedControl(): Control;
  77820. set connectedControl(value: Control);
  77821. /** Gets or sets start coordinates on X axis */
  77822. get x1(): string | number;
  77823. set x1(value: string | number);
  77824. /** Gets or sets start coordinates on Y axis */
  77825. get y1(): string | number;
  77826. set y1(value: string | number);
  77827. /** Gets or sets end coordinates on X axis */
  77828. get x2(): string | number;
  77829. set x2(value: string | number);
  77830. /** Gets or sets end coordinates on Y axis */
  77831. get y2(): string | number;
  77832. set y2(value: string | number);
  77833. /** Gets or sets line width */
  77834. get lineWidth(): number;
  77835. set lineWidth(value: number);
  77836. /** Gets or sets horizontal alignment */
  77837. set horizontalAlignment(value: number);
  77838. /** Gets or sets vertical alignment */
  77839. set verticalAlignment(value: number);
  77840. private get _effectiveX2();
  77841. private get _effectiveY2();
  77842. /**
  77843. * Creates a new Line
  77844. * @param name defines the control name
  77845. */
  77846. constructor(name?: string | undefined);
  77847. protected _getTypeName(): string;
  77848. _draw(context: CanvasRenderingContext2D): void;
  77849. _measure(): void;
  77850. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77851. /**
  77852. * Move one end of the line given 3D cartesian coordinates.
  77853. * @param position Targeted world position
  77854. * @param scene BABYLON.Scene
  77855. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77856. */
  77857. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77858. /**
  77859. * Move one end of the line to a position in screen absolute space.
  77860. * @param projectedPosition Position in screen absolute space (X, Y)
  77861. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77862. */
  77863. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77864. }
  77865. }
  77866. declare module BABYLON.GUI {
  77867. /**
  77868. * Class used to store a point for a MultiLine object.
  77869. * The point can be pure 2D coordinates, a mesh or a control
  77870. */
  77871. export class MultiLinePoint {
  77872. private _multiLine;
  77873. private _x;
  77874. private _y;
  77875. private _control;
  77876. private _mesh;
  77877. private _controlObserver;
  77878. private _meshObserver;
  77879. /** @hidden */
  77880. _point: BABYLON.Vector2;
  77881. /**
  77882. * Creates a new MultiLinePoint
  77883. * @param multiLine defines the source MultiLine object
  77884. */
  77885. constructor(multiLine: MultiLine);
  77886. /** Gets or sets x coordinate */
  77887. get x(): string | number;
  77888. set x(value: string | number);
  77889. /** Gets or sets y coordinate */
  77890. get y(): string | number;
  77891. set y(value: string | number);
  77892. /** Gets or sets the control associated with this point */
  77893. get control(): BABYLON.Nullable<Control>;
  77894. set control(value: BABYLON.Nullable<Control>);
  77895. /** Gets or sets the mesh associated with this point */
  77896. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77897. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77898. /** Resets links */
  77899. resetLinks(): void;
  77900. /**
  77901. * Gets a translation vector
  77902. * @returns the translation vector
  77903. */
  77904. translate(): BABYLON.Vector2;
  77905. private _translatePoint;
  77906. /** Release associated resources */
  77907. dispose(): void;
  77908. }
  77909. }
  77910. declare module BABYLON.GUI {
  77911. /**
  77912. * Class used to create multi line control
  77913. */
  77914. export class MultiLine extends Control {
  77915. name?: string | undefined;
  77916. private _lineWidth;
  77917. private _dash;
  77918. private _points;
  77919. private _minX;
  77920. private _minY;
  77921. private _maxX;
  77922. private _maxY;
  77923. /**
  77924. * Creates a new MultiLine
  77925. * @param name defines the control name
  77926. */
  77927. constructor(name?: string | undefined);
  77928. /** Gets or sets dash pattern */
  77929. get dash(): Array<number>;
  77930. set dash(value: Array<number>);
  77931. /**
  77932. * Gets point stored at specified index
  77933. * @param index defines the index to look for
  77934. * @returns the requested point if found
  77935. */
  77936. getAt(index: number): MultiLinePoint;
  77937. /** Function called when a point is updated */
  77938. onPointUpdate: () => void;
  77939. /**
  77940. * Adds new points to the point collection
  77941. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77942. * @returns the list of created MultiLinePoint
  77943. */
  77944. add(...items: (AbstractMesh | Control | {
  77945. x: string | number;
  77946. y: string | number;
  77947. })[]): MultiLinePoint[];
  77948. /**
  77949. * Adds a new point to the point collection
  77950. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77951. * @returns the created MultiLinePoint
  77952. */
  77953. push(item?: (AbstractMesh | Control | {
  77954. x: string | number;
  77955. y: string | number;
  77956. })): MultiLinePoint;
  77957. /**
  77958. * Remove a specific value or point from the active point collection
  77959. * @param value defines the value or point to remove
  77960. */
  77961. remove(value: number | MultiLinePoint): void;
  77962. /**
  77963. * Resets this object to initial state (no point)
  77964. */
  77965. reset(): void;
  77966. /**
  77967. * Resets all links
  77968. */
  77969. resetLinks(): void;
  77970. /** Gets or sets line width */
  77971. get lineWidth(): number;
  77972. set lineWidth(value: number);
  77973. set horizontalAlignment(value: number);
  77974. set verticalAlignment(value: number);
  77975. protected _getTypeName(): string;
  77976. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77977. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77978. _measure(): void;
  77979. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77980. dispose(): void;
  77981. }
  77982. }
  77983. declare module BABYLON.GUI {
  77984. /**
  77985. * Class used to create radio button controls
  77986. */
  77987. export class RadioButton extends Control {
  77988. name?: string | undefined;
  77989. private _isChecked;
  77990. private _background;
  77991. private _checkSizeRatio;
  77992. private _thickness;
  77993. /** Gets or sets border thickness */
  77994. get thickness(): number;
  77995. set thickness(value: number);
  77996. /** Gets or sets group name */
  77997. group: string;
  77998. /** BABYLON.Observable raised when isChecked is changed */
  77999. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78000. /** Gets or sets a value indicating the ratio between overall size and check size */
  78001. get checkSizeRatio(): number;
  78002. set checkSizeRatio(value: number);
  78003. /** Gets or sets background color */
  78004. get background(): string;
  78005. set background(value: string);
  78006. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78007. get isChecked(): boolean;
  78008. set isChecked(value: boolean);
  78009. /**
  78010. * Creates a new RadioButton
  78011. * @param name defines the control name
  78012. */
  78013. constructor(name?: string | undefined);
  78014. protected _getTypeName(): string;
  78015. _draw(context: CanvasRenderingContext2D): void;
  78016. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78017. /**
  78018. * Utility function to easily create a radio button with a header
  78019. * @param title defines the label to use for the header
  78020. * @param group defines the group to use for the radio button
  78021. * @param isChecked defines the initial state of the radio button
  78022. * @param onValueChanged defines the callback to call when value changes
  78023. * @returns a StackPanel containing the radio button and a textBlock
  78024. */
  78025. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  78026. }
  78027. }
  78028. declare module BABYLON.GUI {
  78029. /**
  78030. * Class used to create slider controls
  78031. */
  78032. export class BaseSlider extends Control {
  78033. name?: string | undefined;
  78034. protected _thumbWidth: ValueAndUnit;
  78035. private _minimum;
  78036. private _maximum;
  78037. private _value;
  78038. private _isVertical;
  78039. protected _barOffset: ValueAndUnit;
  78040. private _isThumbClamped;
  78041. protected _displayThumb: boolean;
  78042. private _step;
  78043. private _lastPointerDownID;
  78044. protected _effectiveBarOffset: number;
  78045. protected _renderLeft: number;
  78046. protected _renderTop: number;
  78047. protected _renderWidth: number;
  78048. protected _renderHeight: number;
  78049. protected _backgroundBoxLength: number;
  78050. protected _backgroundBoxThickness: number;
  78051. protected _effectiveThumbThickness: number;
  78052. /** BABYLON.Observable raised when the sldier value changes */
  78053. onValueChangedObservable: BABYLON.Observable<number>;
  78054. /** Gets or sets a boolean indicating if the thumb must be rendered */
  78055. get displayThumb(): boolean;
  78056. set displayThumb(value: boolean);
  78057. /** Gets or sets a step to apply to values (0 by default) */
  78058. get step(): number;
  78059. set step(value: number);
  78060. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  78061. get barOffset(): string | number;
  78062. /** Gets main bar offset in pixels*/
  78063. get barOffsetInPixels(): number;
  78064. set barOffset(value: string | number);
  78065. /** Gets or sets thumb width */
  78066. get thumbWidth(): string | number;
  78067. /** Gets thumb width in pixels */
  78068. get thumbWidthInPixels(): number;
  78069. set thumbWidth(value: string | number);
  78070. /** Gets or sets minimum value */
  78071. get minimum(): number;
  78072. set minimum(value: number);
  78073. /** Gets or sets maximum value */
  78074. get maximum(): number;
  78075. set maximum(value: number);
  78076. /** Gets or sets current value */
  78077. get value(): number;
  78078. set value(value: number);
  78079. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  78080. get isVertical(): boolean;
  78081. set isVertical(value: boolean);
  78082. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  78083. get isThumbClamped(): boolean;
  78084. set isThumbClamped(value: boolean);
  78085. /**
  78086. * Creates a new BaseSlider
  78087. * @param name defines the control name
  78088. */
  78089. constructor(name?: string | undefined);
  78090. protected _getTypeName(): string;
  78091. protected _getThumbPosition(): number;
  78092. protected _getThumbThickness(type: string): number;
  78093. protected _prepareRenderingData(type: string): void;
  78094. private _pointerIsDown;
  78095. /** @hidden */
  78096. protected _updateValueFromPointer(x: number, y: number): void;
  78097. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78098. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78099. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78100. }
  78101. }
  78102. declare module BABYLON.GUI {
  78103. /**
  78104. * Class used to create slider controls
  78105. */
  78106. export class Slider extends BaseSlider {
  78107. name?: string | undefined;
  78108. private _background;
  78109. private _borderColor;
  78110. private _isThumbCircle;
  78111. protected _displayValueBar: boolean;
  78112. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78113. get displayValueBar(): boolean;
  78114. set displayValueBar(value: boolean);
  78115. /** Gets or sets border color */
  78116. get borderColor(): string;
  78117. set borderColor(value: string);
  78118. /** Gets or sets background color */
  78119. get background(): string;
  78120. set background(value: string);
  78121. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78122. get isThumbCircle(): boolean;
  78123. set isThumbCircle(value: boolean);
  78124. /**
  78125. * Creates a new Slider
  78126. * @param name defines the control name
  78127. */
  78128. constructor(name?: string | undefined);
  78129. protected _getTypeName(): string;
  78130. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78131. }
  78132. }
  78133. declare module BABYLON.GUI {
  78134. /** Class used to create a RadioGroup
  78135. * which contains groups of radio buttons
  78136. */
  78137. export class SelectorGroup {
  78138. /** name of SelectorGroup */
  78139. name: string;
  78140. private _groupPanel;
  78141. private _selectors;
  78142. private _groupHeader;
  78143. /**
  78144. * Creates a new SelectorGroup
  78145. * @param name of group, used as a group heading
  78146. */
  78147. constructor(
  78148. /** name of SelectorGroup */
  78149. name: string);
  78150. /** Gets the groupPanel of the SelectorGroup */
  78151. get groupPanel(): StackPanel;
  78152. /** Gets the selectors array */
  78153. get selectors(): StackPanel[];
  78154. /** Gets and sets the group header */
  78155. get header(): string;
  78156. set header(label: string);
  78157. /** @hidden */
  78158. private _addGroupHeader;
  78159. /** @hidden*/
  78160. _getSelector(selectorNb: number): StackPanel | undefined;
  78161. /** Removes the selector at the given position
  78162. * @param selectorNb the position of the selector within the group
  78163. */
  78164. removeSelector(selectorNb: number): void;
  78165. }
  78166. /** Class used to create a CheckboxGroup
  78167. * which contains groups of checkbox buttons
  78168. */
  78169. export class CheckboxGroup extends SelectorGroup {
  78170. /** Adds a checkbox as a control
  78171. * @param text is the label for the selector
  78172. * @param func is the function called when the Selector is checked
  78173. * @param checked is true when Selector is checked
  78174. */
  78175. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  78176. /** @hidden */
  78177. _setSelectorLabel(selectorNb: number, label: string): void;
  78178. /** @hidden */
  78179. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78180. /** @hidden */
  78181. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78182. /** @hidden */
  78183. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78184. }
  78185. /** Class used to create a RadioGroup
  78186. * which contains groups of radio buttons
  78187. */
  78188. export class RadioGroup extends SelectorGroup {
  78189. private _selectNb;
  78190. /** Adds a radio button as a control
  78191. * @param label is the label for the selector
  78192. * @param func is the function called when the Selector is checked
  78193. * @param checked is true when Selector is checked
  78194. */
  78195. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  78196. /** @hidden */
  78197. _setSelectorLabel(selectorNb: number, label: string): void;
  78198. /** @hidden */
  78199. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78200. /** @hidden */
  78201. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78202. /** @hidden */
  78203. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78204. }
  78205. /** Class used to create a SliderGroup
  78206. * which contains groups of slider buttons
  78207. */
  78208. export class SliderGroup extends SelectorGroup {
  78209. /**
  78210. * Adds a slider to the SelectorGroup
  78211. * @param label is the label for the SliderBar
  78212. * @param func is the function called when the Slider moves
  78213. * @param unit is a string describing the units used, eg degrees or metres
  78214. * @param min is the minimum value for the Slider
  78215. * @param max is the maximum value for the Slider
  78216. * @param value is the start value for the Slider between min and max
  78217. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  78218. */
  78219. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  78220. /** @hidden */
  78221. _setSelectorLabel(selectorNb: number, label: string): void;
  78222. /** @hidden */
  78223. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78224. /** @hidden */
  78225. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78226. /** @hidden */
  78227. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78228. }
  78229. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  78230. * @see https://doc.babylonjs.com/how_to/selector
  78231. */
  78232. export class SelectionPanel extends Rectangle {
  78233. /** name of SelectionPanel */
  78234. name: string;
  78235. /** an array of SelectionGroups */
  78236. groups: SelectorGroup[];
  78237. private _panel;
  78238. private _buttonColor;
  78239. private _buttonBackground;
  78240. private _headerColor;
  78241. private _barColor;
  78242. private _barHeight;
  78243. private _spacerHeight;
  78244. private _labelColor;
  78245. private _groups;
  78246. private _bars;
  78247. /**
  78248. * Creates a new SelectionPanel
  78249. * @param name of SelectionPanel
  78250. * @param groups is an array of SelectionGroups
  78251. */
  78252. constructor(
  78253. /** name of SelectionPanel */
  78254. name: string,
  78255. /** an array of SelectionGroups */
  78256. groups?: SelectorGroup[]);
  78257. protected _getTypeName(): string;
  78258. /** Gets or sets the headerColor */
  78259. get headerColor(): string;
  78260. set headerColor(color: string);
  78261. private _setHeaderColor;
  78262. /** Gets or sets the button color */
  78263. get buttonColor(): string;
  78264. set buttonColor(color: string);
  78265. private _setbuttonColor;
  78266. /** Gets or sets the label color */
  78267. get labelColor(): string;
  78268. set labelColor(color: string);
  78269. private _setLabelColor;
  78270. /** Gets or sets the button background */
  78271. get buttonBackground(): string;
  78272. set buttonBackground(color: string);
  78273. private _setButtonBackground;
  78274. /** Gets or sets the color of separator bar */
  78275. get barColor(): string;
  78276. set barColor(color: string);
  78277. private _setBarColor;
  78278. /** Gets or sets the height of separator bar */
  78279. get barHeight(): string;
  78280. set barHeight(value: string);
  78281. private _setBarHeight;
  78282. /** Gets or sets the height of spacers*/
  78283. get spacerHeight(): string;
  78284. set spacerHeight(value: string);
  78285. private _setSpacerHeight;
  78286. /** Adds a bar between groups */
  78287. private _addSpacer;
  78288. /** Add a group to the selection panel
  78289. * @param group is the selector group to add
  78290. */
  78291. addGroup(group: SelectorGroup): void;
  78292. /** Remove the group from the given position
  78293. * @param groupNb is the position of the group in the list
  78294. */
  78295. removeGroup(groupNb: number): void;
  78296. /** Change a group header label
  78297. * @param label is the new group header label
  78298. * @param groupNb is the number of the group to relabel
  78299. * */
  78300. setHeaderName(label: string, groupNb: number): void;
  78301. /** Change selector label to the one given
  78302. * @param label is the new selector label
  78303. * @param groupNb is the number of the groupcontaining the selector
  78304. * @param selectorNb is the number of the selector within a group to relabel
  78305. * */
  78306. relabel(label: string, groupNb: number, selectorNb: number): void;
  78307. /** For a given group position remove the selector at the given position
  78308. * @param groupNb is the number of the group to remove the selector from
  78309. * @param selectorNb is the number of the selector within the group
  78310. */
  78311. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  78312. /** For a given group position of correct type add a checkbox button
  78313. * @param groupNb is the number of the group to remove the selector from
  78314. * @param label is the label for the selector
  78315. * @param func is the function called when the Selector is checked
  78316. * @param checked is true when Selector is checked
  78317. */
  78318. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78319. /** For a given group position of correct type add a radio button
  78320. * @param groupNb is the number of the group to remove the selector from
  78321. * @param label is the label for the selector
  78322. * @param func is the function called when the Selector is checked
  78323. * @param checked is true when Selector is checked
  78324. */
  78325. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78326. /**
  78327. * For a given slider group add a slider
  78328. * @param groupNb is the number of the group to add the slider to
  78329. * @param label is the label for the Slider
  78330. * @param func is the function called when the Slider moves
  78331. * @param unit is a string describing the units used, eg degrees or metres
  78332. * @param min is the minimum value for the Slider
  78333. * @param max is the maximum value for the Slider
  78334. * @param value is the start value for the Slider between min and max
  78335. * @param onVal is the function used to format the value displayed, eg radians to degrees
  78336. */
  78337. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  78338. }
  78339. }
  78340. declare module BABYLON.GUI {
  78341. /**
  78342. * Class used to hold a the container for ScrollViewer
  78343. * @hidden
  78344. */
  78345. export class _ScrollViewerWindow extends Container {
  78346. parentClientWidth: number;
  78347. parentClientHeight: number;
  78348. private _freezeControls;
  78349. private _parentMeasure;
  78350. private _oldLeft;
  78351. private _oldTop;
  78352. get freezeControls(): boolean;
  78353. set freezeControls(value: boolean);
  78354. private _bucketWidth;
  78355. private _bucketHeight;
  78356. private _buckets;
  78357. private _bucketLen;
  78358. get bucketWidth(): number;
  78359. get bucketHeight(): number;
  78360. setBucketSizes(width: number, height: number): void;
  78361. private _useBuckets;
  78362. private _makeBuckets;
  78363. private _dispatchInBuckets;
  78364. private _updateMeasures;
  78365. private _updateChildrenMeasures;
  78366. private _restoreMeasures;
  78367. /**
  78368. * Creates a new ScrollViewerWindow
  78369. * @param name of ScrollViewerWindow
  78370. */
  78371. constructor(name?: string);
  78372. protected _getTypeName(): string;
  78373. /** @hidden */
  78374. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78375. /** @hidden */
  78376. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78377. private _scrollChildren;
  78378. private _scrollChildrenWithBuckets;
  78379. /** @hidden */
  78380. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78381. protected _postMeasure(): void;
  78382. }
  78383. }
  78384. declare module BABYLON.GUI {
  78385. /**
  78386. * Class used to create slider controls
  78387. */
  78388. export class ScrollBar extends BaseSlider {
  78389. name?: string | undefined;
  78390. private _background;
  78391. private _borderColor;
  78392. private _tempMeasure;
  78393. /** Gets or sets border color */
  78394. get borderColor(): string;
  78395. set borderColor(value: string);
  78396. /** Gets or sets background color */
  78397. get background(): string;
  78398. set background(value: string);
  78399. /**
  78400. * Creates a new Slider
  78401. * @param name defines the control name
  78402. */
  78403. constructor(name?: string | undefined);
  78404. protected _getTypeName(): string;
  78405. protected _getThumbThickness(): number;
  78406. _draw(context: CanvasRenderingContext2D): void;
  78407. private _first;
  78408. private _originX;
  78409. private _originY;
  78410. /** @hidden */
  78411. protected _updateValueFromPointer(x: number, y: number): void;
  78412. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78413. }
  78414. }
  78415. declare module BABYLON.GUI {
  78416. /**
  78417. * Class used to create slider controls
  78418. */
  78419. export class ImageScrollBar extends BaseSlider {
  78420. name?: string | undefined;
  78421. private _backgroundBaseImage;
  78422. private _backgroundImage;
  78423. private _thumbImage;
  78424. private _thumbBaseImage;
  78425. private _thumbLength;
  78426. private _thumbHeight;
  78427. private _barImageHeight;
  78428. private _tempMeasure;
  78429. /** Number of 90° rotation to apply on the images when in vertical mode */
  78430. num90RotationInVerticalMode: number;
  78431. /**
  78432. * Gets or sets the image used to render the background for horizontal bar
  78433. */
  78434. get backgroundImage(): Image;
  78435. set backgroundImage(value: Image);
  78436. /**
  78437. * Gets or sets the image used to render the thumb
  78438. */
  78439. get thumbImage(): Image;
  78440. set thumbImage(value: Image);
  78441. /**
  78442. * Gets or sets the length of the thumb
  78443. */
  78444. get thumbLength(): number;
  78445. set thumbLength(value: number);
  78446. /**
  78447. * Gets or sets the height of the thumb
  78448. */
  78449. get thumbHeight(): number;
  78450. set thumbHeight(value: number);
  78451. /**
  78452. * Gets or sets the height of the bar image
  78453. */
  78454. get barImageHeight(): number;
  78455. set barImageHeight(value: number);
  78456. /**
  78457. * Creates a new ImageScrollBar
  78458. * @param name defines the control name
  78459. */
  78460. constructor(name?: string | undefined);
  78461. protected _getTypeName(): string;
  78462. protected _getThumbThickness(): number;
  78463. _draw(context: CanvasRenderingContext2D): void;
  78464. private _first;
  78465. private _originX;
  78466. private _originY;
  78467. /** @hidden */
  78468. protected _updateValueFromPointer(x: number, y: number): void;
  78469. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78470. }
  78471. }
  78472. declare module BABYLON.GUI {
  78473. /**
  78474. * Class used to hold a viewer window and sliders in a grid
  78475. */
  78476. export class ScrollViewer extends Rectangle {
  78477. private _grid;
  78478. private _horizontalBarSpace;
  78479. private _verticalBarSpace;
  78480. private _dragSpace;
  78481. private _horizontalBar;
  78482. private _verticalBar;
  78483. private _barColor;
  78484. private _barBackground;
  78485. private _barImage;
  78486. private _horizontalBarImage;
  78487. private _verticalBarImage;
  78488. private _barBackgroundImage;
  78489. private _horizontalBarBackgroundImage;
  78490. private _verticalBarBackgroundImage;
  78491. private _barSize;
  78492. private _window;
  78493. private _pointerIsOver;
  78494. private _wheelPrecision;
  78495. private _onWheelObserver;
  78496. private _clientWidth;
  78497. private _clientHeight;
  78498. private _useImageBar;
  78499. private _thumbLength;
  78500. private _thumbHeight;
  78501. private _barImageHeight;
  78502. private _horizontalBarImageHeight;
  78503. private _verticalBarImageHeight;
  78504. private _oldWindowContentsWidth;
  78505. private _oldWindowContentsHeight;
  78506. /**
  78507. * Gets the horizontal scrollbar
  78508. */
  78509. get horizontalBar(): ScrollBar | ImageScrollBar;
  78510. /**
  78511. * Gets the vertical scrollbar
  78512. */
  78513. get verticalBar(): ScrollBar | ImageScrollBar;
  78514. /**
  78515. * Adds a new control to the current container
  78516. * @param control defines the control to add
  78517. * @returns the current container
  78518. */
  78519. addControl(control: BABYLON.Nullable<Control>): Container;
  78520. /**
  78521. * Removes a control from the current container
  78522. * @param control defines the control to remove
  78523. * @returns the current container
  78524. */
  78525. removeControl(control: Control): Container;
  78526. /** Gets the list of children */
  78527. get children(): Control[];
  78528. _flagDescendantsAsMatrixDirty(): void;
  78529. /**
  78530. * Freezes or unfreezes the controls in the window.
  78531. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  78532. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  78533. */
  78534. get freezeControls(): boolean;
  78535. set freezeControls(value: boolean);
  78536. /** Gets the bucket width */
  78537. get bucketWidth(): number;
  78538. /** Gets the bucket height */
  78539. get bucketHeight(): number;
  78540. /**
  78541. * Sets the bucket sizes.
  78542. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  78543. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  78544. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  78545. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  78546. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  78547. * used), that's why it is not enabled by default.
  78548. * @param width width of the bucket
  78549. * @param height height of the bucket
  78550. */
  78551. setBucketSizes(width: number, height: number): void;
  78552. private _forceHorizontalBar;
  78553. private _forceVerticalBar;
  78554. /**
  78555. * Forces the horizontal scroll bar to be displayed
  78556. */
  78557. get forceHorizontalBar(): boolean;
  78558. set forceHorizontalBar(value: boolean);
  78559. /**
  78560. * Forces the vertical scroll bar to be displayed
  78561. */
  78562. get forceVerticalBar(): boolean;
  78563. set forceVerticalBar(value: boolean);
  78564. /**
  78565. * Creates a new ScrollViewer
  78566. * @param name of ScrollViewer
  78567. */
  78568. constructor(name?: string, isImageBased?: boolean);
  78569. /** Reset the scroll viewer window to initial size */
  78570. resetWindow(): void;
  78571. protected _getTypeName(): string;
  78572. private _buildClientSizes;
  78573. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78574. protected _postMeasure(): void;
  78575. /**
  78576. * Gets or sets the mouse wheel precision
  78577. * from 0 to 1 with a default value of 0.05
  78578. * */
  78579. get wheelPrecision(): number;
  78580. set wheelPrecision(value: number);
  78581. /** Gets or sets the scroll bar container background color */
  78582. get scrollBackground(): string;
  78583. set scrollBackground(color: string);
  78584. /** Gets or sets the bar color */
  78585. get barColor(): string;
  78586. set barColor(color: string);
  78587. /** Gets or sets the bar image */
  78588. get thumbImage(): Image;
  78589. set thumbImage(value: Image);
  78590. /** Gets or sets the horizontal bar image */
  78591. get horizontalThumbImage(): Image;
  78592. set horizontalThumbImage(value: Image);
  78593. /** Gets or sets the vertical bar image */
  78594. get verticalThumbImage(): Image;
  78595. set verticalThumbImage(value: Image);
  78596. /** Gets or sets the size of the bar */
  78597. get barSize(): number;
  78598. set barSize(value: number);
  78599. /** Gets or sets the length of the thumb */
  78600. get thumbLength(): number;
  78601. set thumbLength(value: number);
  78602. /** Gets or sets the height of the thumb */
  78603. get thumbHeight(): number;
  78604. set thumbHeight(value: number);
  78605. /** Gets or sets the height of the bar image */
  78606. get barImageHeight(): number;
  78607. set barImageHeight(value: number);
  78608. /** Gets or sets the height of the horizontal bar image */
  78609. get horizontalBarImageHeight(): number;
  78610. set horizontalBarImageHeight(value: number);
  78611. /** Gets or sets the height of the vertical bar image */
  78612. get verticalBarImageHeight(): number;
  78613. set verticalBarImageHeight(value: number);
  78614. /** Gets or sets the bar background */
  78615. get barBackground(): string;
  78616. set barBackground(color: string);
  78617. /** Gets or sets the bar background image */
  78618. get barImage(): Image;
  78619. set barImage(value: Image);
  78620. /** Gets or sets the horizontal bar background image */
  78621. get horizontalBarImage(): Image;
  78622. set horizontalBarImage(value: Image);
  78623. /** Gets or sets the vertical bar background image */
  78624. get verticalBarImage(): Image;
  78625. set verticalBarImage(value: Image);
  78626. private _setWindowPosition;
  78627. /** @hidden */
  78628. private _updateScroller;
  78629. _link(host: AdvancedDynamicTexture): void;
  78630. /** @hidden */
  78631. private _addBar;
  78632. /** @hidden */
  78633. private _attachWheel;
  78634. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78635. /** Releases associated resources */
  78636. dispose(): void;
  78637. }
  78638. }
  78639. declare module BABYLON.GUI {
  78640. /** Class used to render a grid */
  78641. export class DisplayGrid extends Control {
  78642. name?: string | undefined;
  78643. private _cellWidth;
  78644. private _cellHeight;
  78645. private _minorLineTickness;
  78646. private _minorLineColor;
  78647. private _majorLineTickness;
  78648. private _majorLineColor;
  78649. private _majorLineFrequency;
  78650. private _background;
  78651. private _displayMajorLines;
  78652. private _displayMinorLines;
  78653. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78654. get displayMinorLines(): boolean;
  78655. set displayMinorLines(value: boolean);
  78656. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78657. get displayMajorLines(): boolean;
  78658. set displayMajorLines(value: boolean);
  78659. /** Gets or sets background color (Black by default) */
  78660. get background(): string;
  78661. set background(value: string);
  78662. /** Gets or sets the width of each cell (20 by default) */
  78663. get cellWidth(): number;
  78664. set cellWidth(value: number);
  78665. /** Gets or sets the height of each cell (20 by default) */
  78666. get cellHeight(): number;
  78667. set cellHeight(value: number);
  78668. /** Gets or sets the tickness of minor lines (1 by default) */
  78669. get minorLineTickness(): number;
  78670. set minorLineTickness(value: number);
  78671. /** Gets or sets the color of minor lines (DarkGray by default) */
  78672. get minorLineColor(): string;
  78673. set minorLineColor(value: string);
  78674. /** Gets or sets the tickness of major lines (2 by default) */
  78675. get majorLineTickness(): number;
  78676. set majorLineTickness(value: number);
  78677. /** Gets or sets the color of major lines (White by default) */
  78678. get majorLineColor(): string;
  78679. set majorLineColor(value: string);
  78680. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78681. get majorLineFrequency(): number;
  78682. set majorLineFrequency(value: number);
  78683. /**
  78684. * Creates a new GridDisplayRectangle
  78685. * @param name defines the control name
  78686. */
  78687. constructor(name?: string | undefined);
  78688. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78689. protected _getTypeName(): string;
  78690. }
  78691. }
  78692. declare module BABYLON.GUI {
  78693. /**
  78694. * Class used to create slider controls based on images
  78695. */
  78696. export class ImageBasedSlider extends BaseSlider {
  78697. name?: string | undefined;
  78698. private _backgroundImage;
  78699. private _thumbImage;
  78700. private _valueBarImage;
  78701. private _tempMeasure;
  78702. get displayThumb(): boolean;
  78703. set displayThumb(value: boolean);
  78704. /**
  78705. * Gets or sets the image used to render the background
  78706. */
  78707. get backgroundImage(): Image;
  78708. set backgroundImage(value: Image);
  78709. /**
  78710. * Gets or sets the image used to render the value bar
  78711. */
  78712. get valueBarImage(): Image;
  78713. set valueBarImage(value: Image);
  78714. /**
  78715. * Gets or sets the image used to render the thumb
  78716. */
  78717. get thumbImage(): Image;
  78718. set thumbImage(value: Image);
  78719. /**
  78720. * Creates a new ImageBasedSlider
  78721. * @param name defines the control name
  78722. */
  78723. constructor(name?: string | undefined);
  78724. protected _getTypeName(): string;
  78725. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78726. }
  78727. }
  78728. declare module BABYLON.GUI {
  78729. /**
  78730. * Forcing an export so that this code will execute
  78731. * @hidden
  78732. */
  78733. const name = "Statics";
  78734. }
  78735. declare module BABYLON.GUI {
  78736. /**
  78737. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78738. */
  78739. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78740. /**
  78741. * Define the instrumented AdvancedDynamicTexture.
  78742. */
  78743. texture: AdvancedDynamicTexture;
  78744. private _captureRenderTime;
  78745. private _renderTime;
  78746. private _captureLayoutTime;
  78747. private _layoutTime;
  78748. private _onBeginRenderObserver;
  78749. private _onEndRenderObserver;
  78750. private _onBeginLayoutObserver;
  78751. private _onEndLayoutObserver;
  78752. /**
  78753. * Gets the perf counter used to capture render time
  78754. */
  78755. get renderTimeCounter(): BABYLON.PerfCounter;
  78756. /**
  78757. * Gets the perf counter used to capture layout time
  78758. */
  78759. get layoutTimeCounter(): BABYLON.PerfCounter;
  78760. /**
  78761. * Enable or disable the render time capture
  78762. */
  78763. get captureRenderTime(): boolean;
  78764. set captureRenderTime(value: boolean);
  78765. /**
  78766. * Enable or disable the layout time capture
  78767. */
  78768. get captureLayoutTime(): boolean;
  78769. set captureLayoutTime(value: boolean);
  78770. /**
  78771. * Instantiates a new advanced dynamic texture instrumentation.
  78772. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78773. * @param texture Defines the AdvancedDynamicTexture to instrument
  78774. */
  78775. constructor(
  78776. /**
  78777. * Define the instrumented AdvancedDynamicTexture.
  78778. */
  78779. texture: AdvancedDynamicTexture);
  78780. /**
  78781. * Dispose and release associated resources.
  78782. */
  78783. dispose(): void;
  78784. }
  78785. }
  78786. declare module BABYLON.GUI {
  78787. /**
  78788. * Class used to load GUI via XML.
  78789. */
  78790. export class XmlLoader {
  78791. private _nodes;
  78792. private _nodeTypes;
  78793. private _isLoaded;
  78794. private _objectAttributes;
  78795. private _parentClass;
  78796. /**
  78797. * Create a new xml loader
  78798. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78799. */
  78800. constructor(parentClass?: null);
  78801. private _getChainElement;
  78802. private _getClassAttribute;
  78803. private _createGuiElement;
  78804. private _parseGrid;
  78805. private _parseElement;
  78806. private _prepareSourceElement;
  78807. private _parseElementsFromSource;
  78808. private _parseXml;
  78809. /**
  78810. * Gets if the loading has finished.
  78811. * @returns whether the loading has finished or not
  78812. */
  78813. isLoaded(): boolean;
  78814. /**
  78815. * Gets a loaded node / control by id.
  78816. * @param id the Controls id set in the xml
  78817. * @returns element of type Control
  78818. */
  78819. getNodeById(id: string): any;
  78820. /**
  78821. * Gets all loaded nodes / controls
  78822. * @returns Array of controls
  78823. */
  78824. getNodes(): any;
  78825. /**
  78826. * Initiates the xml layout loading
  78827. * @param xmlFile defines the xml layout to load
  78828. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78829. * @param callback defines the callback called on layout load.
  78830. */
  78831. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78832. }
  78833. }
  78834. declare module BABYLON.GUI {
  78835. /**
  78836. * Class used to create containers for controls
  78837. */
  78838. export class Container3D extends Control3D {
  78839. private _blockLayout;
  78840. /**
  78841. * Gets the list of child controls
  78842. */
  78843. protected _children: Control3D[];
  78844. /**
  78845. * Gets the list of child controls
  78846. */
  78847. get children(): Array<Control3D>;
  78848. /**
  78849. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78850. * This is helpful to optimize layout operation when adding multiple children in a row
  78851. */
  78852. get blockLayout(): boolean;
  78853. set blockLayout(value: boolean);
  78854. /**
  78855. * Creates a new container
  78856. * @param name defines the container name
  78857. */
  78858. constructor(name?: string);
  78859. /**
  78860. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78861. * @returns the current container
  78862. */
  78863. updateLayout(): Container3D;
  78864. /**
  78865. * Gets a boolean indicating if the given control is in the children of this control
  78866. * @param control defines the control to check
  78867. * @returns true if the control is in the child list
  78868. */
  78869. containsControl(control: Control3D): boolean;
  78870. /**
  78871. * Adds a control to the children of this control
  78872. * @param control defines the control to add
  78873. * @returns the current container
  78874. */
  78875. addControl(control: Control3D): Container3D;
  78876. /**
  78877. * This function will be called everytime a new control is added
  78878. */
  78879. protected _arrangeChildren(): void;
  78880. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78881. /**
  78882. * Removes a control from the children of this control
  78883. * @param control defines the control to remove
  78884. * @returns the current container
  78885. */
  78886. removeControl(control: Control3D): Container3D;
  78887. protected _getTypeName(): string;
  78888. /**
  78889. * Releases all associated resources
  78890. */
  78891. dispose(): void;
  78892. /** Control rotation will remain unchanged */
  78893. static readonly UNSET_ORIENTATION: number;
  78894. /** Control will rotate to make it look at sphere central axis */
  78895. static readonly FACEORIGIN_ORIENTATION: number;
  78896. /** Control will rotate to make it look back at sphere central axis */
  78897. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78898. /** Control will rotate to look at z axis (0, 0, 1) */
  78899. static readonly FACEFORWARD_ORIENTATION: number;
  78900. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78901. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78902. }
  78903. }
  78904. declare module BABYLON.GUI {
  78905. /**
  78906. * Class used to manage 3D user interface
  78907. * @see https://doc.babylonjs.com/how_to/gui3d
  78908. */
  78909. export class GUI3DManager implements BABYLON.IDisposable {
  78910. private _scene;
  78911. private _sceneDisposeObserver;
  78912. private _utilityLayer;
  78913. private _rootContainer;
  78914. private _pointerObserver;
  78915. private _pointerOutObserver;
  78916. /** @hidden */
  78917. _lastPickedControl: Control3D;
  78918. /** @hidden */
  78919. _lastControlOver: {
  78920. [pointerId: number]: Control3D;
  78921. };
  78922. /** @hidden */
  78923. _lastControlDown: {
  78924. [pointerId: number]: Control3D;
  78925. };
  78926. /**
  78927. * BABYLON.Observable raised when the point picked by the pointer events changed
  78928. */
  78929. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78930. /** @hidden */
  78931. _sharedMaterials: {
  78932. [key: string]: BABYLON.Material;
  78933. };
  78934. /** Gets the hosting scene */
  78935. get scene(): BABYLON.Scene;
  78936. /** Gets associated utility layer */
  78937. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78938. /**
  78939. * Creates a new GUI3DManager
  78940. * @param scene
  78941. */
  78942. constructor(scene?: BABYLON.Scene);
  78943. private _handlePointerOut;
  78944. private _doPicking;
  78945. /**
  78946. * Gets the root container
  78947. */
  78948. get rootContainer(): Container3D;
  78949. /**
  78950. * Gets a boolean indicating if the given control is in the root child list
  78951. * @param control defines the control to check
  78952. * @returns true if the control is in the root child list
  78953. */
  78954. containsControl(control: Control3D): boolean;
  78955. /**
  78956. * Adds a control to the root child list
  78957. * @param control defines the control to add
  78958. * @returns the current manager
  78959. */
  78960. addControl(control: Control3D): GUI3DManager;
  78961. /**
  78962. * Removes a control from the root child list
  78963. * @param control defines the control to remove
  78964. * @returns the current container
  78965. */
  78966. removeControl(control: Control3D): GUI3DManager;
  78967. /**
  78968. * Releases all associated resources
  78969. */
  78970. dispose(): void;
  78971. }
  78972. }
  78973. declare module BABYLON.GUI {
  78974. /**
  78975. * Class used to transport BABYLON.Vector3 information for pointer events
  78976. */
  78977. export class Vector3WithInfo extends BABYLON.Vector3 {
  78978. /** defines the current mouse button index */
  78979. buttonIndex: number;
  78980. /**
  78981. * Creates a new Vector3WithInfo
  78982. * @param source defines the vector3 data to transport
  78983. * @param buttonIndex defines the current mouse button index
  78984. */
  78985. constructor(source: BABYLON.Vector3,
  78986. /** defines the current mouse button index */
  78987. buttonIndex?: number);
  78988. }
  78989. }
  78990. declare module BABYLON.GUI {
  78991. /**
  78992. * Class used as base class for controls
  78993. */
  78994. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78995. /** Defines the control name */
  78996. name?: string | undefined;
  78997. /** @hidden */
  78998. _host: GUI3DManager;
  78999. private _node;
  79000. private _downCount;
  79001. private _enterCount;
  79002. private _downPointerIds;
  79003. private _isVisible;
  79004. /** Gets or sets the control position in world space */
  79005. get position(): BABYLON.Vector3;
  79006. set position(value: BABYLON.Vector3);
  79007. /** Gets or sets the control scaling in world space */
  79008. get scaling(): BABYLON.Vector3;
  79009. set scaling(value: BABYLON.Vector3);
  79010. /** Callback used to start pointer enter animation */
  79011. pointerEnterAnimation: () => void;
  79012. /** Callback used to start pointer out animation */
  79013. pointerOutAnimation: () => void;
  79014. /** Callback used to start pointer down animation */
  79015. pointerDownAnimation: () => void;
  79016. /** Callback used to start pointer up animation */
  79017. pointerUpAnimation: () => void;
  79018. /**
  79019. * An event triggered when the pointer move over the control
  79020. */
  79021. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  79022. /**
  79023. * An event triggered when the pointer move out of the control
  79024. */
  79025. onPointerOutObservable: BABYLON.Observable<Control3D>;
  79026. /**
  79027. * An event triggered when the pointer taps the control
  79028. */
  79029. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  79030. /**
  79031. * An event triggered when pointer is up
  79032. */
  79033. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  79034. /**
  79035. * An event triggered when a control is clicked on (with a mouse)
  79036. */
  79037. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  79038. /**
  79039. * An event triggered when pointer enters the control
  79040. */
  79041. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  79042. /**
  79043. * Gets or sets the parent container
  79044. */
  79045. parent: BABYLON.Nullable<Container3D>;
  79046. private _behaviors;
  79047. /**
  79048. * Gets the list of attached behaviors
  79049. * @see https://doc.babylonjs.com/features/behaviour
  79050. */
  79051. get behaviors(): BABYLON.Behavior<Control3D>[];
  79052. /**
  79053. * Attach a behavior to the control
  79054. * @see https://doc.babylonjs.com/features/behaviour
  79055. * @param behavior defines the behavior to attach
  79056. * @returns the current control
  79057. */
  79058. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79059. /**
  79060. * Remove an attached behavior
  79061. * @see https://doc.babylonjs.com/features/behaviour
  79062. * @param behavior defines the behavior to attach
  79063. * @returns the current control
  79064. */
  79065. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79066. /**
  79067. * Gets an attached behavior by name
  79068. * @param name defines the name of the behavior to look for
  79069. * @see https://doc.babylonjs.com/features/behaviour
  79070. * @returns null if behavior was not found else the requested behavior
  79071. */
  79072. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  79073. /** Gets or sets a boolean indicating if the control is visible */
  79074. get isVisible(): boolean;
  79075. set isVisible(value: boolean);
  79076. /**
  79077. * Creates a new control
  79078. * @param name defines the control name
  79079. */
  79080. constructor(
  79081. /** Defines the control name */
  79082. name?: string | undefined);
  79083. /**
  79084. * Gets a string representing the class name
  79085. */
  79086. get typeName(): string;
  79087. /**
  79088. * Get the current class name of the control.
  79089. * @returns current class name
  79090. */
  79091. getClassName(): string;
  79092. protected _getTypeName(): string;
  79093. /**
  79094. * Gets the transform node used by this control
  79095. */
  79096. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  79097. /**
  79098. * Gets the mesh used to render this control
  79099. */
  79100. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79101. /**
  79102. * Link the control as child of the given node
  79103. * @param node defines the node to link to. Use null to unlink the control
  79104. * @returns the current control
  79105. */
  79106. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79107. /** @hidden **/
  79108. _prepareNode(scene: BABYLON.Scene): void;
  79109. /**
  79110. * Node creation.
  79111. * Can be overriden by children
  79112. * @param scene defines the scene where the node must be attached
  79113. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79114. */
  79115. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79116. /**
  79117. * Affect a material to the given mesh
  79118. * @param mesh defines the mesh which will represent the control
  79119. */
  79120. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79121. /** @hidden */
  79122. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79123. /** @hidden */
  79124. _onPointerEnter(target: Control3D): boolean;
  79125. /** @hidden */
  79126. _onPointerOut(target: Control3D): void;
  79127. /** @hidden */
  79128. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79129. /** @hidden */
  79130. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79131. /** @hidden */
  79132. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79133. /** @hidden */
  79134. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79135. /** @hidden */
  79136. _disposeNode(): void;
  79137. /**
  79138. * Releases all associated resources
  79139. */
  79140. dispose(): void;
  79141. }
  79142. }
  79143. declare module BABYLON.GUI {
  79144. /**
  79145. * Class used as a root to all buttons
  79146. */
  79147. export class AbstractButton3D extends Control3D {
  79148. /**
  79149. * Creates a new button
  79150. * @param name defines the control name
  79151. */
  79152. constructor(name?: string);
  79153. protected _getTypeName(): string;
  79154. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79155. }
  79156. }
  79157. declare module BABYLON.GUI {
  79158. /**
  79159. * Class used to create a button in 3D
  79160. */
  79161. export class Button3D extends AbstractButton3D {
  79162. /** @hidden */
  79163. protected _currentMaterial: BABYLON.Material;
  79164. private _facadeTexture;
  79165. private _content;
  79166. private _contentResolution;
  79167. private _contentScaleRatio;
  79168. /**
  79169. * Gets or sets the texture resolution used to render content (512 by default)
  79170. */
  79171. get contentResolution(): BABYLON.int;
  79172. set contentResolution(value: BABYLON.int);
  79173. /**
  79174. * Gets or sets the texture scale ratio used to render content (2 by default)
  79175. */
  79176. get contentScaleRatio(): number;
  79177. set contentScaleRatio(value: number);
  79178. protected _disposeFacadeTexture(): void;
  79179. protected _resetContent(): void;
  79180. /**
  79181. * Creates a new button
  79182. * @param name defines the control name
  79183. */
  79184. constructor(name?: string);
  79185. /**
  79186. * Gets or sets the GUI 2D content used to display the button's facade
  79187. */
  79188. get content(): Control;
  79189. set content(value: Control);
  79190. /**
  79191. * Apply the facade texture (created from the content property).
  79192. * This function can be overloaded by child classes
  79193. * @param facadeTexture defines the AdvancedDynamicTexture to use
  79194. */
  79195. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79196. protected _getTypeName(): string;
  79197. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79198. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79199. /**
  79200. * Releases all associated resources
  79201. */
  79202. dispose(): void;
  79203. }
  79204. }
  79205. declare module BABYLON.GUI {
  79206. /**
  79207. * Abstract class used to create a container panel deployed on the surface of a volume
  79208. */
  79209. export abstract class VolumeBasedPanel extends Container3D {
  79210. private _columns;
  79211. private _rows;
  79212. private _rowThenColum;
  79213. private _orientation;
  79214. protected _cellWidth: number;
  79215. protected _cellHeight: number;
  79216. /**
  79217. * Gets or sets the distance between elements
  79218. */
  79219. margin: number;
  79220. /**
  79221. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  79222. * | Value | Type | Description |
  79223. * | ----- | ----------------------------------- | ----------- |
  79224. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  79225. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  79226. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  79227. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  79228. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  79229. */
  79230. get orientation(): number;
  79231. set orientation(value: number);
  79232. /**
  79233. * Gets or sets the number of columns requested (10 by default).
  79234. * The panel will automatically compute the number of rows based on number of child controls.
  79235. */
  79236. get columns(): BABYLON.int;
  79237. set columns(value: BABYLON.int);
  79238. /**
  79239. * Gets or sets a the number of rows requested.
  79240. * The panel will automatically compute the number of columns based on number of child controls.
  79241. */
  79242. get rows(): BABYLON.int;
  79243. set rows(value: BABYLON.int);
  79244. /**
  79245. * Creates new VolumeBasedPanel
  79246. */
  79247. constructor();
  79248. protected _arrangeChildren(): void;
  79249. /** Child classes must implement this function to provide correct control positioning */
  79250. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79251. /** Child classes can implement this function to provide additional processing */
  79252. protected _finalProcessing(): void;
  79253. }
  79254. }
  79255. declare module BABYLON.GUI {
  79256. /**
  79257. * Class used to create a container panel deployed on the surface of a cylinder
  79258. */
  79259. export class CylinderPanel extends VolumeBasedPanel {
  79260. private _radius;
  79261. /**
  79262. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  79263. */
  79264. get radius(): BABYLON.float;
  79265. set radius(value: BABYLON.float);
  79266. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79267. private _cylindricalMapping;
  79268. }
  79269. }
  79270. declare module BABYLON.GUI {
  79271. /** @hidden */
  79272. export var fluentVertexShader: {
  79273. name: string;
  79274. shader: string;
  79275. };
  79276. }
  79277. declare module BABYLON.GUI {
  79278. /** @hidden */
  79279. export var fluentPixelShader: {
  79280. name: string;
  79281. shader: string;
  79282. };
  79283. }
  79284. declare module BABYLON.GUI {
  79285. /** @hidden */
  79286. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  79287. INNERGLOW: boolean;
  79288. BORDER: boolean;
  79289. HOVERLIGHT: boolean;
  79290. TEXTURE: boolean;
  79291. constructor();
  79292. }
  79293. /**
  79294. * Class used to render controls with fluent desgin
  79295. */
  79296. export class FluentMaterial extends BABYLON.PushMaterial {
  79297. /**
  79298. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  79299. */
  79300. innerGlowColorIntensity: number;
  79301. /**
  79302. * Gets or sets the inner glow color (white by default)
  79303. */
  79304. innerGlowColor: BABYLON.Color3;
  79305. /**
  79306. * Gets or sets alpha value (default is 1.0)
  79307. */
  79308. alpha: number;
  79309. /**
  79310. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  79311. */
  79312. albedoColor: BABYLON.Color3;
  79313. /**
  79314. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  79315. */
  79316. renderBorders: boolean;
  79317. /**
  79318. * Gets or sets border width (default is 0.5)
  79319. */
  79320. borderWidth: number;
  79321. /**
  79322. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  79323. */
  79324. edgeSmoothingValue: number;
  79325. /**
  79326. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  79327. */
  79328. borderMinValue: number;
  79329. /**
  79330. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  79331. */
  79332. renderHoverLight: boolean;
  79333. /**
  79334. * Gets or sets the radius used to render the hover light (default is 1.0)
  79335. */
  79336. hoverRadius: number;
  79337. /**
  79338. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  79339. */
  79340. hoverColor: BABYLON.Color4;
  79341. /**
  79342. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  79343. */
  79344. hoverPosition: BABYLON.Vector3;
  79345. private _albedoTexture;
  79346. /** Gets or sets the texture to use for albedo color */
  79347. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79348. /**
  79349. * Creates a new Fluent material
  79350. * @param name defines the name of the material
  79351. * @param scene defines the hosting scene
  79352. */
  79353. constructor(name: string, scene: BABYLON.Scene);
  79354. needAlphaBlending(): boolean;
  79355. needAlphaTesting(): boolean;
  79356. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79357. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79358. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79359. getActiveTextures(): BABYLON.BaseTexture[];
  79360. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79361. dispose(forceDisposeEffect?: boolean): void;
  79362. clone(name: string): FluentMaterial;
  79363. serialize(): any;
  79364. getClassName(): string;
  79365. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79366. }
  79367. }
  79368. declare module BABYLON.GUI {
  79369. /**
  79370. * Class used to create a holographic button in 3D
  79371. */
  79372. export class HolographicButton extends Button3D {
  79373. private _backPlate;
  79374. private _textPlate;
  79375. private _frontPlate;
  79376. private _text;
  79377. private _imageUrl;
  79378. private _shareMaterials;
  79379. private _frontMaterial;
  79380. private _backMaterial;
  79381. private _plateMaterial;
  79382. private _pickedPointObserver;
  79383. private _tooltipFade;
  79384. private _tooltipTextBlock;
  79385. private _tooltipTexture;
  79386. private _tooltipMesh;
  79387. private _tooltipHoverObserver;
  79388. private _tooltipOutObserver;
  79389. private _disposeTooltip;
  79390. /**
  79391. * Rendering ground id of all the mesh in the button
  79392. */
  79393. set renderingGroupId(id: number);
  79394. get renderingGroupId(): number;
  79395. /**
  79396. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79397. */
  79398. set tooltipText(text: BABYLON.Nullable<string>);
  79399. get tooltipText(): BABYLON.Nullable<string>;
  79400. /**
  79401. * Gets or sets text for the button
  79402. */
  79403. get text(): string;
  79404. set text(value: string);
  79405. /**
  79406. * Gets or sets the image url for the button
  79407. */
  79408. get imageUrl(): string;
  79409. set imageUrl(value: string);
  79410. /**
  79411. * Gets the back material used by this button
  79412. */
  79413. get backMaterial(): FluentMaterial;
  79414. /**
  79415. * Gets the front material used by this button
  79416. */
  79417. get frontMaterial(): FluentMaterial;
  79418. /**
  79419. * Gets the plate material used by this button
  79420. */
  79421. get plateMaterial(): BABYLON.StandardMaterial;
  79422. /**
  79423. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79424. */
  79425. get shareMaterials(): boolean;
  79426. /**
  79427. * Creates a new button
  79428. * @param name defines the control name
  79429. */
  79430. constructor(name?: string, shareMaterials?: boolean);
  79431. protected _getTypeName(): string;
  79432. private _rebuildContent;
  79433. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79434. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79435. private _createBackMaterial;
  79436. private _createFrontMaterial;
  79437. private _createPlateMaterial;
  79438. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  79439. /**
  79440. * Releases all associated resources
  79441. */
  79442. dispose(): void;
  79443. }
  79444. }
  79445. declare module BABYLON.GUI {
  79446. /**
  79447. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  79448. */
  79449. export class MeshButton3D extends Button3D {
  79450. /** @hidden */
  79451. protected _currentMesh: BABYLON.Mesh;
  79452. /**
  79453. * Creates a new 3D button based on a mesh
  79454. * @param mesh mesh to become a 3D button
  79455. * @param name defines the control name
  79456. */
  79457. constructor(mesh: BABYLON.Mesh, name?: string);
  79458. protected _getTypeName(): string;
  79459. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79460. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79461. }
  79462. }
  79463. declare module BABYLON.GUI {
  79464. /**
  79465. * Class used to create a container panel deployed on the surface of a plane
  79466. */
  79467. export class PlanePanel extends VolumeBasedPanel {
  79468. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79469. }
  79470. }
  79471. declare module BABYLON.GUI {
  79472. /**
  79473. * Class used to create a container panel where items get randomized planar mapping
  79474. */
  79475. export class ScatterPanel extends VolumeBasedPanel {
  79476. private _iteration;
  79477. /**
  79478. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  79479. */
  79480. get iteration(): BABYLON.float;
  79481. set iteration(value: BABYLON.float);
  79482. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79483. private _scatterMapping;
  79484. protected _finalProcessing(): void;
  79485. }
  79486. }
  79487. declare module BABYLON.GUI {
  79488. /**
  79489. * Class used to create a container panel deployed on the surface of a sphere
  79490. */
  79491. export class SpherePanel extends VolumeBasedPanel {
  79492. private _radius;
  79493. /**
  79494. * Gets or sets the radius of the sphere where to project controls (5 by default)
  79495. */
  79496. get radius(): BABYLON.float;
  79497. set radius(value: BABYLON.float);
  79498. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79499. private _sphericalMapping;
  79500. }
  79501. }
  79502. declare module BABYLON.GUI {
  79503. /**
  79504. * Class used to create a stack panel in 3D on XY plane
  79505. */
  79506. export class StackPanel3D extends Container3D {
  79507. private _isVertical;
  79508. /**
  79509. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  79510. */
  79511. get isVertical(): boolean;
  79512. set isVertical(value: boolean);
  79513. /**
  79514. * Gets or sets the distance between elements
  79515. */
  79516. margin: number;
  79517. /**
  79518. * Creates new StackPanel
  79519. * @param isVertical
  79520. */
  79521. constructor(isVertical?: boolean);
  79522. protected _arrangeChildren(): void;
  79523. }
  79524. }
  79525. declare module BABYLON {
  79526. /**
  79527. * Configuration for glTF validation
  79528. */
  79529. export interface IGLTFValidationConfiguration {
  79530. /**
  79531. * The url of the glTF validator.
  79532. */
  79533. url: string;
  79534. }
  79535. /**
  79536. * glTF validation
  79537. */
  79538. export class GLTFValidation {
  79539. /**
  79540. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  79541. */
  79542. static Configuration: IGLTFValidationConfiguration;
  79543. private static _LoadScriptPromise;
  79544. /**
  79545. * Validate a glTF asset using the glTF-Validator.
  79546. * @param data The JSON of a glTF or the array buffer of a binary glTF
  79547. * @param rootUrl The root url for the glTF
  79548. * @param fileName The file name for the glTF
  79549. * @param getExternalResource The callback to get external resources for the glTF validator
  79550. * @returns A promise that resolves with the glTF validation results once complete
  79551. */
  79552. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  79553. }
  79554. }
  79555. declare module BABYLON {
  79556. /**
  79557. * Mode that determines the coordinate system to use.
  79558. */
  79559. export enum GLTFLoaderCoordinateSystemMode {
  79560. /**
  79561. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  79562. */
  79563. AUTO = 0,
  79564. /**
  79565. * Sets the useRightHandedSystem flag on the scene.
  79566. */
  79567. FORCE_RIGHT_HANDED = 1
  79568. }
  79569. /**
  79570. * Mode that determines what animations will start.
  79571. */
  79572. export enum GLTFLoaderAnimationStartMode {
  79573. /**
  79574. * No animation will start.
  79575. */
  79576. NONE = 0,
  79577. /**
  79578. * The first animation will start.
  79579. */
  79580. FIRST = 1,
  79581. /**
  79582. * All animations will start.
  79583. */
  79584. ALL = 2
  79585. }
  79586. /**
  79587. * Interface that contains the data for the glTF asset.
  79588. */
  79589. export interface IGLTFLoaderData {
  79590. /**
  79591. * The object that represents the glTF JSON.
  79592. */
  79593. json: Object;
  79594. /**
  79595. * The BIN chunk of a binary glTF.
  79596. */
  79597. bin: Nullable<IDataBuffer>;
  79598. }
  79599. /**
  79600. * Interface for extending the loader.
  79601. */
  79602. export interface IGLTFLoaderExtension {
  79603. /**
  79604. * The name of this extension.
  79605. */
  79606. readonly name: string;
  79607. /**
  79608. * Defines whether this extension is enabled.
  79609. */
  79610. enabled: boolean;
  79611. /**
  79612. * Defines the order of this extension.
  79613. * The loader sorts the extensions using these values when loading.
  79614. */
  79615. order?: number;
  79616. }
  79617. /**
  79618. * Loader state.
  79619. */
  79620. export enum GLTFLoaderState {
  79621. /**
  79622. * The asset is loading.
  79623. */
  79624. LOADING = 0,
  79625. /**
  79626. * The asset is ready for rendering.
  79627. */
  79628. READY = 1,
  79629. /**
  79630. * The asset is completely loaded.
  79631. */
  79632. COMPLETE = 2
  79633. }
  79634. /** @hidden */
  79635. export interface IImportMeshAsyncOutput {
  79636. meshes: AbstractMesh[];
  79637. particleSystems: IParticleSystem[];
  79638. skeletons: Skeleton[];
  79639. animationGroups: AnimationGroup[];
  79640. lights: Light[];
  79641. transformNodes: TransformNode[];
  79642. }
  79643. /** @hidden */
  79644. export interface IGLTFLoader extends IDisposable {
  79645. readonly state: Nullable<GLTFLoaderState>;
  79646. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  79647. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79648. }
  79649. /**
  79650. * File loader for loading glTF files into a scene.
  79651. */
  79652. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79653. /** @hidden */
  79654. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79655. /** @hidden */
  79656. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79657. /**
  79658. * Raised when the asset has been parsed
  79659. */
  79660. onParsedObservable: Observable<IGLTFLoaderData>;
  79661. private _onParsedObserver;
  79662. /**
  79663. * Raised when the asset has been parsed
  79664. */
  79665. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79666. /**
  79667. * 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.
  79668. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79669. * Defaults to true.
  79670. * @hidden
  79671. */
  79672. static IncrementalLoading: boolean;
  79673. /**
  79674. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79675. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79676. * @hidden
  79677. */
  79678. static HomogeneousCoordinates: boolean;
  79679. /**
  79680. * The coordinate system mode. Defaults to AUTO.
  79681. */
  79682. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79683. /**
  79684. * The animation start mode. Defaults to FIRST.
  79685. */
  79686. animationStartMode: GLTFLoaderAnimationStartMode;
  79687. /**
  79688. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79689. */
  79690. compileMaterials: boolean;
  79691. /**
  79692. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79693. */
  79694. useClipPlane: boolean;
  79695. /**
  79696. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79697. */
  79698. compileShadowGenerators: boolean;
  79699. /**
  79700. * Defines if the Alpha blended materials are only applied as coverage.
  79701. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79702. * If true, no extra effects are applied to transparent pixels.
  79703. */
  79704. transparencyAsCoverage: boolean;
  79705. /**
  79706. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79707. * Enabling will disable offline support and glTF validator.
  79708. * Defaults to false.
  79709. */
  79710. useRangeRequests: boolean;
  79711. /**
  79712. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79713. */
  79714. createInstances: boolean;
  79715. /**
  79716. * 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.
  79717. */
  79718. alwaysComputeBoundingBox: boolean;
  79719. /**
  79720. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  79721. */
  79722. loadAllMaterials: boolean;
  79723. /**
  79724. * Function called before loading a url referenced by the asset.
  79725. */
  79726. preprocessUrlAsync: (url: string) => Promise<string>;
  79727. /**
  79728. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79729. */
  79730. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79731. private _onMeshLoadedObserver;
  79732. /**
  79733. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79734. */
  79735. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79736. /**
  79737. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79738. */
  79739. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79740. private _onTextureLoadedObserver;
  79741. /**
  79742. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79743. */
  79744. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79745. /**
  79746. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79747. */
  79748. readonly onMaterialLoadedObservable: Observable<Material>;
  79749. private _onMaterialLoadedObserver;
  79750. /**
  79751. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79752. */
  79753. set onMaterialLoaded(callback: (material: Material) => void);
  79754. /**
  79755. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79756. */
  79757. readonly onCameraLoadedObservable: Observable<Camera>;
  79758. private _onCameraLoadedObserver;
  79759. /**
  79760. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79761. */
  79762. set onCameraLoaded(callback: (camera: Camera) => void);
  79763. /**
  79764. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79765. * For assets with LODs, raised when all of the LODs are complete.
  79766. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79767. */
  79768. readonly onCompleteObservable: Observable<void>;
  79769. private _onCompleteObserver;
  79770. /**
  79771. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79772. * For assets with LODs, raised when all of the LODs are complete.
  79773. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79774. */
  79775. set onComplete(callback: () => void);
  79776. /**
  79777. * Observable raised when an error occurs.
  79778. */
  79779. readonly onErrorObservable: Observable<any>;
  79780. private _onErrorObserver;
  79781. /**
  79782. * Callback raised when an error occurs.
  79783. */
  79784. set onError(callback: (reason: any) => void);
  79785. /**
  79786. * Observable raised after the loader is disposed.
  79787. */
  79788. readonly onDisposeObservable: Observable<void>;
  79789. private _onDisposeObserver;
  79790. /**
  79791. * Callback raised after the loader is disposed.
  79792. */
  79793. set onDispose(callback: () => void);
  79794. /**
  79795. * Observable raised after a loader extension is created.
  79796. * Set additional options for a loader extension in this event.
  79797. */
  79798. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79799. private _onExtensionLoadedObserver;
  79800. /**
  79801. * Callback raised after a loader extension is created.
  79802. */
  79803. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79804. /**
  79805. * Defines if the loader logging is enabled.
  79806. */
  79807. get loggingEnabled(): boolean;
  79808. set loggingEnabled(value: boolean);
  79809. /**
  79810. * Defines if the loader should capture performance counters.
  79811. */
  79812. get capturePerformanceCounters(): boolean;
  79813. set capturePerformanceCounters(value: boolean);
  79814. /**
  79815. * Defines if the loader should validate the asset.
  79816. */
  79817. validate: boolean;
  79818. /**
  79819. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79820. */
  79821. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79822. private _onValidatedObserver;
  79823. /**
  79824. * Callback raised after a loader extension is created.
  79825. */
  79826. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79827. private _loader;
  79828. private _progressCallback?;
  79829. private _requests;
  79830. private static magicBase64Encoded;
  79831. /**
  79832. * Name of the loader ("gltf")
  79833. */
  79834. name: string;
  79835. /** @hidden */
  79836. extensions: ISceneLoaderPluginExtensions;
  79837. /**
  79838. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79839. */
  79840. dispose(): void;
  79841. /** @hidden */
  79842. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79843. /** @hidden */
  79844. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79845. /** @hidden */
  79846. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79847. meshes: AbstractMesh[];
  79848. particleSystems: IParticleSystem[];
  79849. skeletons: Skeleton[];
  79850. animationGroups: AnimationGroup[];
  79851. }>;
  79852. /** @hidden */
  79853. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79854. /** @hidden */
  79855. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79856. /** @hidden */
  79857. canDirectLoad(data: string): boolean;
  79858. /** @hidden */
  79859. directLoad(scene: Scene, data: string): Promise<any>;
  79860. /**
  79861. * The callback that allows custom handling of the root url based on the response url.
  79862. * @param rootUrl the original root url
  79863. * @param responseURL the response url if available
  79864. * @returns the new root url
  79865. */
  79866. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79867. /** @hidden */
  79868. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79869. /**
  79870. * The loader state or null if the loader is not active.
  79871. */
  79872. get loaderState(): Nullable<GLTFLoaderState>;
  79873. /**
  79874. * Returns a promise that resolves when the asset is completely loaded.
  79875. * @returns a promise that resolves when the asset is completely loaded.
  79876. */
  79877. whenCompleteAsync(): Promise<void>;
  79878. /** @hidden */
  79879. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79880. /** @hidden */
  79881. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79882. private _onProgress;
  79883. private _validate;
  79884. private _getLoader;
  79885. private _parseJson;
  79886. private _unpackBinaryAsync;
  79887. private _unpackBinaryV1Async;
  79888. private _unpackBinaryV2Async;
  79889. private static _parseVersion;
  79890. private static _compareVersion;
  79891. private static readonly _logSpaces;
  79892. private _logIndentLevel;
  79893. private _loggingEnabled;
  79894. /** @hidden */
  79895. _log: (message: string) => void;
  79896. /** @hidden */
  79897. _logOpen(message: string): void;
  79898. /** @hidden */
  79899. _logClose(): void;
  79900. private _logEnabled;
  79901. private _logDisabled;
  79902. private _capturePerformanceCounters;
  79903. /** @hidden */
  79904. _startPerformanceCounter: (counterName: string) => void;
  79905. /** @hidden */
  79906. _endPerformanceCounter: (counterName: string) => void;
  79907. private _startPerformanceCounterEnabled;
  79908. private _startPerformanceCounterDisabled;
  79909. private _endPerformanceCounterEnabled;
  79910. private _endPerformanceCounterDisabled;
  79911. }
  79912. }
  79913. declare module BABYLON.GLTF1 {
  79914. /**
  79915. * Enums
  79916. * @hidden
  79917. */
  79918. export enum EComponentType {
  79919. BYTE = 5120,
  79920. UNSIGNED_BYTE = 5121,
  79921. SHORT = 5122,
  79922. UNSIGNED_SHORT = 5123,
  79923. FLOAT = 5126
  79924. }
  79925. /** @hidden */
  79926. export enum EShaderType {
  79927. FRAGMENT = 35632,
  79928. VERTEX = 35633
  79929. }
  79930. /** @hidden */
  79931. export enum EParameterType {
  79932. BYTE = 5120,
  79933. UNSIGNED_BYTE = 5121,
  79934. SHORT = 5122,
  79935. UNSIGNED_SHORT = 5123,
  79936. INT = 5124,
  79937. UNSIGNED_INT = 5125,
  79938. FLOAT = 5126,
  79939. FLOAT_VEC2 = 35664,
  79940. FLOAT_VEC3 = 35665,
  79941. FLOAT_VEC4 = 35666,
  79942. INT_VEC2 = 35667,
  79943. INT_VEC3 = 35668,
  79944. INT_VEC4 = 35669,
  79945. BOOL = 35670,
  79946. BOOL_VEC2 = 35671,
  79947. BOOL_VEC3 = 35672,
  79948. BOOL_VEC4 = 35673,
  79949. FLOAT_MAT2 = 35674,
  79950. FLOAT_MAT3 = 35675,
  79951. FLOAT_MAT4 = 35676,
  79952. SAMPLER_2D = 35678
  79953. }
  79954. /** @hidden */
  79955. export enum ETextureWrapMode {
  79956. CLAMP_TO_EDGE = 33071,
  79957. MIRRORED_REPEAT = 33648,
  79958. REPEAT = 10497
  79959. }
  79960. /** @hidden */
  79961. export enum ETextureFilterType {
  79962. NEAREST = 9728,
  79963. LINEAR = 9728,
  79964. NEAREST_MIPMAP_NEAREST = 9984,
  79965. LINEAR_MIPMAP_NEAREST = 9985,
  79966. NEAREST_MIPMAP_LINEAR = 9986,
  79967. LINEAR_MIPMAP_LINEAR = 9987
  79968. }
  79969. /** @hidden */
  79970. export enum ETextureFormat {
  79971. ALPHA = 6406,
  79972. RGB = 6407,
  79973. RGBA = 6408,
  79974. LUMINANCE = 6409,
  79975. LUMINANCE_ALPHA = 6410
  79976. }
  79977. /** @hidden */
  79978. export enum ECullingType {
  79979. FRONT = 1028,
  79980. BACK = 1029,
  79981. FRONT_AND_BACK = 1032
  79982. }
  79983. /** @hidden */
  79984. export enum EBlendingFunction {
  79985. ZERO = 0,
  79986. ONE = 1,
  79987. SRC_COLOR = 768,
  79988. ONE_MINUS_SRC_COLOR = 769,
  79989. DST_COLOR = 774,
  79990. ONE_MINUS_DST_COLOR = 775,
  79991. SRC_ALPHA = 770,
  79992. ONE_MINUS_SRC_ALPHA = 771,
  79993. DST_ALPHA = 772,
  79994. ONE_MINUS_DST_ALPHA = 773,
  79995. CONSTANT_COLOR = 32769,
  79996. ONE_MINUS_CONSTANT_COLOR = 32770,
  79997. CONSTANT_ALPHA = 32771,
  79998. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79999. SRC_ALPHA_SATURATE = 776
  80000. }
  80001. /** @hidden */
  80002. export interface IGLTFProperty {
  80003. extensions?: {
  80004. [key: string]: any;
  80005. };
  80006. extras?: Object;
  80007. }
  80008. /** @hidden */
  80009. export interface IGLTFChildRootProperty extends IGLTFProperty {
  80010. name?: string;
  80011. }
  80012. /** @hidden */
  80013. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  80014. bufferView: string;
  80015. byteOffset: number;
  80016. byteStride: number;
  80017. count: number;
  80018. type: string;
  80019. componentType: EComponentType;
  80020. max?: number[];
  80021. min?: number[];
  80022. name?: string;
  80023. }
  80024. /** @hidden */
  80025. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  80026. buffer: string;
  80027. byteOffset: number;
  80028. byteLength: number;
  80029. byteStride: number;
  80030. target?: number;
  80031. }
  80032. /** @hidden */
  80033. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  80034. uri: string;
  80035. byteLength?: number;
  80036. type?: string;
  80037. }
  80038. /** @hidden */
  80039. export interface IGLTFShader extends IGLTFChildRootProperty {
  80040. uri: string;
  80041. type: EShaderType;
  80042. }
  80043. /** @hidden */
  80044. export interface IGLTFProgram extends IGLTFChildRootProperty {
  80045. attributes: string[];
  80046. fragmentShader: string;
  80047. vertexShader: string;
  80048. }
  80049. /** @hidden */
  80050. export interface IGLTFTechniqueParameter {
  80051. type: number;
  80052. count?: number;
  80053. semantic?: string;
  80054. node?: string;
  80055. value?: number | boolean | string | Array<any>;
  80056. source?: string;
  80057. babylonValue?: any;
  80058. }
  80059. /** @hidden */
  80060. export interface IGLTFTechniqueCommonProfile {
  80061. lightingModel: string;
  80062. texcoordBindings: Object;
  80063. parameters?: Array<any>;
  80064. }
  80065. /** @hidden */
  80066. export interface IGLTFTechniqueStatesFunctions {
  80067. blendColor?: number[];
  80068. blendEquationSeparate?: number[];
  80069. blendFuncSeparate?: number[];
  80070. colorMask: boolean[];
  80071. cullFace: number[];
  80072. }
  80073. /** @hidden */
  80074. export interface IGLTFTechniqueStates {
  80075. enable: number[];
  80076. functions: IGLTFTechniqueStatesFunctions;
  80077. }
  80078. /** @hidden */
  80079. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  80080. parameters: {
  80081. [key: string]: IGLTFTechniqueParameter;
  80082. };
  80083. program: string;
  80084. attributes: {
  80085. [key: string]: string;
  80086. };
  80087. uniforms: {
  80088. [key: string]: string;
  80089. };
  80090. states: IGLTFTechniqueStates;
  80091. }
  80092. /** @hidden */
  80093. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  80094. technique?: string;
  80095. values: string[];
  80096. }
  80097. /** @hidden */
  80098. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  80099. attributes: {
  80100. [key: string]: string;
  80101. };
  80102. indices: string;
  80103. material: string;
  80104. mode?: number;
  80105. }
  80106. /** @hidden */
  80107. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80108. primitives: IGLTFMeshPrimitive[];
  80109. }
  80110. /** @hidden */
  80111. export interface IGLTFImage extends IGLTFChildRootProperty {
  80112. uri: string;
  80113. }
  80114. /** @hidden */
  80115. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80116. magFilter?: number;
  80117. minFilter?: number;
  80118. wrapS?: number;
  80119. wrapT?: number;
  80120. }
  80121. /** @hidden */
  80122. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80123. sampler: string;
  80124. source: string;
  80125. format?: ETextureFormat;
  80126. internalFormat?: ETextureFormat;
  80127. target?: number;
  80128. type?: number;
  80129. babylonTexture?: Texture;
  80130. }
  80131. /** @hidden */
  80132. export interface IGLTFAmbienLight {
  80133. color?: number[];
  80134. }
  80135. /** @hidden */
  80136. export interface IGLTFDirectionalLight {
  80137. color?: number[];
  80138. }
  80139. /** @hidden */
  80140. export interface IGLTFPointLight {
  80141. color?: number[];
  80142. constantAttenuation?: number;
  80143. linearAttenuation?: number;
  80144. quadraticAttenuation?: number;
  80145. }
  80146. /** @hidden */
  80147. export interface IGLTFSpotLight {
  80148. color?: number[];
  80149. constantAttenuation?: number;
  80150. fallOfAngle?: number;
  80151. fallOffExponent?: number;
  80152. linearAttenuation?: number;
  80153. quadraticAttenuation?: number;
  80154. }
  80155. /** @hidden */
  80156. export interface IGLTFLight extends IGLTFChildRootProperty {
  80157. type: string;
  80158. }
  80159. /** @hidden */
  80160. export interface IGLTFCameraOrthographic {
  80161. xmag: number;
  80162. ymag: number;
  80163. zfar: number;
  80164. znear: number;
  80165. }
  80166. /** @hidden */
  80167. export interface IGLTFCameraPerspective {
  80168. aspectRatio: number;
  80169. yfov: number;
  80170. zfar: number;
  80171. znear: number;
  80172. }
  80173. /** @hidden */
  80174. export interface IGLTFCamera extends IGLTFChildRootProperty {
  80175. type: string;
  80176. }
  80177. /** @hidden */
  80178. export interface IGLTFAnimationChannelTarget {
  80179. id: string;
  80180. path: string;
  80181. }
  80182. /** @hidden */
  80183. export interface IGLTFAnimationChannel {
  80184. sampler: string;
  80185. target: IGLTFAnimationChannelTarget;
  80186. }
  80187. /** @hidden */
  80188. export interface IGLTFAnimationSampler {
  80189. input: string;
  80190. output: string;
  80191. interpolation?: string;
  80192. }
  80193. /** @hidden */
  80194. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  80195. channels?: IGLTFAnimationChannel[];
  80196. parameters?: {
  80197. [key: string]: string;
  80198. };
  80199. samplers?: {
  80200. [key: string]: IGLTFAnimationSampler;
  80201. };
  80202. }
  80203. /** @hidden */
  80204. export interface IGLTFNodeInstanceSkin {
  80205. skeletons: string[];
  80206. skin: string;
  80207. meshes: string[];
  80208. }
  80209. /** @hidden */
  80210. export interface IGLTFSkins extends IGLTFChildRootProperty {
  80211. bindShapeMatrix: number[];
  80212. inverseBindMatrices: string;
  80213. jointNames: string[];
  80214. babylonSkeleton?: Skeleton;
  80215. }
  80216. /** @hidden */
  80217. export interface IGLTFNode extends IGLTFChildRootProperty {
  80218. camera?: string;
  80219. children: string[];
  80220. skin?: string;
  80221. jointName?: string;
  80222. light?: string;
  80223. matrix: number[];
  80224. mesh?: string;
  80225. meshes?: string[];
  80226. rotation?: number[];
  80227. scale?: number[];
  80228. translation?: number[];
  80229. babylonNode?: Node;
  80230. }
  80231. /** @hidden */
  80232. export interface IGLTFScene extends IGLTFChildRootProperty {
  80233. nodes: string[];
  80234. }
  80235. /** @hidden */
  80236. export interface IGLTFRuntime {
  80237. extensions: {
  80238. [key: string]: any;
  80239. };
  80240. accessors: {
  80241. [key: string]: IGLTFAccessor;
  80242. };
  80243. buffers: {
  80244. [key: string]: IGLTFBuffer;
  80245. };
  80246. bufferViews: {
  80247. [key: string]: IGLTFBufferView;
  80248. };
  80249. meshes: {
  80250. [key: string]: IGLTFMesh;
  80251. };
  80252. lights: {
  80253. [key: string]: IGLTFLight;
  80254. };
  80255. cameras: {
  80256. [key: string]: IGLTFCamera;
  80257. };
  80258. nodes: {
  80259. [key: string]: IGLTFNode;
  80260. };
  80261. images: {
  80262. [key: string]: IGLTFImage;
  80263. };
  80264. textures: {
  80265. [key: string]: IGLTFTexture;
  80266. };
  80267. shaders: {
  80268. [key: string]: IGLTFShader;
  80269. };
  80270. programs: {
  80271. [key: string]: IGLTFProgram;
  80272. };
  80273. samplers: {
  80274. [key: string]: IGLTFSampler;
  80275. };
  80276. techniques: {
  80277. [key: string]: IGLTFTechnique;
  80278. };
  80279. materials: {
  80280. [key: string]: IGLTFMaterial;
  80281. };
  80282. animations: {
  80283. [key: string]: IGLTFAnimation;
  80284. };
  80285. skins: {
  80286. [key: string]: IGLTFSkins;
  80287. };
  80288. currentScene?: Object;
  80289. scenes: {
  80290. [key: string]: IGLTFScene;
  80291. };
  80292. extensionsUsed: string[];
  80293. extensionsRequired?: string[];
  80294. buffersCount: number;
  80295. shaderscount: number;
  80296. scene: Scene;
  80297. rootUrl: string;
  80298. loadedBufferCount: number;
  80299. loadedBufferViews: {
  80300. [name: string]: ArrayBufferView;
  80301. };
  80302. loadedShaderCount: number;
  80303. importOnlyMeshes: boolean;
  80304. importMeshesNames?: string[];
  80305. dummyNodes: Node[];
  80306. forAssetContainer: boolean;
  80307. }
  80308. /** @hidden */
  80309. export interface INodeToRoot {
  80310. bone: Bone;
  80311. node: IGLTFNode;
  80312. id: string;
  80313. }
  80314. /** @hidden */
  80315. export interface IJointNode {
  80316. node: IGLTFNode;
  80317. id: string;
  80318. }
  80319. }
  80320. declare module BABYLON.GLTF1 {
  80321. /**
  80322. * Utils functions for GLTF
  80323. * @hidden
  80324. */
  80325. export class GLTFUtils {
  80326. /**
  80327. * Sets the given "parameter" matrix
  80328. * @param scene: the Scene object
  80329. * @param source: the source node where to pick the matrix
  80330. * @param parameter: the GLTF technique parameter
  80331. * @param uniformName: the name of the shader's uniform
  80332. * @param shaderMaterial: the shader material
  80333. */
  80334. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  80335. /**
  80336. * Sets the given "parameter" matrix
  80337. * @param shaderMaterial: the shader material
  80338. * @param uniform: the name of the shader's uniform
  80339. * @param value: the value of the uniform
  80340. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  80341. */
  80342. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  80343. /**
  80344. * Returns the wrap mode of the texture
  80345. * @param mode: the mode value
  80346. */
  80347. static GetWrapMode(mode: number): number;
  80348. /**
  80349. * Returns the byte stride giving an accessor
  80350. * @param accessor: the GLTF accessor objet
  80351. */
  80352. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  80353. /**
  80354. * Returns the texture filter mode giving a mode value
  80355. * @param mode: the filter mode value
  80356. */
  80357. static GetTextureFilterMode(mode: number): ETextureFilterType;
  80358. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  80359. /**
  80360. * Returns a buffer from its accessor
  80361. * @param gltfRuntime: the GLTF runtime
  80362. * @param accessor: the GLTF accessor
  80363. */
  80364. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80365. /**
  80366. * Decodes a buffer view into a string
  80367. * @param view: the buffer view
  80368. */
  80369. static DecodeBufferToText(view: ArrayBufferView): string;
  80370. /**
  80371. * Returns the default material of gltf. Related to
  80372. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80373. * @param scene: the Babylon.js scene
  80374. */
  80375. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80376. private static _DefaultMaterial;
  80377. }
  80378. }
  80379. declare module BABYLON.GLTF1 {
  80380. /**
  80381. * Implementation of the base glTF spec
  80382. * @hidden
  80383. */
  80384. export class GLTFLoaderBase {
  80385. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80386. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80387. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80388. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80389. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80390. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80391. }
  80392. /**
  80393. * glTF V1 Loader
  80394. * @hidden
  80395. */
  80396. export class GLTFLoader implements IGLTFLoader {
  80397. static Extensions: {
  80398. [name: string]: GLTFLoaderExtension;
  80399. };
  80400. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80401. state: Nullable<GLTFLoaderState>;
  80402. dispose(): void;
  80403. private _importMeshAsync;
  80404. /**
  80405. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80406. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80407. * @param scene the scene the meshes should be added to
  80408. * @param forAssetContainer defines if the entities must be stored in the scene
  80409. * @param data gltf data containing information of the meshes in a loaded file
  80410. * @param rootUrl root url to load from
  80411. * @param onProgress event that fires when loading progress has occured
  80412. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80413. */
  80414. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80415. private _loadAsync;
  80416. /**
  80417. * Imports all objects from a loaded gltf file and adds them to the scene
  80418. * @param scene the scene the objects should be added to
  80419. * @param data gltf data containing information of the meshes in a loaded file
  80420. * @param rootUrl root url to load from
  80421. * @param onProgress event that fires when loading progress has occured
  80422. * @returns a promise which completes when objects have been loaded to the scene
  80423. */
  80424. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80425. private _loadShadersAsync;
  80426. private _loadBuffersAsync;
  80427. private _createNodes;
  80428. }
  80429. /** @hidden */
  80430. export abstract class GLTFLoaderExtension {
  80431. private _name;
  80432. constructor(name: string);
  80433. get name(): string;
  80434. /**
  80435. * Defines an override for loading the runtime
  80436. * Return true to stop further extensions from loading the runtime
  80437. */
  80438. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  80439. /**
  80440. * Defines an onverride for creating gltf runtime
  80441. * Return true to stop further extensions from creating the runtime
  80442. */
  80443. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  80444. /**
  80445. * Defines an override for loading buffers
  80446. * Return true to stop further extensions from loading this buffer
  80447. */
  80448. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  80449. /**
  80450. * Defines an override for loading texture buffers
  80451. * Return true to stop further extensions from loading this texture data
  80452. */
  80453. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80454. /**
  80455. * Defines an override for creating textures
  80456. * Return true to stop further extensions from loading this texture
  80457. */
  80458. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  80459. /**
  80460. * Defines an override for loading shader strings
  80461. * Return true to stop further extensions from loading this shader data
  80462. */
  80463. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80464. /**
  80465. * Defines an override for loading materials
  80466. * Return true to stop further extensions from loading this material
  80467. */
  80468. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80469. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  80470. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  80471. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80472. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80473. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  80474. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80475. private static LoadTextureBufferAsync;
  80476. private static CreateTextureAsync;
  80477. private static ApplyExtensions;
  80478. }
  80479. }
  80480. declare module BABYLON.GLTF1 {
  80481. /** @hidden */
  80482. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  80483. private _bin;
  80484. constructor();
  80485. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  80486. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80487. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80488. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80489. }
  80490. }
  80491. declare module BABYLON.GLTF1 {
  80492. /** @hidden */
  80493. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  80494. constructor();
  80495. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  80496. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80497. private _loadTexture;
  80498. }
  80499. }
  80500. declare module BABYLON.GLTF2.Loader {
  80501. /**
  80502. * Loader interface with an index field.
  80503. */
  80504. export interface IArrayItem {
  80505. /**
  80506. * The index of this item in the array.
  80507. */
  80508. index: number;
  80509. }
  80510. /**
  80511. * Loader interface with additional members.
  80512. */
  80513. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  80514. /** @hidden */
  80515. _data?: Promise<ArrayBufferView>;
  80516. /** @hidden */
  80517. _babylonVertexBuffer?: Promise<VertexBuffer>;
  80518. }
  80519. /**
  80520. * Loader interface with additional members.
  80521. */
  80522. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  80523. }
  80524. /** @hidden */
  80525. export interface _IAnimationSamplerData {
  80526. input: Float32Array;
  80527. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  80528. output: Float32Array;
  80529. }
  80530. /**
  80531. * Loader interface with additional members.
  80532. */
  80533. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  80534. /** @hidden */
  80535. _data?: Promise<_IAnimationSamplerData>;
  80536. }
  80537. /**
  80538. * Loader interface with additional members.
  80539. */
  80540. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  80541. channels: IAnimationChannel[];
  80542. samplers: IAnimationSampler[];
  80543. /** @hidden */
  80544. _babylonAnimationGroup?: AnimationGroup;
  80545. }
  80546. /**
  80547. * Loader interface with additional members.
  80548. */
  80549. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  80550. /** @hidden */
  80551. _data?: Promise<ArrayBufferView>;
  80552. }
  80553. /**
  80554. * Loader interface with additional members.
  80555. */
  80556. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  80557. /** @hidden */
  80558. _data?: Promise<ArrayBufferView>;
  80559. /** @hidden */
  80560. _babylonBuffer?: Promise<Buffer>;
  80561. }
  80562. /**
  80563. * Loader interface with additional members.
  80564. */
  80565. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  80566. }
  80567. /**
  80568. * Loader interface with additional members.
  80569. */
  80570. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  80571. /** @hidden */
  80572. _data?: Promise<ArrayBufferView>;
  80573. }
  80574. /**
  80575. * Loader interface with additional members.
  80576. */
  80577. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  80578. }
  80579. /**
  80580. * Loader interface with additional members.
  80581. */
  80582. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  80583. }
  80584. /**
  80585. * Loader interface with additional members.
  80586. */
  80587. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  80588. baseColorTexture?: ITextureInfo;
  80589. metallicRoughnessTexture?: ITextureInfo;
  80590. }
  80591. /**
  80592. * Loader interface with additional members.
  80593. */
  80594. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  80595. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80596. normalTexture?: IMaterialNormalTextureInfo;
  80597. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80598. emissiveTexture?: ITextureInfo;
  80599. /** @hidden */
  80600. _data?: {
  80601. [babylonDrawMode: number]: {
  80602. babylonMaterial: Material;
  80603. babylonMeshes: AbstractMesh[];
  80604. promise: Promise<void>;
  80605. };
  80606. };
  80607. }
  80608. /**
  80609. * Loader interface with additional members.
  80610. */
  80611. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  80612. primitives: IMeshPrimitive[];
  80613. }
  80614. /**
  80615. * Loader interface with additional members.
  80616. */
  80617. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  80618. /** @hidden */
  80619. _instanceData?: {
  80620. babylonSourceMesh: Mesh;
  80621. promise: Promise<any>;
  80622. };
  80623. }
  80624. /**
  80625. * Loader interface with additional members.
  80626. */
  80627. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  80628. /**
  80629. * The parent glTF node.
  80630. */
  80631. parent?: INode;
  80632. /** @hidden */
  80633. _babylonTransformNode?: TransformNode;
  80634. /** @hidden */
  80635. _primitiveBabylonMeshes?: AbstractMesh[];
  80636. /** @hidden */
  80637. _babylonBones?: Bone[];
  80638. /** @hidden */
  80639. _numMorphTargets?: number;
  80640. }
  80641. /** @hidden */
  80642. export interface _ISamplerData {
  80643. noMipMaps: boolean;
  80644. samplingMode: number;
  80645. wrapU: number;
  80646. wrapV: number;
  80647. }
  80648. /**
  80649. * Loader interface with additional members.
  80650. */
  80651. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80652. /** @hidden */
  80653. _data?: _ISamplerData;
  80654. }
  80655. /**
  80656. * Loader interface with additional members.
  80657. */
  80658. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80659. }
  80660. /**
  80661. * Loader interface with additional members.
  80662. */
  80663. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80664. /** @hidden */
  80665. _data?: {
  80666. babylonSkeleton: Skeleton;
  80667. promise: Promise<void>;
  80668. };
  80669. }
  80670. /**
  80671. * Loader interface with additional members.
  80672. */
  80673. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80674. }
  80675. /**
  80676. * Loader interface with additional members.
  80677. */
  80678. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80679. }
  80680. /**
  80681. * Loader interface with additional members.
  80682. */
  80683. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80684. accessors?: IAccessor[];
  80685. animations?: IAnimation[];
  80686. buffers?: IBuffer[];
  80687. bufferViews?: IBufferView[];
  80688. cameras?: ICamera[];
  80689. images?: IImage[];
  80690. materials?: IMaterial[];
  80691. meshes?: IMesh[];
  80692. nodes?: INode[];
  80693. samplers?: ISampler[];
  80694. scenes?: IScene[];
  80695. skins?: ISkin[];
  80696. textures?: ITexture[];
  80697. }
  80698. }
  80699. declare module BABYLON.GLTF2 {
  80700. /**
  80701. * Interface for a glTF loader extension.
  80702. */
  80703. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80704. /**
  80705. * Called after the loader state changes to LOADING.
  80706. */
  80707. onLoading?(): void;
  80708. /**
  80709. * Called after the loader state changes to READY.
  80710. */
  80711. onReady?(): void;
  80712. /**
  80713. * Define this method to modify the default behavior when loading scenes.
  80714. * @param context The context when loading the asset
  80715. * @param scene The glTF scene property
  80716. * @returns A promise that resolves when the load is complete or null if not handled
  80717. */
  80718. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80719. /**
  80720. * Define this method to modify the default behavior when loading nodes.
  80721. * @param context The context when loading the asset
  80722. * @param node The glTF node property
  80723. * @param assign A function called synchronously after parsing the glTF properties
  80724. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80725. */
  80726. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80727. /**
  80728. * Define this method to modify the default behavior when loading cameras.
  80729. * @param context The context when loading the asset
  80730. * @param camera The glTF camera property
  80731. * @param assign A function called synchronously after parsing the glTF properties
  80732. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80733. */
  80734. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80735. /**
  80736. * @hidden
  80737. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80738. * @param context The context when loading the asset
  80739. * @param primitive The glTF mesh primitive property
  80740. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80741. */
  80742. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80743. /**
  80744. * @hidden
  80745. * Define this method to modify the default behavior when loading data for mesh primitives.
  80746. * @param context The context when loading the asset
  80747. * @param name The mesh name when loading the asset
  80748. * @param node The glTF node when loading the asset
  80749. * @param mesh The glTF mesh when loading the asset
  80750. * @param primitive The glTF mesh primitive property
  80751. * @param assign A function called synchronously after parsing the glTF properties
  80752. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80753. */
  80754. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80755. /**
  80756. * @hidden
  80757. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80758. * @param context The context when loading the asset
  80759. * @param material The glTF material property
  80760. * @param assign A function called synchronously after parsing the glTF properties
  80761. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80762. */
  80763. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80764. /**
  80765. * Define this method to modify the default behavior when creating materials.
  80766. * @param context The context when loading the asset
  80767. * @param material The glTF material property
  80768. * @param babylonDrawMode The draw mode for the Babylon material
  80769. * @returns The Babylon material or null if not handled
  80770. */
  80771. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80772. /**
  80773. * Define this method to modify the default behavior when loading material properties.
  80774. * @param context The context when loading the asset
  80775. * @param material The glTF material property
  80776. * @param babylonMaterial The Babylon material
  80777. * @returns A promise that resolves when the load is complete or null if not handled
  80778. */
  80779. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80780. /**
  80781. * Define this method to modify the default behavior when loading texture infos.
  80782. * @param context The context when loading the asset
  80783. * @param textureInfo The glTF texture info property
  80784. * @param assign A function called synchronously after parsing the glTF properties
  80785. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80786. */
  80787. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80788. /**
  80789. * @hidden
  80790. * Define this method to modify the default behavior when loading textures.
  80791. * @param context The context when loading the asset
  80792. * @param texture The glTF texture property
  80793. * @param assign A function called synchronously after parsing the glTF properties
  80794. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80795. */
  80796. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80797. /**
  80798. * Define this method to modify the default behavior when loading animations.
  80799. * @param context The context when loading the asset
  80800. * @param animation The glTF animation property
  80801. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80802. */
  80803. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80804. /**
  80805. * @hidden
  80806. * Define this method to modify the default behavior when loading skins.
  80807. * @param context The context when loading the asset
  80808. * @param node The glTF node property
  80809. * @param skin The glTF skin property
  80810. * @returns A promise that resolves when the load is complete or null if not handled
  80811. */
  80812. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80813. /**
  80814. * @hidden
  80815. * Define this method to modify the default behavior when loading uris.
  80816. * @param context The context when loading the asset
  80817. * @param property The glTF property associated with the uri
  80818. * @param uri The uri to load
  80819. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80820. */
  80821. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80822. /**
  80823. * Define this method to modify the default behavior when loading buffer views.
  80824. * @param context The context when loading the asset
  80825. * @param bufferView The glTF buffer view property
  80826. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80827. */
  80828. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80829. /**
  80830. * Define this method to modify the default behavior when loading buffers.
  80831. * @param context The context when loading the asset
  80832. * @param buffer The glTF buffer property
  80833. * @param byteOffset The byte offset to load
  80834. * @param byteLength The byte length to load
  80835. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80836. */
  80837. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80838. }
  80839. }
  80840. declare module BABYLON.GLTF2 {
  80841. /**
  80842. * Helper class for working with arrays when loading the glTF asset
  80843. */
  80844. export class ArrayItem {
  80845. /**
  80846. * Gets an item from the given array.
  80847. * @param context The context when loading the asset
  80848. * @param array The array to get the item from
  80849. * @param index The index to the array
  80850. * @returns The array item
  80851. */
  80852. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80853. /**
  80854. * Assign an `index` field to each item of the given array.
  80855. * @param array The array of items
  80856. */
  80857. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80858. }
  80859. /**
  80860. * The glTF 2.0 loader
  80861. */
  80862. export class GLTFLoader implements IGLTFLoader {
  80863. /** @hidden */
  80864. _completePromises: Promise<any>[];
  80865. /** @hidden */
  80866. _forAssetContainer: boolean;
  80867. /** Storage */
  80868. _babylonLights: Light[];
  80869. /** @hidden */
  80870. _disableInstancedMesh: number;
  80871. private _disposed;
  80872. private _parent;
  80873. private _state;
  80874. private _extensions;
  80875. private _rootUrl;
  80876. private _fileName;
  80877. private _uniqueRootUrl;
  80878. private _gltf;
  80879. private _bin;
  80880. private _babylonScene;
  80881. private _rootBabylonMesh;
  80882. private _defaultBabylonMaterialData;
  80883. private static _RegisteredExtensions;
  80884. /**
  80885. * The default glTF sampler.
  80886. */
  80887. static readonly DefaultSampler: ISampler;
  80888. /**
  80889. * Registers a loader extension.
  80890. * @param name The name of the loader extension.
  80891. * @param factory The factory function that creates the loader extension.
  80892. */
  80893. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80894. /**
  80895. * Unregisters a loader extension.
  80896. * @param name The name of the loader extension.
  80897. * @returns A boolean indicating whether the extension has been unregistered
  80898. */
  80899. static UnregisterExtension(name: string): boolean;
  80900. /**
  80901. * The loader state.
  80902. */
  80903. get state(): Nullable<GLTFLoaderState>;
  80904. /**
  80905. * The object that represents the glTF JSON.
  80906. */
  80907. get gltf(): IGLTF;
  80908. /**
  80909. * The BIN chunk of a binary glTF.
  80910. */
  80911. get bin(): Nullable<IDataBuffer>;
  80912. /**
  80913. * The parent file loader.
  80914. */
  80915. get parent(): GLTFFileLoader;
  80916. /**
  80917. * The Babylon scene when loading the asset.
  80918. */
  80919. get babylonScene(): Scene;
  80920. /**
  80921. * The root Babylon mesh when loading the asset.
  80922. */
  80923. get rootBabylonMesh(): Mesh;
  80924. /** @hidden */
  80925. constructor(parent: GLTFFileLoader);
  80926. /** @hidden */
  80927. dispose(): void;
  80928. /** @hidden */
  80929. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80930. /** @hidden */
  80931. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80932. private _loadAsync;
  80933. private _loadData;
  80934. private _setupData;
  80935. private _loadExtensions;
  80936. private _checkExtensions;
  80937. private _setState;
  80938. private _createRootNode;
  80939. /**
  80940. * Loads a glTF scene.
  80941. * @param context The context when loading the asset
  80942. * @param scene The glTF scene property
  80943. * @returns A promise that resolves when the load is complete
  80944. */
  80945. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80946. private _forEachPrimitive;
  80947. private _getMeshes;
  80948. private _getTransformNodes;
  80949. private _getSkeletons;
  80950. private _getAnimationGroups;
  80951. private _startAnimations;
  80952. /**
  80953. * Loads a glTF node.
  80954. * @param context The context when loading the asset
  80955. * @param node The glTF node property
  80956. * @param assign A function called synchronously after parsing the glTF properties
  80957. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80958. */
  80959. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80960. private _loadMeshAsync;
  80961. /**
  80962. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80963. * @param context The context when loading the asset
  80964. * @param name The mesh name when loading the asset
  80965. * @param node The glTF node when loading the asset
  80966. * @param mesh The glTF mesh when loading the asset
  80967. * @param primitive The glTF mesh primitive property
  80968. * @param assign A function called synchronously after parsing the glTF properties
  80969. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80970. */
  80971. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80972. private _loadVertexDataAsync;
  80973. private _createMorphTargets;
  80974. private _loadMorphTargetsAsync;
  80975. private _loadMorphTargetVertexDataAsync;
  80976. private static _LoadTransform;
  80977. private _loadSkinAsync;
  80978. private _loadBones;
  80979. private _loadBone;
  80980. private _loadSkinInverseBindMatricesDataAsync;
  80981. private _updateBoneMatrices;
  80982. private _getNodeMatrix;
  80983. /**
  80984. * Loads a glTF camera.
  80985. * @param context The context when loading the asset
  80986. * @param camera The glTF camera property
  80987. * @param assign A function called synchronously after parsing the glTF properties
  80988. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80989. */
  80990. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80991. private _loadAnimationsAsync;
  80992. /**
  80993. * Loads a glTF animation.
  80994. * @param context The context when loading the asset
  80995. * @param animation The glTF animation property
  80996. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80997. */
  80998. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80999. /**
  81000. * @hidden Loads a glTF animation channel.
  81001. * @param context The context when loading the asset
  81002. * @param animationContext The context of the animation when loading the asset
  81003. * @param animation The glTF animation property
  81004. * @param channel The glTF animation channel property
  81005. * @param babylonAnimationGroup The babylon animation group property
  81006. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  81007. * @returns A void promise when the channel load is complete
  81008. */
  81009. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  81010. private _loadAnimationSamplerAsync;
  81011. private _loadBufferAsync;
  81012. /**
  81013. * Loads a glTF buffer view.
  81014. * @param context The context when loading the asset
  81015. * @param bufferView The glTF buffer view property
  81016. * @returns A promise that resolves with the loaded data when the load is complete
  81017. */
  81018. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  81019. private _loadAccessorAsync;
  81020. /** @hidden */
  81021. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  81022. private _loadIndicesAccessorAsync;
  81023. private _loadVertexBufferViewAsync;
  81024. private _loadVertexAccessorAsync;
  81025. private _loadMaterialMetallicRoughnessPropertiesAsync;
  81026. /** @hidden */
  81027. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  81028. private _createDefaultMaterial;
  81029. /**
  81030. * Creates a Babylon material from a glTF material.
  81031. * @param context The context when loading the asset
  81032. * @param material The glTF material property
  81033. * @param babylonDrawMode The draw mode for the Babylon material
  81034. * @returns The Babylon material
  81035. */
  81036. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  81037. /**
  81038. * Loads properties from a glTF material into a Babylon material.
  81039. * @param context The context when loading the asset
  81040. * @param material The glTF material property
  81041. * @param babylonMaterial The Babylon material
  81042. * @returns A promise that resolves when the load is complete
  81043. */
  81044. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81045. /**
  81046. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  81047. * @param context The context when loading the asset
  81048. * @param material The glTF material property
  81049. * @param babylonMaterial The Babylon material
  81050. * @returns A promise that resolves when the load is complete
  81051. */
  81052. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81053. /**
  81054. * Loads the alpha properties from a glTF material into a Babylon material.
  81055. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  81056. * @param context The context when loading the asset
  81057. * @param material The glTF material property
  81058. * @param babylonMaterial The Babylon material
  81059. */
  81060. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  81061. /**
  81062. * Loads a glTF texture info.
  81063. * @param context The context when loading the asset
  81064. * @param textureInfo The glTF texture info property
  81065. * @param assign A function called synchronously after parsing the glTF properties
  81066. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  81067. */
  81068. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81069. /** @hidden */
  81070. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81071. /** @hidden */
  81072. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81073. private _loadSampler;
  81074. /**
  81075. * Loads a glTF image.
  81076. * @param context The context when loading the asset
  81077. * @param image The glTF image property
  81078. * @returns A promise that resolves with the loaded data when the load is complete
  81079. */
  81080. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  81081. /**
  81082. * Loads a glTF uri.
  81083. * @param context The context when loading the asset
  81084. * @param property The glTF property associated with the uri
  81085. * @param uri The base64 or relative uri
  81086. * @returns A promise that resolves with the loaded data when the load is complete
  81087. */
  81088. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  81089. /**
  81090. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  81091. * @param babylonObject the Babylon object with metadata
  81092. * @param pointer the JSON pointer
  81093. */
  81094. static AddPointerMetadata(babylonObject: {
  81095. metadata: any;
  81096. }, pointer: string): void;
  81097. private static _GetTextureWrapMode;
  81098. private static _GetTextureSamplingMode;
  81099. private static _GetTypedArrayConstructor;
  81100. private static _GetTypedArray;
  81101. private static _GetNumComponents;
  81102. private static _ValidateUri;
  81103. /** @hidden */
  81104. static _GetDrawMode(context: string, mode: number | undefined): number;
  81105. private _compileMaterialsAsync;
  81106. private _compileShadowGeneratorsAsync;
  81107. private _forEachExtensions;
  81108. private _applyExtensions;
  81109. private _extensionsOnLoading;
  81110. private _extensionsOnReady;
  81111. private _extensionsLoadSceneAsync;
  81112. private _extensionsLoadNodeAsync;
  81113. private _extensionsLoadCameraAsync;
  81114. private _extensionsLoadVertexDataAsync;
  81115. private _extensionsLoadMeshPrimitiveAsync;
  81116. private _extensionsLoadMaterialAsync;
  81117. private _extensionsCreateMaterial;
  81118. private _extensionsLoadMaterialPropertiesAsync;
  81119. private _extensionsLoadTextureInfoAsync;
  81120. private _extensionsLoadTextureAsync;
  81121. private _extensionsLoadAnimationAsync;
  81122. private _extensionsLoadSkinAsync;
  81123. private _extensionsLoadUriAsync;
  81124. private _extensionsLoadBufferViewAsync;
  81125. private _extensionsLoadBufferAsync;
  81126. /**
  81127. * Helper method called by a loader extension to load an glTF extension.
  81128. * @param context The context when loading the asset
  81129. * @param property The glTF property to load the extension from
  81130. * @param extensionName The name of the extension to load
  81131. * @param actionAsync The action to run
  81132. * @returns The promise returned by actionAsync or null if the extension does not exist
  81133. */
  81134. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81135. /**
  81136. * Helper method called by a loader extension to load a glTF extra.
  81137. * @param context The context when loading the asset
  81138. * @param property The glTF property to load the extra from
  81139. * @param extensionName The name of the extension to load
  81140. * @param actionAsync The action to run
  81141. * @returns The promise returned by actionAsync or null if the extra does not exist
  81142. */
  81143. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81144. /**
  81145. * Checks for presence of an extension.
  81146. * @param name The name of the extension to check
  81147. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81148. */
  81149. isExtensionUsed(name: string): boolean;
  81150. /**
  81151. * Increments the indentation level and logs a message.
  81152. * @param message The message to log
  81153. */
  81154. logOpen(message: string): void;
  81155. /**
  81156. * Decrements the indentation level.
  81157. */
  81158. logClose(): void;
  81159. /**
  81160. * Logs a message
  81161. * @param message The message to log
  81162. */
  81163. log(message: string): void;
  81164. /**
  81165. * Starts a performance counter.
  81166. * @param counterName The name of the performance counter
  81167. */
  81168. startPerformanceCounter(counterName: string): void;
  81169. /**
  81170. * Ends a performance counter.
  81171. * @param counterName The name of the performance counter
  81172. */
  81173. endPerformanceCounter(counterName: string): void;
  81174. }
  81175. }
  81176. declare module BABYLON.GLTF2.Loader.Extensions {
  81177. /** @hidden */
  81178. interface IEXTLightsImageBased_LightImageBased {
  81179. _babylonTexture?: BaseTexture;
  81180. _loaded?: Promise<void>;
  81181. }
  81182. /**
  81183. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  81184. */
  81185. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  81186. /**
  81187. * The name of this extension.
  81188. */
  81189. readonly name: string;
  81190. /**
  81191. * Defines whether this extension is enabled.
  81192. */
  81193. enabled: boolean;
  81194. private _loader;
  81195. private _lights?;
  81196. /** @hidden */
  81197. constructor(loader: GLTFLoader);
  81198. /** @hidden */
  81199. dispose(): void;
  81200. /** @hidden */
  81201. onLoading(): void;
  81202. /** @hidden */
  81203. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81204. private _loadLightAsync;
  81205. }
  81206. }
  81207. declare module BABYLON.GLTF2.Loader.Extensions {
  81208. /**
  81209. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  81210. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  81211. * !!! Experimental Extension Subject to Changes !!!
  81212. */
  81213. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  81214. /**
  81215. * The name of this extension.
  81216. */
  81217. readonly name: string;
  81218. /**
  81219. * Defines whether this extension is enabled.
  81220. */
  81221. enabled: boolean;
  81222. private _loader;
  81223. /** @hidden */
  81224. constructor(loader: GLTFLoader);
  81225. /** @hidden */
  81226. dispose(): void;
  81227. /** @hidden */
  81228. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81229. }
  81230. }
  81231. declare module BABYLON.GLTF2.Loader.Extensions {
  81232. /**
  81233. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  81234. */
  81235. export class EXT_texture_webp implements IGLTFLoaderExtension {
  81236. /** The name of this extension. */
  81237. readonly name: string;
  81238. /** Defines whether this extension is enabled. */
  81239. enabled: boolean;
  81240. private _loader;
  81241. /** @hidden */
  81242. constructor(loader: GLTFLoader);
  81243. /** @hidden */
  81244. dispose(): void;
  81245. /** @hidden */
  81246. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81247. }
  81248. }
  81249. declare module BABYLON.GLTF2.Loader.Extensions {
  81250. /**
  81251. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  81252. */
  81253. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  81254. /**
  81255. * The name of this extension.
  81256. */
  81257. readonly name: string;
  81258. /**
  81259. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  81260. */
  81261. dracoCompression?: DracoCompression;
  81262. /**
  81263. * Defines whether this extension is enabled.
  81264. */
  81265. enabled: boolean;
  81266. private _loader;
  81267. /** @hidden */
  81268. constructor(loader: GLTFLoader);
  81269. /** @hidden */
  81270. dispose(): void;
  81271. /** @hidden */
  81272. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81273. }
  81274. }
  81275. declare module BABYLON.GLTF2.Loader.Extensions {
  81276. /**
  81277. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  81278. */
  81279. export class KHR_lights implements IGLTFLoaderExtension {
  81280. /**
  81281. * The name of this extension.
  81282. */
  81283. readonly name: string;
  81284. /**
  81285. * Defines whether this extension is enabled.
  81286. */
  81287. enabled: boolean;
  81288. private _loader;
  81289. private _lights?;
  81290. /** @hidden */
  81291. constructor(loader: GLTFLoader);
  81292. /** @hidden */
  81293. dispose(): void;
  81294. /** @hidden */
  81295. onLoading(): void;
  81296. /** @hidden */
  81297. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81298. }
  81299. }
  81300. declare module BABYLON.GLTF2.Loader.Extensions {
  81301. /**
  81302. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  81303. */
  81304. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  81305. /**
  81306. * The name of this extension.
  81307. */
  81308. readonly name: string;
  81309. /**
  81310. * Defines whether this extension is enabled.
  81311. */
  81312. enabled: boolean;
  81313. /**
  81314. * Defines a number that determines the order the extensions are applied.
  81315. */
  81316. order: number;
  81317. private _loader;
  81318. /** @hidden */
  81319. constructor(loader: GLTFLoader);
  81320. /** @hidden */
  81321. dispose(): void;
  81322. /** @hidden */
  81323. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81324. private _loadSpecularGlossinessPropertiesAsync;
  81325. }
  81326. }
  81327. declare module BABYLON.GLTF2.Loader.Extensions {
  81328. /**
  81329. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  81330. */
  81331. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  81332. /**
  81333. * The name of this extension.
  81334. */
  81335. readonly name: string;
  81336. /**
  81337. * Defines whether this extension is enabled.
  81338. */
  81339. enabled: boolean;
  81340. /**
  81341. * Defines a number that determines the order the extensions are applied.
  81342. */
  81343. order: number;
  81344. private _loader;
  81345. /** @hidden */
  81346. constructor(loader: GLTFLoader);
  81347. /** @hidden */
  81348. dispose(): void;
  81349. /** @hidden */
  81350. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81351. private _loadUnlitPropertiesAsync;
  81352. }
  81353. }
  81354. declare module BABYLON.GLTF2.Loader.Extensions {
  81355. /**
  81356. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  81357. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  81358. * !!! Experimental Extension Subject to Changes !!!
  81359. */
  81360. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  81361. /**
  81362. * The name of this extension.
  81363. */
  81364. readonly name: string;
  81365. /**
  81366. * Defines whether this extension is enabled.
  81367. */
  81368. enabled: boolean;
  81369. /**
  81370. * Defines a number that determines the order the extensions are applied.
  81371. */
  81372. order: number;
  81373. private _loader;
  81374. /** @hidden */
  81375. constructor(loader: GLTFLoader);
  81376. /** @hidden */
  81377. dispose(): void;
  81378. /** @hidden */
  81379. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81380. private _loadClearCoatPropertiesAsync;
  81381. }
  81382. }
  81383. declare module BABYLON.GLTF2.Loader.Extensions {
  81384. /**
  81385. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81386. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81387. * !!! Experimental Extension Subject to Changes !!!
  81388. */
  81389. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81390. /**
  81391. * The name of this extension.
  81392. */
  81393. readonly name: string;
  81394. /**
  81395. * Defines whether this extension is enabled.
  81396. */
  81397. enabled: boolean;
  81398. /**
  81399. * Defines a number that determines the order the extensions are applied.
  81400. */
  81401. order: number;
  81402. private _loader;
  81403. /** @hidden */
  81404. constructor(loader: GLTFLoader);
  81405. /** @hidden */
  81406. dispose(): void;
  81407. /** @hidden */
  81408. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81409. private _loadSheenPropertiesAsync;
  81410. }
  81411. }
  81412. declare module BABYLON.GLTF2.Loader.Extensions {
  81413. /**
  81414. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81415. * !!! Experimental Extension Subject to Changes !!!
  81416. */
  81417. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81418. /**
  81419. * The name of this extension.
  81420. */
  81421. readonly name: string;
  81422. /**
  81423. * Defines whether this extension is enabled.
  81424. */
  81425. enabled: boolean;
  81426. /**
  81427. * Defines a number that determines the order the extensions are applied.
  81428. */
  81429. order: number;
  81430. private _loader;
  81431. /** @hidden */
  81432. constructor(loader: GLTFLoader);
  81433. /** @hidden */
  81434. dispose(): void;
  81435. /** @hidden */
  81436. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81437. private _loadSpecularPropertiesAsync;
  81438. }
  81439. }
  81440. declare module BABYLON.GLTF2.Loader.Extensions {
  81441. /**
  81442. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  81443. * !!! Experimental Extension Subject to Changes !!!
  81444. */
  81445. export class KHR_materials_ior implements IGLTFLoaderExtension {
  81446. /**
  81447. * Default ior Value from the spec.
  81448. */
  81449. private static readonly _DEFAULT_IOR;
  81450. /**
  81451. * The name of this extension.
  81452. */
  81453. readonly name: string;
  81454. /**
  81455. * Defines whether this extension is enabled.
  81456. */
  81457. enabled: boolean;
  81458. /**
  81459. * Defines a number that determines the order the extensions are applied.
  81460. */
  81461. order: number;
  81462. private _loader;
  81463. /** @hidden */
  81464. constructor(loader: GLTFLoader);
  81465. /** @hidden */
  81466. dispose(): void;
  81467. /** @hidden */
  81468. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81469. private _loadIorPropertiesAsync;
  81470. }
  81471. }
  81472. declare module BABYLON.GLTF2.Loader.Extensions {
  81473. /**
  81474. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  81475. * !!! Experimental Extension Subject to Changes !!!
  81476. */
  81477. export class KHR_materials_variants implements IGLTFLoaderExtension {
  81478. /**
  81479. * The name of this extension.
  81480. */
  81481. readonly name: string;
  81482. /**
  81483. * Defines whether this extension is enabled.
  81484. */
  81485. enabled: boolean;
  81486. private _loader;
  81487. /** @hidden */
  81488. constructor(loader: GLTFLoader);
  81489. /** @hidden */
  81490. dispose(): void;
  81491. /**
  81492. * Gets the list of available variant names for this asset.
  81493. * @param rootMesh The glTF root mesh
  81494. * @returns the list of all the variant names for this model
  81495. */
  81496. static GetAvailableVariants(rootMesh: Mesh): string[];
  81497. /**
  81498. * Gets the list of available variant names for this asset.
  81499. * @param rootMesh The glTF root mesh
  81500. * @returns the list of all the variant names for this model
  81501. */
  81502. getAvailableVariants(rootMesh: Mesh): string[];
  81503. /**
  81504. * Select a variant given a variant name or a list of variant names.
  81505. * @param rootMesh The glTF root mesh
  81506. * @param variantName The variant name(s) to select.
  81507. */
  81508. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81509. /**
  81510. * Select a variant given a variant name or a list of variant names.
  81511. * @param rootMesh The glTF root mesh
  81512. * @param variantName The variant name(s) to select.
  81513. */
  81514. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81515. /**
  81516. * Reset back to the original before selecting a variant.
  81517. * @param rootMesh The glTF root mesh
  81518. */
  81519. static Reset(rootMesh: Mesh): void;
  81520. /**
  81521. * Reset back to the original before selecting a variant.
  81522. * @param rootMesh The glTF root mesh
  81523. */
  81524. reset(rootMesh: Mesh): void;
  81525. /**
  81526. * Gets the last selected variant name(s) or null if original.
  81527. * @param rootMesh The glTF root mesh
  81528. * @returns The selected variant name(s).
  81529. */
  81530. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81531. /**
  81532. * Gets the last selected variant name(s) or null if original.
  81533. * @param rootMesh The glTF root mesh
  81534. * @returns The selected variant name(s).
  81535. */
  81536. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81537. private static _GetExtensionMetadata;
  81538. /** @hidden */
  81539. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81540. }
  81541. }
  81542. declare module BABYLON.GLTF2.Loader.Extensions {
  81543. /**
  81544. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  81545. * !!! Experimental Extension Subject to Changes !!!
  81546. */
  81547. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  81548. /**
  81549. * The name of this extension.
  81550. */
  81551. readonly name: string;
  81552. /**
  81553. * Defines whether this extension is enabled.
  81554. */
  81555. enabled: boolean;
  81556. /**
  81557. * Defines a number that determines the order the extensions are applied.
  81558. */
  81559. order: number;
  81560. private _loader;
  81561. /** @hidden */
  81562. constructor(loader: GLTFLoader);
  81563. /** @hidden */
  81564. dispose(): void;
  81565. /** @hidden */
  81566. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81567. private _loadTransparentPropertiesAsync;
  81568. }
  81569. }
  81570. declare module BABYLON.GLTF2.Loader.Extensions {
  81571. /**
  81572. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  81573. */
  81574. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  81575. /**
  81576. * The name of this extension.
  81577. */
  81578. readonly name: string;
  81579. /**
  81580. * Defines whether this extension is enabled.
  81581. */
  81582. enabled: boolean;
  81583. /** @hidden */
  81584. constructor(loader: GLTFLoader);
  81585. /** @hidden */
  81586. dispose(): void;
  81587. }
  81588. }
  81589. declare module BABYLON.GLTF2.Loader.Extensions {
  81590. /**
  81591. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  81592. * !!! Experimental Extension Subject to Changes !!!
  81593. */
  81594. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  81595. /** The name of this extension. */
  81596. readonly name: string;
  81597. /** Defines whether this extension is enabled. */
  81598. enabled: boolean;
  81599. private _loader;
  81600. /** @hidden */
  81601. constructor(loader: GLTFLoader);
  81602. /** @hidden */
  81603. dispose(): void;
  81604. /** @hidden */
  81605. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81606. }
  81607. }
  81608. declare module BABYLON.GLTF2.Loader.Extensions {
  81609. /**
  81610. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  81611. */
  81612. export class KHR_texture_transform implements IGLTFLoaderExtension {
  81613. /**
  81614. * The name of this extension.
  81615. */
  81616. readonly name: string;
  81617. /**
  81618. * Defines whether this extension is enabled.
  81619. */
  81620. enabled: boolean;
  81621. private _loader;
  81622. /** @hidden */
  81623. constructor(loader: GLTFLoader);
  81624. /** @hidden */
  81625. dispose(): void;
  81626. /** @hidden */
  81627. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81628. }
  81629. }
  81630. declare module BABYLON.GLTF2.Loader.Extensions {
  81631. /**
  81632. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  81633. * !!! Experimental Extension Subject to Changes !!!
  81634. */
  81635. export class KHR_xmp implements IGLTFLoaderExtension {
  81636. /**
  81637. * The name of this extension.
  81638. */
  81639. readonly name: string;
  81640. /**
  81641. * Defines whether this extension is enabled.
  81642. */
  81643. enabled: boolean;
  81644. /**
  81645. * Defines a number that determines the order the extensions are applied.
  81646. */
  81647. order: number;
  81648. private _loader;
  81649. /** @hidden */
  81650. constructor(loader: GLTFLoader);
  81651. /** @hidden */
  81652. dispose(): void;
  81653. /**
  81654. * Called after the loader state changes to LOADING.
  81655. */
  81656. onLoading(): void;
  81657. }
  81658. }
  81659. declare module BABYLON.GLTF2.Loader.Extensions {
  81660. /**
  81661. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  81662. */
  81663. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  81664. /**
  81665. * The name of this extension.
  81666. */
  81667. readonly name: string;
  81668. /**
  81669. * Defines whether this extension is enabled.
  81670. */
  81671. enabled: boolean;
  81672. private _loader;
  81673. private _clips;
  81674. private _emitters;
  81675. /** @hidden */
  81676. constructor(loader: GLTFLoader);
  81677. /** @hidden */
  81678. dispose(): void;
  81679. /** @hidden */
  81680. onLoading(): void;
  81681. /** @hidden */
  81682. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81683. /** @hidden */
  81684. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81685. /** @hidden */
  81686. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81687. private _loadClipAsync;
  81688. private _loadEmitterAsync;
  81689. private _getEventAction;
  81690. private _loadAnimationEventAsync;
  81691. }
  81692. }
  81693. declare module BABYLON.GLTF2.Loader.Extensions {
  81694. /**
  81695. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81696. */
  81697. export class MSFT_lod implements IGLTFLoaderExtension {
  81698. /**
  81699. * The name of this extension.
  81700. */
  81701. readonly name: string;
  81702. /**
  81703. * Defines whether this extension is enabled.
  81704. */
  81705. enabled: boolean;
  81706. /**
  81707. * Defines a number that determines the order the extensions are applied.
  81708. */
  81709. order: number;
  81710. /**
  81711. * Maximum number of LODs to load, starting from the lowest LOD.
  81712. */
  81713. maxLODsToLoad: number;
  81714. /**
  81715. * Observable raised when all node LODs of one level are loaded.
  81716. * The event data is the index of the loaded LOD starting from zero.
  81717. * Dispose the loader to cancel the loading of the next level of LODs.
  81718. */
  81719. onNodeLODsLoadedObservable: Observable<number>;
  81720. /**
  81721. * Observable raised when all material LODs of one level are loaded.
  81722. * The event data is the index of the loaded LOD starting from zero.
  81723. * Dispose the loader to cancel the loading of the next level of LODs.
  81724. */
  81725. onMaterialLODsLoadedObservable: Observable<number>;
  81726. private _loader;
  81727. private _bufferLODs;
  81728. private _nodeIndexLOD;
  81729. private _nodeSignalLODs;
  81730. private _nodePromiseLODs;
  81731. private _nodeBufferLODs;
  81732. private _materialIndexLOD;
  81733. private _materialSignalLODs;
  81734. private _materialPromiseLODs;
  81735. private _materialBufferLODs;
  81736. /** @hidden */
  81737. constructor(loader: GLTFLoader);
  81738. /** @hidden */
  81739. dispose(): void;
  81740. /** @hidden */
  81741. onReady(): void;
  81742. /** @hidden */
  81743. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81744. /** @hidden */
  81745. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81746. /** @hidden */
  81747. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81748. /** @hidden */
  81749. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81750. /** @hidden */
  81751. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81752. private _loadBufferLOD;
  81753. /**
  81754. * Gets an array of LOD properties from lowest to highest.
  81755. */
  81756. private _getLODs;
  81757. private _disposeTransformNode;
  81758. private _disposeMaterials;
  81759. }
  81760. }
  81761. declare module BABYLON.GLTF2.Loader.Extensions {
  81762. /** @hidden */
  81763. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81764. readonly name: string;
  81765. enabled: boolean;
  81766. private _loader;
  81767. constructor(loader: GLTFLoader);
  81768. dispose(): void;
  81769. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81770. }
  81771. }
  81772. declare module BABYLON.GLTF2.Loader.Extensions {
  81773. /** @hidden */
  81774. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81775. readonly name: string;
  81776. enabled: boolean;
  81777. private _loader;
  81778. constructor(loader: GLTFLoader);
  81779. dispose(): void;
  81780. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81781. }
  81782. }
  81783. declare module BABYLON.GLTF2.Loader.Extensions {
  81784. /**
  81785. * Store glTF extras (if present) in BJS objects' metadata
  81786. */
  81787. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81788. /**
  81789. * The name of this extension.
  81790. */
  81791. readonly name: string;
  81792. /**
  81793. * Defines whether this extension is enabled.
  81794. */
  81795. enabled: boolean;
  81796. private _loader;
  81797. private _assignExtras;
  81798. /** @hidden */
  81799. constructor(loader: GLTFLoader);
  81800. /** @hidden */
  81801. dispose(): void;
  81802. /** @hidden */
  81803. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81804. /** @hidden */
  81805. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81806. /** @hidden */
  81807. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81808. }
  81809. }
  81810. declare module BABYLON {
  81811. /**
  81812. * Class reading and parsing the MTL file bundled with the obj file.
  81813. */
  81814. export class MTLFileLoader {
  81815. /**
  81816. * Invert Y-Axis of referenced textures on load
  81817. */
  81818. static INVERT_TEXTURE_Y: boolean;
  81819. /**
  81820. * All material loaded from the mtl will be set here
  81821. */
  81822. materials: StandardMaterial[];
  81823. /**
  81824. * This function will read the mtl file and create each material described inside
  81825. * This function could be improve by adding :
  81826. * -some component missing (Ni, Tf...)
  81827. * -including the specific options available
  81828. *
  81829. * @param scene defines the scene the material will be created in
  81830. * @param data defines the mtl data to parse
  81831. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81832. * @param forAssetContainer defines if the material should be registered in the scene
  81833. */
  81834. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81835. /**
  81836. * Gets the texture for the material.
  81837. *
  81838. * If the material is imported from input file,
  81839. * We sanitize the url to ensure it takes the textre from aside the material.
  81840. *
  81841. * @param rootUrl The root url to load from
  81842. * @param value The value stored in the mtl
  81843. * @return The Texture
  81844. */
  81845. private static _getTexture;
  81846. }
  81847. }
  81848. declare module BABYLON {
  81849. /**
  81850. * Options for loading OBJ/MTL files
  81851. */
  81852. type MeshLoadOptions = {
  81853. /**
  81854. * Defines if UVs are optimized by default during load.
  81855. */
  81856. OptimizeWithUV: boolean;
  81857. /**
  81858. * Defines custom scaling of UV coordinates of loaded meshes.
  81859. */
  81860. UVScaling: Vector2;
  81861. /**
  81862. * Invert model on y-axis (does a model scaling inversion)
  81863. */
  81864. InvertY: boolean;
  81865. /**
  81866. * Invert Y-Axis of referenced textures on load
  81867. */
  81868. InvertTextureY: boolean;
  81869. /**
  81870. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81871. */
  81872. ImportVertexColors: boolean;
  81873. /**
  81874. * Compute the normals for the model, even if normals are present in the file.
  81875. */
  81876. ComputeNormals: boolean;
  81877. /**
  81878. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81879. */
  81880. SkipMaterials: boolean;
  81881. /**
  81882. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81883. */
  81884. MaterialLoadingFailsSilently: boolean;
  81885. };
  81886. /**
  81887. * OBJ file type loader.
  81888. * This is a babylon scene loader plugin.
  81889. */
  81890. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81891. /**
  81892. * Defines if UVs are optimized by default during load.
  81893. */
  81894. static OPTIMIZE_WITH_UV: boolean;
  81895. /**
  81896. * Invert model on y-axis (does a model scaling inversion)
  81897. */
  81898. static INVERT_Y: boolean;
  81899. /**
  81900. * Invert Y-Axis of referenced textures on load
  81901. */
  81902. static get INVERT_TEXTURE_Y(): boolean;
  81903. static set INVERT_TEXTURE_Y(value: boolean);
  81904. /**
  81905. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81906. */
  81907. static IMPORT_VERTEX_COLORS: boolean;
  81908. /**
  81909. * Compute the normals for the model, even if normals are present in the file.
  81910. */
  81911. static COMPUTE_NORMALS: boolean;
  81912. /**
  81913. * Defines custom scaling of UV coordinates of loaded meshes.
  81914. */
  81915. static UV_SCALING: Vector2;
  81916. /**
  81917. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81918. */
  81919. static SKIP_MATERIALS: boolean;
  81920. /**
  81921. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81922. *
  81923. * Defaults to true for backwards compatibility.
  81924. */
  81925. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81926. /**
  81927. * Defines the name of the plugin.
  81928. */
  81929. name: string;
  81930. /**
  81931. * Defines the extension the plugin is able to load.
  81932. */
  81933. extensions: string;
  81934. /** @hidden */
  81935. obj: RegExp;
  81936. /** @hidden */
  81937. group: RegExp;
  81938. /** @hidden */
  81939. mtllib: RegExp;
  81940. /** @hidden */
  81941. usemtl: RegExp;
  81942. /** @hidden */
  81943. smooth: RegExp;
  81944. /** @hidden */
  81945. vertexPattern: RegExp;
  81946. /** @hidden */
  81947. normalPattern: RegExp;
  81948. /** @hidden */
  81949. uvPattern: RegExp;
  81950. /** @hidden */
  81951. facePattern1: RegExp;
  81952. /** @hidden */
  81953. facePattern2: RegExp;
  81954. /** @hidden */
  81955. facePattern3: RegExp;
  81956. /** @hidden */
  81957. facePattern4: RegExp;
  81958. /** @hidden */
  81959. facePattern5: RegExp;
  81960. private _forAssetContainer;
  81961. private _meshLoadOptions;
  81962. /**
  81963. * Creates loader for .OBJ files
  81964. *
  81965. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81966. */
  81967. constructor(meshLoadOptions?: MeshLoadOptions);
  81968. private static get currentMeshLoadOptions();
  81969. /**
  81970. * Calls synchronously the MTL file attached to this obj.
  81971. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81972. * Without this function materials are not displayed in the first frame (but displayed after).
  81973. * In consequence it is impossible to get material information in your HTML file
  81974. *
  81975. * @param url The URL of the MTL file
  81976. * @param rootUrl
  81977. * @param onSuccess Callback function to be called when the MTL file is loaded
  81978. * @private
  81979. */
  81980. private _loadMTL;
  81981. /**
  81982. * Instantiates a OBJ file loader plugin.
  81983. * @returns the created plugin
  81984. */
  81985. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81986. /**
  81987. * If the data string can be loaded directly.
  81988. *
  81989. * @param data string containing the file data
  81990. * @returns if the data can be loaded directly
  81991. */
  81992. canDirectLoad(data: string): boolean;
  81993. /**
  81994. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81995. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81996. * @param scene the scene the meshes should be added to
  81997. * @param data the OBJ data to load
  81998. * @param rootUrl root url to load from
  81999. * @param onProgress event that fires when loading progress has occured
  82000. * @param fileName Defines the name of the file to load
  82001. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82002. */
  82003. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82004. meshes: AbstractMesh[];
  82005. particleSystems: IParticleSystem[];
  82006. skeletons: Skeleton[];
  82007. animationGroups: AnimationGroup[];
  82008. }>;
  82009. /**
  82010. * Imports all objects from the loaded OBJ data and adds them to the scene
  82011. * @param scene the scene the objects should be added to
  82012. * @param data the OBJ data to load
  82013. * @param rootUrl root url to load from
  82014. * @param onProgress event that fires when loading progress has occured
  82015. * @param fileName Defines the name of the file to load
  82016. * @returns a promise which completes when objects have been loaded to the scene
  82017. */
  82018. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82019. /**
  82020. * Load into an asset container.
  82021. * @param scene The scene to load into
  82022. * @param data The data to import
  82023. * @param rootUrl The root url for scene and resources
  82024. * @param onProgress The callback when the load progresses
  82025. * @param fileName Defines the name of the file to load
  82026. * @returns The loaded asset container
  82027. */
  82028. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82029. /**
  82030. * Read the OBJ file and create an Array of meshes.
  82031. * Each mesh contains all information given by the OBJ and the MTL file.
  82032. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  82033. *
  82034. * @param meshesNames
  82035. * @param scene Scene The scene where are displayed the data
  82036. * @param data String The content of the obj file
  82037. * @param rootUrl String The path to the folder
  82038. * @returns Array<AbstractMesh>
  82039. * @private
  82040. */
  82041. private _parseSolid;
  82042. }
  82043. }
  82044. declare module BABYLON {
  82045. /**
  82046. * STL file type loader.
  82047. * This is a babylon scene loader plugin.
  82048. */
  82049. export class STLFileLoader implements ISceneLoaderPlugin {
  82050. /** @hidden */
  82051. solidPattern: RegExp;
  82052. /** @hidden */
  82053. facetsPattern: RegExp;
  82054. /** @hidden */
  82055. normalPattern: RegExp;
  82056. /** @hidden */
  82057. vertexPattern: RegExp;
  82058. /**
  82059. * Defines the name of the plugin.
  82060. */
  82061. name: string;
  82062. /**
  82063. * Defines the extensions the stl loader is able to load.
  82064. * force data to come in as an ArrayBuffer
  82065. * we'll convert to string if it looks like it's an ASCII .stl
  82066. */
  82067. extensions: ISceneLoaderPluginExtensions;
  82068. /**
  82069. * Import meshes into a scene.
  82070. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  82071. * @param scene The scene to import into
  82072. * @param data The data to import
  82073. * @param rootUrl The root url for scene and resources
  82074. * @param meshes The meshes array to import into
  82075. * @param particleSystems The particle systems array to import into
  82076. * @param skeletons The skeletons array to import into
  82077. * @param onError The callback when import fails
  82078. * @returns True if successful or false otherwise
  82079. */
  82080. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  82081. /**
  82082. * Load into a scene.
  82083. * @param scene The scene to load into
  82084. * @param data The data to import
  82085. * @param rootUrl The root url for scene and resources
  82086. * @param onError The callback when import fails
  82087. * @returns true if successful or false otherwise
  82088. */
  82089. load(scene: Scene, data: any, rootUrl: string): boolean;
  82090. /**
  82091. * Load into an asset container.
  82092. * @param scene The scene to load into
  82093. * @param data The data to import
  82094. * @param rootUrl The root url for scene and resources
  82095. * @param onError The callback when import fails
  82096. * @returns The loaded asset container
  82097. */
  82098. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82099. private _isBinary;
  82100. private _parseBinary;
  82101. private _parseASCII;
  82102. }
  82103. }
  82104. declare module BABYLON {
  82105. /**
  82106. * Class for generating OBJ data from a Babylon scene.
  82107. */
  82108. export class OBJExport {
  82109. /**
  82110. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82111. * @param mesh defines the list of meshes to serialize
  82112. * @param materials defines if materials should be exported
  82113. * @param matlibname defines the name of the associated mtl file
  82114. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82115. * @returns the OBJ content
  82116. */
  82117. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82118. /**
  82119. * Exports the material(s) of a mesh in .MTL file format (text)
  82120. * @param mesh defines the mesh to extract the material from
  82121. * @returns the mtl content
  82122. */
  82123. static MTL(mesh: Mesh): string;
  82124. }
  82125. }
  82126. declare module BABYLON {
  82127. /** @hidden */
  82128. export var __IGLTFExporterExtension: number;
  82129. /**
  82130. * Interface for extending the exporter
  82131. * @hidden
  82132. */
  82133. export interface IGLTFExporterExtension {
  82134. /**
  82135. * The name of this extension
  82136. */
  82137. readonly name: string;
  82138. /**
  82139. * Defines whether this extension is enabled
  82140. */
  82141. enabled: boolean;
  82142. /**
  82143. * Defines whether this extension is required
  82144. */
  82145. required: boolean;
  82146. }
  82147. }
  82148. declare module BABYLON.GLTF2.Exporter {
  82149. /** @hidden */
  82150. export var __IGLTFExporterExtensionV2: number;
  82151. /**
  82152. * Interface for a glTF exporter extension
  82153. * @hidden
  82154. */
  82155. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82156. /**
  82157. * Define this method to modify the default behavior before exporting a texture
  82158. * @param context The context when loading the asset
  82159. * @param babylonTexture The Babylon.js texture
  82160. * @param mimeType The mime-type of the generated image
  82161. * @returns A promise that resolves with the exported texture
  82162. */
  82163. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  82164. /**
  82165. * Define this method to get notified when a texture info is created
  82166. * @param context The context when loading the asset
  82167. * @param textureInfo The glTF texture info
  82168. * @param babylonTexture The Babylon.js texture
  82169. */
  82170. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82171. /**
  82172. * Define this method to modify the default behavior when exporting texture info
  82173. * @param context The context when loading the asset
  82174. * @param meshPrimitive glTF mesh primitive
  82175. * @param babylonSubMesh Babylon submesh
  82176. * @param binaryWriter glTF serializer binary writer instance
  82177. * @returns nullable IMeshPrimitive promise
  82178. */
  82179. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  82180. /**
  82181. * Define this method to modify the default behavior when exporting a node
  82182. * @param context The context when exporting the node
  82183. * @param node glTF node
  82184. * @param babylonNode BabylonJS node
  82185. * @returns nullable INode promise
  82186. */
  82187. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82188. [key: number]: number;
  82189. }): Promise<Nullable<INode>>;
  82190. /**
  82191. * Define this method to modify the default behavior when exporting a material
  82192. * @param material glTF material
  82193. * @param babylonMaterial BabylonJS material
  82194. * @returns nullable IMaterial promise
  82195. */
  82196. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  82197. /**
  82198. * Define this method to return additional textures to export from a material
  82199. * @param material glTF material
  82200. * @param babylonMaterial BabylonJS material
  82201. * @returns List of textures
  82202. */
  82203. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82204. /** Gets a boolean indicating that this extension was used */
  82205. wasUsed: boolean;
  82206. /** Gets a boolean indicating that this extension is required for the file to work */
  82207. required: boolean;
  82208. /**
  82209. * Called after the exporter state changes to EXPORTING
  82210. */
  82211. onExporting?(): void;
  82212. }
  82213. }
  82214. declare module BABYLON.GLTF2.Exporter {
  82215. /**
  82216. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  82217. * @hidden
  82218. */
  82219. export class _GLTFMaterialExporter {
  82220. /**
  82221. * Represents the dielectric specular values for R, G and B
  82222. */
  82223. private static readonly _DielectricSpecular;
  82224. /**
  82225. * Allows the maximum specular power to be defined for material calculations
  82226. */
  82227. private static readonly _MaxSpecularPower;
  82228. /**
  82229. * Mapping to store textures
  82230. */
  82231. private _textureMap;
  82232. /**
  82233. * Numeric tolerance value
  82234. */
  82235. private static readonly _Epsilon;
  82236. /**
  82237. * Reference to the glTF Exporter
  82238. */
  82239. private _exporter;
  82240. constructor(exporter: _Exporter);
  82241. /**
  82242. * Specifies if two colors are approximately equal in value
  82243. * @param color1 first color to compare to
  82244. * @param color2 second color to compare to
  82245. * @param epsilon threshold value
  82246. */
  82247. private static FuzzyEquals;
  82248. /**
  82249. * Gets the materials from a Babylon scene and converts them to glTF materials
  82250. * @param scene babylonjs scene
  82251. * @param mimeType texture mime type
  82252. * @param images array of images
  82253. * @param textures array of textures
  82254. * @param materials array of materials
  82255. * @param imageData mapping of texture names to base64 textures
  82256. * @param hasTextureCoords specifies if texture coordinates are present on the material
  82257. */
  82258. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  82259. /**
  82260. * Makes a copy of the glTF material without the texture parameters
  82261. * @param originalMaterial original glTF material
  82262. * @returns glTF material without texture parameters
  82263. */
  82264. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  82265. /**
  82266. * Specifies if the material has any texture parameters present
  82267. * @param material glTF Material
  82268. * @returns boolean specifying if texture parameters are present
  82269. */
  82270. _hasTexturesPresent(material: IMaterial): boolean;
  82271. /**
  82272. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  82273. * @param babylonStandardMaterial
  82274. * @returns glTF Metallic Roughness Material representation
  82275. */
  82276. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  82277. /**
  82278. * Computes the metallic factor
  82279. * @param diffuse diffused value
  82280. * @param specular specular value
  82281. * @param oneMinusSpecularStrength one minus the specular strength
  82282. * @returns metallic value
  82283. */
  82284. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  82285. /**
  82286. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  82287. * @param glTFMaterial glTF material
  82288. * @param babylonMaterial Babylon material
  82289. */
  82290. private static _SetAlphaMode;
  82291. /**
  82292. * Converts a Babylon Standard Material to a glTF Material
  82293. * @param babylonStandardMaterial BJS Standard Material
  82294. * @param mimeType mime type to use for the textures
  82295. * @param images array of glTF image interfaces
  82296. * @param textures array of glTF texture interfaces
  82297. * @param materials array of glTF material interfaces
  82298. * @param imageData map of image file name to data
  82299. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82300. */
  82301. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82302. private _finishMaterial;
  82303. /**
  82304. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82305. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  82306. * @param mimeType mime type to use for the textures
  82307. * @param images array of glTF image interfaces
  82308. * @param textures array of glTF texture interfaces
  82309. * @param materials array of glTF material interfaces
  82310. * @param imageData map of image file name to data
  82311. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82312. */
  82313. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82314. /**
  82315. * Converts an image typed array buffer to a base64 image
  82316. * @param buffer typed array buffer
  82317. * @param width width of the image
  82318. * @param height height of the image
  82319. * @param mimeType mimetype of the image
  82320. * @returns base64 image string
  82321. */
  82322. private _createBase64FromCanvasAsync;
  82323. /**
  82324. * Generates a white texture based on the specified width and height
  82325. * @param width width of the texture in pixels
  82326. * @param height height of the texture in pixels
  82327. * @param scene babylonjs scene
  82328. * @returns white texture
  82329. */
  82330. private _createWhiteTexture;
  82331. /**
  82332. * 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
  82333. * @param texture1 first texture to resize
  82334. * @param texture2 second texture to resize
  82335. * @param scene babylonjs scene
  82336. * @returns resized textures or null
  82337. */
  82338. private _resizeTexturesToSameDimensions;
  82339. /**
  82340. * Converts an array of pixels to a Float32Array
  82341. * Throws an error if the pixel format is not supported
  82342. * @param pixels - array buffer containing pixel values
  82343. * @returns Float32 of pixels
  82344. */
  82345. private _convertPixelArrayToFloat32;
  82346. /**
  82347. * Convert Specular Glossiness Textures to Metallic Roughness
  82348. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  82349. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  82350. * @param diffuseTexture texture used to store diffuse information
  82351. * @param specularGlossinessTexture texture used to store specular and glossiness information
  82352. * @param factors specular glossiness material factors
  82353. * @param mimeType the mime type to use for the texture
  82354. * @returns pbr metallic roughness interface or null
  82355. */
  82356. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  82357. /**
  82358. * Converts specular glossiness material properties to metallic roughness
  82359. * @param specularGlossiness interface with specular glossiness material properties
  82360. * @returns interface with metallic roughness material properties
  82361. */
  82362. private _convertSpecularGlossinessToMetallicRoughness;
  82363. /**
  82364. * Calculates the surface reflectance, independent of lighting conditions
  82365. * @param color Color source to calculate brightness from
  82366. * @returns number representing the perceived brightness, or zero if color is undefined
  82367. */
  82368. private _getPerceivedBrightness;
  82369. /**
  82370. * Returns the maximum color component value
  82371. * @param color
  82372. * @returns maximum color component value, or zero if color is null or undefined
  82373. */
  82374. private _getMaxComponent;
  82375. /**
  82376. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  82377. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82378. * @param mimeType mime type to use for the textures
  82379. * @param images array of glTF image interfaces
  82380. * @param textures array of glTF texture interfaces
  82381. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82382. * @param imageData map of image file name to data
  82383. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82384. * @returns glTF PBR Metallic Roughness factors
  82385. */
  82386. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82387. private _getGLTFTextureSampler;
  82388. private _getGLTFTextureWrapMode;
  82389. private _getGLTFTextureWrapModesSampler;
  82390. /**
  82391. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82392. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82393. * @param mimeType mime type to use for the textures
  82394. * @param images array of glTF image interfaces
  82395. * @param textures array of glTF texture interfaces
  82396. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82397. * @param imageData map of image file name to data
  82398. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82399. * @returns glTF PBR Metallic Roughness factors
  82400. */
  82401. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82402. /**
  82403. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82404. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82405. * @param mimeType mime type to use for the textures
  82406. * @param images array of glTF image interfaces
  82407. * @param textures array of glTF texture interfaces
  82408. * @param materials array of glTF material interfaces
  82409. * @param imageData map of image file name to data
  82410. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82411. */
  82412. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82413. private setMetallicRoughnessPbrMaterial;
  82414. private getPixelsFromTexture;
  82415. /**
  82416. * Extracts a texture from a Babylon texture into file data and glTF data
  82417. * @param babylonTexture Babylon texture to extract
  82418. * @param mimeType Mime Type of the babylonTexture
  82419. * @return glTF texture info, or null if the texture format is not supported
  82420. */
  82421. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82422. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82423. /**
  82424. * Builds a texture from base64 string
  82425. * @param base64Texture base64 texture string
  82426. * @param baseTextureName Name to use for the texture
  82427. * @param mimeType image mime type for the texture
  82428. * @param images array of images
  82429. * @param textures array of textures
  82430. * @param imageData map of image data
  82431. * @returns glTF texture info, or null if the texture format is not supported
  82432. */
  82433. private _getTextureInfoFromBase64;
  82434. }
  82435. }
  82436. declare module BABYLON {
  82437. /**
  82438. * Class for holding and downloading glTF file data
  82439. */
  82440. export class GLTFData {
  82441. /**
  82442. * Object which contains the file name as the key and its data as the value
  82443. */
  82444. glTFFiles: {
  82445. [fileName: string]: string | Blob;
  82446. };
  82447. /**
  82448. * Initializes the glTF file object
  82449. */
  82450. constructor();
  82451. /**
  82452. * Downloads the glTF data as files based on their names and data
  82453. */
  82454. downloadFiles(): void;
  82455. }
  82456. }
  82457. declare module BABYLON {
  82458. /**
  82459. * Holds a collection of exporter options and parameters
  82460. */
  82461. export interface IExportOptions {
  82462. /**
  82463. * Function which indicates whether a babylon node should be exported or not
  82464. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  82465. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  82466. */
  82467. shouldExportNode?(node: Node): boolean;
  82468. /**
  82469. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  82470. * @param metadata source metadata to read from
  82471. * @returns the data to store to glTF node extras
  82472. */
  82473. metadataSelector?(metadata: any): any;
  82474. /**
  82475. * The sample rate to bake animation curves
  82476. */
  82477. animationSampleRate?: number;
  82478. /**
  82479. * Begin serialization without waiting for the scene to be ready
  82480. */
  82481. exportWithoutWaitingForScene?: boolean;
  82482. /**
  82483. * Indicates if coordinate system swapping root nodes should be included in export
  82484. */
  82485. includeCoordinateSystemConversionNodes?: boolean;
  82486. }
  82487. /**
  82488. * Class for generating glTF data from a Babylon scene.
  82489. */
  82490. export class GLTF2Export {
  82491. /**
  82492. * Exports the geometry of the scene to .gltf file format asynchronously
  82493. * @param scene Babylon scene with scene hierarchy information
  82494. * @param filePrefix File prefix to use when generating the glTF file
  82495. * @param options Exporter options
  82496. * @returns Returns an object with a .gltf file and associates texture names
  82497. * as keys and their data and paths as values
  82498. */
  82499. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82500. private static _PreExportAsync;
  82501. private static _PostExportAsync;
  82502. /**
  82503. * Exports the geometry of the scene to .glb file format asychronously
  82504. * @param scene Babylon scene with scene hierarchy information
  82505. * @param filePrefix File prefix to use when generating glb file
  82506. * @param options Exporter options
  82507. * @returns Returns an object with a .glb filename as key and data as value
  82508. */
  82509. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82510. }
  82511. }
  82512. declare module BABYLON.GLTF2.Exporter {
  82513. /**
  82514. * @hidden
  82515. */
  82516. export class _GLTFUtilities {
  82517. /**
  82518. * Creates a buffer view based on the supplied arguments
  82519. * @param bufferIndex index value of the specified buffer
  82520. * @param byteOffset byte offset value
  82521. * @param byteLength byte length of the bufferView
  82522. * @param byteStride byte distance between conequential elements
  82523. * @param name name of the buffer view
  82524. * @returns bufferView for glTF
  82525. */
  82526. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  82527. /**
  82528. * Creates an accessor based on the supplied arguments
  82529. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  82530. * @param name The name of the accessor
  82531. * @param type The type of the accessor
  82532. * @param componentType The datatype of components in the attribute
  82533. * @param count The number of attributes referenced by this accessor
  82534. * @param byteOffset The offset relative to the start of the bufferView in bytes
  82535. * @param min Minimum value of each component in this attribute
  82536. * @param max Maximum value of each component in this attribute
  82537. * @returns accessor for glTF
  82538. */
  82539. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  82540. /**
  82541. * Calculates the minimum and maximum values of an array of position floats
  82542. * @param positions Positions array of a mesh
  82543. * @param vertexStart Starting vertex offset to calculate min and max values
  82544. * @param vertexCount Number of vertices to check for min and max values
  82545. * @returns min number array and max number array
  82546. */
  82547. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  82548. min: number[];
  82549. max: number[];
  82550. };
  82551. /**
  82552. * Converts a new right-handed Vector3
  82553. * @param vector vector3 array
  82554. * @returns right-handed Vector3
  82555. */
  82556. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  82557. /**
  82558. * Converts a Vector3 to right-handed
  82559. * @param vector Vector3 to convert to right-handed
  82560. */
  82561. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  82562. /**
  82563. * Converts a three element number array to right-handed
  82564. * @param vector number array to convert to right-handed
  82565. */
  82566. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  82567. /**
  82568. * Converts a new right-handed Vector3
  82569. * @param vector vector3 array
  82570. * @returns right-handed Vector3
  82571. */
  82572. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  82573. /**
  82574. * Converts a Vector3 to right-handed
  82575. * @param vector Vector3 to convert to right-handed
  82576. */
  82577. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  82578. /**
  82579. * Converts a three element number array to right-handed
  82580. * @param vector number array to convert to right-handed
  82581. */
  82582. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  82583. /**
  82584. * Converts a Vector4 to right-handed
  82585. * @param vector Vector4 to convert to right-handed
  82586. */
  82587. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  82588. /**
  82589. * Converts a Vector4 to right-handed
  82590. * @param vector Vector4 to convert to right-handed
  82591. */
  82592. static _GetRightHandedArray4FromRef(vector: number[]): void;
  82593. /**
  82594. * Converts a Quaternion to right-handed
  82595. * @param quaternion Source quaternion to convert to right-handed
  82596. */
  82597. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  82598. /**
  82599. * Converts a Quaternion to right-handed
  82600. * @param quaternion Source quaternion to convert to right-handed
  82601. */
  82602. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  82603. static _NormalizeTangentFromRef(tangent: Vector4): void;
  82604. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  82605. }
  82606. }
  82607. declare module BABYLON.GLTF2.Exporter {
  82608. /**
  82609. * Converts Babylon Scene into glTF 2.0.
  82610. * @hidden
  82611. */
  82612. export class _Exporter {
  82613. /**
  82614. * Stores the glTF to export
  82615. */
  82616. _glTF: IGLTF;
  82617. /**
  82618. * Stores all generated buffer views, which represents views into the main glTF buffer data
  82619. */
  82620. _bufferViews: IBufferView[];
  82621. /**
  82622. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  82623. */
  82624. _accessors: IAccessor[];
  82625. /**
  82626. * Stores all the generated nodes, which contains transform and/or mesh information per node
  82627. */
  82628. _nodes: INode[];
  82629. /**
  82630. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  82631. */
  82632. private _scenes;
  82633. /**
  82634. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  82635. */
  82636. private _meshes;
  82637. /**
  82638. * Stores all the generated material information, which represents the appearance of each primitive
  82639. */
  82640. _materials: IMaterial[];
  82641. _materialMap: {
  82642. [materialID: number]: number;
  82643. };
  82644. /**
  82645. * Stores all the generated texture information, which is referenced by glTF materials
  82646. */
  82647. _textures: ITexture[];
  82648. /**
  82649. * Stores all the generated image information, which is referenced by glTF textures
  82650. */
  82651. _images: IImage[];
  82652. /**
  82653. * Stores all the texture samplers
  82654. */
  82655. _samplers: ISampler[];
  82656. /**
  82657. * Stores all the generated glTF skins
  82658. */
  82659. _skins: ISkin[];
  82660. /**
  82661. * Stores all the generated animation samplers, which is referenced by glTF animations
  82662. */
  82663. /**
  82664. * Stores the animations for glTF models
  82665. */
  82666. private _animations;
  82667. /**
  82668. * Stores the total amount of bytes stored in the glTF buffer
  82669. */
  82670. private _totalByteLength;
  82671. /**
  82672. * Stores a reference to the Babylon scene containing the source geometry and material information
  82673. */
  82674. _babylonScene: Scene;
  82675. /**
  82676. * Stores a map of the image data, where the key is the file name and the value
  82677. * is the image data
  82678. */
  82679. _imageData: {
  82680. [fileName: string]: {
  82681. data: Uint8Array;
  82682. mimeType: ImageMimeType;
  82683. };
  82684. };
  82685. /**
  82686. * Stores a map of the unique id of a node to its index in the node array
  82687. */
  82688. _nodeMap: {
  82689. [key: number]: number;
  82690. };
  82691. /**
  82692. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82693. */
  82694. _convertToRightHandedSystem: boolean;
  82695. /**
  82696. * Specifies if a Babylon node should be converted to right-handed on export
  82697. */
  82698. _convertToRightHandedSystemMap: {
  82699. [nodeId: number]: boolean;
  82700. };
  82701. _includeCoordinateSystemConversionNodes: boolean;
  82702. /**
  82703. * Baked animation sample rate
  82704. */
  82705. private _animationSampleRate;
  82706. private _options;
  82707. private _localEngine;
  82708. _glTFMaterialExporter: _GLTFMaterialExporter;
  82709. private _extensions;
  82710. private static _ExtensionNames;
  82711. private static _ExtensionFactories;
  82712. private _applyExtension;
  82713. private _applyExtensions;
  82714. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82715. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82716. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82717. [key: number]: number;
  82718. }): Promise<Nullable<INode>>;
  82719. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82720. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82721. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82722. private _forEachExtensions;
  82723. private _extensionsOnExporting;
  82724. /**
  82725. * Load glTF serializer extensions
  82726. */
  82727. private _loadExtensions;
  82728. /**
  82729. * Creates a glTF Exporter instance, which can accept optional exporter options
  82730. * @param babylonScene Babylon scene object
  82731. * @param options Options to modify the behavior of the exporter
  82732. */
  82733. constructor(babylonScene: Scene, options?: IExportOptions);
  82734. dispose(): void;
  82735. /**
  82736. * Registers a glTF exporter extension
  82737. * @param name Name of the extension to export
  82738. * @param factory The factory function that creates the exporter extension
  82739. */
  82740. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82741. /**
  82742. * Un-registers an exporter extension
  82743. * @param name The name fo the exporter extension
  82744. * @returns A boolean indicating whether the extension has been un-registered
  82745. */
  82746. static UnregisterExtension(name: string): boolean;
  82747. /**
  82748. * Lazy load a local engine
  82749. */
  82750. _getLocalEngine(): Engine;
  82751. private reorderIndicesBasedOnPrimitiveMode;
  82752. /**
  82753. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82754. * clock-wise during export to glTF
  82755. * @param submesh BabylonJS submesh
  82756. * @param primitiveMode Primitive mode of the mesh
  82757. * @param sideOrientation the winding order of the submesh
  82758. * @param vertexBufferKind The type of vertex attribute
  82759. * @param meshAttributeArray The vertex attribute data
  82760. * @param byteOffset The offset to the binary data
  82761. * @param binaryWriter The binary data for the glTF file
  82762. * @param convertToRightHandedSystem Converts the values to right-handed
  82763. */
  82764. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82765. /**
  82766. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82767. * clock-wise during export to glTF
  82768. * @param submesh BabylonJS submesh
  82769. * @param primitiveMode Primitive mode of the mesh
  82770. * @param sideOrientation the winding order of the submesh
  82771. * @param vertexBufferKind The type of vertex attribute
  82772. * @param meshAttributeArray The vertex attribute data
  82773. * @param byteOffset The offset to the binary data
  82774. * @param binaryWriter The binary data for the glTF file
  82775. * @param convertToRightHandedSystem Converts the values to right-handed
  82776. */
  82777. private reorderTriangleFillMode;
  82778. /**
  82779. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82780. * clock-wise during export to glTF
  82781. * @param submesh BabylonJS submesh
  82782. * @param primitiveMode Primitive mode of the mesh
  82783. * @param sideOrientation the winding order of the submesh
  82784. * @param vertexBufferKind The type of vertex attribute
  82785. * @param meshAttributeArray The vertex attribute data
  82786. * @param byteOffset The offset to the binary data
  82787. * @param binaryWriter The binary data for the glTF file
  82788. * @param convertToRightHandedSystem Converts the values to right-handed
  82789. */
  82790. private reorderTriangleStripDrawMode;
  82791. /**
  82792. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82793. * clock-wise during export to glTF
  82794. * @param submesh BabylonJS submesh
  82795. * @param primitiveMode Primitive mode of the mesh
  82796. * @param sideOrientation the winding order of the submesh
  82797. * @param vertexBufferKind The type of vertex attribute
  82798. * @param meshAttributeArray The vertex attribute data
  82799. * @param byteOffset The offset to the binary data
  82800. * @param binaryWriter The binary data for the glTF file
  82801. * @param convertToRightHandedSystem Converts the values to right-handed
  82802. */
  82803. private reorderTriangleFanMode;
  82804. /**
  82805. * Writes the vertex attribute data to binary
  82806. * @param vertices The vertices to write to the binary writer
  82807. * @param byteOffset The offset into the binary writer to overwrite binary data
  82808. * @param vertexAttributeKind The vertex attribute type
  82809. * @param meshAttributeArray The vertex attribute data
  82810. * @param binaryWriter The writer containing the binary data
  82811. * @param convertToRightHandedSystem Converts the values to right-handed
  82812. */
  82813. private writeVertexAttributeData;
  82814. /**
  82815. * Writes mesh attribute data to a data buffer
  82816. * Returns the bytelength of the data
  82817. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82818. * @param meshAttributeArray Array containing the attribute data
  82819. * @param byteStride Specifies the space between data
  82820. * @param binaryWriter The buffer to write the binary data to
  82821. * @param convertToRightHandedSystem Converts the values to right-handed
  82822. */
  82823. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  82824. /**
  82825. * Generates glTF json data
  82826. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82827. * @param glTFPrefix Text to use when prefixing a glTF file
  82828. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82829. * @returns json data as string
  82830. */
  82831. private generateJSON;
  82832. /**
  82833. * Generates data for .gltf and .bin files based on the glTF prefix string
  82834. * @param glTFPrefix Text to use when prefixing a glTF file
  82835. * @param dispose Dispose the exporter
  82836. * @returns GLTFData with glTF file data
  82837. */
  82838. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82839. /**
  82840. * Creates a binary buffer for glTF
  82841. * @returns array buffer for binary data
  82842. */
  82843. private _generateBinaryAsync;
  82844. /**
  82845. * Pads the number to a multiple of 4
  82846. * @param num number to pad
  82847. * @returns padded number
  82848. */
  82849. private _getPadding;
  82850. /**
  82851. * @hidden
  82852. */
  82853. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82854. /**
  82855. * Sets the TRS for each node
  82856. * @param node glTF Node for storing the transformation data
  82857. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82858. * @param convertToRightHandedSystem Converts the values to right-handed
  82859. */
  82860. private setNodeTransformation;
  82861. private getVertexBufferFromMesh;
  82862. /**
  82863. * Creates a bufferview based on the vertices type for the Babylon mesh
  82864. * @param kind Indicates the type of vertices data
  82865. * @param componentType Indicates the numerical type used to store the data
  82866. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82867. * @param binaryWriter The buffer to write the bufferview data to
  82868. * @param convertToRightHandedSystem Converts the values to right-handed
  82869. */
  82870. private createBufferViewKind;
  82871. /**
  82872. * The primitive mode of the Babylon mesh
  82873. * @param babylonMesh The BabylonJS mesh
  82874. */
  82875. private getMeshPrimitiveMode;
  82876. /**
  82877. * Sets the primitive mode of the glTF mesh primitive
  82878. * @param meshPrimitive glTF mesh primitive
  82879. * @param primitiveMode The primitive mode
  82880. */
  82881. private setPrimitiveMode;
  82882. /**
  82883. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82884. * @param meshPrimitive glTF mesh primitive
  82885. * @param attributeKind vertex attribute
  82886. * @returns boolean specifying if uv coordinates are present
  82887. */
  82888. private setAttributeKind;
  82889. /**
  82890. * Sets data for the primitive attributes of each submesh
  82891. * @param mesh glTF Mesh object to store the primitive attribute information
  82892. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82893. * @param binaryWriter Buffer to write the attribute data to
  82894. * @param convertToRightHandedSystem Converts the values to right-handed
  82895. */
  82896. private setPrimitiveAttributesAsync;
  82897. /**
  82898. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82899. * @param node The node to check
  82900. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82901. */
  82902. private isBabylonCoordinateSystemConvertingNode;
  82903. /**
  82904. * Creates a glTF scene based on the array of meshes
  82905. * Returns the the total byte offset
  82906. * @param babylonScene Babylon scene to get the mesh data from
  82907. * @param binaryWriter Buffer to write binary data to
  82908. */
  82909. private createSceneAsync;
  82910. /**
  82911. * Creates a mapping of Node unique id to node index and handles animations
  82912. * @param babylonScene Babylon Scene
  82913. * @param nodes Babylon transform nodes
  82914. * @param binaryWriter Buffer to write binary data to
  82915. * @returns Node mapping of unique id to index
  82916. */
  82917. private createNodeMapAndAnimationsAsync;
  82918. /**
  82919. * Creates a glTF node from a Babylon mesh
  82920. * @param babylonMesh Source Babylon mesh
  82921. * @param binaryWriter Buffer for storing geometry data
  82922. * @param convertToRightHandedSystem Converts the values to right-handed
  82923. * @param nodeMap Node mapping of unique id to glTF node index
  82924. * @returns glTF node
  82925. */
  82926. private createNodeAsync;
  82927. /**
  82928. * Creates a glTF skin from a Babylon skeleton
  82929. * @param babylonScene Babylon Scene
  82930. * @param nodes Babylon transform nodes
  82931. * @param binaryWriter Buffer to write binary data to
  82932. * @returns Node mapping of unique id to index
  82933. */
  82934. private createSkinsAsync;
  82935. }
  82936. /**
  82937. * @hidden
  82938. *
  82939. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82940. */
  82941. export class _BinaryWriter {
  82942. /**
  82943. * Array buffer which stores all binary data
  82944. */
  82945. private _arrayBuffer;
  82946. /**
  82947. * View of the array buffer
  82948. */
  82949. private _dataView;
  82950. /**
  82951. * byte offset of data in array buffer
  82952. */
  82953. private _byteOffset;
  82954. /**
  82955. * Initialize binary writer with an initial byte length
  82956. * @param byteLength Initial byte length of the array buffer
  82957. */
  82958. constructor(byteLength: number);
  82959. /**
  82960. * Resize the array buffer to the specified byte length
  82961. * @param byteLength
  82962. */
  82963. private resizeBuffer;
  82964. /**
  82965. * Get an array buffer with the length of the byte offset
  82966. * @returns ArrayBuffer resized to the byte offset
  82967. */
  82968. getArrayBuffer(): ArrayBuffer;
  82969. /**
  82970. * Get the byte offset of the array buffer
  82971. * @returns byte offset
  82972. */
  82973. getByteOffset(): number;
  82974. /**
  82975. * Stores an UInt8 in the array buffer
  82976. * @param entry
  82977. * @param byteOffset If defined, specifies where to set the value as an offset.
  82978. */
  82979. setUInt8(entry: number, byteOffset?: number): void;
  82980. /**
  82981. * Stores an UInt16 in the array buffer
  82982. * @param entry
  82983. * @param byteOffset If defined, specifies where to set the value as an offset.
  82984. */
  82985. setUInt16(entry: number, byteOffset?: number): void;
  82986. /**
  82987. * Gets an UInt32 in the array buffer
  82988. * @param entry
  82989. * @param byteOffset If defined, specifies where to set the value as an offset.
  82990. */
  82991. getUInt32(byteOffset: number): number;
  82992. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82993. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82994. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82995. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82996. /**
  82997. * Stores a Float32 in the array buffer
  82998. * @param entry
  82999. */
  83000. setFloat32(entry: number, byteOffset?: number): void;
  83001. /**
  83002. * Stores an UInt32 in the array buffer
  83003. * @param entry
  83004. * @param byteOffset If defined, specifies where to set the value as an offset.
  83005. */
  83006. setUInt32(entry: number, byteOffset?: number): void;
  83007. }
  83008. }
  83009. declare module BABYLON.GLTF2.Exporter {
  83010. /**
  83011. * @hidden
  83012. * Interface to store animation data.
  83013. */
  83014. export interface _IAnimationData {
  83015. /**
  83016. * Keyframe data.
  83017. */
  83018. inputs: number[];
  83019. /**
  83020. * Value data.
  83021. */
  83022. outputs: number[][];
  83023. /**
  83024. * Animation interpolation data.
  83025. */
  83026. samplerInterpolation: AnimationSamplerInterpolation;
  83027. /**
  83028. * Minimum keyframe value.
  83029. */
  83030. inputsMin: number;
  83031. /**
  83032. * Maximum keyframe value.
  83033. */
  83034. inputsMax: number;
  83035. }
  83036. /**
  83037. * @hidden
  83038. */
  83039. export interface _IAnimationInfo {
  83040. /**
  83041. * The target channel for the animation
  83042. */
  83043. animationChannelTargetPath: AnimationChannelTargetPath;
  83044. /**
  83045. * The glTF accessor type for the data.
  83046. */
  83047. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  83048. /**
  83049. * Specifies if quaternions should be used.
  83050. */
  83051. useQuaternion: boolean;
  83052. }
  83053. /**
  83054. * @hidden
  83055. * Utility class for generating glTF animation data from BabylonJS.
  83056. */
  83057. export class _GLTFAnimation {
  83058. /**
  83059. * @ignore
  83060. *
  83061. * Creates glTF channel animation from BabylonJS animation.
  83062. * @param babylonTransformNode - BabylonJS mesh.
  83063. * @param animation - animation.
  83064. * @param animationChannelTargetPath - The target animation channel.
  83065. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  83066. * @param useQuaternion - Specifies if quaternions are used.
  83067. * @returns nullable IAnimationData
  83068. */
  83069. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  83070. private static _DeduceAnimationInfo;
  83071. /**
  83072. * @ignore
  83073. * Create node animations from the transform node animations
  83074. * @param babylonNode
  83075. * @param runtimeGLTFAnimation
  83076. * @param idleGLTFAnimations
  83077. * @param nodeMap
  83078. * @param nodes
  83079. * @param binaryWriter
  83080. * @param bufferViews
  83081. * @param accessors
  83082. * @param convertToRightHandedSystem
  83083. * @param animationSampleRate
  83084. */
  83085. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83086. [key: number]: number;
  83087. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83088. /**
  83089. * @ignore
  83090. * Create node animations from the animation groups
  83091. * @param babylonScene
  83092. * @param glTFAnimations
  83093. * @param nodeMap
  83094. * @param nodes
  83095. * @param binaryWriter
  83096. * @param bufferViews
  83097. * @param accessors
  83098. * @param convertToRightHandedSystemMap
  83099. * @param animationSampleRate
  83100. */
  83101. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  83102. [key: number]: number;
  83103. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  83104. [nodeId: number]: boolean;
  83105. }, animationSampleRate: number): void;
  83106. private static AddAnimation;
  83107. /**
  83108. * Create a baked animation
  83109. * @param babylonTransformNode BabylonJS mesh
  83110. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83111. * @param animationChannelTargetPath animation target channel
  83112. * @param minFrame minimum animation frame
  83113. * @param maxFrame maximum animation frame
  83114. * @param fps frames per second of the animation
  83115. * @param inputs input key frames of the animation
  83116. * @param outputs output key frame data of the animation
  83117. * @param convertToRightHandedSystem converts the values to right-handed
  83118. * @param useQuaternion specifies if quaternions should be used
  83119. */
  83120. private static _CreateBakedAnimation;
  83121. private static _ConvertFactorToVector3OrQuaternion;
  83122. private static _SetInterpolatedValue;
  83123. /**
  83124. * Creates linear animation from the animation key frames
  83125. * @param babylonTransformNode BabylonJS mesh
  83126. * @param animation BabylonJS animation
  83127. * @param animationChannelTargetPath The target animation channel
  83128. * @param frameDelta The difference between the last and first frame of the animation
  83129. * @param inputs Array to store the key frame times
  83130. * @param outputs Array to store the key frame data
  83131. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83132. * @param useQuaternion Specifies if quaternions are used in the animation
  83133. */
  83134. private static _CreateLinearOrStepAnimation;
  83135. /**
  83136. * Creates cubic spline animation from the animation key frames
  83137. * @param babylonTransformNode BabylonJS mesh
  83138. * @param animation BabylonJS animation
  83139. * @param animationChannelTargetPath The target animation channel
  83140. * @param frameDelta The difference between the last and first frame of the animation
  83141. * @param inputs Array to store the key frame times
  83142. * @param outputs Array to store the key frame data
  83143. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83144. * @param useQuaternion Specifies if quaternions are used in the animation
  83145. */
  83146. private static _CreateCubicSplineAnimation;
  83147. private static _GetBasePositionRotationOrScale;
  83148. /**
  83149. * Adds a key frame value
  83150. * @param keyFrame
  83151. * @param animation
  83152. * @param outputs
  83153. * @param animationChannelTargetPath
  83154. * @param basePositionRotationOrScale
  83155. * @param convertToRightHandedSystem
  83156. * @param useQuaternion
  83157. */
  83158. private static _AddKeyframeValue;
  83159. /**
  83160. * Determine the interpolation based on the key frames
  83161. * @param keyFrames
  83162. * @param animationChannelTargetPath
  83163. * @param useQuaternion
  83164. */
  83165. private static _DeduceInterpolation;
  83166. /**
  83167. * Adds an input tangent or output tangent to the output data
  83168. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  83169. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  83170. * @param outputs The animation data by keyframe
  83171. * @param animationChannelTargetPath The target animation channel
  83172. * @param interpolation The interpolation type
  83173. * @param keyFrame The key frame with the animation data
  83174. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  83175. * @param useQuaternion Specifies if quaternions are used
  83176. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  83177. */
  83178. private static AddSplineTangent;
  83179. /**
  83180. * Get the minimum and maximum key frames' frame values
  83181. * @param keyFrames animation key frames
  83182. * @returns the minimum and maximum key frame value
  83183. */
  83184. private static calculateMinMaxKeyFrames;
  83185. }
  83186. }
  83187. declare module BABYLON.GLTF2.Exporter {
  83188. /** @hidden */
  83189. export var textureTransformPixelShader: {
  83190. name: string;
  83191. shader: string;
  83192. };
  83193. }
  83194. declare module BABYLON.GLTF2.Exporter.Extensions {
  83195. /**
  83196. * @hidden
  83197. */
  83198. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  83199. private _recordedTextures;
  83200. /** Name of this extension */
  83201. readonly name: string;
  83202. /** Defines whether this extension is enabled */
  83203. enabled: boolean;
  83204. /** Defines whether this extension is required */
  83205. required: boolean;
  83206. /** Reference to the glTF exporter */
  83207. private _wasUsed;
  83208. constructor(exporter: _Exporter);
  83209. dispose(): void;
  83210. /** @hidden */
  83211. get wasUsed(): boolean;
  83212. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83213. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  83214. /**
  83215. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  83216. * @param babylonTexture
  83217. * @param offset
  83218. * @param rotation
  83219. * @param scale
  83220. * @param scene
  83221. */
  83222. private _textureTransformTextureAsync;
  83223. }
  83224. }
  83225. declare module BABYLON.GLTF2.Exporter.Extensions {
  83226. /**
  83227. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  83228. */
  83229. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  83230. /** The name of this extension. */
  83231. readonly name: string;
  83232. /** Defines whether this extension is enabled. */
  83233. enabled: boolean;
  83234. /** Defines whether this extension is required */
  83235. required: boolean;
  83236. /** Reference to the glTF exporter */
  83237. private _exporter;
  83238. private _lights;
  83239. /** @hidden */
  83240. constructor(exporter: _Exporter);
  83241. /** @hidden */
  83242. dispose(): void;
  83243. /** @hidden */
  83244. get wasUsed(): boolean;
  83245. /** @hidden */
  83246. onExporting(): void;
  83247. /**
  83248. * Define this method to modify the default behavior when exporting a node
  83249. * @param context The context when exporting the node
  83250. * @param node glTF node
  83251. * @param babylonNode BabylonJS node
  83252. * @param nodeMap Node mapping of unique id to glTF node index
  83253. * @returns nullable INode promise
  83254. */
  83255. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83256. [key: number]: number;
  83257. }): Promise<Nullable<INode>>;
  83258. }
  83259. }
  83260. declare module BABYLON.GLTF2.Exporter.Extensions {
  83261. /**
  83262. * @hidden
  83263. */
  83264. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  83265. /** Name of this extension */
  83266. readonly name: string;
  83267. /** Defines whether this extension is enabled */
  83268. enabled: boolean;
  83269. /** Defines whether this extension is required */
  83270. required: boolean;
  83271. /** Reference to the glTF exporter */
  83272. private _textureInfos;
  83273. private _exportedTextures;
  83274. private _wasUsed;
  83275. constructor(exporter: _Exporter);
  83276. dispose(): void;
  83277. /** @hidden */
  83278. get wasUsed(): boolean;
  83279. private _getTextureIndex;
  83280. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83281. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83282. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83283. }
  83284. }
  83285. declare module BABYLON.GLTF2.Exporter.Extensions {
  83286. /**
  83287. * @hidden
  83288. */
  83289. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  83290. /** Name of this extension */
  83291. readonly name: string;
  83292. /** Defines whether this extension is enabled */
  83293. enabled: boolean;
  83294. /** Defines whether this extension is required */
  83295. required: boolean;
  83296. private _wasUsed;
  83297. constructor(exporter: _Exporter);
  83298. /** @hidden */
  83299. get wasUsed(): boolean;
  83300. dispose(): void;
  83301. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83302. }
  83303. }
  83304. declare module BABYLON {
  83305. /**
  83306. * Class for generating STL data from a Babylon scene.
  83307. */
  83308. export class STLExport {
  83309. /**
  83310. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  83311. * @param meshes list defines the mesh to serialize
  83312. * @param download triggers the automatic download of the file.
  83313. * @param fileName changes the downloads fileName.
  83314. * @param binary changes the STL to a binary type.
  83315. * @param isLittleEndian toggle for binary type exporter.
  83316. * @returns the STL as UTF8 string
  83317. */
  83318. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  83319. }
  83320. }
  83321. declare module "babylonjs-gltf2interface" {
  83322. export = BABYLON.GLTF2;
  83323. }
  83324. /**
  83325. * Module for glTF 2.0 Interface
  83326. */
  83327. declare module BABYLON.GLTF2 {
  83328. /**
  83329. * The datatype of the components in the attribute
  83330. */
  83331. const enum AccessorComponentType {
  83332. /**
  83333. * Byte
  83334. */
  83335. BYTE = 5120,
  83336. /**
  83337. * Unsigned Byte
  83338. */
  83339. UNSIGNED_BYTE = 5121,
  83340. /**
  83341. * Short
  83342. */
  83343. SHORT = 5122,
  83344. /**
  83345. * Unsigned Short
  83346. */
  83347. UNSIGNED_SHORT = 5123,
  83348. /**
  83349. * Unsigned Int
  83350. */
  83351. UNSIGNED_INT = 5125,
  83352. /**
  83353. * Float
  83354. */
  83355. FLOAT = 5126,
  83356. }
  83357. /**
  83358. * Specifies if the attirbute is a scalar, vector, or matrix
  83359. */
  83360. const enum AccessorType {
  83361. /**
  83362. * Scalar
  83363. */
  83364. SCALAR = "SCALAR",
  83365. /**
  83366. * Vector2
  83367. */
  83368. VEC2 = "VEC2",
  83369. /**
  83370. * Vector3
  83371. */
  83372. VEC3 = "VEC3",
  83373. /**
  83374. * Vector4
  83375. */
  83376. VEC4 = "VEC4",
  83377. /**
  83378. * Matrix2x2
  83379. */
  83380. MAT2 = "MAT2",
  83381. /**
  83382. * Matrix3x3
  83383. */
  83384. MAT3 = "MAT3",
  83385. /**
  83386. * Matrix4x4
  83387. */
  83388. MAT4 = "MAT4",
  83389. }
  83390. /**
  83391. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83392. */
  83393. const enum AnimationChannelTargetPath {
  83394. /**
  83395. * Translation
  83396. */
  83397. TRANSLATION = "translation",
  83398. /**
  83399. * Rotation
  83400. */
  83401. ROTATION = "rotation",
  83402. /**
  83403. * Scale
  83404. */
  83405. SCALE = "scale",
  83406. /**
  83407. * Weights
  83408. */
  83409. WEIGHTS = "weights",
  83410. }
  83411. /**
  83412. * Interpolation algorithm
  83413. */
  83414. const enum AnimationSamplerInterpolation {
  83415. /**
  83416. * The animated values are linearly interpolated between keyframes
  83417. */
  83418. LINEAR = "LINEAR",
  83419. /**
  83420. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  83421. */
  83422. STEP = "STEP",
  83423. /**
  83424. * The animation's interpolation is computed using a cubic spline with specified tangents
  83425. */
  83426. CUBICSPLINE = "CUBICSPLINE",
  83427. }
  83428. /**
  83429. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83430. */
  83431. const enum CameraType {
  83432. /**
  83433. * A perspective camera containing properties to create a perspective projection matrix
  83434. */
  83435. PERSPECTIVE = "perspective",
  83436. /**
  83437. * An orthographic camera containing properties to create an orthographic projection matrix
  83438. */
  83439. ORTHOGRAPHIC = "orthographic",
  83440. }
  83441. /**
  83442. * The mime-type of the image
  83443. */
  83444. const enum ImageMimeType {
  83445. /**
  83446. * JPEG Mime-type
  83447. */
  83448. JPEG = "image/jpeg",
  83449. /**
  83450. * PNG Mime-type
  83451. */
  83452. PNG = "image/png",
  83453. }
  83454. /**
  83455. * The alpha rendering mode of the material
  83456. */
  83457. const enum MaterialAlphaMode {
  83458. /**
  83459. * The alpha value is ignored and the rendered output is fully opaque
  83460. */
  83461. OPAQUE = "OPAQUE",
  83462. /**
  83463. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  83464. */
  83465. MASK = "MASK",
  83466. /**
  83467. * 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)
  83468. */
  83469. BLEND = "BLEND",
  83470. }
  83471. /**
  83472. * The type of the primitives to render
  83473. */
  83474. const enum MeshPrimitiveMode {
  83475. /**
  83476. * Points
  83477. */
  83478. POINTS = 0,
  83479. /**
  83480. * Lines
  83481. */
  83482. LINES = 1,
  83483. /**
  83484. * Line Loop
  83485. */
  83486. LINE_LOOP = 2,
  83487. /**
  83488. * Line Strip
  83489. */
  83490. LINE_STRIP = 3,
  83491. /**
  83492. * Triangles
  83493. */
  83494. TRIANGLES = 4,
  83495. /**
  83496. * Triangle Strip
  83497. */
  83498. TRIANGLE_STRIP = 5,
  83499. /**
  83500. * Triangle Fan
  83501. */
  83502. TRIANGLE_FAN = 6,
  83503. }
  83504. /**
  83505. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83506. */
  83507. const enum TextureMagFilter {
  83508. /**
  83509. * Nearest
  83510. */
  83511. NEAREST = 9728,
  83512. /**
  83513. * Linear
  83514. */
  83515. LINEAR = 9729,
  83516. }
  83517. /**
  83518. * Minification filter. All valid values correspond to WebGL enums
  83519. */
  83520. const enum TextureMinFilter {
  83521. /**
  83522. * Nearest
  83523. */
  83524. NEAREST = 9728,
  83525. /**
  83526. * Linear
  83527. */
  83528. LINEAR = 9729,
  83529. /**
  83530. * Nearest Mip-Map Nearest
  83531. */
  83532. NEAREST_MIPMAP_NEAREST = 9984,
  83533. /**
  83534. * Linear Mipmap Nearest
  83535. */
  83536. LINEAR_MIPMAP_NEAREST = 9985,
  83537. /**
  83538. * Nearest Mipmap Linear
  83539. */
  83540. NEAREST_MIPMAP_LINEAR = 9986,
  83541. /**
  83542. * Linear Mipmap Linear
  83543. */
  83544. LINEAR_MIPMAP_LINEAR = 9987,
  83545. }
  83546. /**
  83547. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83548. */
  83549. const enum TextureWrapMode {
  83550. /**
  83551. * Clamp to Edge
  83552. */
  83553. CLAMP_TO_EDGE = 33071,
  83554. /**
  83555. * Mirrored Repeat
  83556. */
  83557. MIRRORED_REPEAT = 33648,
  83558. /**
  83559. * Repeat
  83560. */
  83561. REPEAT = 10497,
  83562. }
  83563. /**
  83564. * glTF Property
  83565. */
  83566. interface IProperty {
  83567. /**
  83568. * Dictionary object with extension-specific objects
  83569. */
  83570. extensions?: {
  83571. [key: string]: any;
  83572. };
  83573. /**
  83574. * Application-Specific data
  83575. */
  83576. extras?: any;
  83577. }
  83578. /**
  83579. * glTF Child of Root Property
  83580. */
  83581. interface IChildRootProperty extends IProperty {
  83582. /**
  83583. * The user-defined name of this object
  83584. */
  83585. name?: string;
  83586. }
  83587. /**
  83588. * Indices of those attributes that deviate from their initialization value
  83589. */
  83590. interface IAccessorSparseIndices extends IProperty {
  83591. /**
  83592. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83593. */
  83594. bufferView: number;
  83595. /**
  83596. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83597. */
  83598. byteOffset?: number;
  83599. /**
  83600. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  83601. */
  83602. componentType: AccessorComponentType;
  83603. }
  83604. /**
  83605. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  83606. */
  83607. interface IAccessorSparseValues extends IProperty {
  83608. /**
  83609. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83610. */
  83611. bufferView: number;
  83612. /**
  83613. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83614. */
  83615. byteOffset?: number;
  83616. }
  83617. /**
  83618. * Sparse storage of attributes that deviate from their initialization value
  83619. */
  83620. interface IAccessorSparse extends IProperty {
  83621. /**
  83622. * The number of attributes encoded in this sparse accessor
  83623. */
  83624. count: number;
  83625. /**
  83626. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  83627. */
  83628. indices: IAccessorSparseIndices;
  83629. /**
  83630. * 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
  83631. */
  83632. values: IAccessorSparseValues;
  83633. }
  83634. /**
  83635. * 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
  83636. */
  83637. interface IAccessor extends IChildRootProperty {
  83638. /**
  83639. * The index of the bufferview
  83640. */
  83641. bufferView?: number;
  83642. /**
  83643. * The offset relative to the start of the bufferView in bytes
  83644. */
  83645. byteOffset?: number;
  83646. /**
  83647. * The datatype of components in the attribute
  83648. */
  83649. componentType: AccessorComponentType;
  83650. /**
  83651. * Specifies whether integer data values should be normalized
  83652. */
  83653. normalized?: boolean;
  83654. /**
  83655. * The number of attributes referenced by this accessor
  83656. */
  83657. count: number;
  83658. /**
  83659. * Specifies if the attribute is a scalar, vector, or matrix
  83660. */
  83661. type: AccessorType;
  83662. /**
  83663. * Maximum value of each component in this attribute
  83664. */
  83665. max?: number[];
  83666. /**
  83667. * Minimum value of each component in this attribute
  83668. */
  83669. min?: number[];
  83670. /**
  83671. * Sparse storage of attributes that deviate from their initialization value
  83672. */
  83673. sparse?: IAccessorSparse;
  83674. }
  83675. /**
  83676. * Targets an animation's sampler at a node's property
  83677. */
  83678. interface IAnimationChannel extends IProperty {
  83679. /**
  83680. * The index of a sampler in this animation used to compute the value for the target
  83681. */
  83682. sampler: number;
  83683. /**
  83684. * The index of the node and TRS property to target
  83685. */
  83686. target: IAnimationChannelTarget;
  83687. }
  83688. /**
  83689. * The index of the node and TRS property that an animation channel targets
  83690. */
  83691. interface IAnimationChannelTarget extends IProperty {
  83692. /**
  83693. * The index of the node to target
  83694. */
  83695. node: number;
  83696. /**
  83697. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83698. */
  83699. path: AnimationChannelTargetPath;
  83700. }
  83701. /**
  83702. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83703. */
  83704. interface IAnimationSampler extends IProperty {
  83705. /**
  83706. * The index of an accessor containing keyframe input values, e.g., time
  83707. */
  83708. input: number;
  83709. /**
  83710. * Interpolation algorithm
  83711. */
  83712. interpolation?: AnimationSamplerInterpolation;
  83713. /**
  83714. * The index of an accessor, containing keyframe output values
  83715. */
  83716. output: number;
  83717. }
  83718. /**
  83719. * A keyframe animation
  83720. */
  83721. interface IAnimation extends IChildRootProperty {
  83722. /**
  83723. * An array of channels, each of which targets an animation's sampler at a node's property
  83724. */
  83725. channels: IAnimationChannel[];
  83726. /**
  83727. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83728. */
  83729. samplers: IAnimationSampler[];
  83730. }
  83731. /**
  83732. * Metadata about the glTF asset
  83733. */
  83734. interface IAsset extends IChildRootProperty {
  83735. /**
  83736. * A copyright message suitable for display to credit the content creator
  83737. */
  83738. copyright?: string;
  83739. /**
  83740. * Tool that generated this glTF model. Useful for debugging
  83741. */
  83742. generator?: string;
  83743. /**
  83744. * The glTF version that this asset targets
  83745. */
  83746. version: string;
  83747. /**
  83748. * The minimum glTF version that this asset targets
  83749. */
  83750. minVersion?: string;
  83751. }
  83752. /**
  83753. * A buffer points to binary geometry, animation, or skins
  83754. */
  83755. interface IBuffer extends IChildRootProperty {
  83756. /**
  83757. * 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
  83758. */
  83759. uri?: string;
  83760. /**
  83761. * The length of the buffer in bytes
  83762. */
  83763. byteLength: number;
  83764. }
  83765. /**
  83766. * A view into a buffer generally representing a subset of the buffer
  83767. */
  83768. interface IBufferView extends IChildRootProperty {
  83769. /**
  83770. * The index of the buffer
  83771. */
  83772. buffer: number;
  83773. /**
  83774. * The offset into the buffer in bytes
  83775. */
  83776. byteOffset?: number;
  83777. /**
  83778. * The lenth of the bufferView in bytes
  83779. */
  83780. byteLength: number;
  83781. /**
  83782. * The stride, in bytes
  83783. */
  83784. byteStride?: number;
  83785. }
  83786. /**
  83787. * An orthographic camera containing properties to create an orthographic projection matrix
  83788. */
  83789. interface ICameraOrthographic extends IProperty {
  83790. /**
  83791. * The floating-point horizontal magnification of the view. Must not be zero
  83792. */
  83793. xmag: number;
  83794. /**
  83795. * The floating-point vertical magnification of the view. Must not be zero
  83796. */
  83797. ymag: number;
  83798. /**
  83799. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83800. */
  83801. zfar: number;
  83802. /**
  83803. * The floating-point distance to the near clipping plane
  83804. */
  83805. znear: number;
  83806. }
  83807. /**
  83808. * A perspective camera containing properties to create a perspective projection matrix
  83809. */
  83810. interface ICameraPerspective extends IProperty {
  83811. /**
  83812. * The floating-point aspect ratio of the field of view
  83813. */
  83814. aspectRatio?: number;
  83815. /**
  83816. * The floating-point vertical field of view in radians
  83817. */
  83818. yfov: number;
  83819. /**
  83820. * The floating-point distance to the far clipping plane
  83821. */
  83822. zfar?: number;
  83823. /**
  83824. * The floating-point distance to the near clipping plane
  83825. */
  83826. znear: number;
  83827. }
  83828. /**
  83829. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83830. */
  83831. interface ICamera extends IChildRootProperty {
  83832. /**
  83833. * An orthographic camera containing properties to create an orthographic projection matrix
  83834. */
  83835. orthographic?: ICameraOrthographic;
  83836. /**
  83837. * A perspective camera containing properties to create a perspective projection matrix
  83838. */
  83839. perspective?: ICameraPerspective;
  83840. /**
  83841. * Specifies if the camera uses a perspective or orthographic projection
  83842. */
  83843. type: CameraType;
  83844. }
  83845. /**
  83846. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83847. */
  83848. interface IImage extends IChildRootProperty {
  83849. /**
  83850. * 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
  83851. */
  83852. uri?: string;
  83853. /**
  83854. * The image's MIME type
  83855. */
  83856. mimeType?: ImageMimeType;
  83857. /**
  83858. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83859. */
  83860. bufferView?: number;
  83861. }
  83862. /**
  83863. * Material Normal Texture Info
  83864. */
  83865. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83866. /**
  83867. * The scalar multiplier applied to each normal vector of the normal texture
  83868. */
  83869. scale?: number;
  83870. }
  83871. /**
  83872. * Material Occlusion Texture Info
  83873. */
  83874. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83875. /**
  83876. * A scalar multiplier controlling the amount of occlusion applied
  83877. */
  83878. strength?: number;
  83879. }
  83880. /**
  83881. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83882. */
  83883. interface IMaterialPbrMetallicRoughness {
  83884. /**
  83885. * The material's base color factor
  83886. */
  83887. baseColorFactor?: number[];
  83888. /**
  83889. * The base color texture
  83890. */
  83891. baseColorTexture?: ITextureInfo;
  83892. /**
  83893. * The metalness of the material
  83894. */
  83895. metallicFactor?: number;
  83896. /**
  83897. * The roughness of the material
  83898. */
  83899. roughnessFactor?: number;
  83900. /**
  83901. * The metallic-roughness texture
  83902. */
  83903. metallicRoughnessTexture?: ITextureInfo;
  83904. }
  83905. /**
  83906. * The material appearance of a primitive
  83907. */
  83908. interface IMaterial extends IChildRootProperty {
  83909. /**
  83910. * 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
  83911. */
  83912. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83913. /**
  83914. * The normal map texture
  83915. */
  83916. normalTexture?: IMaterialNormalTextureInfo;
  83917. /**
  83918. * The occlusion map texture
  83919. */
  83920. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83921. /**
  83922. * The emissive map texture
  83923. */
  83924. emissiveTexture?: ITextureInfo;
  83925. /**
  83926. * 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
  83927. */
  83928. emissiveFactor?: number[];
  83929. /**
  83930. * The alpha rendering mode of the material
  83931. */
  83932. alphaMode?: MaterialAlphaMode;
  83933. /**
  83934. * The alpha cutoff value of the material
  83935. */
  83936. alphaCutoff?: number;
  83937. /**
  83938. * Specifies whether the material is double sided
  83939. */
  83940. doubleSided?: boolean;
  83941. }
  83942. /**
  83943. * Geometry to be rendered with the given material
  83944. */
  83945. interface IMeshPrimitive extends IProperty {
  83946. /**
  83947. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83948. */
  83949. attributes: {
  83950. [name: string]: number;
  83951. };
  83952. /**
  83953. * The index of the accessor that contains the indices
  83954. */
  83955. indices?: number;
  83956. /**
  83957. * The index of the material to apply to this primitive when rendering
  83958. */
  83959. material?: number;
  83960. /**
  83961. * The type of primitives to render. All valid values correspond to WebGL enums
  83962. */
  83963. mode?: MeshPrimitiveMode;
  83964. /**
  83965. * 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
  83966. */
  83967. targets?: {
  83968. [name: string]: number;
  83969. }[];
  83970. }
  83971. /**
  83972. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83973. */
  83974. interface IMesh extends IChildRootProperty {
  83975. /**
  83976. * An array of primitives, each defining geometry to be rendered with a material
  83977. */
  83978. primitives: IMeshPrimitive[];
  83979. /**
  83980. * Array of weights to be applied to the Morph Targets
  83981. */
  83982. weights?: number[];
  83983. }
  83984. /**
  83985. * A node in the node hierarchy
  83986. */
  83987. interface INode extends IChildRootProperty {
  83988. /**
  83989. * The index of the camera referenced by this node
  83990. */
  83991. camera?: number;
  83992. /**
  83993. * The indices of this node's children
  83994. */
  83995. children?: number[];
  83996. /**
  83997. * The index of the skin referenced by this node
  83998. */
  83999. skin?: number;
  84000. /**
  84001. * A floating-point 4x4 transformation matrix stored in column-major order
  84002. */
  84003. matrix?: number[];
  84004. /**
  84005. * The index of the mesh in this node
  84006. */
  84007. mesh?: number;
  84008. /**
  84009. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  84010. */
  84011. rotation?: number[];
  84012. /**
  84013. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  84014. */
  84015. scale?: number[];
  84016. /**
  84017. * The node's translation along the x, y, and z axes
  84018. */
  84019. translation?: number[];
  84020. /**
  84021. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  84022. */
  84023. weights?: number[];
  84024. }
  84025. /**
  84026. * Texture sampler properties for filtering and wrapping modes
  84027. */
  84028. interface ISampler extends IChildRootProperty {
  84029. /**
  84030. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84031. */
  84032. magFilter?: TextureMagFilter;
  84033. /**
  84034. * Minification filter. All valid values correspond to WebGL enums
  84035. */
  84036. minFilter?: TextureMinFilter;
  84037. /**
  84038. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84039. */
  84040. wrapS?: TextureWrapMode;
  84041. /**
  84042. * T (V) wrapping mode. All valid values correspond to WebGL enums
  84043. */
  84044. wrapT?: TextureWrapMode;
  84045. }
  84046. /**
  84047. * The root nodes of a scene
  84048. */
  84049. interface IScene extends IChildRootProperty {
  84050. /**
  84051. * The indices of each root node
  84052. */
  84053. nodes: number[];
  84054. }
  84055. /**
  84056. * Joints and matrices defining a skin
  84057. */
  84058. interface ISkin extends IChildRootProperty {
  84059. /**
  84060. * 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
  84061. */
  84062. inverseBindMatrices?: number;
  84063. /**
  84064. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  84065. */
  84066. skeleton?: number;
  84067. /**
  84068. * 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)
  84069. */
  84070. joints: number[];
  84071. }
  84072. /**
  84073. * A texture and its sampler
  84074. */
  84075. interface ITexture extends IChildRootProperty {
  84076. /**
  84077. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  84078. */
  84079. sampler?: number;
  84080. /**
  84081. * The index of the image used by this texture
  84082. */
  84083. source: number;
  84084. }
  84085. /**
  84086. * Reference to a texture
  84087. */
  84088. interface ITextureInfo extends IProperty {
  84089. /**
  84090. * The index of the texture
  84091. */
  84092. index: number;
  84093. /**
  84094. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  84095. */
  84096. texCoord?: number;
  84097. }
  84098. /**
  84099. * The root object for a glTF asset
  84100. */
  84101. interface IGLTF extends IProperty {
  84102. /**
  84103. * An array of accessors. An accessor is a typed view into a bufferView
  84104. */
  84105. accessors?: IAccessor[];
  84106. /**
  84107. * An array of keyframe animations
  84108. */
  84109. animations?: IAnimation[];
  84110. /**
  84111. * Metadata about the glTF asset
  84112. */
  84113. asset: IAsset;
  84114. /**
  84115. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84116. */
  84117. buffers?: IBuffer[];
  84118. /**
  84119. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84120. */
  84121. bufferViews?: IBufferView[];
  84122. /**
  84123. * An array of cameras
  84124. */
  84125. cameras?: ICamera[];
  84126. /**
  84127. * Names of glTF extensions used somewhere in this asset
  84128. */
  84129. extensionsUsed?: string[];
  84130. /**
  84131. * Names of glTF extensions required to properly load this asset
  84132. */
  84133. extensionsRequired?: string[];
  84134. /**
  84135. * An array of images. An image defines data used to create a texture
  84136. */
  84137. images?: IImage[];
  84138. /**
  84139. * An array of materials. A material defines the appearance of a primitive
  84140. */
  84141. materials?: IMaterial[];
  84142. /**
  84143. * An array of meshes. A mesh is a set of primitives to be rendered
  84144. */
  84145. meshes?: IMesh[];
  84146. /**
  84147. * An array of nodes
  84148. */
  84149. nodes?: INode[];
  84150. /**
  84151. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  84152. */
  84153. samplers?: ISampler[];
  84154. /**
  84155. * The index of the default scene
  84156. */
  84157. scene?: number;
  84158. /**
  84159. * An array of scenes
  84160. */
  84161. scenes?: IScene[];
  84162. /**
  84163. * An array of skins. A skin is defined by joints and matrices
  84164. */
  84165. skins?: ISkin[];
  84166. /**
  84167. * An array of textures
  84168. */
  84169. textures?: ITexture[];
  84170. }
  84171. /**
  84172. * The glTF validation results
  84173. * @ignore
  84174. */
  84175. interface IGLTFValidationResults {
  84176. info: {
  84177. generator: string;
  84178. hasAnimations: boolean;
  84179. hasDefaultScene: boolean;
  84180. hasMaterials: boolean;
  84181. hasMorphTargets: boolean;
  84182. hasSkins: boolean;
  84183. hasTextures: boolean;
  84184. maxAttributesUsed: number;
  84185. primitivesCount: number
  84186. };
  84187. issues: {
  84188. messages: Array<string>;
  84189. numErrors: number;
  84190. numHints: number;
  84191. numInfos: number;
  84192. numWarnings: number;
  84193. truncated: boolean
  84194. };
  84195. mimeType: string;
  84196. uri: string;
  84197. validatedAt: string;
  84198. validatorVersion: string;
  84199. }
  84200. /**
  84201. * The glTF validation options
  84202. */
  84203. interface IGLTFValidationOptions {
  84204. /** Uri to use */
  84205. uri?: string;
  84206. /** Function used to load external resources */
  84207. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  84208. /** Boolean indicating that we need to validate accessor data */
  84209. validateAccessorData?: boolean;
  84210. /** max number of issues allowed */
  84211. maxIssues?: number;
  84212. /** Ignored issues */
  84213. ignoredIssues?: Array<string>;
  84214. /** Value to override severy settings */
  84215. severityOverrides?: Object;
  84216. }
  84217. /**
  84218. * The glTF validator object
  84219. * @ignore
  84220. */
  84221. interface IGLTFValidator {
  84222. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84223. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84224. }
  84225. /**
  84226. * Interfaces from the EXT_lights_image_based extension
  84227. */
  84228. /** @hidden */
  84229. interface IEXTLightsImageBased_LightReferenceImageBased {
  84230. light: number;
  84231. }
  84232. /** @hidden */
  84233. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  84234. intensity: number;
  84235. rotation: number[];
  84236. specularImageSize: number;
  84237. specularImages: number[][];
  84238. irradianceCoefficients: number[][];
  84239. }
  84240. /** @hidden */
  84241. interface IEXTLightsImageBased {
  84242. lights: IEXTLightsImageBased_LightImageBased[];
  84243. }
  84244. /**
  84245. * Interfaces from the EXT_mesh_gpu_instancing extension
  84246. * !!! Experimental Extension Subject to Changes !!!
  84247. */
  84248. /** @hidden */
  84249. interface IEXTMeshGpuInstancing {
  84250. mesh?: number;
  84251. attributes: { [name: string]: number };
  84252. }
  84253. /**
  84254. * Interfaces from the KHR_draco_mesh_compression extension
  84255. */
  84256. /** @hidden */
  84257. interface IKHRDracoMeshCompression {
  84258. bufferView: number;
  84259. attributes: { [name: string]: number };
  84260. }
  84261. /**
  84262. * Interfaces from the KHR_lights_punctual extension
  84263. */
  84264. /** @hidden */
  84265. const enum IKHRLightsPunctual_LightType {
  84266. DIRECTIONAL = "directional",
  84267. POINT = "point",
  84268. SPOT = "spot"
  84269. }
  84270. /** @hidden */
  84271. interface IKHRLightsPunctual_LightReference {
  84272. light: number;
  84273. }
  84274. /** @hidden */
  84275. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  84276. type: IKHRLightsPunctual_LightType;
  84277. color?: number[];
  84278. intensity?: number;
  84279. range?: number;
  84280. spot?: {
  84281. innerConeAngle?: number;
  84282. outerConeAngle?: number;
  84283. };
  84284. }
  84285. /** @hidden */
  84286. interface IKHRLightsPunctual {
  84287. lights: IKHRLightsPunctual_Light[];
  84288. }
  84289. /**
  84290. * Interfaces from the KHR_materials_clearcoat extension
  84291. * !!! Experimental Extension Subject to Changes !!!
  84292. */
  84293. /** @hidden */
  84294. interface IKHRMaterialsClearcoat {
  84295. clearcoatFactor: number;
  84296. clearcoatTexture: ITextureInfo;
  84297. clearcoatRoughnessFactor: number;
  84298. clearcoatRoughnessTexture: ITextureInfo;
  84299. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  84300. }
  84301. /**
  84302. * Interfaces from the KHR_materials_ior extension
  84303. * !!! Experimental Extension Subject to Changes !!!
  84304. */
  84305. /** @hidden */
  84306. interface IKHRMaterialsIor {
  84307. ior: number;
  84308. }
  84309. /**
  84310. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  84311. */
  84312. /** @hidden */
  84313. interface IKHRMaterialsPbrSpecularGlossiness {
  84314. diffuseFactor: number[];
  84315. diffuseTexture: ITextureInfo;
  84316. specularFactor: number[];
  84317. glossinessFactor: number;
  84318. specularGlossinessTexture: ITextureInfo;
  84319. }
  84320. /**
  84321. * Interfaces from the KHR_materials_sheen extension
  84322. * !!! Experimental Extension Subject to Changes !!!
  84323. */
  84324. /** @hidden */
  84325. interface IKHRMaterialsSheen {
  84326. sheenColorFactor?: number[];
  84327. sheenTexture?: ITextureInfo;
  84328. sheenRoughnessFactor?: number;
  84329. }
  84330. /**
  84331. * Interfaces from the KHR_materials_specular extension
  84332. * !!! Experimental Extension Subject to Changes !!!
  84333. */
  84334. /** @hidden */
  84335. interface IKHRMaterialsSpecular {
  84336. specularFactor: number;
  84337. specularColorFactor: number[];
  84338. specularTexture: ITextureInfo;
  84339. }
  84340. /**
  84341. * Interfaces from the KHR_materials_transmission extension
  84342. * !!! Experimental Extension Subject to Changes !!!
  84343. */
  84344. /** @hidden */
  84345. interface IKHRMaterialsTransmission {
  84346. transmissionFactor?: number;
  84347. transmissionTexture?: ITextureInfo;
  84348. }
  84349. /**
  84350. * Interfaces from the KHR_materials_variants extension
  84351. * !!! Experimental Extension Subject to Changes !!!
  84352. */
  84353. /** @hidden */
  84354. interface IKHRMaterialVariants_Mapping {
  84355. variants: string[];
  84356. material: number;
  84357. }
  84358. /** @hidden */
  84359. interface IKHRMaterialVariants {
  84360. mapping: IKHRMaterialVariants_Mapping[];
  84361. }
  84362. /**
  84363. * Interfaces from the KHR_texture_basisu extension
  84364. * !!! Experimental Extension Subject to Changes !!!
  84365. */
  84366. /** @hidden */
  84367. interface IKHRTextureBasisU {
  84368. source: number;
  84369. }
  84370. /**
  84371. * Interfaces from the EXT_texture_webp extension
  84372. */
  84373. /** @hidden */
  84374. interface IEXTTextureWebP {
  84375. source: number;
  84376. }
  84377. /**
  84378. * Interfaces from the KHR_texture_transform extension
  84379. */
  84380. /** @hidden */
  84381. interface IKHRTextureTransform {
  84382. offset?: number[];
  84383. rotation?: number;
  84384. scale?: number[];
  84385. texCoord?: number;
  84386. }
  84387. /**
  84388. * Interfaces from the KHR_xmp extension
  84389. * !!! Experimental Extension Subject to Changes !!!
  84390. */
  84391. /** @hidden */
  84392. interface IKHRXmp_Data {
  84393. [key: string]: unknown;
  84394. }
  84395. /** @hidden */
  84396. interface IKHRXmp_Gltf {
  84397. packets: IKHRXmp_Data[];
  84398. }
  84399. /** @hidden */
  84400. interface IKHRXmp_Node {
  84401. packet: number;
  84402. }
  84403. /**
  84404. * Interfaces from the MSFT_audio_emitter extension
  84405. */
  84406. /** @hidden */
  84407. interface IMSFTAudioEmitter_ClipReference {
  84408. clip: number;
  84409. weight?: number;
  84410. }
  84411. /** @hidden */
  84412. interface IMSFTAudioEmitter_EmittersReference {
  84413. emitters: number[];
  84414. }
  84415. /** @hidden */
  84416. const enum IMSFTAudioEmitter_DistanceModel {
  84417. linear = "linear",
  84418. inverse = "inverse",
  84419. exponential = "exponential",
  84420. }
  84421. /** @hidden */
  84422. interface IMSFTAudioEmitter_Emitter {
  84423. name?: string;
  84424. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  84425. refDistance?: number;
  84426. maxDistance?: number;
  84427. rolloffFactor?: number;
  84428. innerAngle?: number;
  84429. outerAngle?: number;
  84430. loop?: boolean;
  84431. volume?: number;
  84432. clips: IMSFTAudioEmitter_ClipReference[];
  84433. }
  84434. /** @hidden */
  84435. const enum IMSFTAudioEmitter_AudioMimeType {
  84436. WAV = "audio/wav",
  84437. }
  84438. /** @hidden */
  84439. interface IMSFTAudioEmitter_Clip extends IProperty {
  84440. uri?: string;
  84441. bufferView?: number;
  84442. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  84443. }
  84444. /** @hidden */
  84445. const enum IMSFTAudioEmitter_AnimationEventAction {
  84446. play = "play",
  84447. pause = "pause",
  84448. stop = "stop",
  84449. }
  84450. /** @hidden */
  84451. interface IMSFTAudioEmitter_AnimationEvent {
  84452. action: IMSFTAudioEmitter_AnimationEventAction;
  84453. emitter: number;
  84454. time: number;
  84455. startOffset?: number;
  84456. }
  84457. /**
  84458. * Interfaces from the MSFT_lod extension
  84459. */
  84460. /** @hidden */
  84461. interface IMSFTLOD {
  84462. ids: number[];
  84463. }
  84464. }
  84465. declare module BABYLON {
  84466. /** @hidden */
  84467. export var cellPixelShader: {
  84468. name: string;
  84469. shader: string;
  84470. };
  84471. }
  84472. declare module BABYLON {
  84473. /** @hidden */
  84474. export var cellVertexShader: {
  84475. name: string;
  84476. shader: string;
  84477. };
  84478. }
  84479. declare module BABYLON {
  84480. export class CellMaterial extends BABYLON.PushMaterial {
  84481. private _diffuseTexture;
  84482. diffuseTexture: BABYLON.BaseTexture;
  84483. diffuseColor: BABYLON.Color3;
  84484. _computeHighLevel: boolean;
  84485. computeHighLevel: boolean;
  84486. private _disableLighting;
  84487. disableLighting: boolean;
  84488. private _maxSimultaneousLights;
  84489. maxSimultaneousLights: number;
  84490. constructor(name: string, scene: BABYLON.Scene);
  84491. needAlphaBlending(): boolean;
  84492. needAlphaTesting(): boolean;
  84493. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84494. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84495. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84496. getAnimatables(): BABYLON.IAnimatable[];
  84497. getActiveTextures(): BABYLON.BaseTexture[];
  84498. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84499. dispose(forceDisposeEffect?: boolean): void;
  84500. getClassName(): string;
  84501. clone(name: string): CellMaterial;
  84502. serialize(): any;
  84503. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  84504. }
  84505. }
  84506. declare module BABYLON {
  84507. export class CustomShaderStructure {
  84508. FragmentStore: string;
  84509. VertexStore: string;
  84510. constructor();
  84511. }
  84512. export class ShaderSpecialParts {
  84513. constructor();
  84514. Fragment_Begin: string;
  84515. Fragment_Definitions: string;
  84516. Fragment_MainBegin: string;
  84517. Fragment_Custom_Diffuse: string;
  84518. Fragment_Before_Lights: string;
  84519. Fragment_Before_Fog: string;
  84520. Fragment_Custom_Alpha: string;
  84521. Fragment_Before_FragColor: string;
  84522. Vertex_Begin: string;
  84523. Vertex_Definitions: string;
  84524. Vertex_MainBegin: string;
  84525. Vertex_Before_PositionUpdated: string;
  84526. Vertex_Before_NormalUpdated: string;
  84527. Vertex_After_WorldPosComputed: string;
  84528. Vertex_MainEnd: string;
  84529. }
  84530. export class CustomMaterial extends BABYLON.StandardMaterial {
  84531. static ShaderIndexer: number;
  84532. CustomParts: ShaderSpecialParts;
  84533. _isCreatedShader: boolean;
  84534. _createdShaderName: string;
  84535. _customUniform: string[];
  84536. _newUniforms: string[];
  84537. _newUniformInstances: {
  84538. [name: string]: any;
  84539. };
  84540. _newSamplerInstances: {
  84541. [name: string]: BABYLON.Texture;
  84542. };
  84543. _customAttributes: string[];
  84544. FragmentShader: string;
  84545. VertexShader: string;
  84546. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84547. ReviewUniform(name: string, arr: string[]): string[];
  84548. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84549. constructor(name: string, scene: BABYLON.Scene);
  84550. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  84551. AddAttribute(name: string): CustomMaterial;
  84552. Fragment_Begin(shaderPart: string): CustomMaterial;
  84553. Fragment_Definitions(shaderPart: string): CustomMaterial;
  84554. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  84555. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  84556. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  84557. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  84558. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  84559. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  84560. Vertex_Begin(shaderPart: string): CustomMaterial;
  84561. Vertex_Definitions(shaderPart: string): CustomMaterial;
  84562. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  84563. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  84564. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  84565. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  84566. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  84567. }
  84568. }
  84569. declare module BABYLON {
  84570. export class ShaderAlebdoParts {
  84571. constructor();
  84572. Fragment_Begin: string;
  84573. Fragment_Definitions: string;
  84574. Fragment_MainBegin: string;
  84575. Fragment_Custom_Albedo: string;
  84576. Fragment_Before_Lights: string;
  84577. Fragment_Custom_MetallicRoughness: string;
  84578. Fragment_Custom_MicroSurface: string;
  84579. Fragment_Before_Fog: string;
  84580. Fragment_Custom_Alpha: string;
  84581. Fragment_Before_FragColor: string;
  84582. Vertex_Begin: string;
  84583. Vertex_Definitions: string;
  84584. Vertex_MainBegin: string;
  84585. Vertex_Before_PositionUpdated: string;
  84586. Vertex_Before_NormalUpdated: string;
  84587. Vertex_After_WorldPosComputed: string;
  84588. Vertex_MainEnd: string;
  84589. }
  84590. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  84591. static ShaderIndexer: number;
  84592. CustomParts: ShaderAlebdoParts;
  84593. _isCreatedShader: boolean;
  84594. _createdShaderName: string;
  84595. _customUniform: string[];
  84596. _newUniforms: string[];
  84597. _newUniformInstances: {
  84598. [name: string]: any;
  84599. };
  84600. _newSamplerInstances: {
  84601. [name: string]: BABYLON.Texture;
  84602. };
  84603. _customAttributes: string[];
  84604. FragmentShader: string;
  84605. VertexShader: string;
  84606. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84607. ReviewUniform(name: string, arr: string[]): string[];
  84608. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84609. constructor(name: string, scene: BABYLON.Scene);
  84610. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  84611. AddAttribute(name: string): PBRCustomMaterial;
  84612. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  84613. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  84614. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  84615. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  84616. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  84617. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  84618. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  84619. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  84620. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  84621. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  84622. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  84623. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  84624. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  84625. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  84626. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  84627. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  84628. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  84629. }
  84630. }
  84631. declare module BABYLON {
  84632. /** @hidden */
  84633. export var firePixelShader: {
  84634. name: string;
  84635. shader: string;
  84636. };
  84637. }
  84638. declare module BABYLON {
  84639. /** @hidden */
  84640. export var fireVertexShader: {
  84641. name: string;
  84642. shader: string;
  84643. };
  84644. }
  84645. declare module BABYLON {
  84646. export class FireMaterial extends BABYLON.PushMaterial {
  84647. private _diffuseTexture;
  84648. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84649. private _distortionTexture;
  84650. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84651. private _opacityTexture;
  84652. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84653. diffuseColor: BABYLON.Color3;
  84654. speed: number;
  84655. private _scaledDiffuse;
  84656. private _lastTime;
  84657. constructor(name: string, scene: BABYLON.Scene);
  84658. needAlphaBlending(): boolean;
  84659. needAlphaTesting(): boolean;
  84660. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84661. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84662. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84663. getAnimatables(): BABYLON.IAnimatable[];
  84664. getActiveTextures(): BABYLON.BaseTexture[];
  84665. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84666. getClassName(): string;
  84667. dispose(forceDisposeEffect?: boolean): void;
  84668. clone(name: string): FireMaterial;
  84669. serialize(): any;
  84670. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  84671. }
  84672. }
  84673. declare module BABYLON {
  84674. /** @hidden */
  84675. export var furPixelShader: {
  84676. name: string;
  84677. shader: string;
  84678. };
  84679. }
  84680. declare module BABYLON {
  84681. /** @hidden */
  84682. export var furVertexShader: {
  84683. name: string;
  84684. shader: string;
  84685. };
  84686. }
  84687. declare module BABYLON {
  84688. export class FurMaterial extends BABYLON.PushMaterial {
  84689. private _diffuseTexture;
  84690. diffuseTexture: BABYLON.BaseTexture;
  84691. private _heightTexture;
  84692. heightTexture: BABYLON.BaseTexture;
  84693. diffuseColor: BABYLON.Color3;
  84694. furLength: number;
  84695. furAngle: number;
  84696. furColor: BABYLON.Color3;
  84697. furOffset: number;
  84698. furSpacing: number;
  84699. furGravity: BABYLON.Vector3;
  84700. furSpeed: number;
  84701. furDensity: number;
  84702. furOcclusion: number;
  84703. furTexture: BABYLON.DynamicTexture;
  84704. private _disableLighting;
  84705. disableLighting: boolean;
  84706. private _maxSimultaneousLights;
  84707. maxSimultaneousLights: number;
  84708. highLevelFur: boolean;
  84709. _meshes: BABYLON.AbstractMesh[];
  84710. private _furTime;
  84711. constructor(name: string, scene: BABYLON.Scene);
  84712. get furTime(): number;
  84713. set furTime(furTime: number);
  84714. needAlphaBlending(): boolean;
  84715. needAlphaTesting(): boolean;
  84716. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84717. updateFur(): void;
  84718. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84719. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84720. getAnimatables(): BABYLON.IAnimatable[];
  84721. getActiveTextures(): BABYLON.BaseTexture[];
  84722. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84723. dispose(forceDisposeEffect?: boolean): void;
  84724. clone(name: string): FurMaterial;
  84725. serialize(): any;
  84726. getClassName(): string;
  84727. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84728. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84729. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84730. }
  84731. }
  84732. declare module BABYLON {
  84733. /** @hidden */
  84734. export var gradientPixelShader: {
  84735. name: string;
  84736. shader: string;
  84737. };
  84738. }
  84739. declare module BABYLON {
  84740. /** @hidden */
  84741. export var gradientVertexShader: {
  84742. name: string;
  84743. shader: string;
  84744. };
  84745. }
  84746. declare module BABYLON {
  84747. export class GradientMaterial extends BABYLON.PushMaterial {
  84748. private _maxSimultaneousLights;
  84749. maxSimultaneousLights: number;
  84750. topColor: BABYLON.Color3;
  84751. topColorAlpha: number;
  84752. bottomColor: BABYLON.Color3;
  84753. bottomColorAlpha: number;
  84754. offset: number;
  84755. scale: number;
  84756. smoothness: number;
  84757. private _disableLighting;
  84758. disableLighting: boolean;
  84759. constructor(name: string, scene: BABYLON.Scene);
  84760. needAlphaBlending(): boolean;
  84761. needAlphaTesting(): boolean;
  84762. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84763. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84764. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84765. getAnimatables(): BABYLON.IAnimatable[];
  84766. dispose(forceDisposeEffect?: boolean): void;
  84767. clone(name: string): GradientMaterial;
  84768. serialize(): any;
  84769. getClassName(): string;
  84770. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84771. }
  84772. }
  84773. declare module BABYLON {
  84774. /** @hidden */
  84775. export var gridPixelShader: {
  84776. name: string;
  84777. shader: string;
  84778. };
  84779. }
  84780. declare module BABYLON {
  84781. /** @hidden */
  84782. export var gridVertexShader: {
  84783. name: string;
  84784. shader: string;
  84785. };
  84786. }
  84787. declare module BABYLON {
  84788. /**
  84789. * The grid materials allows you to wrap any shape with a grid.
  84790. * Colors are customizable.
  84791. */
  84792. export class GridMaterial extends BABYLON.PushMaterial {
  84793. /**
  84794. * Main color of the grid (e.g. between lines)
  84795. */
  84796. mainColor: BABYLON.Color3;
  84797. /**
  84798. * Color of the grid lines.
  84799. */
  84800. lineColor: BABYLON.Color3;
  84801. /**
  84802. * The scale of the grid compared to unit.
  84803. */
  84804. gridRatio: number;
  84805. /**
  84806. * Allows setting an offset for the grid lines.
  84807. */
  84808. gridOffset: BABYLON.Vector3;
  84809. /**
  84810. * The frequency of thicker lines.
  84811. */
  84812. majorUnitFrequency: number;
  84813. /**
  84814. * The visibility of minor units in the grid.
  84815. */
  84816. minorUnitVisibility: number;
  84817. /**
  84818. * The grid opacity outside of the lines.
  84819. */
  84820. opacity: number;
  84821. /**
  84822. * Determine RBG output is premultiplied by alpha value.
  84823. */
  84824. preMultiplyAlpha: boolean;
  84825. private _opacityTexture;
  84826. opacityTexture: BABYLON.BaseTexture;
  84827. private _gridControl;
  84828. /**
  84829. * constructor
  84830. * @param name The name given to the material in order to identify it afterwards.
  84831. * @param scene The scene the material is used in.
  84832. */
  84833. constructor(name: string, scene: BABYLON.Scene);
  84834. /**
  84835. * Returns wehter or not the grid requires alpha blending.
  84836. */
  84837. needAlphaBlending(): boolean;
  84838. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84839. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84840. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84841. /**
  84842. * Dispose the material and its associated resources.
  84843. * @param forceDisposeEffect will also dispose the used effect when true
  84844. */
  84845. dispose(forceDisposeEffect?: boolean): void;
  84846. clone(name: string): GridMaterial;
  84847. serialize(): any;
  84848. getClassName(): string;
  84849. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84850. }
  84851. }
  84852. declare module BABYLON {
  84853. /** @hidden */
  84854. export var lavaPixelShader: {
  84855. name: string;
  84856. shader: string;
  84857. };
  84858. }
  84859. declare module BABYLON {
  84860. /** @hidden */
  84861. export var lavaVertexShader: {
  84862. name: string;
  84863. shader: string;
  84864. };
  84865. }
  84866. declare module BABYLON {
  84867. export class LavaMaterial extends BABYLON.PushMaterial {
  84868. private _diffuseTexture;
  84869. diffuseTexture: BABYLON.BaseTexture;
  84870. noiseTexture: BABYLON.BaseTexture;
  84871. fogColor: BABYLON.Color3;
  84872. speed: number;
  84873. movingSpeed: number;
  84874. lowFrequencySpeed: number;
  84875. fogDensity: number;
  84876. private _lastTime;
  84877. diffuseColor: BABYLON.Color3;
  84878. private _disableLighting;
  84879. disableLighting: boolean;
  84880. private _unlit;
  84881. unlit: boolean;
  84882. private _maxSimultaneousLights;
  84883. maxSimultaneousLights: number;
  84884. private _scaledDiffuse;
  84885. constructor(name: string, scene: BABYLON.Scene);
  84886. needAlphaBlending(): boolean;
  84887. needAlphaTesting(): boolean;
  84888. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84889. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84890. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84891. getAnimatables(): BABYLON.IAnimatable[];
  84892. getActiveTextures(): BABYLON.BaseTexture[];
  84893. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84894. dispose(forceDisposeEffect?: boolean): void;
  84895. clone(name: string): LavaMaterial;
  84896. serialize(): any;
  84897. getClassName(): string;
  84898. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84899. }
  84900. }
  84901. declare module BABYLON {
  84902. /** @hidden */
  84903. export var mixPixelShader: {
  84904. name: string;
  84905. shader: string;
  84906. };
  84907. }
  84908. declare module BABYLON {
  84909. /** @hidden */
  84910. export var mixVertexShader: {
  84911. name: string;
  84912. shader: string;
  84913. };
  84914. }
  84915. declare module BABYLON {
  84916. export class MixMaterial extends BABYLON.PushMaterial {
  84917. /**
  84918. * Mix textures
  84919. */
  84920. private _mixTexture1;
  84921. mixTexture1: BABYLON.BaseTexture;
  84922. private _mixTexture2;
  84923. mixTexture2: BABYLON.BaseTexture;
  84924. /**
  84925. * Diffuse textures
  84926. */
  84927. private _diffuseTexture1;
  84928. diffuseTexture1: BABYLON.Texture;
  84929. private _diffuseTexture2;
  84930. diffuseTexture2: BABYLON.Texture;
  84931. private _diffuseTexture3;
  84932. diffuseTexture3: BABYLON.Texture;
  84933. private _diffuseTexture4;
  84934. diffuseTexture4: BABYLON.Texture;
  84935. private _diffuseTexture5;
  84936. diffuseTexture5: BABYLON.Texture;
  84937. private _diffuseTexture6;
  84938. diffuseTexture6: BABYLON.Texture;
  84939. private _diffuseTexture7;
  84940. diffuseTexture7: BABYLON.Texture;
  84941. private _diffuseTexture8;
  84942. diffuseTexture8: BABYLON.Texture;
  84943. /**
  84944. * Uniforms
  84945. */
  84946. diffuseColor: BABYLON.Color3;
  84947. specularColor: BABYLON.Color3;
  84948. specularPower: number;
  84949. private _disableLighting;
  84950. disableLighting: boolean;
  84951. private _maxSimultaneousLights;
  84952. maxSimultaneousLights: number;
  84953. constructor(name: string, scene: BABYLON.Scene);
  84954. needAlphaBlending(): boolean;
  84955. needAlphaTesting(): boolean;
  84956. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84957. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84958. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84959. getAnimatables(): BABYLON.IAnimatable[];
  84960. getActiveTextures(): BABYLON.BaseTexture[];
  84961. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84962. dispose(forceDisposeEffect?: boolean): void;
  84963. clone(name: string): MixMaterial;
  84964. serialize(): any;
  84965. getClassName(): string;
  84966. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84967. }
  84968. }
  84969. declare module BABYLON {
  84970. /** @hidden */
  84971. export var normalPixelShader: {
  84972. name: string;
  84973. shader: string;
  84974. };
  84975. }
  84976. declare module BABYLON {
  84977. /** @hidden */
  84978. export var normalVertexShader: {
  84979. name: string;
  84980. shader: string;
  84981. };
  84982. }
  84983. declare module BABYLON {
  84984. export class NormalMaterial extends BABYLON.PushMaterial {
  84985. private _diffuseTexture;
  84986. diffuseTexture: BABYLON.BaseTexture;
  84987. diffuseColor: BABYLON.Color3;
  84988. private _disableLighting;
  84989. disableLighting: boolean;
  84990. private _maxSimultaneousLights;
  84991. maxSimultaneousLights: number;
  84992. constructor(name: string, scene: BABYLON.Scene);
  84993. needAlphaBlending(): boolean;
  84994. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84995. needAlphaTesting(): boolean;
  84996. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84997. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84998. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84999. getAnimatables(): BABYLON.IAnimatable[];
  85000. getActiveTextures(): BABYLON.BaseTexture[];
  85001. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85002. dispose(forceDisposeEffect?: boolean): void;
  85003. clone(name: string): NormalMaterial;
  85004. serialize(): any;
  85005. getClassName(): string;
  85006. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  85007. }
  85008. }
  85009. declare module BABYLON {
  85010. /** @hidden */
  85011. export var shadowOnlyPixelShader: {
  85012. name: string;
  85013. shader: string;
  85014. };
  85015. }
  85016. declare module BABYLON {
  85017. /** @hidden */
  85018. export var shadowOnlyVertexShader: {
  85019. name: string;
  85020. shader: string;
  85021. };
  85022. }
  85023. declare module BABYLON {
  85024. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  85025. private _activeLight;
  85026. private _needAlphaBlending;
  85027. constructor(name: string, scene: BABYLON.Scene);
  85028. shadowColor: BABYLON.Color3;
  85029. needAlphaBlending(): boolean;
  85030. needAlphaTesting(): boolean;
  85031. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85032. get activeLight(): BABYLON.IShadowLight;
  85033. set activeLight(light: BABYLON.IShadowLight);
  85034. private _getFirstShadowLightForMesh;
  85035. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85036. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85037. clone(name: string): ShadowOnlyMaterial;
  85038. serialize(): any;
  85039. getClassName(): string;
  85040. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  85041. }
  85042. }
  85043. declare module BABYLON {
  85044. /** @hidden */
  85045. export var simplePixelShader: {
  85046. name: string;
  85047. shader: string;
  85048. };
  85049. }
  85050. declare module BABYLON {
  85051. /** @hidden */
  85052. export var simpleVertexShader: {
  85053. name: string;
  85054. shader: string;
  85055. };
  85056. }
  85057. declare module BABYLON {
  85058. export class SimpleMaterial extends BABYLON.PushMaterial {
  85059. private _diffuseTexture;
  85060. diffuseTexture: BABYLON.BaseTexture;
  85061. diffuseColor: BABYLON.Color3;
  85062. private _disableLighting;
  85063. disableLighting: boolean;
  85064. private _maxSimultaneousLights;
  85065. maxSimultaneousLights: number;
  85066. constructor(name: string, scene: BABYLON.Scene);
  85067. needAlphaBlending(): boolean;
  85068. needAlphaTesting(): boolean;
  85069. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85070. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85071. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85072. getAnimatables(): BABYLON.IAnimatable[];
  85073. getActiveTextures(): BABYLON.BaseTexture[];
  85074. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85075. dispose(forceDisposeEffect?: boolean): void;
  85076. clone(name: string): SimpleMaterial;
  85077. serialize(): any;
  85078. getClassName(): string;
  85079. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  85080. }
  85081. }
  85082. declare module BABYLON {
  85083. /** @hidden */
  85084. export var skyPixelShader: {
  85085. name: string;
  85086. shader: string;
  85087. };
  85088. }
  85089. declare module BABYLON {
  85090. /** @hidden */
  85091. export var skyVertexShader: {
  85092. name: string;
  85093. shader: string;
  85094. };
  85095. }
  85096. declare module BABYLON {
  85097. /**
  85098. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  85099. * @see https://doc.babylonjs.com/extensions/sky
  85100. */
  85101. export class SkyMaterial extends BABYLON.PushMaterial {
  85102. /**
  85103. * Defines the overall luminance of sky in interval ]0, 1[.
  85104. */
  85105. luminance: number;
  85106. /**
  85107. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85108. */
  85109. turbidity: number;
  85110. /**
  85111. * Defines the sky appearance (light intensity).
  85112. */
  85113. rayleigh: number;
  85114. /**
  85115. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  85116. */
  85117. mieCoefficient: number;
  85118. /**
  85119. * Defines the amount of haze particles following the Mie scattering theory.
  85120. */
  85121. mieDirectionalG: number;
  85122. /**
  85123. * Defines the distance of the sun according to the active scene camera.
  85124. */
  85125. distance: number;
  85126. /**
  85127. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  85128. * "inclined".
  85129. */
  85130. inclination: number;
  85131. /**
  85132. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  85133. * an object direction and a reference direction.
  85134. */
  85135. azimuth: number;
  85136. /**
  85137. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  85138. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  85139. */
  85140. sunPosition: BABYLON.Vector3;
  85141. /**
  85142. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  85143. * .sunPosition property.
  85144. */
  85145. useSunPosition: boolean;
  85146. /**
  85147. * Defines an offset vector used to get a horizon offset.
  85148. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  85149. */
  85150. cameraOffset: BABYLON.Vector3;
  85151. private _cameraPosition;
  85152. /**
  85153. * Instantiates a new sky material.
  85154. * This material allows to create dynamic and texture free
  85155. * effects for skyboxes by taking care of the atmosphere state.
  85156. * @see https://doc.babylonjs.com/extensions/sky
  85157. * @param name Define the name of the material in the scene
  85158. * @param scene Define the scene the material belong to
  85159. */
  85160. constructor(name: string, scene: BABYLON.Scene);
  85161. /**
  85162. * Specifies if the material will require alpha blending
  85163. * @returns a boolean specifying if alpha blending is needed
  85164. */
  85165. needAlphaBlending(): boolean;
  85166. /**
  85167. * Specifies if this material should be rendered in alpha test mode
  85168. * @returns false as the sky material doesn't need alpha testing.
  85169. */
  85170. needAlphaTesting(): boolean;
  85171. /**
  85172. * Get the texture used for alpha test purpose.
  85173. * @returns null as the sky material has no texture.
  85174. */
  85175. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85176. /**
  85177. * Get if the submesh is ready to be used and all its information available.
  85178. * Child classes can use it to update shaders
  85179. * @param mesh defines the mesh to check
  85180. * @param subMesh defines which submesh to check
  85181. * @param useInstances specifies that instances should be used
  85182. * @returns a boolean indicating that the submesh is ready or not
  85183. */
  85184. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85185. /**
  85186. * Binds the submesh to this material by preparing the effect and shader to draw
  85187. * @param world defines the world transformation matrix
  85188. * @param mesh defines the mesh containing the submesh
  85189. * @param subMesh defines the submesh to bind the material to
  85190. */
  85191. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85192. /**
  85193. * Get the list of animatables in the material.
  85194. * @returns the list of animatables object used in the material
  85195. */
  85196. getAnimatables(): BABYLON.IAnimatable[];
  85197. /**
  85198. * Disposes the material
  85199. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85200. */
  85201. dispose(forceDisposeEffect?: boolean): void;
  85202. /**
  85203. * Makes a duplicate of the material, and gives it a new name
  85204. * @param name defines the new name for the duplicated material
  85205. * @returns the cloned material
  85206. */
  85207. clone(name: string): SkyMaterial;
  85208. /**
  85209. * Serializes this material in a JSON representation
  85210. * @returns the serialized material object
  85211. */
  85212. serialize(): any;
  85213. /**
  85214. * Gets the current class name of the material e.g. "SkyMaterial"
  85215. * Mainly use in serialization.
  85216. * @returns the class name
  85217. */
  85218. getClassName(): string;
  85219. /**
  85220. * Creates a sky material from parsed material data
  85221. * @param source defines the JSON representation of the material
  85222. * @param scene defines the hosting scene
  85223. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85224. * @returns a new sky material
  85225. */
  85226. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  85227. }
  85228. }
  85229. declare module BABYLON {
  85230. /** @hidden */
  85231. export var terrainPixelShader: {
  85232. name: string;
  85233. shader: string;
  85234. };
  85235. }
  85236. declare module BABYLON {
  85237. /** @hidden */
  85238. export var terrainVertexShader: {
  85239. name: string;
  85240. shader: string;
  85241. };
  85242. }
  85243. declare module BABYLON {
  85244. export class TerrainMaterial extends BABYLON.PushMaterial {
  85245. private _mixTexture;
  85246. mixTexture: BABYLON.BaseTexture;
  85247. private _diffuseTexture1;
  85248. diffuseTexture1: BABYLON.Texture;
  85249. private _diffuseTexture2;
  85250. diffuseTexture2: BABYLON.Texture;
  85251. private _diffuseTexture3;
  85252. diffuseTexture3: BABYLON.Texture;
  85253. private _bumpTexture1;
  85254. bumpTexture1: BABYLON.Texture;
  85255. private _bumpTexture2;
  85256. bumpTexture2: BABYLON.Texture;
  85257. private _bumpTexture3;
  85258. bumpTexture3: BABYLON.Texture;
  85259. diffuseColor: BABYLON.Color3;
  85260. specularColor: BABYLON.Color3;
  85261. specularPower: number;
  85262. private _disableLighting;
  85263. disableLighting: boolean;
  85264. private _maxSimultaneousLights;
  85265. maxSimultaneousLights: number;
  85266. constructor(name: string, scene: BABYLON.Scene);
  85267. needAlphaBlending(): boolean;
  85268. needAlphaTesting(): boolean;
  85269. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85270. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85271. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85272. getAnimatables(): BABYLON.IAnimatable[];
  85273. getActiveTextures(): BABYLON.BaseTexture[];
  85274. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85275. dispose(forceDisposeEffect?: boolean): void;
  85276. clone(name: string): TerrainMaterial;
  85277. serialize(): any;
  85278. getClassName(): string;
  85279. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  85280. }
  85281. }
  85282. declare module BABYLON {
  85283. /** @hidden */
  85284. export var triplanarPixelShader: {
  85285. name: string;
  85286. shader: string;
  85287. };
  85288. }
  85289. declare module BABYLON {
  85290. /** @hidden */
  85291. export var triplanarVertexShader: {
  85292. name: string;
  85293. shader: string;
  85294. };
  85295. }
  85296. declare module BABYLON {
  85297. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  85298. mixTexture: BABYLON.BaseTexture;
  85299. private _diffuseTextureX;
  85300. diffuseTextureX: BABYLON.BaseTexture;
  85301. private _diffuseTextureY;
  85302. diffuseTextureY: BABYLON.BaseTexture;
  85303. private _diffuseTextureZ;
  85304. diffuseTextureZ: BABYLON.BaseTexture;
  85305. private _normalTextureX;
  85306. normalTextureX: BABYLON.BaseTexture;
  85307. private _normalTextureY;
  85308. normalTextureY: BABYLON.BaseTexture;
  85309. private _normalTextureZ;
  85310. normalTextureZ: BABYLON.BaseTexture;
  85311. tileSize: number;
  85312. diffuseColor: BABYLON.Color3;
  85313. specularColor: BABYLON.Color3;
  85314. specularPower: number;
  85315. private _disableLighting;
  85316. disableLighting: boolean;
  85317. private _maxSimultaneousLights;
  85318. maxSimultaneousLights: number;
  85319. constructor(name: string, scene: BABYLON.Scene);
  85320. needAlphaBlending(): boolean;
  85321. needAlphaTesting(): boolean;
  85322. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85323. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85324. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85325. getAnimatables(): BABYLON.IAnimatable[];
  85326. getActiveTextures(): BABYLON.BaseTexture[];
  85327. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85328. dispose(forceDisposeEffect?: boolean): void;
  85329. clone(name: string): TriPlanarMaterial;
  85330. serialize(): any;
  85331. getClassName(): string;
  85332. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  85333. }
  85334. }
  85335. declare module BABYLON {
  85336. /** @hidden */
  85337. export var waterPixelShader: {
  85338. name: string;
  85339. shader: string;
  85340. };
  85341. }
  85342. declare module BABYLON {
  85343. /** @hidden */
  85344. export var waterVertexShader: {
  85345. name: string;
  85346. shader: string;
  85347. };
  85348. }
  85349. declare module BABYLON {
  85350. export class WaterMaterial extends BABYLON.PushMaterial {
  85351. renderTargetSize: BABYLON.Vector2;
  85352. private _bumpTexture;
  85353. bumpTexture: BABYLON.BaseTexture;
  85354. diffuseColor: BABYLON.Color3;
  85355. specularColor: BABYLON.Color3;
  85356. specularPower: number;
  85357. private _disableLighting;
  85358. disableLighting: boolean;
  85359. private _maxSimultaneousLights;
  85360. maxSimultaneousLights: number;
  85361. /**
  85362. * @param {number}: Represents the wind force
  85363. */
  85364. windForce: number;
  85365. /**
  85366. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  85367. */
  85368. windDirection: BABYLON.Vector2;
  85369. /**
  85370. * @param {number}: Wave height, represents the height of the waves
  85371. */
  85372. waveHeight: number;
  85373. /**
  85374. * @param {number}: Bump height, represents the bump height related to the bump map
  85375. */
  85376. bumpHeight: number;
  85377. /**
  85378. * @param {boolean}: Add a smaller moving bump to less steady waves.
  85379. */
  85380. private _bumpSuperimpose;
  85381. bumpSuperimpose: boolean;
  85382. /**
  85383. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  85384. */
  85385. private _fresnelSeparate;
  85386. fresnelSeparate: boolean;
  85387. /**
  85388. * @param {boolean}: bump Waves modify the reflection.
  85389. */
  85390. private _bumpAffectsReflection;
  85391. bumpAffectsReflection: boolean;
  85392. /**
  85393. * @param {number}: The water color blended with the refraction (near)
  85394. */
  85395. waterColor: BABYLON.Color3;
  85396. /**
  85397. * @param {number}: The blend factor related to the water color
  85398. */
  85399. colorBlendFactor: number;
  85400. /**
  85401. * @param {number}: The water color blended with the reflection (far)
  85402. */
  85403. waterColor2: BABYLON.Color3;
  85404. /**
  85405. * @param {number}: The blend factor related to the water color (reflection, far)
  85406. */
  85407. colorBlendFactor2: number;
  85408. /**
  85409. * @param {number}: Represents the maximum length of a wave
  85410. */
  85411. waveLength: number;
  85412. /**
  85413. * @param {number}: Defines the waves speed
  85414. */
  85415. waveSpeed: number;
  85416. /**
  85417. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  85418. * will avoid calculating useless pixels in the pixel shader of the water material.
  85419. */
  85420. disableClipPlane: boolean;
  85421. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  85422. private _mesh;
  85423. private _refractionRTT;
  85424. private _reflectionRTT;
  85425. private _reflectionTransform;
  85426. private _lastTime;
  85427. private _lastDeltaTime;
  85428. private _useLogarithmicDepth;
  85429. private _waitingRenderList;
  85430. private _imageProcessingConfiguration;
  85431. private _imageProcessingObserver;
  85432. /**
  85433. * Gets a boolean indicating that current material needs to register RTT
  85434. */
  85435. get hasRenderTargetTextures(): boolean;
  85436. /**
  85437. * Constructor
  85438. */
  85439. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  85440. get useLogarithmicDepth(): boolean;
  85441. set useLogarithmicDepth(value: boolean);
  85442. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85443. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85444. addToRenderList(node: any): void;
  85445. enableRenderTargets(enable: boolean): void;
  85446. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  85447. get renderTargetsEnabled(): boolean;
  85448. needAlphaBlending(): boolean;
  85449. needAlphaTesting(): boolean;
  85450. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85451. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85452. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85453. private _createRenderTargets;
  85454. getAnimatables(): BABYLON.IAnimatable[];
  85455. getActiveTextures(): BABYLON.BaseTexture[];
  85456. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85457. dispose(forceDisposeEffect?: boolean): void;
  85458. clone(name: string): WaterMaterial;
  85459. serialize(): any;
  85460. getClassName(): string;
  85461. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  85462. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  85463. }
  85464. }
  85465. declare module BABYLON {
  85466. /** @hidden */
  85467. export var asciiartPixelShader: {
  85468. name: string;
  85469. shader: string;
  85470. };
  85471. }
  85472. declare module BABYLON {
  85473. /**
  85474. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  85475. *
  85476. * It basically takes care rendering the font front the given font size to a texture.
  85477. * This is used later on in the postprocess.
  85478. */
  85479. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  85480. private _font;
  85481. private _text;
  85482. private _charSize;
  85483. /**
  85484. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85485. */
  85486. get charSize(): number;
  85487. /**
  85488. * Create a new instance of the Ascii Art FontTexture class
  85489. * @param name the name of the texture
  85490. * @param font the font to use, use the W3C CSS notation
  85491. * @param text the caracter set to use in the rendering.
  85492. * @param scene the scene that owns the texture
  85493. */
  85494. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85495. /**
  85496. * Gets the max char width of a font.
  85497. * @param font the font to use, use the W3C CSS notation
  85498. * @return the max char width
  85499. */
  85500. private getFontWidth;
  85501. /**
  85502. * Gets the max char height of a font.
  85503. * @param font the font to use, use the W3C CSS notation
  85504. * @return the max char height
  85505. */
  85506. private getFontHeight;
  85507. /**
  85508. * Clones the current AsciiArtTexture.
  85509. * @return the clone of the texture.
  85510. */
  85511. clone(): AsciiArtFontTexture;
  85512. /**
  85513. * Parses a json object representing the texture and returns an instance of it.
  85514. * @param source the source JSON representation
  85515. * @param scene the scene to create the texture for
  85516. * @return the parsed texture
  85517. */
  85518. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  85519. }
  85520. /**
  85521. * Option available in the Ascii Art Post Process.
  85522. */
  85523. export interface IAsciiArtPostProcessOptions {
  85524. /**
  85525. * The font to use following the w3c font definition.
  85526. */
  85527. font?: string;
  85528. /**
  85529. * The character set to use in the postprocess.
  85530. */
  85531. characterSet?: string;
  85532. /**
  85533. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85534. * This number is defined between 0 and 1;
  85535. */
  85536. mixToTile?: number;
  85537. /**
  85538. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85539. * This number is defined between 0 and 1;
  85540. */
  85541. mixToNormal?: number;
  85542. }
  85543. /**
  85544. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  85545. *
  85546. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85547. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  85548. */
  85549. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  85550. /**
  85551. * The font texture used to render the char in the post process.
  85552. */
  85553. private _asciiArtFontTexture;
  85554. /**
  85555. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85556. * This number is defined between 0 and 1;
  85557. */
  85558. mixToTile: number;
  85559. /**
  85560. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85561. * This number is defined between 0 and 1;
  85562. */
  85563. mixToNormal: number;
  85564. /**
  85565. * Instantiates a new Ascii Art Post Process.
  85566. * @param name the name to give to the postprocess
  85567. * @camera the camera to apply the post process to.
  85568. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  85569. */
  85570. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  85571. }
  85572. }
  85573. declare module BABYLON {
  85574. /** @hidden */
  85575. export var digitalrainPixelShader: {
  85576. name: string;
  85577. shader: string;
  85578. };
  85579. }
  85580. declare module BABYLON {
  85581. /**
  85582. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  85583. *
  85584. * It basically takes care rendering the font front the given font size to a texture.
  85585. * This is used later on in the postprocess.
  85586. */
  85587. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  85588. private _font;
  85589. private _text;
  85590. private _charSize;
  85591. /**
  85592. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85593. */
  85594. get charSize(): number;
  85595. /**
  85596. * Create a new instance of the Digital Rain FontTexture class
  85597. * @param name the name of the texture
  85598. * @param font the font to use, use the W3C CSS notation
  85599. * @param text the caracter set to use in the rendering.
  85600. * @param scene the scene that owns the texture
  85601. */
  85602. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85603. /**
  85604. * Gets the max char width of a font.
  85605. * @param font the font to use, use the W3C CSS notation
  85606. * @return the max char width
  85607. */
  85608. private getFontWidth;
  85609. /**
  85610. * Gets the max char height of a font.
  85611. * @param font the font to use, use the W3C CSS notation
  85612. * @return the max char height
  85613. */
  85614. private getFontHeight;
  85615. /**
  85616. * Clones the current DigitalRainFontTexture.
  85617. * @return the clone of the texture.
  85618. */
  85619. clone(): DigitalRainFontTexture;
  85620. /**
  85621. * Parses a json object representing the texture and returns an instance of it.
  85622. * @param source the source JSON representation
  85623. * @param scene the scene to create the texture for
  85624. * @return the parsed texture
  85625. */
  85626. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  85627. }
  85628. /**
  85629. * Option available in the Digital Rain Post Process.
  85630. */
  85631. export interface IDigitalRainPostProcessOptions {
  85632. /**
  85633. * The font to use following the w3c font definition.
  85634. */
  85635. font?: string;
  85636. /**
  85637. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85638. * This number is defined between 0 and 1;
  85639. */
  85640. mixToTile?: number;
  85641. /**
  85642. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85643. * This number is defined between 0 and 1;
  85644. */
  85645. mixToNormal?: number;
  85646. }
  85647. /**
  85648. * DigitalRainPostProcess helps rendering everithing in digital rain.
  85649. *
  85650. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85651. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  85652. */
  85653. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  85654. /**
  85655. * The font texture used to render the char in the post process.
  85656. */
  85657. private _digitalRainFontTexture;
  85658. /**
  85659. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85660. * This number is defined between 0 and 1;
  85661. */
  85662. mixToTile: number;
  85663. /**
  85664. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85665. * This number is defined between 0 and 1;
  85666. */
  85667. mixToNormal: number;
  85668. /**
  85669. * Instantiates a new Digital Rain Post Process.
  85670. * @param name the name to give to the postprocess
  85671. * @camera the camera to apply the post process to.
  85672. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  85673. */
  85674. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  85675. }
  85676. }
  85677. declare module BABYLON {
  85678. /** @hidden */
  85679. export var brickProceduralTexturePixelShader: {
  85680. name: string;
  85681. shader: string;
  85682. };
  85683. }
  85684. declare module BABYLON {
  85685. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85686. private _numberOfBricksHeight;
  85687. private _numberOfBricksWidth;
  85688. private _jointColor;
  85689. private _brickColor;
  85690. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85691. updateShaderUniforms(): void;
  85692. get numberOfBricksHeight(): number;
  85693. set numberOfBricksHeight(value: number);
  85694. get numberOfBricksWidth(): number;
  85695. set numberOfBricksWidth(value: number);
  85696. get jointColor(): BABYLON.Color3;
  85697. set jointColor(value: BABYLON.Color3);
  85698. get brickColor(): BABYLON.Color3;
  85699. set brickColor(value: BABYLON.Color3);
  85700. /**
  85701. * Serializes this brick procedural texture
  85702. * @returns a serialized brick procedural texture object
  85703. */
  85704. serialize(): any;
  85705. /**
  85706. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85707. * @param parsedTexture defines parsed texture data
  85708. * @param scene defines the current scene
  85709. * @param rootUrl defines the root URL containing brick procedural texture information
  85710. * @returns a parsed Brick Procedural BABYLON.Texture
  85711. */
  85712. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85713. }
  85714. }
  85715. declare module BABYLON {
  85716. /** @hidden */
  85717. export var cloudProceduralTexturePixelShader: {
  85718. name: string;
  85719. shader: string;
  85720. };
  85721. }
  85722. declare module BABYLON {
  85723. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85724. private _skyColor;
  85725. private _cloudColor;
  85726. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85727. updateShaderUniforms(): void;
  85728. get skyColor(): BABYLON.Color4;
  85729. set skyColor(value: BABYLON.Color4);
  85730. get cloudColor(): BABYLON.Color4;
  85731. set cloudColor(value: BABYLON.Color4);
  85732. /**
  85733. * Serializes this cloud procedural texture
  85734. * @returns a serialized cloud procedural texture object
  85735. */
  85736. serialize(): any;
  85737. /**
  85738. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85739. * @param parsedTexture defines parsed texture data
  85740. * @param scene defines the current scene
  85741. * @param rootUrl defines the root URL containing cloud procedural texture information
  85742. * @returns a parsed Cloud Procedural BABYLON.Texture
  85743. */
  85744. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85745. }
  85746. }
  85747. declare module BABYLON {
  85748. /** @hidden */
  85749. export var fireProceduralTexturePixelShader: {
  85750. name: string;
  85751. shader: string;
  85752. };
  85753. }
  85754. declare module BABYLON {
  85755. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85756. private _time;
  85757. private _speed;
  85758. private _autoGenerateTime;
  85759. private _fireColors;
  85760. private _alphaThreshold;
  85761. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85762. updateShaderUniforms(): void;
  85763. render(useCameraPostProcess?: boolean): void;
  85764. static get PurpleFireColors(): BABYLON.Color3[];
  85765. static get GreenFireColors(): BABYLON.Color3[];
  85766. static get RedFireColors(): BABYLON.Color3[];
  85767. static get BlueFireColors(): BABYLON.Color3[];
  85768. get autoGenerateTime(): boolean;
  85769. set autoGenerateTime(value: boolean);
  85770. get fireColors(): BABYLON.Color3[];
  85771. set fireColors(value: BABYLON.Color3[]);
  85772. get time(): number;
  85773. set time(value: number);
  85774. get speed(): BABYLON.Vector2;
  85775. set speed(value: BABYLON.Vector2);
  85776. get alphaThreshold(): number;
  85777. set alphaThreshold(value: number);
  85778. /**
  85779. * Serializes this fire procedural texture
  85780. * @returns a serialized fire procedural texture object
  85781. */
  85782. serialize(): any;
  85783. /**
  85784. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85785. * @param parsedTexture defines parsed texture data
  85786. * @param scene defines the current scene
  85787. * @param rootUrl defines the root URL containing fire procedural texture information
  85788. * @returns a parsed Fire Procedural BABYLON.Texture
  85789. */
  85790. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85791. }
  85792. }
  85793. declare module BABYLON {
  85794. /** @hidden */
  85795. export var grassProceduralTexturePixelShader: {
  85796. name: string;
  85797. shader: string;
  85798. };
  85799. }
  85800. declare module BABYLON {
  85801. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85802. private _grassColors;
  85803. private _groundColor;
  85804. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85805. updateShaderUniforms(): void;
  85806. get grassColors(): BABYLON.Color3[];
  85807. set grassColors(value: BABYLON.Color3[]);
  85808. get groundColor(): BABYLON.Color3;
  85809. set groundColor(value: BABYLON.Color3);
  85810. /**
  85811. * Serializes this grass procedural texture
  85812. * @returns a serialized grass procedural texture object
  85813. */
  85814. serialize(): any;
  85815. /**
  85816. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85817. * @param parsedTexture defines parsed texture data
  85818. * @param scene defines the current scene
  85819. * @param rootUrl defines the root URL containing grass procedural texture information
  85820. * @returns a parsed Grass Procedural BABYLON.Texture
  85821. */
  85822. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85823. }
  85824. }
  85825. declare module BABYLON {
  85826. /** @hidden */
  85827. export var marbleProceduralTexturePixelShader: {
  85828. name: string;
  85829. shader: string;
  85830. };
  85831. }
  85832. declare module BABYLON {
  85833. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85834. private _numberOfTilesHeight;
  85835. private _numberOfTilesWidth;
  85836. private _amplitude;
  85837. private _jointColor;
  85838. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85839. updateShaderUniforms(): void;
  85840. get numberOfTilesHeight(): number;
  85841. set numberOfTilesHeight(value: number);
  85842. get amplitude(): number;
  85843. set amplitude(value: number);
  85844. get numberOfTilesWidth(): number;
  85845. set numberOfTilesWidth(value: number);
  85846. get jointColor(): BABYLON.Color3;
  85847. set jointColor(value: BABYLON.Color3);
  85848. /**
  85849. * Serializes this marble procedural texture
  85850. * @returns a serialized marble procedural texture object
  85851. */
  85852. serialize(): any;
  85853. /**
  85854. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85855. * @param parsedTexture defines parsed texture data
  85856. * @param scene defines the current scene
  85857. * @param rootUrl defines the root URL containing marble procedural texture information
  85858. * @returns a parsed Marble Procedural BABYLON.Texture
  85859. */
  85860. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85861. }
  85862. }
  85863. declare module BABYLON {
  85864. /** @hidden */
  85865. export var normalMapProceduralTexturePixelShader: {
  85866. name: string;
  85867. shader: string;
  85868. };
  85869. }
  85870. declare module BABYLON {
  85871. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85872. private _baseTexture;
  85873. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85874. updateShaderUniforms(): void;
  85875. render(useCameraPostProcess?: boolean): void;
  85876. resize(size: any, generateMipMaps: any): void;
  85877. get baseTexture(): BABYLON.Texture;
  85878. set baseTexture(texture: BABYLON.Texture);
  85879. /**
  85880. * Serializes this normal map procedural texture
  85881. * @returns a serialized normal map procedural texture object
  85882. */
  85883. serialize(): any;
  85884. /**
  85885. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85886. * @param parsedTexture defines parsed texture data
  85887. * @param scene defines the current scene
  85888. * @param rootUrl defines the root URL containing normal map procedural texture information
  85889. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85890. */
  85891. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85892. }
  85893. }
  85894. declare module BABYLON {
  85895. /** @hidden */
  85896. export var perlinNoiseProceduralTexturePixelShader: {
  85897. name: string;
  85898. shader: string;
  85899. };
  85900. }
  85901. declare module BABYLON {
  85902. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85903. time: number;
  85904. timeScale: number;
  85905. translationSpeed: number;
  85906. private _currentTranslation;
  85907. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85908. updateShaderUniforms(): void;
  85909. render(useCameraPostProcess?: boolean): void;
  85910. resize(size: any, generateMipMaps: any): void;
  85911. /**
  85912. * Serializes this perlin noise procedural texture
  85913. * @returns a serialized perlin noise procedural texture object
  85914. */
  85915. serialize(): any;
  85916. /**
  85917. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85918. * @param parsedTexture defines parsed texture data
  85919. * @param scene defines the current scene
  85920. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85921. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85922. */
  85923. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85924. }
  85925. }
  85926. declare module BABYLON {
  85927. /** @hidden */
  85928. export var roadProceduralTexturePixelShader: {
  85929. name: string;
  85930. shader: string;
  85931. };
  85932. }
  85933. declare module BABYLON {
  85934. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85935. private _roadColor;
  85936. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85937. updateShaderUniforms(): void;
  85938. get roadColor(): BABYLON.Color3;
  85939. set roadColor(value: BABYLON.Color3);
  85940. /**
  85941. * Serializes this road procedural texture
  85942. * @returns a serialized road procedural texture object
  85943. */
  85944. serialize(): any;
  85945. /**
  85946. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85947. * @param parsedTexture defines parsed texture data
  85948. * @param scene defines the current scene
  85949. * @param rootUrl defines the root URL containing road procedural texture information
  85950. * @returns a parsed Road Procedural BABYLON.Texture
  85951. */
  85952. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85953. }
  85954. }
  85955. declare module BABYLON {
  85956. /** @hidden */
  85957. export var starfieldProceduralTexturePixelShader: {
  85958. name: string;
  85959. shader: string;
  85960. };
  85961. }
  85962. declare module BABYLON {
  85963. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85964. private _time;
  85965. private _alpha;
  85966. private _beta;
  85967. private _zoom;
  85968. private _formuparam;
  85969. private _stepsize;
  85970. private _tile;
  85971. private _brightness;
  85972. private _darkmatter;
  85973. private _distfading;
  85974. private _saturation;
  85975. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85976. updateShaderUniforms(): void;
  85977. get time(): number;
  85978. set time(value: number);
  85979. get alpha(): number;
  85980. set alpha(value: number);
  85981. get beta(): number;
  85982. set beta(value: number);
  85983. get formuparam(): number;
  85984. set formuparam(value: number);
  85985. get stepsize(): number;
  85986. set stepsize(value: number);
  85987. get zoom(): number;
  85988. set zoom(value: number);
  85989. get tile(): number;
  85990. set tile(value: number);
  85991. get brightness(): number;
  85992. set brightness(value: number);
  85993. get darkmatter(): number;
  85994. set darkmatter(value: number);
  85995. get distfading(): number;
  85996. set distfading(value: number);
  85997. get saturation(): number;
  85998. set saturation(value: number);
  85999. /**
  86000. * Serializes this starfield procedural texture
  86001. * @returns a serialized starfield procedural texture object
  86002. */
  86003. serialize(): any;
  86004. /**
  86005. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  86006. * @param parsedTexture defines parsed texture data
  86007. * @param scene defines the current scene
  86008. * @param rootUrl defines the root URL containing startfield procedural texture information
  86009. * @returns a parsed Starfield Procedural BABYLON.Texture
  86010. */
  86011. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  86012. }
  86013. }
  86014. declare module BABYLON {
  86015. /** @hidden */
  86016. export var woodProceduralTexturePixelShader: {
  86017. name: string;
  86018. shader: string;
  86019. };
  86020. }
  86021. declare module BABYLON {
  86022. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  86023. private _ampScale;
  86024. private _woodColor;
  86025. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86026. updateShaderUniforms(): void;
  86027. get ampScale(): number;
  86028. set ampScale(value: number);
  86029. get woodColor(): BABYLON.Color3;
  86030. set woodColor(value: BABYLON.Color3);
  86031. /**
  86032. * Serializes this wood procedural texture
  86033. * @returns a serialized wood procedural texture object
  86034. */
  86035. serialize(): any;
  86036. /**
  86037. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  86038. * @param parsedTexture defines parsed texture data
  86039. * @param scene defines the current scene
  86040. * @param rootUrl defines the root URL containing wood procedural texture information
  86041. * @returns a parsed Wood Procedural BABYLON.Texture
  86042. */
  86043. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  86044. }
  86045. }